diff options
author | Christian Grothoff <christian@grothoff.org> | 2019-10-05 15:09:28 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2019-10-05 15:09:28 +0200 |
commit | c4e9ba925ffd758aaa3feee2ccfc0b76f26fe207 (patch) | |
tree | cac3ce030d77b4cbe7c7dc62ed58cfe6d24f73e1 /src/revocation/gnunet-revocation.c | |
parent | fbb71d527c7d6babf269a8fefce1db291b9f7068 (diff) | |
download | gnunet-c4e9ba925ffd758aaa3feee2ccfc0b76f26fe207.tar.gz gnunet-c4e9ba925ffd758aaa3feee2ccfc0b76f26fe207.zip |
global reindent, now with uncrustify hook enabled
Diffstat (limited to 'src/revocation/gnunet-revocation.c')
-rw-r--r-- | src/revocation/gnunet-revocation.c | 491 |
1 files changed, 246 insertions, 245 deletions
diff --git a/src/revocation/gnunet-revocation.c b/src/revocation/gnunet-revocation.c index da93e6903..652c1e62d 100644 --- a/src/revocation/gnunet-revocation.c +++ b/src/revocation/gnunet-revocation.c | |||
@@ -91,23 +91,23 @@ static struct GNUNET_SCHEDULER_Task *pow_task; | |||
91 | * @param cls closure | 91 | * @param cls closure |
92 | */ | 92 | */ |
93 | static void | 93 | static void |
94 | do_shutdown(void *cls) | 94 | do_shutdown (void *cls) |
95 | { | 95 | { |
96 | if (NULL != el) | 96 | if (NULL != el) |
97 | { | 97 | { |
98 | GNUNET_IDENTITY_ego_lookup_cancel(el); | 98 | GNUNET_IDENTITY_ego_lookup_cancel (el); |
99 | el = NULL; | 99 | el = NULL; |
100 | } | 100 | } |
101 | if (NULL != q) | 101 | if (NULL != q) |
102 | { | 102 | { |
103 | GNUNET_REVOCATION_query_cancel(q); | 103 | GNUNET_REVOCATION_query_cancel (q); |
104 | q = NULL; | 104 | q = NULL; |
105 | } | 105 | } |
106 | if (NULL != h) | 106 | if (NULL != h) |
107 | { | 107 | { |
108 | GNUNET_REVOCATION_revoke_cancel(h); | 108 | GNUNET_REVOCATION_revoke_cancel (h); |
109 | h = NULL; | 109 | h = NULL; |
110 | } | 110 | } |
111 | } | 111 | } |
112 | 112 | ||
113 | 113 | ||
@@ -118,28 +118,28 @@ do_shutdown(void *cls) | |||
118 | * @param is_valid #GNUNET_YES if the key is still valid, #GNUNET_NO if not, #GNUNET_SYSERR on error | 118 | * @param is_valid #GNUNET_YES if the key is still valid, #GNUNET_NO if not, #GNUNET_SYSERR on error |
119 | */ | 119 | */ |
120 | static void | 120 | static void |
121 | print_query_result(void *cls, int is_valid) | 121 | print_query_result (void *cls, int is_valid) |
122 | { | 122 | { |
123 | q = NULL; | 123 | q = NULL; |
124 | switch (is_valid) | 124 | switch (is_valid) |
125 | { | 125 | { |
126 | case GNUNET_YES: | 126 | case GNUNET_YES: |
127 | fprintf(stdout, _("Key `%s' is valid\n"), test_ego); | 127 | fprintf (stdout, _ ("Key `%s' is valid\n"), test_ego); |
128 | break; | 128 | break; |
129 | 129 | ||
130 | case GNUNET_NO: | 130 | case GNUNET_NO: |
131 | fprintf(stdout, _("Key `%s' has been revoked\n"), test_ego); | 131 | fprintf (stdout, _ ("Key `%s' has been revoked\n"), test_ego); |
132 | break; | 132 | break; |
133 | 133 | ||
134 | case GNUNET_SYSERR: | 134 | case GNUNET_SYSERR: |
135 | fprintf(stdout, "%s", _("Internal error\n")); | 135 | fprintf (stdout, "%s", _ ("Internal error\n")); |
136 | break; | 136 | break; |
137 | 137 | ||
138 | default: | 138 | default: |
139 | GNUNET_break(0); | 139 | GNUNET_break (0); |
140 | break; | 140 | break; |
141 | } | 141 | } |
142 | GNUNET_SCHEDULER_shutdown(); | 142 | GNUNET_SCHEDULER_shutdown (); |
143 | } | 143 | } |
144 | 144 | ||
145 | 145 | ||
@@ -150,47 +150,48 @@ print_query_result(void *cls, int is_valid) | |||
150 | * @param is_valid #GNUNET_YES if the key is still valid, #GNUNET_NO if not, #GNUNET_SYSERR on error | 150 | * @param is_valid #GNUNET_YES if the key is still valid, #GNUNET_NO if not, #GNUNET_SYSERR on error |
151 | */ | 151 | */ |
152 | static void | 152 | static void |
153 | print_revocation_result(void *cls, int is_valid) | 153 | print_revocation_result (void *cls, int is_valid) |
154 | { | 154 | { |
155 | h = NULL; | 155 | h = NULL; |
156 | switch (is_valid) | 156 | switch (is_valid) |
157 | { | 157 | { |
158 | case GNUNET_YES: | 158 | case GNUNET_YES: |
159 | if (NULL != revoke_ego) | 159 | if (NULL != revoke_ego) |
160 | fprintf(stdout, | 160 | fprintf (stdout, |
161 | _("Key for ego `%s' is still valid, revocation failed (!)\n"), | 161 | _ ("Key for ego `%s' is still valid, revocation failed (!)\n"), |
162 | revoke_ego); | 162 | revoke_ego); |
163 | else | 163 | else |
164 | fprintf(stdout, "%s", _("Revocation failed (!)\n")); | 164 | fprintf (stdout, "%s", _ ("Revocation failed (!)\n")); |
165 | break; | 165 | break; |
166 | 166 | ||
167 | case GNUNET_NO: | 167 | case GNUNET_NO: |
168 | if (NULL != revoke_ego) | 168 | if (NULL != revoke_ego) |
169 | fprintf(stdout, | 169 | fprintf (stdout, |
170 | _("Key for ego `%s' has been successfully revoked\n"), | 170 | _ ("Key for ego `%s' has been successfully revoked\n"), |
171 | revoke_ego); | 171 | revoke_ego); |
172 | else | 172 | else |
173 | fprintf(stdout, "%s", _("Revocation successful.\n")); | 173 | fprintf (stdout, "%s", _ ("Revocation successful.\n")); |
174 | break; | 174 | break; |
175 | 175 | ||
176 | case GNUNET_SYSERR: | 176 | case GNUNET_SYSERR: |
177 | fprintf(stdout, | 177 | fprintf (stdout, |
178 | "%s", | 178 | "%s", |
179 | _("Internal error, key revocation might have failed\n")); | 179 | _ ("Internal error, key revocation might have failed\n")); |
180 | break; | 180 | break; |
181 | 181 | ||
182 | default: | 182 | default: |
183 | GNUNET_break(0); | 183 | GNUNET_break (0); |
184 | break; | 184 | break; |
185 | } | 185 | } |
186 | GNUNET_SCHEDULER_shutdown(); | 186 | GNUNET_SCHEDULER_shutdown (); |
187 | } | 187 | } |
188 | 188 | ||
189 | 189 | ||
190 | /** | 190 | /** |
191 | * Data needed to perform a revocation. | 191 | * Data needed to perform a revocation. |
192 | */ | 192 | */ |
193 | struct RevocationData { | 193 | struct RevocationData |
194 | { | ||
194 | /** | 195 | /** |
195 | * Public key. | 196 | * Public key. |
196 | */ | 197 | */ |
@@ -212,14 +213,14 @@ struct RevocationData { | |||
212 | * Perform the revocation. | 213 | * Perform the revocation. |
213 | */ | 214 | */ |
214 | static void | 215 | static void |
215 | perform_revocation(const struct RevocationData *rd) | 216 | perform_revocation (const struct RevocationData *rd) |
216 | { | 217 | { |
217 | h = GNUNET_REVOCATION_revoke(cfg, | 218 | h = GNUNET_REVOCATION_revoke (cfg, |
218 | &rd->key, | 219 | &rd->key, |
219 | &rd->sig, | 220 | &rd->sig, |
220 | rd->pow, | 221 | rd->pow, |
221 | &print_revocation_result, | 222 | &print_revocation_result, |
222 | NULL); | 223 | NULL); |
223 | } | 224 | } |
224 | 225 | ||
225 | 226 | ||
@@ -230,16 +231,16 @@ perform_revocation(const struct RevocationData *rd) | |||
230 | * @param rd data to sync | 231 | * @param rd data to sync |
231 | */ | 232 | */ |
232 | static void | 233 | static void |
233 | sync_rd(const struct RevocationData *rd) | 234 | sync_rd (const struct RevocationData *rd) |
234 | { | 235 | { |
235 | if ((NULL != filename) && | 236 | if ((NULL != filename) && |
236 | (sizeof(struct RevocationData) == | 237 | (sizeof(struct RevocationData) == |
237 | GNUNET_DISK_fn_write(filename, | 238 | GNUNET_DISK_fn_write (filename, |
238 | &rd, | 239 | &rd, |
239 | sizeof(rd), | 240 | sizeof(rd), |
240 | GNUNET_DISK_PERM_USER_READ | | 241 | GNUNET_DISK_PERM_USER_READ |
241 | GNUNET_DISK_PERM_USER_WRITE))) | 242 | | GNUNET_DISK_PERM_USER_WRITE))) |
242 | GNUNET_log_strerror_file(GNUNET_ERROR_TYPE_ERROR, "write", filename); | 243 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, "write", filename); |
243 | } | 244 | } |
244 | 245 | ||
245 | 246 | ||
@@ -249,17 +250,17 @@ sync_rd(const struct RevocationData *rd) | |||
249 | * @param cls the `struct RevocationData` | 250 | * @param cls the `struct RevocationData` |
250 | */ | 251 | */ |
251 | static void | 252 | static void |
252 | calculate_pow_shutdown(void *cls) | 253 | calculate_pow_shutdown (void *cls) |
253 | { | 254 | { |
254 | struct RevocationData *rd = cls; | 255 | struct RevocationData *rd = cls; |
255 | 256 | ||
256 | if (NULL != pow_task) | 257 | if (NULL != pow_task) |
257 | { | 258 | { |
258 | GNUNET_SCHEDULER_cancel(pow_task); | 259 | GNUNET_SCHEDULER_cancel (pow_task); |
259 | pow_task = NULL; | 260 | pow_task = NULL; |
260 | } | 261 | } |
261 | sync_rd(rd); | 262 | sync_rd (rd); |
262 | GNUNET_free(rd); | 263 | GNUNET_free (rd); |
263 | } | 264 | } |
264 | 265 | ||
265 | 266 | ||
@@ -269,53 +270,53 @@ calculate_pow_shutdown(void *cls) | |||
269 | * @param cls the `struct RevocationData` | 270 | * @param cls the `struct RevocationData` |
270 | */ | 271 | */ |
271 | static void | 272 | static void |
272 | calculate_pow(void *cls) | 273 | calculate_pow (void *cls) |
273 | { | 274 | { |
274 | struct RevocationData *rd = cls; | 275 | struct RevocationData *rd = cls; |
275 | 276 | ||
276 | /* store temporary results */ | 277 | /* store temporary results */ |
277 | pow_task = NULL; | 278 | pow_task = NULL; |
278 | if (0 == (rd->pow % 128)) | 279 | if (0 == (rd->pow % 128)) |
279 | sync_rd(rd); | 280 | sync_rd (rd); |
280 | /* display progress estimate */ | 281 | /* display progress estimate */ |
281 | if ((0 == ((1 << matching_bits) / 100 / 50)) || | 282 | if ((0 == ((1 << matching_bits) / 100 / 50)) || |
282 | (0 == (rd->pow % ((1 << matching_bits) / 100 / 50)))) | 283 | (0 == (rd->pow % ((1 << matching_bits) / 100 / 50)))) |
283 | fprintf(stderr, "%s", "."); | 284 | fprintf (stderr, "%s", "."); |
284 | if ((0 != rd->pow) && ((0 == ((1 << matching_bits) / 100)) || | 285 | if ((0 != rd->pow) && ((0 == ((1 << matching_bits) / 100)) || |
285 | (0 == (rd->pow % ((1 << matching_bits) / 100))))) | 286 | (0 == (rd->pow % ((1 << matching_bits) / 100))))) |
286 | fprintf(stderr, | 287 | fprintf (stderr, |
287 | " - @ %3u%% (estimate)\n", | 288 | " - @ %3u%% (estimate)\n", |
288 | (unsigned int)(rd->pow * 100) / (1 << matching_bits)); | 289 | (unsigned int) (rd->pow * 100) / (1 << matching_bits)); |
289 | /* actually do POW calculation */ | 290 | /* actually do POW calculation */ |
290 | rd->pow++; | 291 | rd->pow++; |
291 | if (GNUNET_OK == GNUNET_REVOCATION_check_pow(&rd->key, | 292 | if (GNUNET_OK == GNUNET_REVOCATION_check_pow (&rd->key, |
292 | rd->pow, | 293 | rd->pow, |
293 | (unsigned int)matching_bits)) | 294 | (unsigned int) matching_bits)) |
295 | { | ||
296 | if ((NULL != filename) && | ||
297 | (sizeof(struct RevocationData) != | ||
298 | GNUNET_DISK_fn_write (filename, | ||
299 | rd, | ||
300 | sizeof(struct RevocationData), | ||
301 | GNUNET_DISK_PERM_USER_READ | ||
302 | | GNUNET_DISK_PERM_USER_WRITE))) | ||
303 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, "write", filename); | ||
304 | if (perform) | ||
294 | { | 305 | { |
295 | if ((NULL != filename) && | 306 | perform_revocation (rd); |
296 | (sizeof(struct RevocationData) != | ||
297 | GNUNET_DISK_fn_write(filename, | ||
298 | rd, | ||
299 | sizeof(struct RevocationData), | ||
300 | GNUNET_DISK_PERM_USER_READ | | ||
301 | GNUNET_DISK_PERM_USER_WRITE))) | ||
302 | GNUNET_log_strerror_file(GNUNET_ERROR_TYPE_ERROR, "write", filename); | ||
303 | if (perform) | ||
304 | { | ||
305 | perform_revocation(rd); | ||
306 | } | ||
307 | else | ||
308 | { | ||
309 | fprintf(stderr, "%s", "\n"); | ||
310 | fprintf(stderr, | ||
311 | _("Revocation certificate for `%s' stored in `%s'\n"), | ||
312 | revoke_ego, | ||
313 | filename); | ||
314 | GNUNET_SCHEDULER_shutdown(); | ||
315 | } | ||
316 | return; | ||
317 | } | 307 | } |
318 | pow_task = GNUNET_SCHEDULER_add_now(&calculate_pow, rd); | 308 | else |
309 | { | ||
310 | fprintf (stderr, "%s", "\n"); | ||
311 | fprintf (stderr, | ||
312 | _ ("Revocation certificate for `%s' stored in `%s'\n"), | ||
313 | revoke_ego, | ||
314 | filename); | ||
315 | GNUNET_SCHEDULER_shutdown (); | ||
316 | } | ||
317 | return; | ||
318 | } | ||
319 | pow_task = GNUNET_SCHEDULER_add_now (&calculate_pow, rd); | ||
319 | } | 320 | } |
320 | 321 | ||
321 | 322 | ||
@@ -326,57 +327,57 @@ calculate_pow(void *cls) | |||
326 | * @param ego the ego, NULL if not found | 327 | * @param ego the ego, NULL if not found |
327 | */ | 328 | */ |
328 | static void | 329 | static void |
329 | ego_callback(void *cls, const struct GNUNET_IDENTITY_Ego *ego) | 330 | ego_callback (void *cls, const struct GNUNET_IDENTITY_Ego *ego) |
330 | { | 331 | { |
331 | struct RevocationData *rd; | 332 | struct RevocationData *rd; |
332 | struct GNUNET_CRYPTO_EcdsaPublicKey key; | 333 | struct GNUNET_CRYPTO_EcdsaPublicKey key; |
333 | 334 | ||
334 | el = NULL; | 335 | el = NULL; |
335 | if (NULL == ego) | 336 | if (NULL == ego) |
336 | { | 337 | { |
337 | fprintf(stdout, _("Ego `%s' not found.\n"), revoke_ego); | 338 | fprintf (stdout, _ ("Ego `%s' not found.\n"), revoke_ego); |
338 | GNUNET_SCHEDULER_shutdown(); | 339 | GNUNET_SCHEDULER_shutdown (); |
339 | return; | 340 | return; |
340 | } | 341 | } |
341 | GNUNET_IDENTITY_ego_get_public_key(ego, &key); | 342 | GNUNET_IDENTITY_ego_get_public_key (ego, &key); |
342 | rd = GNUNET_new(struct RevocationData); | 343 | rd = GNUNET_new (struct RevocationData); |
343 | if ((NULL != filename) && (GNUNET_YES == GNUNET_DISK_file_test(filename)) && | 344 | if ((NULL != filename) && (GNUNET_YES == GNUNET_DISK_file_test (filename)) && |
344 | (sizeof(struct RevocationData) == | 345 | (sizeof(struct RevocationData) == |
345 | GNUNET_DISK_fn_read(filename, rd, sizeof(struct RevocationData)))) | 346 | GNUNET_DISK_fn_read (filename, rd, sizeof(struct RevocationData)))) |
347 | { | ||
348 | if (0 != GNUNET_memcmp (&rd->key, &key)) | ||
346 | { | 349 | { |
347 | if (0 != GNUNET_memcmp(&rd->key, &key)) | 350 | fprintf (stderr, |
348 | { | 351 | _ ("Error: revocation certificate in `%s' is not for `%s'\n"), |
349 | fprintf(stderr, | 352 | filename, |
350 | _("Error: revocation certificate in `%s' is not for `%s'\n"), | 353 | revoke_ego); |
351 | filename, | 354 | GNUNET_free (rd); |
352 | revoke_ego); | 355 | return; |
353 | GNUNET_free(rd); | ||
354 | return; | ||
355 | } | ||
356 | } | 356 | } |
357 | } | ||
357 | else | 358 | else |
358 | { | 359 | { |
359 | GNUNET_REVOCATION_sign_revocation(GNUNET_IDENTITY_ego_get_private_key( | 360 | GNUNET_REVOCATION_sign_revocation (GNUNET_IDENTITY_ego_get_private_key ( |
360 | ego), | 361 | ego), |
361 | &rd->sig); | 362 | &rd->sig); |
362 | rd->key = key; | 363 | rd->key = key; |
363 | } | 364 | } |
364 | if (GNUNET_YES == | 365 | if (GNUNET_YES == |
365 | GNUNET_REVOCATION_check_pow(&key, rd->pow, (unsigned int)matching_bits)) | 366 | GNUNET_REVOCATION_check_pow (&key, rd->pow, (unsigned int) matching_bits)) |
366 | { | 367 | { |
367 | fprintf(stderr, "%s", _("Revocation certificate ready\n")); | 368 | fprintf (stderr, "%s", _ ("Revocation certificate ready\n")); |
368 | if (perform) | 369 | if (perform) |
369 | perform_revocation(rd); | 370 | perform_revocation (rd); |
370 | else | 371 | else |
371 | GNUNET_SCHEDULER_shutdown(); | 372 | GNUNET_SCHEDULER_shutdown (); |
372 | GNUNET_free(rd); | 373 | GNUNET_free (rd); |
373 | return; | 374 | return; |
374 | } | 375 | } |
375 | fprintf(stderr, | 376 | fprintf (stderr, |
376 | "%s", | 377 | "%s", |
377 | _("Revocation certificate not ready, calculating proof of work\n")); | 378 | _ ("Revocation certificate not ready, calculating proof of work\n")); |
378 | pow_task = GNUNET_SCHEDULER_add_now(&calculate_pow, rd); | 379 | pow_task = GNUNET_SCHEDULER_add_now (&calculate_pow, rd); |
379 | GNUNET_SCHEDULER_add_shutdown(&calculate_pow_shutdown, rd); | 380 | GNUNET_SCHEDULER_add_shutdown (&calculate_pow_shutdown, rd); |
380 | } | 381 | } |
381 | 382 | ||
382 | 383 | ||
@@ -389,85 +390,85 @@ ego_callback(void *cls, const struct GNUNET_IDENTITY_Ego *ego) | |||
389 | * @param c configuration | 390 | * @param c configuration |
390 | */ | 391 | */ |
391 | static void | 392 | static void |
392 | run(void *cls, | 393 | run (void *cls, |
393 | char *const *args, | 394 | char *const *args, |
394 | const char *cfgfile, | 395 | const char *cfgfile, |
395 | const struct GNUNET_CONFIGURATION_Handle *c) | 396 | const struct GNUNET_CONFIGURATION_Handle *c) |
396 | { | 397 | { |
397 | struct GNUNET_CRYPTO_EcdsaPublicKey pk; | 398 | struct GNUNET_CRYPTO_EcdsaPublicKey pk; |
398 | struct RevocationData rd; | 399 | struct RevocationData rd; |
399 | 400 | ||
400 | cfg = c; | 401 | cfg = c; |
401 | if (NULL != test_ego) | 402 | if (NULL != test_ego) |
403 | { | ||
404 | if (GNUNET_OK != | ||
405 | GNUNET_CRYPTO_ecdsa_public_key_from_string (test_ego, | ||
406 | strlen (test_ego), | ||
407 | &pk)) | ||
402 | { | 408 | { |
403 | if (GNUNET_OK != | 409 | fprintf (stderr, _ ("Public key `%s' malformed\n"), test_ego); |
404 | GNUNET_CRYPTO_ecdsa_public_key_from_string(test_ego, | ||
405 | strlen(test_ego), | ||
406 | &pk)) | ||
407 | { | ||
408 | fprintf(stderr, _("Public key `%s' malformed\n"), test_ego); | ||
409 | return; | ||
410 | } | ||
411 | GNUNET_SCHEDULER_add_shutdown(&do_shutdown, NULL); | ||
412 | q = GNUNET_REVOCATION_query(cfg, &pk, &print_query_result, NULL); | ||
413 | if (NULL != revoke_ego) | ||
414 | fprintf( | ||
415 | stderr, | ||
416 | "%s", | ||
417 | _( | ||
418 | "Testing and revoking at the same time is not allowed, only executing test.\n")); | ||
419 | return; | 410 | return; |
420 | } | 411 | } |
421 | if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_number(cfg, | 412 | GNUNET_SCHEDULER_add_shutdown (&do_shutdown, NULL); |
422 | "REVOCATION", | 413 | q = GNUNET_REVOCATION_query (cfg, &pk, &print_query_result, NULL); |
423 | "WORKBITS", | 414 | if (NULL != revoke_ego) |
424 | &matching_bits)) | 415 | fprintf ( |
416 | stderr, | ||
417 | "%s", | ||
418 | _ ( | ||
419 | "Testing and revoking at the same time is not allowed, only executing test.\n")); | ||
420 | return; | ||
421 | } | ||
422 | if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_number (cfg, | ||
423 | "REVOCATION", | ||
424 | "WORKBITS", | ||
425 | &matching_bits)) | ||
426 | { | ||
427 | GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, | ||
428 | "REVOCATION", | ||
429 | "WORKBITS"); | ||
430 | return; | ||
431 | } | ||
432 | if (NULL != revoke_ego) | ||
433 | { | ||
434 | if (! perform && (NULL == filename)) | ||
425 | { | 435 | { |
426 | GNUNET_log_config_missing(GNUNET_ERROR_TYPE_ERROR, | 436 | fprintf (stderr, |
427 | "REVOCATION", | 437 | "%s", |
428 | "WORKBITS"); | 438 | _ ("No filename to store revocation certificate given.\n")); |
429 | return; | 439 | return; |
430 | } | 440 | } |
431 | if (NULL != revoke_ego) | 441 | /* main code here */ |
442 | el = GNUNET_IDENTITY_ego_lookup (cfg, revoke_ego, &ego_callback, NULL); | ||
443 | GNUNET_SCHEDULER_add_shutdown (&do_shutdown, NULL); | ||
444 | return; | ||
445 | } | ||
446 | if ((NULL != filename) && (perform)) | ||
447 | { | ||
448 | if (sizeof(rd) != GNUNET_DISK_fn_read (filename, &rd, sizeof(rd))) | ||
432 | { | 449 | { |
433 | if (!perform && (NULL == filename)) | 450 | fprintf (stderr, |
434 | { | 451 | _ ("Failed to read revocation certificate from `%s'\n"), |
435 | fprintf(stderr, | 452 | filename); |
436 | "%s", | ||
437 | _("No filename to store revocation certificate given.\n")); | ||
438 | return; | ||
439 | } | ||
440 | /* main code here */ | ||
441 | el = GNUNET_IDENTITY_ego_lookup(cfg, revoke_ego, &ego_callback, NULL); | ||
442 | GNUNET_SCHEDULER_add_shutdown(&do_shutdown, NULL); | ||
443 | return; | 453 | return; |
444 | } | 454 | } |
445 | if ((NULL != filename) && (perform)) | 455 | GNUNET_SCHEDULER_add_shutdown (&do_shutdown, NULL); |
456 | if (GNUNET_YES != | ||
457 | GNUNET_REVOCATION_check_pow (&rd.key, | ||
458 | rd.pow, | ||
459 | (unsigned int) matching_bits)) | ||
446 | { | 460 | { |
447 | if (sizeof(rd) != GNUNET_DISK_fn_read(filename, &rd, sizeof(rd))) | 461 | struct RevocationData *cp = GNUNET_new (struct RevocationData); |
448 | { | 462 | |
449 | fprintf(stderr, | 463 | *cp = rd; |
450 | _("Failed to read revocation certificate from `%s'\n"), | 464 | pow_task = GNUNET_SCHEDULER_add_now (&calculate_pow, cp); |
451 | filename); | 465 | GNUNET_SCHEDULER_add_shutdown (&calculate_pow_shutdown, cp); |
452 | return; | ||
453 | } | ||
454 | GNUNET_SCHEDULER_add_shutdown(&do_shutdown, NULL); | ||
455 | if (GNUNET_YES != | ||
456 | GNUNET_REVOCATION_check_pow(&rd.key, | ||
457 | rd.pow, | ||
458 | (unsigned int)matching_bits)) | ||
459 | { | ||
460 | struct RevocationData *cp = GNUNET_new(struct RevocationData); | ||
461 | |||
462 | *cp = rd; | ||
463 | pow_task = GNUNET_SCHEDULER_add_now(&calculate_pow, cp); | ||
464 | GNUNET_SCHEDULER_add_shutdown(&calculate_pow_shutdown, cp); | ||
465 | return; | ||
466 | } | ||
467 | perform_revocation(&rd); | ||
468 | return; | 466 | return; |
469 | } | 467 | } |
470 | fprintf(stderr, "%s", _("No action specified. Nothing to do.\n")); | 468 | perform_revocation (&rd); |
469 | return; | ||
470 | } | ||
471 | fprintf (stderr, "%s", _ ("No action specified. Nothing to do.\n")); | ||
471 | } | 472 | } |
472 | 473 | ||
473 | 474 | ||
@@ -479,54 +480,54 @@ run(void *cls, | |||
479 | * @return 0 ok, 1 on error | 480 | * @return 0 ok, 1 on error |
480 | */ | 481 | */ |
481 | int | 482 | int |
482 | main(int argc, char *const *argv) | 483 | main (int argc, char *const *argv) |
483 | { | 484 | { |
484 | struct GNUNET_GETOPT_CommandLineOption options[] = { | 485 | struct GNUNET_GETOPT_CommandLineOption options[] = { |
485 | GNUNET_GETOPT_option_string('f', | 486 | GNUNET_GETOPT_option_string ('f', |
486 | "filename", | 487 | "filename", |
487 | "NAME", | 488 | "NAME", |
488 | gettext_noop( | 489 | gettext_noop ( |
489 | "use NAME for the name of the revocation file"), | 490 | "use NAME for the name of the revocation file"), |
490 | &filename), | 491 | &filename), |
491 | 492 | ||
492 | GNUNET_GETOPT_option_string( | 493 | GNUNET_GETOPT_option_string ( |
493 | 'R', | 494 | 'R', |
494 | "revoke", | 495 | "revoke", |
495 | "NAME", | 496 | "NAME", |
496 | gettext_noop( | 497 | gettext_noop ( |
497 | "revoke the private key associated for the the private key associated with the ego NAME "), | 498 | "revoke the private key associated for the the private key associated with the ego NAME "), |
498 | &revoke_ego), | 499 | &revoke_ego), |
499 | 500 | ||
500 | GNUNET_GETOPT_option_flag( | 501 | GNUNET_GETOPT_option_flag ( |
501 | 'p', | 502 | 'p', |
502 | "perform", | 503 | "perform", |
503 | gettext_noop( | 504 | gettext_noop ( |
504 | "actually perform revocation, otherwise we just do the precomputation"), | 505 | "actually perform revocation, otherwise we just do the precomputation"), |
505 | &perform), | 506 | &perform), |
506 | 507 | ||
507 | GNUNET_GETOPT_option_string('t', | 508 | GNUNET_GETOPT_option_string ('t', |
508 | "test", | 509 | "test", |
509 | "KEY", | 510 | "KEY", |
510 | gettext_noop( | 511 | gettext_noop ( |
511 | "test if the public key KEY has been revoked"), | 512 | "test if the public key KEY has been revoked"), |
512 | &test_ego), | 513 | &test_ego), |
513 | 514 | ||
514 | GNUNET_GETOPT_OPTION_END | 515 | GNUNET_GETOPT_OPTION_END |
515 | }; | 516 | }; |
516 | 517 | ||
517 | if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args(argc, argv, &argc, &argv)) | 518 | if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv)) |
518 | return 2; | 519 | return 2; |
519 | 520 | ||
520 | ret = (GNUNET_OK == GNUNET_PROGRAM_run(argc, | 521 | ret = (GNUNET_OK == GNUNET_PROGRAM_run (argc, |
521 | argv, | 522 | argv, |
522 | "gnunet-revocation", | 523 | "gnunet-revocation", |
523 | gettext_noop("help text"), | 524 | gettext_noop ("help text"), |
524 | options, | 525 | options, |
525 | &run, | 526 | &run, |
526 | NULL)) | 527 | NULL)) |
527 | ? ret | 528 | ? ret |
528 | : 1; | 529 | : 1; |
529 | GNUNET_free((void *)argv); | 530 | GNUNET_free ((void *) argv); |
530 | return ret; | 531 | return ret; |
531 | } | 532 | } |
532 | 533 | ||