gnunet-svn
[Top][All Lists]
Advanced

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

[gnunet] branch master updated: IDENTITY: Fix inplace encryption


From: gnunet
Subject: [gnunet] branch master updated: IDENTITY: Fix inplace encryption
Date: Mon, 07 Aug 2023 22:37:50 +0200

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

thejackimonster pushed a commit to branch master
in repository gnunet.

The following commit(s) were added to refs/heads/master by this push:
     new e569f5c6a IDENTITY: Fix inplace encryption
e569f5c6a is described below

commit e569f5c6aaebd4339cee70b5b8c8dacc02f4cc81
Author: TheJackiMonster <thejackimonster@gmail.com>
AuthorDate: Mon Aug 7 22:37:38 2023 +0200

    IDENTITY: Fix inplace encryption
    
    Signed-off-by: TheJackiMonster <thejackimonster@gmail.com>
---
 src/identity/identity_api.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/src/identity/identity_api.c b/src/identity/identity_api.c
index 81e318d19..3a9258aa4 100644
--- a/src/identity/identity_api.c
+++ b/src/identity/identity_api.c
@@ -1182,8 +1182,9 @@ GNUNET_IDENTITY_encrypt (const void *pt,
                          size_t ct_size)
 {
   struct GNUNET_HashCode k;
-  struct GNUNET_CRYPTO_FoKemC *kemc = (struct GNUNET_CRYPTO_FoKemC*) ct_buf;
-  unsigned char *encrypted_data = (unsigned char*) &kemc[1];
+  struct GNUNET_CRYPTO_FoKemC kemc;
+  struct GNUNET_CRYPTO_FoKemC *kemc_buf = (struct GNUNET_CRYPTO_FoKemC*) 
ct_buf;
+  unsigned char *encrypted_data = (unsigned char*) &kemc_buf[1];
   unsigned char nonce[crypto_secretbox_NONCEBYTES];
   unsigned char key[crypto_secretbox_KEYBYTES];
 
@@ -1198,13 +1199,13 @@ GNUNET_IDENTITY_encrypt (const void *pt,
   {
   case GNUNET_IDENTITY_TYPE_ECDSA:
     if (GNUNET_SYSERR == GNUNET_CRYPTO_ecdsa_fo_kem_encaps (&(pub->ecdsa_key),
-                                                            kemc,
+                                                            &kemc,
                                                             &k))
       return GNUNET_SYSERR;
     break;
   case GNUNET_IDENTITY_TYPE_EDDSA:
     if (GNUNET_SYSERR == GNUNET_CRYPTO_eddsa_fo_kem_encaps (&pub->eddsa_key,
-                                                            kemc,
+                                                            &kemc,
                                                             &k))
       return GNUNET_SYSERR;
     break;
@@ -1215,7 +1216,9 @@ GNUNET_IDENTITY_encrypt (const void *pt,
   memcpy (key, &k, crypto_secretbox_KEYBYTES);
   memcpy (nonce, ((char* ) &k) + crypto_secretbox_KEYBYTES,
           crypto_secretbox_NONCEBYTES);
-  crypto_secretbox_easy (encrypted_data, pt, pt_size, nonce, key);
+  if (crypto_secretbox_easy (encrypted_data, pt, pt_size, nonce, key))
+    return GNUNET_SYSERR;
+  memcpy (kemc_buf, &kemc, sizeof (kemc));
   return GNUNET_OK;
 }
 

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

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