diff options
-rw-r--r-- | src/revocation/Makefile.am | 12 | ||||
-rw-r--r-- | src/revocation/gnunet-revocation.c | 73 | ||||
-rw-r--r-- | src/revocation/gnunet-service-revocation.c | 4 | ||||
-rw-r--r-- | src/revocation/revocation_api.c | 4 | ||||
-rw-r--r-- | src/revocation/test_revocation.conf | 2 |
5 files changed, 64 insertions, 31 deletions
diff --git a/src/revocation/Makefile.am b/src/revocation/Makefile.am index 91610b4f0..81af152bd 100644 --- a/src/revocation/Makefile.am +++ b/src/revocation/Makefile.am | |||
@@ -1,7 +1,7 @@ | |||
1 | AM_CPPFLAGS = -I$(top_srcdir)/src/include | 1 | AM_CPPFLAGS = -I$(top_srcdir)/src/include |
2 | 2 | ||
3 | if MINGW | 3 | if MINGW |
4 | WINFLAGS = -Wl,--no-undefined -Wl,--export-all-symbols | 4 | WINFLAGS = -Wl,--no-undefined -Wl,--export-all-symbols |
5 | endif | 5 | endif |
6 | 6 | ||
7 | if USE_COVERAGE | 7 | if USE_COVERAGE |
@@ -17,11 +17,11 @@ pkgcfg_DATA = \ | |||
17 | revocation.conf | 17 | revocation.conf |
18 | 18 | ||
19 | bin_PROGRAMS = \ | 19 | bin_PROGRAMS = \ |
20 | gnunet-revocation | 20 | gnunet-revocation |
21 | 21 | ||
22 | 22 | ||
23 | gnunet_revocation_SOURCES = \ | 23 | gnunet_revocation_SOURCES = \ |
24 | gnunet-revocation.c | 24 | gnunet-revocation.c |
25 | gnunet_revocation_LDADD = \ | 25 | gnunet_revocation_LDADD = \ |
26 | libgnunetrevocation.la \ | 26 | libgnunetrevocation.la \ |
27 | $(top_builddir)/src/identity/libgnunetidentity.la \ | 27 | $(top_builddir)/src/identity/libgnunetidentity.la \ |
@@ -40,11 +40,11 @@ libgnunetrevocation_la_LDFLAGS = \ | |||
40 | -version-info 0:0:0 | 40 | -version-info 0:0:0 |
41 | 41 | ||
42 | libexec_PROGRAMS = \ | 42 | libexec_PROGRAMS = \ |
43 | gnunet-service-revocation | 43 | gnunet-service-revocation |
44 | 44 | ||
45 | 45 | ||
46 | gnunet_service_revocation_SOURCES = \ | 46 | gnunet_service_revocation_SOURCES = \ |
47 | gnunet-service-revocation.c | 47 | gnunet-service-revocation.c |
48 | gnunet_service_revocation_LDADD = \ | 48 | gnunet_service_revocation_LDADD = \ |
49 | $(top_builddir)/src/revocation/libgnunetrevocation.la \ | 49 | $(top_builddir)/src/revocation/libgnunetrevocation.la \ |
50 | $(top_builddir)/src/core/libgnunetcore.la \ | 50 | $(top_builddir)/src/core/libgnunetcore.la \ |
@@ -57,5 +57,5 @@ gnunet_service_revocation_DEPENDENCIES = \ | |||
57 | libgnunetrevocation.la | 57 | libgnunetrevocation.la |
58 | 58 | ||
59 | 59 | ||
60 | EXTRA_DIST = test_revocation.conf | ||
60 | 61 | ||
61 | #EXTRA_DIST = | ||
diff --git a/src/revocation/gnunet-revocation.c b/src/revocation/gnunet-revocation.c index 1859722d8..5f97a7112 100644 --- a/src/revocation/gnunet-revocation.c +++ b/src/revocation/gnunet-revocation.c | |||
@@ -153,14 +153,24 @@ print_revocation_result (void *cls, | |||
153 | switch (is_valid) | 153 | switch (is_valid) |
154 | { | 154 | { |
155 | case GNUNET_YES: | 155 | case GNUNET_YES: |
156 | FPRINTF (stdout, | 156 | if (NULL != revoke_ego) |
157 | _("Key for ego `%s' is still valid, revocation failed (!)\n"), | 157 | FPRINTF (stdout, |
158 | test_ego); | 158 | _("Key for ego `%s' is still valid, revocation failed (!)\n"), |
159 | revoke_ego); | ||
160 | else | ||
161 | FPRINTF (stdout, | ||
162 | "%s", | ||
163 | _("Revocation failed (!)\n")); | ||
159 | break; | 164 | break; |
160 | case GNUNET_NO: | 165 | case GNUNET_NO: |
161 | FPRINTF (stdout, | 166 | if (NULL != revoke_ego) |
162 | _("Key for ego `%s' has been successfully revoked\n"), | 167 | FPRINTF (stdout, |
163 | test_ego); | 168 | _("Key for ego `%s' has been successfully revoked\n"), |
169 | revoke_ego); | ||
170 | else | ||
171 | FPRINTF (stdout, | ||
172 | "%s", | ||
173 | _("Revocation successful.\n")); | ||
164 | break; | 174 | break; |
165 | case GNUNET_SYSERR: | 175 | case GNUNET_SYSERR: |
166 | FPRINTF (stdout, | 176 | FPRINTF (stdout, |
@@ -224,15 +234,10 @@ calculate_pow (void *cls, | |||
224 | { | 234 | { |
225 | struct RevocationData *rd = cls; | 235 | struct RevocationData *rd = cls; |
226 | 236 | ||
237 | /* store temporary results */ | ||
227 | if ( (0 != (GNUNET_SCHEDULER_REASON_SHUTDOWN & tc->reason)) || | 238 | if ( (0 != (GNUNET_SCHEDULER_REASON_SHUTDOWN & tc->reason)) || |
228 | (0 == (rd->pow % 128) ) ) | 239 | (0 == (rd->pow % 128) ) ) |
229 | { | 240 | { |
230 | if (0 == (rd->pow % 128 * 1024)) | ||
231 | { | ||
232 | if (0 == (rd->pow % (1024 * 128 * 80))) | ||
233 | fprintf (stderr, "\n"); | ||
234 | fprintf (stderr, "."); | ||
235 | } | ||
236 | if ( (NULL != filename) && | 241 | if ( (NULL != filename) && |
237 | (sizeof (struct RevocationData) == | 242 | (sizeof (struct RevocationData) == |
238 | GNUNET_DISK_fn_write (filename, | 243 | GNUNET_DISK_fn_write (filename, |
@@ -244,11 +249,21 @@ calculate_pow (void *cls, | |||
244 | "write", | 249 | "write", |
245 | filename); | 250 | filename); |
246 | } | 251 | } |
252 | /* display progress estimate */ | ||
253 | if ( (0 == ((1 << matching_bits) / 100 / 50)) || | ||
254 | (0 == (rd->pow % ((1 << matching_bits) / 100 / 50))) ) | ||
255 | FPRINTF (stderr, "%s", "."); | ||
256 | if ( (0 != rd->pow) && | ||
257 | ( (0 == ((1 << matching_bits) / 100)) || | ||
258 | (0 == (rd->pow % ((1 << matching_bits) / 100))) ) ) | ||
259 | FPRINTF (stderr, " - @ %3u%% (estimate)\n", | ||
260 | (unsigned int) (rd->pow * 100) / (1 << matching_bits)); | ||
247 | if (0 != (GNUNET_SCHEDULER_REASON_SHUTDOWN & tc->reason)) | 261 | if (0 != (GNUNET_SCHEDULER_REASON_SHUTDOWN & tc->reason)) |
248 | { | 262 | { |
249 | GNUNET_free (rd); | 263 | GNUNET_free (rd); |
250 | return; | 264 | return; |
251 | } | 265 | } |
266 | /* actually do POW calculation */ | ||
252 | rd->pow++; | 267 | rd->pow++; |
253 | if (GNUNET_OK == | 268 | if (GNUNET_OK == |
254 | GNUNET_REVOCATION_check_pow (&rd->key, | 269 | GNUNET_REVOCATION_check_pow (&rd->key, |
@@ -256,10 +271,10 @@ calculate_pow (void *cls, | |||
256 | (unsigned int) matching_bits)) | 271 | (unsigned int) matching_bits)) |
257 | { | 272 | { |
258 | if ( (NULL != filename) && | 273 | if ( (NULL != filename) && |
259 | (sizeof (struct RevocationData) == | 274 | (sizeof (struct RevocationData) != |
260 | GNUNET_DISK_fn_write (filename, | 275 | GNUNET_DISK_fn_write (filename, |
261 | &rd, | 276 | rd, |
262 | sizeof (rd), | 277 | sizeof (struct RevocationData), |
263 | GNUNET_DISK_PERM_USER_READ | | 278 | GNUNET_DISK_PERM_USER_READ | |
264 | GNUNET_DISK_PERM_USER_WRITE)) ) | 279 | GNUNET_DISK_PERM_USER_WRITE)) ) |
265 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, | 280 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, |
@@ -269,6 +284,7 @@ calculate_pow (void *cls, | |||
269 | perform_revocation (rd); | 284 | perform_revocation (rd); |
270 | else | 285 | else |
271 | { | 286 | { |
287 | FPRINTF (stderr, "%s", "\n"); | ||
272 | FPRINTF (stderr, | 288 | FPRINTF (stderr, |
273 | _("Revocation certificate for `%s' stored in `%s'\n"), | 289 | _("Revocation certificate for `%s' stored in `%s'\n"), |
274 | revoke_ego, | 290 | revoke_ego, |
@@ -276,6 +292,7 @@ calculate_pow (void *cls, | |||
276 | GNUNET_SCHEDULER_shutdown (); | 292 | GNUNET_SCHEDULER_shutdown (); |
277 | } | 293 | } |
278 | GNUNET_free (rd); | 294 | GNUNET_free (rd); |
295 | return; | ||
279 | } | 296 | } |
280 | GNUNET_SCHEDULER_add_now (&calculate_pow, | 297 | GNUNET_SCHEDULER_add_now (&calculate_pow, |
281 | rd); | 298 | rd); |
@@ -312,8 +329,8 @@ ego_callback (void *cls, | |||
312 | GNUNET_DISK_file_test (filename)) && | 329 | GNUNET_DISK_file_test (filename)) && |
313 | (sizeof (struct RevocationData) == | 330 | (sizeof (struct RevocationData) == |
314 | GNUNET_DISK_fn_read (filename, | 331 | GNUNET_DISK_fn_read (filename, |
315 | &rd, | 332 | rd, |
316 | sizeof (rd))) ) | 333 | sizeof (struct RevocationData))) ) |
317 | { | 334 | { |
318 | if (0 != memcmp (&rd->key, | 335 | if (0 != memcmp (&rd->key, |
319 | &key, | 336 | &key, |
@@ -340,8 +357,11 @@ ego_callback (void *cls, | |||
340 | { | 357 | { |
341 | FPRINTF (stderr, | 358 | FPRINTF (stderr, |
342 | "%s", | 359 | "%s", |
343 | _("Revocation certificate ready, initiating revocation\n")); | 360 | _("Revocation certificate ready\n")); |
344 | perform_revocation (rd); | 361 | if (perform) |
362 | perform_revocation (rd); | ||
363 | else | ||
364 | GNUNET_SCHEDULER_shutdown (); | ||
345 | GNUNET_free (rd); | 365 | GNUNET_free (rd); |
346 | return; | 366 | return; |
347 | } | 367 | } |
@@ -432,10 +452,23 @@ run (void *cls, | |||
432 | filename); | 452 | filename); |
433 | return; | 453 | return; |
434 | } | 454 | } |
435 | perform_revocation (&rd); | ||
436 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, | 455 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, |
437 | &do_shutdown, | 456 | &do_shutdown, |
438 | NULL); | 457 | NULL); |
458 | if (GNUNET_YES != | ||
459 | GNUNET_REVOCATION_check_pow (&rd.key, | ||
460 | rd.pow, | ||
461 | (unsigned int) matching_bits)) | ||
462 | { | ||
463 | struct RevocationData *cp = GNUNET_new (struct RevocationData); | ||
464 | |||
465 | *cp = rd; | ||
466 | GNUNET_SCHEDULER_add_now (&calculate_pow, | ||
467 | cp); | ||
468 | return; | ||
469 | |||
470 | } | ||
471 | perform_revocation (&rd); | ||
439 | return; | 472 | return; |
440 | } | 473 | } |
441 | FPRINTF (stderr, | 474 | FPRINTF (stderr, |
diff --git a/src/revocation/gnunet-service-revocation.c b/src/revocation/gnunet-service-revocation.c index 6a29bb331..16c3640da 100644 --- a/src/revocation/gnunet-service-revocation.c +++ b/src/revocation/gnunet-service-revocation.c | |||
@@ -148,9 +148,7 @@ verify_revoke_message (const struct RevokeMessage *rm) | |||
148 | (unsigned int) revocation_work_required)) | 148 | (unsigned int) revocation_work_required)) |
149 | { | 149 | { |
150 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 150 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
151 | "Proof of work invalid: %llu!\n", | 151 | "Proof of work invalid!\n"); |
152 | (unsigned long long) | ||
153 | GNUNET_ntohll (rm->proof_of_work)); | ||
154 | GNUNET_break_op (0); | 152 | GNUNET_break_op (0); |
155 | return GNUNET_NO; | 153 | return GNUNET_NO; |
156 | } | 154 | } |
diff --git a/src/revocation/revocation_api.c b/src/revocation/revocation_api.c index acc13ba67..ebf85a94e 100644 --- a/src/revocation/revocation_api.c +++ b/src/revocation/revocation_api.c | |||
@@ -294,8 +294,8 @@ send_revoke (void *cls, | |||
294 | GNUNET_REVOCATION_revoke_cancel (h); | 294 | GNUNET_REVOCATION_revoke_cancel (h); |
295 | return 0; | 295 | return 0; |
296 | } | 296 | } |
297 | rm.header.size = htons (sizeof (struct QueryMessage)); | 297 | rm.header.size = htons (sizeof (struct RevokeMessage)); |
298 | rm.header.type = htons (GNUNET_MESSAGE_TYPE_REVOCATION_QUERY); | 298 | rm.header.type = htons (GNUNET_MESSAGE_TYPE_REVOCATION_REVOKE); |
299 | rm.reserved = htonl (0); | 299 | rm.reserved = htonl (0); |
300 | rm.proof_of_work = h->pow; | 300 | rm.proof_of_work = h->pow; |
301 | rm.purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_REVOCATION); | 301 | rm.purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_REVOCATION); |
diff --git a/src/revocation/test_revocation.conf b/src/revocation/test_revocation.conf new file mode 100644 index 000000000..b11a9ddcd --- /dev/null +++ b/src/revocation/test_revocation.conf | |||
@@ -0,0 +1,2 @@ | |||
1 | [revocation] | ||
2 | WORKBITS = 5 | ||