gnunet-svn
[Top][All Lists]
Advanced

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

[taler-anastasis] branch master updated: added assertions


From: gnunet
Subject: [taler-anastasis] branch master updated: added assertions
Date: Wed, 25 Mar 2020 10:14:40 +0100

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

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

The following commit(s) were added to refs/heads/master by this push:
     new f6fa7a5  added assertions
f6fa7a5 is described below

commit f6fa7a520dd7744406cea5170bdb95dfab426dc0
Author: Dennis Neufeld <address@hidden>
AuthorDate: Wed Mar 25 09:14:36 2020 +0000

    added assertions
---
 src/util/anastasis_crypto.c | 46 ++++++++++++++++++++++++---------------------
 1 file changed, 25 insertions(+), 21 deletions(-)

diff --git a/src/util/anastasis_crypto.c b/src/util/anastasis_crypto.c
index 48bd783..a5a65f1 100644
--- a/src/util/anastasis_crypto.c
+++ b/src/util/anastasis_crypto.c
@@ -146,7 +146,7 @@ ANASTASIS_CRYPTO_recovery_document_encrypt (
   void **res,
   size_t *res_size)
 {
-  const struct ANASTASIS_CRYPTO_Nonce nonce;
+  struct ANASTASIS_CRYPTO_Nonce nonce;
   gcry_cipher_hd_t cipher;
   char ciphertext[data_size];
   char sym_key[AES_KEY_SIZE];
@@ -154,6 +154,7 @@ ANASTASIS_CRYPTO_recovery_document_encrypt (
   char gcm_tag[GCM_TAG_SIZE];
   size_t erd_size;
   void *erd;
+  int rc;
 
   GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_NONCE,
                               &nonce,
@@ -162,27 +163,32 @@ ANASTASIS_CRYPTO_recovery_document_encrypt (
               "\n NONCE_1:  %s \n",
               &nonce);
   get_iv_key (id, &nonce, "erd", sym_key, iv);
-  gcry_cipher_open (&cipher,
-                    GCRY_CIPHER_AES256,
-                    GCRY_CIPHER_MODE_GCM,
-                    0);
-  gcry_cipher_setkey (cipher,
-                      sym_key,
-                      sizeof (sym_key));
+  GNUNET_assert (0 ==
+                 gcry_cipher_open (&cipher,
+                                   GCRY_CIPHER_AES256,
+                                   GCRY_CIPHER_MODE_GCM,
+                                   0));
+  rc = gcry_cipher_setkey (cipher,
+                           sym_key,
+                           sizeof (sym_key));
+  GNUNET_assert ((0 == rc) || ((char) rc == GPG_ERR_WEAK_KEY));
+
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "\n SYMKEY_1:  %s \n",
               sym_key);
-  gcry_cipher_setiv (cipher,
-                     &iv,
-                     sizeof (iv));
-  gcry_cipher_encrypt (cipher,
-                       ciphertext,
-                       sizeof (ciphertext),
-                       data,
-                       data_size);
-  gcry_cipher_gettag (cipher,
-                      gcm_tag,
-                      sizeof (gcm_tag));
+  rc = gcry_cipher_setiv (cipher,
+                          &iv,
+                          sizeof (iv));
+  GNUNET_assert ((0 == rc) || ((char) rc == GPG_ERR_WEAK_KEY));
+
+  GNUNET_assert (0 == gcry_cipher_encrypt (cipher,
+                                           ciphertext,
+                                           sizeof (ciphertext),
+                                           data,
+                                           data_size));
+  GNUNET_assert (0 == gcry_cipher_gettag (cipher,
+                                          gcm_tag,
+                                          sizeof (gcm_tag)));
   gcry_cipher_close (cipher);
 
   erd_size = sizeof (ciphertext) + sizeof(struct ANASTASIS_CRYPTO_Nonce)
@@ -199,8 +205,6 @@ ANASTASIS_CRYPTO_recovery_document_encrypt (
           &ciphertext,
           sizeof(ciphertext));
   *res = (void *) erd;
-
-  // GNUNET_free (erd);
 }
 
 /**

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



reply via email to

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