gnunet-svn
[Top][All Lists]
Advanced

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

[taler-anastasis] branch master updated: polish encrypt a bit


From: gnunet
Subject: [taler-anastasis] branch master updated: polish encrypt a bit
Date: Mon, 30 Mar 2020 09:52:38 +0200

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

grothoff pushed a commit to branch master
in repository anastasis.

The following commit(s) were added to refs/heads/master by this push:
     new e7f810f  polish encrypt a bit
e7f810f is described below

commit e7f810f0cffc76cf4b256e5083402159e315c07f
Author: Christian Grothoff <address@hidden>
AuthorDate: Mon Mar 30 09:52:36 2020 +0200

    polish encrypt a bit
---
 src/util/anastasis_crypto.c | 38 +++++++++++++++++++-------------------
 1 file changed, 19 insertions(+), 19 deletions(-)

diff --git a/src/util/anastasis_crypto.c b/src/util/anastasis_crypto.c
index 56a14c0..934d43a 100644
--- a/src/util/anastasis_crypto.c
+++ b/src/util/anastasis_crypto.c
@@ -97,19 +97,21 @@ anastasis_encrypt (const void *msec,
                    void **res,
                    size_t *res_size)
 {
-  struct ANASTASIS_CRYPTO_Nonce nonce;
+  struct ANASTASIS_CRYPTO_Nonce *nonce;
   gcry_cipher_hd_t cipher;
   char sym_key[AES_KEY_SIZE];
   char iv[AES_IV_SIZE];
   int rc;
+  struct ANASTASIS_CRYPTO_AesTag *tag;
+  char *ciphertext;
 
+  nonce = (struct ANASTASIS_CRYPTO_Nonce*) *res;
+  tag = (struct ANASTASIS_CRYPTO_AesTag *) &nonce[1];
+  ciphertext = (char *) &tag[1];
   GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_NONCE,
-                              &nonce,
+                              nonce,
                               sizeof (struct ANASTASIS_CRYPTO_Nonce));
-  memcpy (*res,
-          &nonce,
-          sizeof (struct ANASTASIS_CRYPTO_Nonce));
-  get_iv_key (msec, &nonce, salt, sym_key, iv);
+  get_iv_key (msec, nonce, salt, sym_key, iv);
   GNUNET_assert (0 ==
                  gcry_cipher_open (&cipher,
                                    GCRY_CIPHER_AES256,
@@ -124,19 +126,17 @@ anastasis_encrypt (const void *msec,
                           sizeof (iv));
   GNUNET_assert ((0 == rc) || ((char) rc == GPG_ERR_WEAK_KEY));
 
-  GNUNET_assert (0 == gcry_cipher_encrypt (cipher,
-                                           *res
-                                           + sizeof (struct
-                                                     ANASTASIS_CRYPTO_Nonce)
-                                           + GCM_TAG_SIZE,
-                                           data_size,
-                                           data,
-                                           data_size));
-  GNUNET_assert (0 == gcry_cipher_gettag (cipher,
-                                          *res
-                                          + sizeof (struct
-                                                    ANASTASIS_CRYPTO_Nonce),
-                                          GCM_TAG_SIZE));
+  GNUNET_assert (0 ==
+                 gcry_cipher_encrypt (
+                   cipher,
+                   ciphertext,
+                   data_size,
+                   data,
+                   data_size));
+  GNUNET_assert (0 ==
+                 gcry_cipher_gettag (cipher,
+                                     tag,
+                                     GCM_TAG_SIZE));
   gcry_cipher_close (cipher);
 }
 

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



reply via email to

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