gnunet-svn
[Top][All Lists]
Advanced

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

[taler-anastasis] branch master updated (c173acc -> 8c670ea)


From: gnunet
Subject: [taler-anastasis] branch master updated (c173acc -> 8c670ea)
Date: Thu, 26 Mar 2020 12:06:11 +0100

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

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

    from c173acc  fixed test of erd en-/decryption
     new f95a6c6  code optimization in recovery document encryption
     new 8c670ea  added check of aes_tag to erd decryption

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .gitignore                  |  1 +
 src/util/anastasis_crypto.c | 65 ++++++++++++++++++++-------------------------
 2 files changed, 30 insertions(+), 36 deletions(-)

diff --git a/.gitignore b/.gitignore
index e77457d..7ccb73b 100644
--- a/.gitignore
+++ b/.gitignore
@@ -83,3 +83,4 @@ src/util/test-suite.log
 src/util/test_anastasis_crypto.log
 src/util/test_anastasis_crypto
 src/util/test_anastasis_crypto.trs
+src/lib/test_anastasisrest_api
diff --git a/src/util/anastasis_crypto.c b/src/util/anastasis_crypto.c
index 51c40bb..b16c73d 100644
--- a/src/util/anastasis_crypto.c
+++ b/src/util/anastasis_crypto.c
@@ -150,17 +150,20 @@ ANASTASIS_CRYPTO_recovery_document_encrypt (
 {
   struct ANASTASIS_CRYPTO_Nonce nonce;
   gcry_cipher_hd_t cipher;
-  char ciphertext[data_size];
   char sym_key[AES_KEY_SIZE];
   char iv[AES_IV_SIZE];
-  char gcm_tag[GCM_TAG_SIZE];
-  size_t erd_size;
-  void *erd;
   int rc;
 
+  *res_size = sizeof (data_size) + sizeof(struct ANASTASIS_CRYPTO_Nonce)
+              + GCM_TAG_SIZE;
+  *res = GNUNET_malloc (*res_size);
+
   GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_NONCE,
                               &nonce,
                               sizeof (struct ANASTASIS_CRYPTO_Nonce));
+  memcpy (*res,
+          &nonce,
+          sizeof (struct ANASTASIS_CRYPTO_Nonce));
   get_iv_key (id, &nonce, "erd", sym_key, iv);
   GNUNET_assert (0 ==
                  gcry_cipher_open (&cipher,
@@ -177,29 +180,19 @@ ANASTASIS_CRYPTO_recovery_document_encrypt (
   GNUNET_assert ((0 == rc) || ((char) rc == GPG_ERR_WEAK_KEY));
 
   GNUNET_assert (0 == gcry_cipher_encrypt (cipher,
-                                           ciphertext,
-                                           sizeof (ciphertext),
+                                           *res
+                                           + sizeof (struct
+                                                     ANASTASIS_CRYPTO_Nonce)
+                                           + GCM_TAG_SIZE,
+                                           sizeof (data_size),
                                            data,
                                            data_size));
   GNUNET_assert (0 == gcry_cipher_gettag (cipher,
-                                          gcm_tag,
-                                          sizeof (gcm_tag)));
+                                          *res
+                                          + sizeof (struct
+                                                    ANASTASIS_CRYPTO_Nonce),
+                                          GCM_TAG_SIZE));
   gcry_cipher_close (cipher);
-
-  erd_size = sizeof (ciphertext) + sizeof(struct ANASTASIS_CRYPTO_Nonce)
-             + GCM_TAG_SIZE;
-  *res_size = erd_size;
-  erd = GNUNET_malloc (erd_size);
-  memcpy (erd,
-          &nonce,
-          sizeof (struct ANASTASIS_CRYPTO_Nonce));
-  memcpy (erd + sizeof (struct ANASTASIS_CRYPTO_Nonce),
-          &gcm_tag,
-          GCM_TAG_SIZE);
-  memcpy (erd + sizeof (struct ANASTASIS_CRYPTO_Nonce) + GCM_TAG_SIZE,
-          &ciphertext,
-          sizeof(ciphertext));
-  *res = erd;
 }
 
 /**
@@ -226,21 +219,13 @@ ANASTASIS_CRYPTO_recovery_document_decrypt (
   gcry_cipher_hd_t cipher;
   char sym_key[AES_KEY_SIZE];
   char iv[AES_IV_SIZE];
-  char gcm_tag[GCM_TAG_SIZE];
-  char ciphertext[data_size - sizeof (struct ANASTASIS_CRYPTO_Nonce)
-                  - GCM_TAG_SIZE];
   int rc;
-  *res_size = sizeof (ciphertext);
+
+  *res_size = data_size - sizeof (struct ANASTASIS_CRYPTO_Nonce)
+              - GCM_TAG_SIZE;
   *res = GNUNET_malloc (*res_size);
 
   memcpy (&nonce, data, sizeof (struct ANASTASIS_CRYPTO_Nonce));
-  memcpy (&gcm_tag,
-          data + sizeof (struct ANASTASIS_CRYPTO_Nonce),
-          GCM_TAG_SIZE);
-  memcpy (&ciphertext,
-          data + sizeof (struct ANASTASIS_CRYPTO_Nonce) + GCM_TAG_SIZE,
-          data_size - sizeof (struct ANASTASIS_CRYPTO_Nonce) - GCM_TAG_SIZE);
-
   get_iv_key (id, &nonce, "erd", sym_key, iv);
 
   GNUNET_assert (0 == gcry_cipher_open (&cipher,
@@ -259,8 +244,16 @@ ANASTASIS_CRYPTO_recovery_document_decrypt (
 
   GNUNET_assert (0 == gcry_cipher_decrypt (cipher,
                                            *res, *res_size,
-                                           ciphertext,
-                                           sizeof (ciphertext)));
+                                           data
+                                           + sizeof (struct
+                                                     ANASTASIS_CRYPTO_Nonce)
+                                           + GCM_TAG_SIZE,
+                                           *res_size));
+  GNUNET_assert (0 == gcry_cipher_checktag (cipher,
+                                            data
+                                            + sizeof (struct
+                                                      ANASTASIS_CRYPTO_Nonce),
+                                            GCM_TAG_SIZE));
   gcry_cipher_close (cipher);
 
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,

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



reply via email to

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