From 7cde88367991dcd1deca2485970c353fec5aff3e Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Sat, 30 Nov 2019 23:08:49 +0100 Subject: use new POW function consistently, also in revocation --- src/util/crypto_pow.c | 21 +++++++++++++-------- src/util/gnunet-scrypt.c | 5 ++++- 2 files changed, 17 insertions(+), 9 deletions(-) (limited to 'src/util') diff --git a/src/util/crypto_pow.c b/src/util/crypto_pow.c index 584665e9a..af6837e03 100644 --- a/src/util/crypto_pow.c +++ b/src/util/crypto_pow.c @@ -35,13 +35,16 @@ * We're using a non-standard formula to avoid issues with * ASICs appearing (see #3795). * + * @param salt salt for the hash * @param buf data to hash * @param buf_len number of bytes in @a buf * @param result where to write the resulting hash */ void -GNUNET_CRYPTO_pow_hash (const void *buf, size_t buf_len, struct - GNUNET_HashCode *result) +GNUNET_CRYPTO_pow_hash (const char *salt, + const void *buf, + size_t buf_len, + struct GNUNET_HashCode *result) { #if NEW_CRYPTO struct GNUNET_CRYPTO_SymmetricInitializationVector iv; @@ -52,8 +55,8 @@ GNUNET_CRYPTO_pow_hash (const void *buf, size_t buf_len, struct buf_len, GCRY_KDF_SCRYPT, 1 /* subalgo */, - "gnunet-proof-of-work-1", - strlen ("gnunet-proof-of-work-1"), + salt, + strlen (salt), 2 /* iterations; keep cost of individual op small */, sizeof(skey), &skey)); @@ -61,6 +64,8 @@ GNUNET_CRYPTO_pow_hash (const void *buf, size_t buf_len, struct &skey, "gnunet-proof-of-work-iv", strlen ("gnunet-proof-of-work-iv"), + salt, + strlen (salt), NULL, 0); GNUNET_CRYPTO_symmetric_encrypt (buf, buf_len, @@ -71,8 +76,8 @@ GNUNET_CRYPTO_pow_hash (const void *buf, size_t buf_len, struct buf_len, GCRY_KDF_SCRYPT, 1 /* subalgo */, - "gnunet-proof-of-work-2", - strlen ("gnunet-proof-of-work-2"), + salt, + strlen (salt), 2 /* iterations; keep cost of individual op small */, sizeof(struct GNUNET_HashCode), result)); @@ -81,8 +86,8 @@ GNUNET_CRYPTO_pow_hash (const void *buf, size_t buf_len, struct buf_len, GCRY_KDF_SCRYPT, 1 /* subalgo */, - "gnunet-proof-of-work", - strlen ("gnunet-proof-of-work"), + salt, + strlen (salt), 2 /* iterations; keep cost of individual op small */, sizeof(struct GNUNET_HashCode), result)); diff --git a/src/util/gnunet-scrypt.c b/src/util/gnunet-scrypt.c index d84f486a7..bc8ce83c0 100644 --- a/src/util/gnunet-scrypt.c +++ b/src/util/gnunet-scrypt.c @@ -117,7 +117,10 @@ find_proof (void *cls) while ((counter != UINT64_MAX) && (i < ROUND_SIZE)) { GNUNET_memcpy (buf, &counter, sizeof(uint64_t)); - GNUNET_CRYPTO_pow_hash (buf, sizeof(buf), &result); + GNUNET_CRYPTO_pow_hash ("gnunet-nse-proof-of-work", + buf, + sizeof(buf), + &result); if (nse_work_required <= count_leading_zeroes (&result)) { proof = counter; -- cgit v1.2.3