gnunet-svn
[Top][All Lists]
Advanced

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

[taler-anastasis] 01/02: code optimization in recovery document encrypti


From: gnunet
Subject: [taler-anastasis] 01/02: code optimization in recovery document encryption
Date: Thu, 26 Mar 2020 12:06:12 +0100

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

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

commit f95a6c69716e72dffbf01afe0adca031fe2167fc
Author: Dennis Neufeld <address@hidden>
AuthorDate: Thu Mar 26 10:48:22 2020 +0000

    code optimization in recovery document encryption
---
 .gitignore                  |  1 +
 src/util/anastasis_crypto.c | 39 ++++++++++++++++-----------------------
 2 files changed, 17 insertions(+), 23 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..d11a328 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;
 }
 
 /**

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



reply via email to

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