diff options
Diffstat (limited to 'src/revocation/revocation_api.c')
-rw-r--r-- | src/revocation/revocation_api.c | 28 |
1 files changed, 4 insertions, 24 deletions
diff --git a/src/revocation/revocation_api.c b/src/revocation/revocation_api.c index fd25050e2..ea8db835f 100644 --- a/src/revocation/revocation_api.c +++ b/src/revocation/revocation_api.c | |||
@@ -324,29 +324,6 @@ GNUNET_REVOCATION_revoke_cancel (struct GNUNET_REVOCATION_Handle *h) | |||
324 | 324 | ||
325 | 325 | ||
326 | /** | 326 | /** |
327 | * Calculate the 'proof-of-work' hash (an expensive hash). | ||
328 | * | ||
329 | * @param buf data to hash | ||
330 | * @param buf_len number of bytes in @a buf | ||
331 | * @param result where to write the resulting hash | ||
332 | */ | ||
333 | static void | ||
334 | pow_hash (const void *buf, | ||
335 | size_t buf_len, | ||
336 | struct GNUNET_HashCode *result) | ||
337 | { | ||
338 | GNUNET_break (0 == | ||
339 | gcry_kdf_derive (buf, buf_len, | ||
340 | GCRY_KDF_SCRYPT, | ||
341 | 1 /* subalgo */, | ||
342 | "gnunet-revocation-proof-of-work", | ||
343 | strlen ("gnunet-revocation-proof-of-work"), | ||
344 | 2 /* iterations; keep cost of individual op small */, | ||
345 | sizeof(struct GNUNET_HashCode), result)); | ||
346 | } | ||
347 | |||
348 | |||
349 | /** | ||
350 | * Count the leading zeroes in hash. | 327 | * Count the leading zeroes in hash. |
351 | * | 328 | * |
352 | * @param hash to count leading zeros in | 329 | * @param hash to count leading zeros in |
@@ -385,7 +362,10 @@ GNUNET_REVOCATION_check_pow (const struct GNUNET_CRYPTO_EcdsaPublicKey *key, | |||
385 | GNUNET_memcpy (buf, &pow, sizeof(pow)); | 362 | GNUNET_memcpy (buf, &pow, sizeof(pow)); |
386 | GNUNET_memcpy (&buf[sizeof(pow)], key, | 363 | GNUNET_memcpy (&buf[sizeof(pow)], key, |
387 | sizeof(struct GNUNET_CRYPTO_EcdsaPublicKey)); | 364 | sizeof(struct GNUNET_CRYPTO_EcdsaPublicKey)); |
388 | pow_hash (buf, sizeof(buf), &result); | 365 | GNUNET_CRYPTO_pow_hash ("gnunet-revocation-proof-of-work", |
366 | buf, | ||
367 | sizeof(buf), | ||
368 | &result); | ||
389 | return (count_leading_zeroes (&result) >= | 369 | return (count_leading_zeroes (&result) >= |
390 | matching_bits) ? GNUNET_YES : GNUNET_NO; | 370 | matching_bits) ? GNUNET_YES : GNUNET_NO; |
391 | } | 371 | } |