purge scrypt; add argon2
authorMartin Schanzenbach <mschanzenbach@posteo.de>
Tue, 21 Apr 2020 16:37:28 +0000 (18:37 +0200)
committerMartin Schanzenbach <mschanzenbach@posteo.de>
Tue, 21 Apr 2020 16:37:28 +0000 (18:37 +0200)
README
configure.ac
src/util/crypto_pow.c

diff --git a/README b/README
index f8fd811f8db2c5cb51c26620a8a989b820f36bca..5c4648b8e2dae025e06364b3383662e0a76a0a11 100644 (file)
--- a/README
+++ b/README
@@ -96,6 +96,8 @@ These are the direct dependencies for running GNUnet:
 - which                             (contrib/apparmor(?), gnunet-bugreport,
                                      and possibly more)
 - zlib
+- argon2             >= 20190702    (for proof-of-work calculations in
+                                     revocation)
 
 These are the dependencies for GNUnet's testsuite:
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
index 3b3c9cbe981621233d09a2886c95023b25606b73..b6e44f90e0e159e4b706aac0b1d08e1da03dccd1 100644 (file)
@@ -1033,6 +1033,8 @@ AS_IF([test x$nss = xfalse],
 AC_CHECK_LIB([kvm],[kvm_open])
 AC_CHECK_LIB([kstat],[kstat_open])
 
+# test for argon2 (for POW)
+AC_CHECK_LIB([argon2],[argon2d_hash_raw])
 
 # test for libextractor
 extractor=0
index 1ab4443d11580647d15bd27ebd87541693a225b7..35511a1306caf1edb6b9980bf04ec328a59145cc 100644 (file)
  */
 #include "platform.h"
 #include "gnunet_crypto_lib.h"
-#include <gcrypt.h>
 #include <argon2.h>
 
-#define LSD0001
-
 /**
  * Calculate the 'proof-of-work' hash (an expensive hash).
  * We're using a non-standard formula to avoid issues with
@@ -46,7 +43,6 @@ GNUNET_CRYPTO_pow_hash (const char *salt,
                         size_t buf_len,
                         struct GNUNET_HashCode *result)
 {
-#ifdef LSD0001
   GNUNET_break (ARGON2_OK == argon2d_hash_raw (3, /* iterations */
                                                1024, /* memory (1 MiB) */
                                                1, /* threads */
@@ -58,42 +54,6 @@ GNUNET_CRYPTO_pow_hash (const char *salt,
                                                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_CRYPTO_symmetric_derive_iv (&iv,
-                                     &skey,
-                                     "gnunet-proof-of-work-iv",
-                                     strlen ("gnunet-proof-of-work-iv"),
-                                     salt,
-                                     strlen (salt),
-                                     NULL, 0);
-  GNUNET_CRYPTO_symmetric_encrypt (buf,
-                                   buf_len,
-                                   &skey,
-                                   &iv,
-                                   &rbuf);
-  GNUNET_break (0 == gcry_kdf_derive (rbuf,
-                                      buf_len,
-                                      GCRY_KDF_SCRYPT,
-                                      1 /* subalgo */,
-                                      salt,
-                                      strlen (salt),
-                                      2 /* iterations; keep cost of individual op small */,
-                                      sizeof(struct GNUNET_HashCode),
-                                      result));
-#endif
 }