예제 #1
0
        public async Task <PrivateKeyBook> GenerateBook()
        {
            var result = new PrivateKeyBook();

            result.Book.Add(new PrivateKeyBook.PrivateKeyBookRecord()
            {
                Purpose    = KeyPurpose.MASTER_KEY,
                PrivateKey = await Generate()
            });
            await GenerateSendReceiveKeys(result);

            return(result);
        }
예제 #2
0
 public async Task GenerateSendReceiveKeys(PrivateKeyBook result)
 {
     result.Book.Add(new PrivateKeyBook.PrivateKeyBookRecord()
     {
         Purpose    = KeyPurpose.DH_RECEIVE,
         PrivateKey = await Generate()
     });
     result.Book.Add(new PrivateKeyBook.PrivateKeyBookRecord()
     {
         Purpose    = KeyPurpose.DH_SEND,
         PrivateKey = await Generate()
     });
 }
예제 #3
0
        public async Task <PrivateKeyBook> RefreshBook(PrivateKeyBook book)
        {
            var result = new PrivateKeyBook();

            result.Book.Add(new PrivateKeyBook.PrivateKeyBookRecord()
            {
                Purpose    = KeyPurpose.MASTER_KEY,
                PrivateKey = book.GetMaster()
            });
            await GenerateSendReceiveKeys(result);

            return(result);
        }
예제 #4
0
        public async Task <PrivateKeyBook> RefreshEphemeralBook(PrivateKeyBook book)
        {
            var result = new PrivateKeyBook();

            result.Book.Add(new PrivateKeyBook.PrivateKeyBookRecord()
            {
                Purpose    = KeyPurpose.MASTER_KEY,
                PrivateKey = book.GetMaster()
            });
            result.Book.Add(new PrivateKeyBook.PrivateKeyBookRecord()
            {
                Purpose    = KeyPurpose.DH_RECEIVE,
                PrivateKey = await Generate()
            });
            return(result);
        }
 public bool IsEqual(PrivateKeyBook book)
 {
     if (Version != book.Version)
     {
         return(false);
     }
     if (Book.Count != book.Book.Count)
     {
         return(false);
     }
     for (int i = 0; i < Book.Count; ++i)
     {
         if (Book[i].Purpose != book.Book[i].Purpose)
         {
             return(false);
         }
         if (Book[i].PrivateKey.Serialize().SequenceEqual(book.Book[i].PrivateKey.Serialize()) == false)
         {
             return(false);
         }
     }
     return(true);
 }