gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[taler-anastasis] 01/09: changed msec to key, added key_len


From: gnunet
Subject: [taler-anastasis] 01/09: changed msec to key, added key_len
Date: Wed, 01 Apr 2020 10:12:24 +0200

This is an automated email from the git hooks/post-receive script.

dennis-neufeld pushed a commit to branch master
in repository anastasis.

commit 3e4cbc165fdee2b9ad2513de0c48e133789a4406
Author: Dennis Neufeld <address@hidden>
AuthorDate: Wed Apr 1 07:00:51 2020 +0000

    changed msec to key, added key_len
---
 src/util/anastasis_crypto.c | 84 ++++++++++++++++++++++++++++++++++++---------
 1 file changed, 67 insertions(+), 17 deletions(-)

diff --git a/src/util/anastasis_crypto.c b/src/util/anastasis_crypto.c
index e706b7e..e001a92 100644
--- a/src/util/anastasis_crypto.c
+++ b/src/util/anastasis_crypto.c
@@ -46,14 +46,16 @@
 /**
  * Compute @a key and @a iv.
  *
- * @param msec master secret for calculation
+ * @param key_material key for calculation
+ * @param key_m_len length of key
  * @param nonce nonce for calculation
  * @param salt salt value for calculation
  * @param key[out] where to write the en-/decription key
  * @param iv[out] where to write the IV
  */
 static void
-get_iv_key (const void *msec,
+get_iv_key (const void *key_material,
+            size_t key_m_len,
             const struct ANASTASIS_CRYPTO_Nonce *nonce,
             const char *salt,
             char key[AES_KEY_SIZE],
@@ -66,8 +68,8 @@ get_iv_key (const void *msec,
                                      sizeof (res),
                                      GCRY_MD_SHA512,
                                      GCRY_MD_SHA256,
-                                     msec,
-                                     sizeof(msec),
+                                     key_material,
+                                     key_m_len,
                                      nonce,
                                      sizeof(struct ANASTASIS_CRYPTO_Nonce),
                                      salt,
@@ -82,7 +84,8 @@ get_iv_key (const void *msec,
 /**
  * Encryption of data like recovery document etc.
  *
- * @param msec master secret which is used to derive a key/iv pair from
+ * @param key key which is used to derive a key/iv pair from
+ * @param key_len length of key
  * @param data data to encrypt
  * @param data_size size of the data
  * @param salt salt value which is used for key derivation
@@ -90,7 +93,8 @@ get_iv_key (const void *msec,
  * @param[out] res_size size of the ciphertext
  */
 static void
-anastasis_encrypt (const void *msec,
+anastasis_encrypt (const void *key,
+                   size_t key_len,
                    const void *data,
                    size_t data_size,
                    const char *salt,
@@ -117,7 +121,8 @@ anastasis_encrypt (const void *msec,
   GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_NONCE,
                               nonce,
                               sizeof (struct ANASTASIS_CRYPTO_Nonce));
-  get_iv_key (msec,
+  get_iv_key (key,
+              key_len,
               nonce,
               salt,
               sym_key,
@@ -153,7 +158,8 @@ anastasis_encrypt (const void *msec,
 /**
  * Decryption of data like encrypted recovery document etc.
  *
- * @param msec master secret which is used to derive a key/iv pair from
+ * @param key key which is used to derive a key/iv pair from
+ * @param key_len length of key
  * @param data data to decrypt
  * @param data_size size of the data
  * @param salt salt value which is used for key derivation
@@ -161,7 +167,8 @@ anastasis_encrypt (const void *msec,
  * @param res_size size of the plaintext
  */
 static void
-anastasis_decrypt (const void *msec,
+anastasis_decrypt (const void *key,
+                   size_t key_len,
                    const void *data,
                    size_t data_size,
                    const char *salt,
@@ -185,7 +192,8 @@ anastasis_decrypt (const void *msec,
   nonce = (struct ANASTASIS_CRYPTO_Nonce *) data;
   tag = (struct ANASTASIS_CRYPTO_AesTag *) &nonce[1];
   ciphertext = (char *) &tag[1];
-  get_iv_key (msec,
+  get_iv_key (key,
+              key_len,
               nonce,
               salt,
               sym_key,
@@ -306,7 +314,14 @@ ANASTASIS_CRYPTO_recovery_document_encrypt (
   size_t *res_size)
 {
   char *salt = "erd";
-  anastasis_encrypt (id, data, data_size, salt, res, res_size);
+  anastasis_encrypt (id,
+                     sizeof (struct
+                             ANASTASIS_CRYPTO_UserIdentifier),
+                     data,
+                     data_size,
+                     salt,
+                     res,
+                     res_size);
 }
 
 
@@ -331,7 +346,14 @@ ANASTASIS_CRYPTO_recovery_document_decrypt (
   size_t *res_size)
 {
   char *salt = "erd";
-  anastasis_decrypt (id, data, data_size, salt, res, res_size);
+  anastasis_decrypt (id,
+                     sizeof (struct
+                             ANASTASIS_CRYPTO_UserIdentifier),
+                     data,
+                     data_size,
+                     salt,
+                     res,
+                     res_size);
 }
 
 
@@ -355,8 +377,15 @@ ANASTASIS_CRYPTO_key_share_encrypt (
       bits from the response (e.g. some hash over the answer to the
       security question, see 12.6.-> interface EncryptedKeyShare in spec)
   */
-  anastasis_encrypt (id, key_share, sizeof (struct ANASTASIS_CRYPTO_KeyShare),
-                     salt, res, res_size);
+  anastasis_encrypt (id,
+                     sizeof (struct
+                             ANASTASIS_CRYPTO_UserIdentifier),
+                     key_share,
+                     sizeof (struct
+                             ANASTASIS_CRYPTO_KeyShare),
+                     salt,
+                     res,
+                     res_size);
 }
 
 
@@ -378,7 +407,14 @@ ANASTASIS_CRYPTO_key_share_decrypt (
   size_t *ks_size)
 {
   char *salt = "eks";
-  anastasis_decrypt (id, enc_key_share, eks_size, salt, key_share, ks_size);
+  anastasis_decrypt (id,
+                     sizeof (struct
+                             ANASTASIS_CRYPTO_UserIdentifier),
+                     enc_key_share,
+                     eks_size,
+                     salt,
+                     key_share,
+                     ks_size);
 }
 
 
@@ -403,7 +439,14 @@ ANASTASIS_CRYPTO_truth_encrypt (
   size_t *res_size)
 {
   char *salt = "ect";
-  anastasis_encrypt (truth_enc_key, data, data_size, salt, res, res_size);
+  anastasis_encrypt (truth_enc_key,
+                     sizeof (struct
+                             ANASTASIS_CRYPTO_TruthKey),
+                     data,
+                     data_size,
+                     salt,
+                     res,
+                     res_size);
 }
 
 
@@ -427,7 +470,14 @@ ANASTASIS_CRYPTO_truth_decrypt (
   size_t *res_size)
 {
   char *salt = "ect";
-  anastasis_decrypt (truth_enc_key, data, data_size, salt, res, res_size);
+  anastasis_decrypt (truth_enc_key,
+                     sizeof (struct
+                             ANASTASIS_CRYPTO_TruthKey),
+                     data,
+                     data_size,
+                     salt,
+                     res,
+                     res_size);
 }
 
 

-- 
To stop receiving notification emails like this one, please contact
address@hidden.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]