aboutsummaryrefslogtreecommitdiff
path: root/src/util/crypto_pow.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/util/crypto_pow.c')
-rw-r--r--src/util/crypto_pow.c25
1 files changed, 13 insertions, 12 deletions
diff --git a/src/util/crypto_pow.c b/src/util/crypto_pow.c
index 6176afc33..cfa0676d0 100644
--- a/src/util/crypto_pow.c
+++ b/src/util/crypto_pow.c
@@ -25,14 +25,14 @@
25 */ 25 */
26#include "platform.h" 26#include "platform.h"
27#include "gnunet_crypto_lib.h" 27#include "gnunet_crypto_lib.h"
28#include <argon2.h> 28#include <sodium.h>
29 29
30/** 30/**
31 * Calculate the 'proof-of-work' hash (an expensive hash). 31 * Calculate the 'proof-of-work' hash (an expensive hash).
32 * We're using a non-standard formula to avoid issues with 32 * We're using a non-standard formula to avoid issues with
33 * ASICs appearing (see #3795). 33 * ASICs appearing (see #3795).
34 * 34 *
35 * @param salt salt for the hash 35 * @param salt salt for the hash. Must be crypto_pwhash_argon2id_SALTBYTES long.
36 * @param buf data to hash 36 * @param buf data to hash
37 * @param buf_len number of bytes in @a buf 37 * @param buf_len number of bytes in @a buf
38 * @param result where to write the resulting hash 38 * @param result where to write the resulting hash
@@ -43,16 +43,17 @@ GNUNET_CRYPTO_pow_hash (const char *salt,
43 size_t buf_len, 43 size_t buf_len,
44 struct GNUNET_HashCode *result) 44 struct GNUNET_HashCode *result)
45{ 45{
46 GNUNET_break (ARGON2_OK == 46 GNUNET_assert (strlen (salt) == crypto_pwhash_argon2id_SALTBYTES);
47 argon2id_hash_raw (3, /* iterations */ 47 /* Threads hardcoded at 1 in libsodium */
48 1024, /* memory (1 MiB) */ 48 GNUNET_break (0 ==
49 1, /* threads */ 49 crypto_pwhash_argon2id ((unsigned char *) result,
50 buf, 50 sizeof (struct GNUNET_HashCode),
51 buf_len, 51 buf,
52 salt, 52 buf_len,
53 strlen (salt), 53 (unsigned char*) salt,
54 result, 54 3, /* iterations */
55 sizeof (struct GNUNET_HashCode))); 55 1024 * 1024, /* memory (1 MiB) */
56 crypto_pwhash_argon2id_ALG_ARGON2ID13));
56} 57}
57 58
58 59