aboutsummaryrefslogtreecommitdiff
path: root/src/util
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2019-11-30 23:08:49 +0100
committerChristian Grothoff <christian@grothoff.org>2019-11-30 23:08:49 +0100
commit7cde88367991dcd1deca2485970c353fec5aff3e (patch)
treec2db008b530ac935a3375d562f80e67e85ba32b0 /src/util
parentf536489f831c5fd243c22545be12a2cd0f88a84d (diff)
downloadgnunet-7cde88367991dcd1deca2485970c353fec5aff3e.tar.gz
gnunet-7cde88367991dcd1deca2485970c353fec5aff3e.zip
use new POW function consistently, also in revocation
Diffstat (limited to 'src/util')
-rw-r--r--src/util/crypto_pow.c21
-rw-r--r--src/util/gnunet-scrypt.c5
2 files changed, 17 insertions, 9 deletions
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 @@
35 * We're using a non-standard formula to avoid issues with 35 * We're using a non-standard formula to avoid issues with
36 * ASICs appearing (see #3795). 36 * ASICs appearing (see #3795).
37 * 37 *
38 * @param salt salt for the hash
38 * @param buf data to hash 39 * @param buf data to hash
39 * @param buf_len number of bytes in @a buf 40 * @param buf_len number of bytes in @a buf
40 * @param result where to write the resulting hash 41 * @param result where to write the resulting hash
41 */ 42 */
42void 43void
43GNUNET_CRYPTO_pow_hash (const void *buf, size_t buf_len, struct 44GNUNET_CRYPTO_pow_hash (const char *salt,
44 GNUNET_HashCode *result) 45 const void *buf,
46 size_t buf_len,
47 struct GNUNET_HashCode *result)
45{ 48{
46#if NEW_CRYPTO 49#if NEW_CRYPTO
47 struct GNUNET_CRYPTO_SymmetricInitializationVector iv; 50 struct GNUNET_CRYPTO_SymmetricInitializationVector iv;
@@ -52,8 +55,8 @@ GNUNET_CRYPTO_pow_hash (const void *buf, size_t buf_len, struct
52 buf_len, 55 buf_len,
53 GCRY_KDF_SCRYPT, 56 GCRY_KDF_SCRYPT,
54 1 /* subalgo */, 57 1 /* subalgo */,
55 "gnunet-proof-of-work-1", 58 salt,
56 strlen ("gnunet-proof-of-work-1"), 59 strlen (salt),
57 2 /* iterations; keep cost of individual op small */, 60 2 /* iterations; keep cost of individual op small */,
58 sizeof(skey), 61 sizeof(skey),
59 &skey)); 62 &skey));
@@ -61,6 +64,8 @@ GNUNET_CRYPTO_pow_hash (const void *buf, size_t buf_len, struct
61 &skey, 64 &skey,
62 "gnunet-proof-of-work-iv", 65 "gnunet-proof-of-work-iv",
63 strlen ("gnunet-proof-of-work-iv"), 66 strlen ("gnunet-proof-of-work-iv"),
67 salt,
68 strlen (salt),
64 NULL, 0); 69 NULL, 0);
65 GNUNET_CRYPTO_symmetric_encrypt (buf, 70 GNUNET_CRYPTO_symmetric_encrypt (buf,
66 buf_len, 71 buf_len,
@@ -71,8 +76,8 @@ GNUNET_CRYPTO_pow_hash (const void *buf, size_t buf_len, struct
71 buf_len, 76 buf_len,
72 GCRY_KDF_SCRYPT, 77 GCRY_KDF_SCRYPT,
73 1 /* subalgo */, 78 1 /* subalgo */,
74 "gnunet-proof-of-work-2", 79 salt,
75 strlen ("gnunet-proof-of-work-2"), 80 strlen (salt),
76 2 /* iterations; keep cost of individual op small */, 81 2 /* iterations; keep cost of individual op small */,
77 sizeof(struct GNUNET_HashCode), 82 sizeof(struct GNUNET_HashCode),
78 result)); 83 result));
@@ -81,8 +86,8 @@ GNUNET_CRYPTO_pow_hash (const void *buf, size_t buf_len, struct
81 buf_len, 86 buf_len,
82 GCRY_KDF_SCRYPT, 87 GCRY_KDF_SCRYPT,
83 1 /* subalgo */, 88 1 /* subalgo */,
84 "gnunet-proof-of-work", 89 salt,
85 strlen ("gnunet-proof-of-work"), 90 strlen (salt),
86 2 /* iterations; keep cost of individual op small */, 91 2 /* iterations; keep cost of individual op small */,
87 sizeof(struct GNUNET_HashCode), 92 sizeof(struct GNUNET_HashCode),
88 result)); 93 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)
117 while ((counter != UINT64_MAX) && (i < ROUND_SIZE)) 117 while ((counter != UINT64_MAX) && (i < ROUND_SIZE))
118 { 118 {
119 GNUNET_memcpy (buf, &counter, sizeof(uint64_t)); 119 GNUNET_memcpy (buf, &counter, sizeof(uint64_t));
120 GNUNET_CRYPTO_pow_hash (buf, sizeof(buf), &result); 120 GNUNET_CRYPTO_pow_hash ("gnunet-nse-proof-of-work",
121 buf,
122 sizeof(buf),
123 &result);
121 if (nse_work_required <= count_leading_zeroes (&result)) 124 if (nse_work_required <= count_leading_zeroes (&result))
122 { 125 {
123 proof = counter; 126 proof = counter;