diff options
author | Schanzenbach, Martin <mschanzenbach@posteo.de> | 2020-04-18 19:46:44 +0200 |
---|---|---|
committer | Schanzenbach, Martin <mschanzenbach@posteo.de> | 2020-04-18 19:46:44 +0200 |
commit | f00c18e631ce8bdaf80d20f236ef275c9cb99291 (patch) | |
tree | 7926acf614e631febcbd5c99243d9c00edd2fbc2 /src/revocation/gnunet-revocation.c | |
parent | 91cccda131a12be139d50effe4657c6b24e36135 (diff) | |
download | gnunet-f00c18e631ce8bdaf80d20f236ef275c9cb99291.tar.gz gnunet-f00c18e631ce8bdaf80d20f236ef275c9cb99291.zip |
simplify pow even more; add timestamp to revocation pow
Diffstat (limited to 'src/revocation/gnunet-revocation.c')
-rw-r--r-- | src/revocation/gnunet-revocation.c | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/src/revocation/gnunet-revocation.c b/src/revocation/gnunet-revocation.c index f5aa2d17e..42ec71d16 100644 --- a/src/revocation/gnunet-revocation.c +++ b/src/revocation/gnunet-revocation.c | |||
@@ -203,6 +203,11 @@ struct RevocationData | |||
203 | struct GNUNET_CRYPTO_EcdsaSignature sig; | 203 | struct GNUNET_CRYPTO_EcdsaSignature sig; |
204 | 204 | ||
205 | /** | 205 | /** |
206 | * Time of revocation | ||
207 | */ | ||
208 | struct GNUNET_TIME_AbsoluteNBO ts; | ||
209 | |||
210 | /** | ||
206 | * Proof of work (in NBO). | 211 | * Proof of work (in NBO). |
207 | */ | 212 | */ |
208 | uint64_t pow GNUNET_PACKED; | 213 | uint64_t pow GNUNET_PACKED; |
@@ -215,9 +220,13 @@ struct RevocationData | |||
215 | static void | 220 | static void |
216 | perform_revocation (const struct RevocationData *rd) | 221 | perform_revocation (const struct RevocationData *rd) |
217 | { | 222 | { |
223 | struct GNUNET_TIME_Absolute ts; | ||
224 | |||
225 | ts = GNUNET_TIME_absolute_ntoh (rd->ts); | ||
218 | h = GNUNET_REVOCATION_revoke (cfg, | 226 | h = GNUNET_REVOCATION_revoke (cfg, |
219 | &rd->key, | 227 | &rd->key, |
220 | &rd->sig, | 228 | &rd->sig, |
229 | &ts, | ||
221 | rd->pow, | 230 | rd->pow, |
222 | &print_revocation_result, | 231 | &print_revocation_result, |
223 | NULL); | 232 | NULL); |
@@ -273,6 +282,7 @@ static void | |||
273 | calculate_pow (void *cls) | 282 | calculate_pow (void *cls) |
274 | { | 283 | { |
275 | struct RevocationData *rd = cls; | 284 | struct RevocationData *rd = cls; |
285 | struct GNUNET_TIME_Absolute ts = GNUNET_TIME_absolute_ntoh (rd->ts); | ||
276 | 286 | ||
277 | /* store temporary results */ | 287 | /* store temporary results */ |
278 | pow_task = NULL; | 288 | pow_task = NULL; |
@@ -290,6 +300,7 @@ calculate_pow (void *cls) | |||
290 | /* actually do POW calculation */ | 300 | /* actually do POW calculation */ |
291 | rd->pow++; | 301 | rd->pow++; |
292 | if (GNUNET_OK == GNUNET_REVOCATION_check_pow (&rd->key, | 302 | if (GNUNET_OK == GNUNET_REVOCATION_check_pow (&rd->key, |
303 | &ts, | ||
293 | rd->pow, | 304 | rd->pow, |
294 | (unsigned int) matching_bits)) | 305 | (unsigned int) matching_bits)) |
295 | { | 306 | { |
@@ -331,6 +342,7 @@ ego_callback (void *cls, const struct GNUNET_IDENTITY_Ego *ego) | |||
331 | { | 342 | { |
332 | struct RevocationData *rd; | 343 | struct RevocationData *rd; |
333 | struct GNUNET_CRYPTO_EcdsaPublicKey key; | 344 | struct GNUNET_CRYPTO_EcdsaPublicKey key; |
345 | struct GNUNET_TIME_Absolute ts; | ||
334 | 346 | ||
335 | el = NULL; | 347 | el = NULL; |
336 | if (NULL == ego) | 348 | if (NULL == ego) |
@@ -361,9 +373,14 @@ ego_callback (void *cls, const struct GNUNET_IDENTITY_Ego *ego) | |||
361 | ego), | 373 | ego), |
362 | &rd->sig); | 374 | &rd->sig); |
363 | rd->key = key; | 375 | rd->key = key; |
376 | rd->ts = GNUNET_TIME_absolute_hton (GNUNET_TIME_absolute_get ()); | ||
364 | } | 377 | } |
378 | ts = GNUNET_TIME_absolute_ntoh (rd->ts); | ||
365 | if (GNUNET_YES == | 379 | if (GNUNET_YES == |
366 | GNUNET_REVOCATION_check_pow (&key, rd->pow, (unsigned int) matching_bits)) | 380 | GNUNET_REVOCATION_check_pow (&key, |
381 | &ts, | ||
382 | rd->pow, | ||
383 | (unsigned int) matching_bits)) | ||
367 | { | 384 | { |
368 | fprintf (stderr, "%s", _ ("Revocation certificate ready\n")); | 385 | fprintf (stderr, "%s", _ ("Revocation certificate ready\n")); |
369 | if (perform) | 386 | if (perform) |
@@ -397,6 +414,7 @@ run (void *cls, | |||
397 | { | 414 | { |
398 | struct GNUNET_CRYPTO_EcdsaPublicKey pk; | 415 | struct GNUNET_CRYPTO_EcdsaPublicKey pk; |
399 | struct RevocationData rd; | 416 | struct RevocationData rd; |
417 | struct GNUNET_TIME_Absolute ts; | ||
400 | 418 | ||
401 | cfg = c; | 419 | cfg = c; |
402 | if (NULL != test_ego) | 420 | if (NULL != test_ego) |
@@ -453,8 +471,10 @@ run (void *cls, | |||
453 | return; | 471 | return; |
454 | } | 472 | } |
455 | GNUNET_SCHEDULER_add_shutdown (&do_shutdown, NULL); | 473 | GNUNET_SCHEDULER_add_shutdown (&do_shutdown, NULL); |
474 | ts = GNUNET_TIME_absolute_ntoh (rd.ts); | ||
456 | if (GNUNET_YES != | 475 | if (GNUNET_YES != |
457 | GNUNET_REVOCATION_check_pow (&rd.key, | 476 | GNUNET_REVOCATION_check_pow (&rd.key, |
477 | &ts, | ||
458 | rd.pow, | 478 | rd.pow, |
459 | (unsigned int) matching_bits)) | 479 | (unsigned int) matching_bits)) |
460 | { | 480 | { |