gnunet-svn
[Top][All Lists]
Advanced

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

[gnunet] 02/31: add argon2 for LSD0001


From: gnunet
Subject: [gnunet] 02/31: add argon2 for LSD0001
Date: Wed, 22 Apr 2020 21:52:53 +0200

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

martin-schanzenbach pushed a commit to branch master
in repository gnunet.

commit 2be21d379f34329dd38b66242701549731261828
Author: Schanzenbach, Martin <address@hidden>
AuthorDate: Fri Apr 17 19:58:40 2020 +0200

    add argon2 for LSD0001
---
 src/util/Makefile.am  |  1 +
 src/util/crypto_pow.c | 59 +++++++++++++++++++++++++++++++--------------------
 2 files changed, 37 insertions(+), 23 deletions(-)

diff --git a/src/util/Makefile.am b/src/util/Makefile.am
index ae72abb44..fed0dad79 100644
--- a/src/util/Makefile.am
+++ b/src/util/Makefile.am
@@ -133,6 +133,7 @@ libgnunetutil_la_LIBADD = \
   $(LIBIDN) $(LIBIDN2) \
   $(Z_LIBS) \
   -lunistring \
+  -largon2 \
   $(XLIB) \
   $(PTHREAD)
 
diff --git a/src/util/crypto_pow.c b/src/util/crypto_pow.c
index 9b20ab345..d3e4dbc43 100644
--- a/src/util/crypto_pow.c
+++ b/src/util/crypto_pow.c
@@ -25,7 +25,9 @@
  */
 #include "platform.h"
 #include "gnunet_crypto_lib.h"
-#include <gcrypt.h>
+#include <argon2.h>
+
+#define LSD001
 
 /**
  * Calculate the 'proof-of-work' hash (an expensive hash).
@@ -44,21 +46,21 @@ GNUNET_CRYPTO_pow_hash (const char *salt,
                         struct GNUNET_HashCode *result)
 {
 #ifdef LSD001
-  char twofish_iv[128 / 8]; //128 bit IV
-  char twofish_key[256 / 8]; //256 bit Key
+  char twofish_iv[128 / 8]; // 128 bit IV
+  char twofish_key[256 / 8]; // 256 bit Key
   char rbuf[buf_len];
   int rc;
   gcry_cipher_hd_t handle;
 
-  GNUNET_break (0 == gcry_kdf_derive (buf,
-                                      buf_len,
-                                      GCRY_KDF_SCRYPT,
-                                      1 /* subalgo */,
-                                      salt,
-                                      strlen (salt),
-                                      2 /* iterations; keep cost of individual 
op small */,
-                                      sizeof(twofish_key),
-                                      &twofish_key));
+  GNUNET_break (ARGON2_OK == argon2d_hash_raw (2, /* iterations */
+                                               100000, /* memory (kb) */
+                                               1, /* threads */
+                                               buf,
+                                               buf_len,
+                                               salt,
+                                               strlen (salt),
+                                               &twofish_key,
+                                               sizeof (twofish_key)));
 
   GNUNET_CRYPTO_kdf (twofish_iv,
                      sizeof (twofish_iv),
@@ -80,22 +82,33 @@ GNUNET_CRYPTO_pow_hash (const char *salt,
                           twofish_iv,
                           sizeof(twofish_iv));
   GNUNET_assert ((0 == rc) || ((char) rc == GPG_ERR_WEAK_KEY));
-  GNUNET_assert (0 == gcry_cipher_encrypt (handle, &rbuf, buf_len, buf, 
buf_len));
+  GNUNET_assert (0 == gcry_cipher_encrypt (handle, &rbuf, buf_len, buf,
+                                           buf_len));
   gcry_cipher_close (handle);
+  GNUNET_break (ARGON2_OK == argon2d_hash_raw (2, /* iterations */
+                                               100000, /* memory */
+                                               1, /* threads */
+                                               rbuf,
+                                               buf_len,
+                                               salt,
+                                               strlen (salt),
+                                               result,
+                                               sizeof (struct 
GNUNET_HashCode)));
+
 #else
   struct GNUNET_CRYPTO_SymmetricInitializationVector iv;
   struct GNUNET_CRYPTO_SymmetricSessionKey skey;
   char rbuf[buf_len];
 
-  GNUNET_break (0 == gcry_kdf_derive (buf,
-                                      buf_len,
-                                      GCRY_KDF_SCRYPT,
-                                      1 /* subalgo */,
-                                      salt,
-                                      strlen (salt),
-                                      2 /* iterations; keep cost of individual 
op small */,
-                                      sizeof(skey),
-                                      &skey));
+  GNUNET_break (ARGON2_OK == argon2d_hash_raw (buf,
+                                               buf_len,
+                                               GCRY_KDF_SCRYPT,
+                                               1 /* subalgo */,
+                                               salt,
+                                               strlen (salt),
+                                               2 /* iterations; keep cost of 
individual op small */,
+                                               sizeof(skey),
+                                               &skey));
   GNUNET_CRYPTO_symmetric_derive_iv (&iv,
                                      &skey,
                                      "gnunet-proof-of-work-iv",
@@ -108,7 +121,6 @@ GNUNET_CRYPTO_pow_hash (const char *salt,
                                    &skey,
                                    &iv,
                                    &rbuf);
-#endif
   GNUNET_break (0 == gcry_kdf_derive (rbuf,
                                       buf_len,
                                       GCRY_KDF_SCRYPT,
@@ -118,6 +130,7 @@ GNUNET_CRYPTO_pow_hash (const char *salt,
                                       2 /* iterations; keep cost of individual 
op small */,
                                       sizeof(struct GNUNET_HashCode),
                                       result));
+#endif
 }
 
 

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



reply via email to

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