diff options
Diffstat (limited to 'src/revocation/revocation_api.c')
-rw-r--r-- | src/revocation/revocation_api.c | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/src/revocation/revocation_api.c b/src/revocation/revocation_api.c index 565ce9d0d..f2261ff4f 100644 --- a/src/revocation/revocation_api.c +++ b/src/revocation/revocation_api.c | |||
@@ -319,9 +319,7 @@ GNUNET_REVOCATION_revoke (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
319 | "REVOCATION", | 319 | "REVOCATION", |
320 | "WORKBITS", | 320 | "WORKBITS", |
321 | &matching_bits)) && | 321 | &matching_bits)) && |
322 | (GNUNET_YES != | 322 | (0 >= GNUNET_REVOCATION_check_pow (pow, (unsigned int) matching_bits))) |
323 | GNUNET_REVOCATION_check_pow (pow, | ||
324 | (unsigned int) matching_bits))) | ||
325 | { | 323 | { |
326 | GNUNET_break (0); | 324 | GNUNET_break (0); |
327 | GNUNET_free (h); | 325 | GNUNET_free (h); |
@@ -410,7 +408,7 @@ calculate_score (const struct GNUNET_REVOCATION_PowCalculationHandle *ph) | |||
410 | * @param ts revocation timestamp | 408 | * @param ts revocation timestamp |
411 | * @param pow proof of work value | 409 | * @param pow proof of work value |
412 | * @param matching_bits how many bits must match (configuration) | 410 | * @param matching_bits how many bits must match (configuration) |
413 | * @return #GNUNET_YES if the @a pow is acceptable, #GNUNET_NO if not | 411 | * @return number of epochs valid if the @a pow is acceptable, -1 if not |
414 | */ | 412 | */ |
415 | int | 413 | int |
416 | GNUNET_REVOCATION_check_pow (const struct GNUNET_REVOCATION_Pow *pow, | 414 | GNUNET_REVOCATION_check_pow (const struct GNUNET_REVOCATION_Pow *pow, |
@@ -433,7 +431,7 @@ GNUNET_REVOCATION_check_pow (const struct GNUNET_REVOCATION_Pow *pow, | |||
433 | for (unsigned int j = i + 1; j < POW_COUNT; j++) | 431 | for (unsigned int j = i + 1; j < POW_COUNT; j++) |
434 | { | 432 | { |
435 | if (pow->pow[i] == pow->pow[j]) | 433 | if (pow->pow[i] == pow->pow[j]) |
436 | return GNUNET_NO; | 434 | return -1; |
437 | } | 435 | } |
438 | } | 436 | } |
439 | GNUNET_memcpy (&buf[sizeof(uint64_t)], | 437 | GNUNET_memcpy (&buf[sizeof(uint64_t)], |
@@ -460,10 +458,8 @@ GNUNET_REVOCATION_check_pow (const struct GNUNET_REVOCATION_Pow *pow, | |||
460 | score = score / POW_COUNT; | 458 | score = score / POW_COUNT; |
461 | if (score < difficulty) | 459 | if (score < difficulty) |
462 | return GNUNET_NO; | 460 | return GNUNET_NO; |
463 | // TODO verfiy signature? | 461 | epochs = score - difficulty; |
464 | epochs = score - difficulty + 1; | 462 | return epochs; |
465 | // TODO verify expiration | ||
466 | return GNUNET_YES; | ||
467 | } | 463 | } |
468 | 464 | ||
469 | 465 | ||