diff options
Diffstat (limited to 'src/revocation/revocation_api.c')
-rw-r--r-- | src/revocation/revocation_api.c | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/src/revocation/revocation_api.c b/src/revocation/revocation_api.c index 4755d4816..c2aafd254 100644 --- a/src/revocation/revocation_api.c +++ b/src/revocation/revocation_api.c | |||
@@ -235,6 +235,7 @@ handle_revocation_response (void *cls, | |||
235 | * @param key public key of the key to revoke | 235 | * @param key public key of the key to revoke |
236 | * @param sig signature to use on the revocation (should have been | 236 | * @param sig signature to use on the revocation (should have been |
237 | * created using #GNUNET_REVOCATION_sign_revocation). | 237 | * created using #GNUNET_REVOCATION_sign_revocation). |
238 | * @param ts revocation timestamp | ||
238 | * @param pow proof of work to use (should have been created by | 239 | * @param pow proof of work to use (should have been created by |
239 | * iteratively calling #GNUNET_REVOCATION_check_pow) | 240 | * iteratively calling #GNUNET_REVOCATION_check_pow) |
240 | * @param func funtion to call with the result of the check | 241 | * @param func funtion to call with the result of the check |
@@ -247,6 +248,7 @@ struct GNUNET_REVOCATION_Handle * | |||
247 | GNUNET_REVOCATION_revoke (const struct GNUNET_CONFIGURATION_Handle *cfg, | 248 | GNUNET_REVOCATION_revoke (const struct GNUNET_CONFIGURATION_Handle *cfg, |
248 | const struct GNUNET_CRYPTO_EcdsaPublicKey *key, | 249 | const struct GNUNET_CRYPTO_EcdsaPublicKey *key, |
249 | const struct GNUNET_CRYPTO_EcdsaSignature *sig, | 250 | const struct GNUNET_CRYPTO_EcdsaSignature *sig, |
251 | const struct GNUNET_TIME_Absolute *ts, | ||
250 | uint64_t pow, | 252 | uint64_t pow, |
251 | GNUNET_REVOCATION_Callback func, | 253 | GNUNET_REVOCATION_Callback func, |
252 | void *func_cls) | 254 | void *func_cls) |
@@ -271,6 +273,7 @@ GNUNET_REVOCATION_revoke (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
271 | &matching_bits)) && | 273 | &matching_bits)) && |
272 | (GNUNET_YES != | 274 | (GNUNET_YES != |
273 | GNUNET_REVOCATION_check_pow (key, | 275 | GNUNET_REVOCATION_check_pow (key, |
276 | ts, | ||
274 | pow, | 277 | pow, |
275 | (unsigned int) matching_bits))) | 278 | (unsigned int) matching_bits))) |
276 | { | 279 | { |
@@ -346,22 +349,32 @@ count_leading_zeroes (const struct GNUNET_HashCode *hash) | |||
346 | * would be acceptable for revoking the given key. | 349 | * would be acceptable for revoking the given key. |
347 | * | 350 | * |
348 | * @param key key to check for | 351 | * @param key key to check for |
352 | * @param ts revocation timestamp | ||
349 | * @param pow proof of work value | 353 | * @param pow proof of work value |
350 | * @param matching_bits how many bits must match (configuration) | 354 | * @param matching_bits how many bits must match (configuration) |
351 | * @return #GNUNET_YES if the @a pow is acceptable, #GNUNET_NO if not | 355 | * @return #GNUNET_YES if the @a pow is acceptable, #GNUNET_NO if not |
352 | */ | 356 | */ |
353 | int | 357 | int |
354 | GNUNET_REVOCATION_check_pow (const struct GNUNET_CRYPTO_EcdsaPublicKey *key, | 358 | GNUNET_REVOCATION_check_pow (const struct GNUNET_CRYPTO_EcdsaPublicKey *key, |
359 | const struct GNUNET_TIME_Absolute *ts, | ||
355 | uint64_t pow, | 360 | uint64_t pow, |
356 | unsigned int matching_bits) | 361 | unsigned int matching_bits) |
357 | { | 362 | { |
358 | char buf[sizeof(struct GNUNET_CRYPTO_EcdsaPublicKey) | 363 | char buf[sizeof(struct GNUNET_CRYPTO_EcdsaPublicKey) |
359 | + sizeof(pow)] GNUNET_ALIGN; | 364 | + sizeof(pow) |
365 | + sizeof (struct GNUNET_TIME_AbsoluteNBO)] GNUNET_ALIGN; | ||
360 | struct GNUNET_HashCode result; | 366 | struct GNUNET_HashCode result; |
367 | struct GNUNET_TIME_AbsoluteNBO ts_nbo; | ||
361 | 368 | ||
362 | GNUNET_memcpy (buf, &pow, sizeof(pow)); | 369 | ts_nbo = GNUNET_TIME_absolute_hton (*ts); |
370 | |||
371 | GNUNET_memcpy (buf, &pow, sizeof(pow)) ; | ||
363 | GNUNET_memcpy (&buf[sizeof(pow)], key, | 372 | GNUNET_memcpy (&buf[sizeof(pow)], key, |
364 | sizeof(struct GNUNET_CRYPTO_EcdsaPublicKey)); | 373 | sizeof(struct GNUNET_CRYPTO_EcdsaPublicKey)); |
374 | GNUNET_memcpy (&buf[sizeof(pow) + sizeof (struct GNUNET_TIME_AbsoluteNBO)], | ||
375 | &ts_nbo, | ||
376 | sizeof (struct GNUNET_TIME_AbsoluteNBO)); | ||
377 | |||
365 | GNUNET_CRYPTO_pow_hash ("gnunet-revocation-proof-of-work", | 378 | GNUNET_CRYPTO_pow_hash ("gnunet-revocation-proof-of-work", |
366 | buf, | 379 | buf, |
367 | sizeof(buf), | 380 | sizeof(buf), |