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.c26
1 files changed, 13 insertions, 13 deletions
diff --git a/src/util/crypto_pow.c b/src/util/crypto_pow.c
index 35511a130..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,17 +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 == argon2d_hash_raw (3, /* iterations */ 46 GNUNET_assert (strlen (salt) == crypto_pwhash_argon2id_SALTBYTES);
47 1024, /* memory (1 MiB) */ 47 /* Threads hardcoded at 1 in libsodium */
48 1, /* threads */ 48 GNUNET_break (0 ==
49 buf, 49 crypto_pwhash_argon2id ((unsigned char *) result,
50 buf_len, 50 sizeof (struct GNUNET_HashCode),
51 salt, 51 buf,
52 strlen (salt), 52 buf_len,
53 result, 53 (unsigned char*) salt,
54 sizeof (struct 54 3, /* iterations */
55 GNUNET_HashCode))); 55 1024 * 1024, /* memory (1 MiB) */
56 56 crypto_pwhash_argon2id_ALG_ARGON2ID13));
57} 57}
58 58
59 59