aboutsummaryrefslogtreecommitdiff
path: root/src/util
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2020-08-17 14:45:46 +0200
committerChristian Grothoff <christian@grothoff.org>2020-08-17 14:46:08 +0200
commit6f2ee9eb3c3642147fe381976ffeb88d0c3288e5 (patch)
tree26a66a4d123c667aa88d2aa5595add21390d53a8 /src/util
parentf6acda6d3299bda2e6ea6e38bef5cabfb01b8ab9 (diff)
downloadgnunet-6f2ee9eb3c3642147fe381976ffeb88d0c3288e5.tar.gz
gnunet-6f2ee9eb3c3642147fe381976ffeb88d0c3288e5.zip
clean up GNUNET_CRYPTO_pow_hash API
Diffstat (limited to 'src/util')
-rw-r--r--src/util/crypto_pow.c3
-rw-r--r--src/util/gnunet-scrypt.c9
2 files changed, 9 insertions, 3 deletions
diff --git a/src/util/crypto_pow.c b/src/util/crypto_pow.c
index cfa0676d0..051a0c209 100644
--- a/src/util/crypto_pow.c
+++ b/src/util/crypto_pow.c
@@ -38,12 +38,11 @@
38 * @param result where to write the resulting hash 38 * @param result where to write the resulting hash
39 */ 39 */
40void 40void
41GNUNET_CRYPTO_pow_hash (const char *salt, 41GNUNET_CRYPTO_pow_hash (const struct GNUNET_CRYPTO_PowSalt *salt,
42 const void *buf, 42 const void *buf,
43 size_t buf_len, 43 size_t buf_len,
44 struct GNUNET_HashCode *result) 44 struct GNUNET_HashCode *result)
45{ 45{
46 GNUNET_assert (strlen (salt) == crypto_pwhash_argon2id_SALTBYTES);
47 /* Threads hardcoded at 1 in libsodium */ 46 /* Threads hardcoded at 1 in libsodium */
48 GNUNET_break (0 == 47 GNUNET_break (0 ==
49 crypto_pwhash_argon2id ((unsigned char *) result, 48 crypto_pwhash_argon2id ((unsigned char *) result,
diff --git a/src/util/gnunet-scrypt.c b/src/util/gnunet-scrypt.c
index aa64144a8..136c6debb 100644
--- a/src/util/gnunet-scrypt.c
+++ b/src/util/gnunet-scrypt.c
@@ -26,6 +26,13 @@
26#include "gnunet_util_lib.h" 26#include "gnunet_util_lib.h"
27#include <gcrypt.h> 27#include <gcrypt.h>
28 28
29
30/**
31 * Salt for PoW calcualations.
32 */
33static struct GNUNET_CRYPTO_PowSalt salt = { "gnunet-nse-proof" };
34
35
29/** 36/**
30 * Amount of work required (W-bit collisions) for NSE proofs, in collision-bits. 37 * Amount of work required (W-bit collisions) for NSE proofs, in collision-bits.
31 */ 38 */
@@ -117,7 +124,7 @@ find_proof (void *cls)
117 while ((counter != UINT64_MAX) && (i < ROUND_SIZE)) 124 while ((counter != UINT64_MAX) && (i < ROUND_SIZE))
118 { 125 {
119 GNUNET_memcpy (buf, &counter, sizeof(uint64_t)); 126 GNUNET_memcpy (buf, &counter, sizeof(uint64_t));
120 GNUNET_CRYPTO_pow_hash ("gnunet-nse-proof", 127 GNUNET_CRYPTO_pow_hash (&salt,
121 buf, 128 buf,
122 sizeof(buf), 129 sizeof(buf),
123 &result); 130 &result);