aboutsummaryrefslogtreecommitdiff
path: root/src/revocation/revocation_api.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/revocation/revocation_api.c')
-rw-r--r--src/revocation/revocation_api.c28
1 files changed, 22 insertions, 6 deletions
diff --git a/src/revocation/revocation_api.c b/src/revocation/revocation_api.c
index 6510f9583..c817e612a 100644
--- a/src/revocation/revocation_api.c
+++ b/src/revocation/revocation_api.c
@@ -27,8 +27,7 @@
27#include "gnunet_signatures.h" 27#include "gnunet_signatures.h"
28#include "gnunet_protocols.h" 28#include "gnunet_protocols.h"
29#include "revocation.h" 29#include "revocation.h"
30#include <gcrypt.h> 30#include <inttypes.h>
31
32 31
33/** 32/**
34 * Handle for the key revocation query. 33 * Handle for the key revocation query.
@@ -389,6 +388,16 @@ GNUNET_REVOCATION_check_pow (const struct GNUNET_REVOCATION_Pow *pow,
389 unsigned int epochs; 388 unsigned int epochs;
390 uint64_t pow_val; 389 uint64_t pow_val;
391 390
391 /**
392 * First, check if any duplicates are in the PoW set
393 */
394 for (unsigned int i = 0; i < POW_COUNT; i++)
395 {
396 for (unsigned int j = i+1; j < POW_COUNT; j++) {
397 if (pow->pow[i] == pow->pow[j])
398 return GNUNET_NO;
399 }
400 }
392 GNUNET_memcpy (&buf[sizeof(uint64_t)], 401 GNUNET_memcpy (&buf[sizeof(uint64_t)],
393 &pow->timestamp, 402 &pow->timestamp,
394 sizeof (uint64_t)); 403 sizeof (uint64_t));
@@ -405,8 +414,8 @@ GNUNET_REVOCATION_check_pow (const struct GNUNET_REVOCATION_Pow *pow,
405 &result); 414 &result);
406 tmp_score = count_leading_zeroes (&result); 415 tmp_score = count_leading_zeroes (&result);
407 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 416 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
408 "Score %u (#%u)\n", 417 "Score %u with %"PRIu64" (#%u)\n",
409 tmp_score, i); 418 tmp_score, pow_val, i);
410 score += tmp_score; 419 score += tmp_score;
411 420
412 } 421 }
@@ -460,6 +469,13 @@ GNUNET_REVOCATION_pow_round (struct GNUNET_REVOCATION_PowCalculationHandle *pc)
460 469
461 pc->current_pow++; 470 pc->current_pow++;
462 471
472 /**
473 * Do not try duplicates
474 */
475 for (unsigned int i = 0; i < POW_COUNT; i++)
476 if (pc->current_pow == pc->best[i].pow)
477 return GNUNET_NO;
478
463 GNUNET_memcpy (buf, &pc->current_pow, sizeof(uint64_t)); 479 GNUNET_memcpy (buf, &pc->current_pow, sizeof(uint64_t));
464 GNUNET_memcpy (&buf[sizeof(uint64_t)], 480 GNUNET_memcpy (&buf[sizeof(uint64_t)],
465 &pc->pow.timestamp, 481 &pc->pow.timestamp,
@@ -480,8 +496,8 @@ GNUNET_REVOCATION_pow_round (struct GNUNET_REVOCATION_PowCalculationHandle *pc)
480 pc->best[i].pow = pc->current_pow; 496 pc->best[i].pow = pc->current_pow;
481 pc->pow.pow[i] = GNUNET_htonll (pc->current_pow); 497 pc->pow.pow[i] = GNUNET_htonll (pc->current_pow);
482 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 498 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
483 "New best score %u (#%u)\n", 499 "New best score %u with %"PRIu64" (#%u)\n",
484 zeros, i); 500 zeros, pc->current_pow, i);
485 break; 501 break;
486 } 502 }
487 } 503 }