aboutsummaryrefslogtreecommitdiff
path: root/src/revocation
diff options
context:
space:
mode:
Diffstat (limited to 'src/revocation')
-rw-r--r--src/revocation/gnunet-revocation.c20
-rw-r--r--src/revocation/gnunet-service-revocation.c60
-rw-r--r--src/revocation/revocation_api.c14
3 files changed, 47 insertions, 47 deletions
diff --git a/src/revocation/gnunet-revocation.c b/src/revocation/gnunet-revocation.c
index 10259fc99..1859722d8 100644
--- a/src/revocation/gnunet-revocation.c
+++ b/src/revocation/gnunet-revocation.c
@@ -61,7 +61,7 @@ static struct GNUNET_REVOCATION_Query *q;
61 61
62/** 62/**
63 * Handle for revocation. 63 * Handle for revocation.
64 */ 64 */
65static struct GNUNET_REVOCATION_Handle *h; 65static struct GNUNET_REVOCATION_Handle *h;
66 66
67/** 67/**
@@ -71,12 +71,12 @@ static struct GNUNET_IDENTITY_EgoLookup *el;
71 71
72/** 72/**
73 * Our configuration. 73 * Our configuration.
74 */ 74 */
75static const struct GNUNET_CONFIGURATION_Handle *cfg; 75static const struct GNUNET_CONFIGURATION_Handle *cfg;
76 76
77/** 77/**
78 * Number of matching bits required for revocation. 78 * Number of matching bits required for revocation.
79 */ 79 */
80static unsigned long long matching_bits; 80static unsigned long long matching_bits;
81 81
82 82
@@ -178,7 +178,7 @@ print_revocation_result (void *cls,
178/** 178/**
179 * Data needed to perform a revocation. 179 * Data needed to perform a revocation.
180 */ 180 */
181struct RevocationData 181struct RevocationData
182{ 182{
183 /** 183 /**
184 * Public key. 184 * Public key.
@@ -226,7 +226,7 @@ calculate_pow (void *cls,
226 226
227 if ( (0 != (GNUNET_SCHEDULER_REASON_SHUTDOWN & tc->reason)) || 227 if ( (0 != (GNUNET_SCHEDULER_REASON_SHUTDOWN & tc->reason)) ||
228 (0 == (rd->pow % 128) ) ) 228 (0 == (rd->pow % 128) ) )
229 { 229 {
230 if (0 == (rd->pow % 128 * 1024)) 230 if (0 == (rd->pow % 128 * 1024))
231 { 231 {
232 if (0 == (rd->pow % (1024 * 128 * 80))) 232 if (0 == (rd->pow % (1024 * 128 * 80)))
@@ -308,7 +308,7 @@ ego_callback (void *cls,
308 &key); 308 &key);
309 rd = GNUNET_new (struct RevocationData); 309 rd = GNUNET_new (struct RevocationData);
310 if ( (NULL != filename) && 310 if ( (NULL != filename) &&
311 (GNUNET_YES == 311 (GNUNET_YES ==
312 GNUNET_DISK_file_test (filename)) && 312 GNUNET_DISK_file_test (filename)) &&
313 (sizeof (struct RevocationData) == 313 (sizeof (struct RevocationData) ==
314 GNUNET_DISK_fn_read (filename, 314 GNUNET_DISK_fn_read (filename,
@@ -325,10 +325,10 @@ ego_callback (void *cls,
325 revoke_ego); 325 revoke_ego);
326 GNUNET_free (rd); 326 GNUNET_free (rd);
327 return; 327 return;
328 } 328 }
329 } 329 }
330 else 330 else
331 { 331 {
332 GNUNET_REVOCATION_sign_revocation (GNUNET_IDENTITY_ego_get_private_key (ego), 332 GNUNET_REVOCATION_sign_revocation (GNUNET_IDENTITY_ego_get_private_key (ego),
333 &rd->sig); 333 &rd->sig);
334 rd->key = key; 334 rd->key = key;
@@ -362,8 +362,8 @@ ego_callback (void *cls,
362 * @param c configuration 362 * @param c configuration
363 */ 363 */
364static void 364static void
365run (void *cls, 365run (void *cls,
366 char *const *args, 366 char *const *args,
367 const char *cfgfile, 367 const char *cfgfile,
368 const struct GNUNET_CONFIGURATION_Handle *c) 368 const struct GNUNET_CONFIGURATION_Handle *c)
369{ 369{
diff --git a/src/revocation/gnunet-service-revocation.c b/src/revocation/gnunet-service-revocation.c
index c4622279a..7f85301be 100644
--- a/src/revocation/gnunet-service-revocation.c
+++ b/src/revocation/gnunet-service-revocation.c
@@ -34,7 +34,7 @@
34 * - broadcast p2p revocations 34 * - broadcast p2p revocations
35 * - handle p2p connect (trigger SET union) 35 * - handle p2p connect (trigger SET union)
36 * - optimization: avoid sending revocation back to peer that we got it from; 36 * - optimization: avoid sending revocation back to peer that we got it from;
37 * - optimization: have randomized delay in sending revocations to other peers 37 * - optimization: have randomized delay in sending revocations to other peers
38 * to make it rare to traverse each link twice (NSE-style) 38 * to make it rare to traverse each link twice (NSE-style)
39 */ 39 */
40#include "platform.h" 40#include "platform.h"
@@ -83,7 +83,7 @@ static struct GNUNET_SET_Handle *revocation_set;
83/** 83/**
84 * Hash map with all revoked keys, maps the hash of the public key 84 * Hash map with all revoked keys, maps the hash of the public key
85 * to the respective `struct RevokeMessage`. 85 * to the respective `struct RevokeMessage`.
86 */ 86 */
87static struct GNUNET_CONTAINER_MultiHashMap *revocation_map; 87static struct GNUNET_CONTAINER_MultiHashMap *revocation_map;
88 88
89/** 89/**
@@ -147,7 +147,7 @@ verify_revoke_message (const struct RevokeMessage *rm)
147 rm->proof_of_work, 147 rm->proof_of_work,
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: %llu!\n",
152 (unsigned long long) 152 (unsigned long long)
153 GNUNET_ntohll (rm->proof_of_work)); 153 GNUNET_ntohll (rm->proof_of_work));
@@ -175,7 +175,7 @@ verify_revoke_message (const struct RevokeMessage *rm)
175 * @param message the message received 175 * @param message the message received
176 */ 176 */
177static void 177static void
178handle_query_message (void *cls, 178handle_query_message (void *cls,
179 struct GNUNET_SERVER_Client *client, 179 struct GNUNET_SERVER_Client *client,
180 const struct GNUNET_MessageHeader *message) 180 const struct GNUNET_MessageHeader *message)
181{ 181{
@@ -188,15 +188,15 @@ handle_query_message (void *cls,
188 sizeof (struct GNUNET_CRYPTO_EccPublicSignKey), 188 sizeof (struct GNUNET_CRYPTO_EccPublicSignKey),
189 &hc); 189 &hc);
190 res = GNUNET_CONTAINER_multihashmap_contains (revocation_map, &hc); 190 res = GNUNET_CONTAINER_multihashmap_contains (revocation_map, &hc);
191 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 191 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
192 (GNUNET_NO == res) 192 (GNUNET_NO == res)
193 ? "Received revocation check for valid key `%s' from client\n" 193 ? "Received revocation check for valid key `%s' from client\n"
194 : "Received revocation check for revoked key `%s' from client\n", 194 : "Received revocation check for revoked key `%s' from client\n",
195 GNUNET_h2s (&hc)); 195 GNUNET_h2s (&hc));
196 qrm.header.size = htons (sizeof (struct QueryResponseMessage)); 196 qrm.header.size = htons (sizeof (struct QueryResponseMessage));
197 qrm.header.type = htons (GNUNET_MESSAGE_TYPE_REVOCATION_QUERY_RESPONSE); 197 qrm.header.type = htons (GNUNET_MESSAGE_TYPE_REVOCATION_QUERY_RESPONSE);
198 qrm.is_valid = htons ((GNUNET_YES == res) ? GNUNET_NO : GNUNET_YES); 198 qrm.is_valid = htons ((GNUNET_YES == res) ? GNUNET_NO : GNUNET_YES);
199 GNUNET_SERVER_notification_context_add (nc, 199 GNUNET_SERVER_notification_context_add (nc,
200 client); 200 client);
201 GNUNET_SERVER_notification_context_unicast (nc, 201 GNUNET_SERVER_notification_context_unicast (nc,
202 client, 202 client,
@@ -228,7 +228,7 @@ do_flood (void *cls,
228 * Publicize revocation message. Stores the message locally in the 228 * Publicize revocation message. Stores the message locally in the
229 * database and passes it to all connected neighbours (and adds it to 229 * database and passes it to all connected neighbours (and adds it to
230 * the set for future connections). 230 * the set for future connections).
231 * 231 *
232 * @param rm message to publicize 232 * @param rm message to publicize
233 * @return #GNUNET_OK on success, #GNUNET_NO if we encountered an error, 233 * @return #GNUNET_OK on success, #GNUNET_NO if we encountered an error,
234 * #GNUNET_SYSERR if the message was malformed 234 * #GNUNET_SYSERR if the message was malformed
@@ -251,12 +251,12 @@ publicize_rm (const struct RevokeMessage *rm)
251 _("Duplicate revocation received from peer. Ignored.\n")); 251 _("Duplicate revocation received from peer. Ignored.\n"));
252 return GNUNET_OK; 252 return GNUNET_OK;
253 } 253 }
254 if (GNUNET_OK != 254 if (GNUNET_OK !=
255 verify_revoke_message (rm)) 255 verify_revoke_message (rm))
256 { 256 {
257 GNUNET_break_op (0); 257 GNUNET_break_op (0);
258 return GNUNET_SYSERR; 258 return GNUNET_SYSERR;
259 } 259 }
260 /* write to disk */ 260 /* write to disk */
261 if (sizeof (struct RevokeMessage) != 261 if (sizeof (struct RevokeMessage) !=
262 GNUNET_DISK_file_write (revocation_db, 262 GNUNET_DISK_file_write (revocation_db,
@@ -294,7 +294,7 @@ publicize_rm (const struct RevokeMessage *rm)
294 return GNUNET_OK; 294 return GNUNET_OK;
295 } 295 }
296 /* flood to neighbours */ 296 /* flood to neighbours */
297 GNUNET_CONTAINER_multipeermap_iterate (peers, 297 GNUNET_CONTAINER_multipeermap_iterate (peers,
298 &do_flood, 298 &do_flood,
299 cp); 299 cp);
300 return GNUNET_OK; 300 return GNUNET_OK;
@@ -309,7 +309,7 @@ publicize_rm (const struct RevokeMessage *rm)
309 * @param message the message received 309 * @param message the message received
310 */ 310 */
311static void 311static void
312handle_revoke_message (void *cls, 312handle_revoke_message (void *cls,
313 struct GNUNET_SERVER_Client *client, 313 struct GNUNET_SERVER_Client *client,
314 const struct GNUNET_MessageHeader *message) 314 const struct GNUNET_MessageHeader *message)
315{ 315{
@@ -317,7 +317,7 @@ handle_revoke_message (void *cls,
317 struct RevocationResponseMessage rrm; 317 struct RevocationResponseMessage rrm;
318 int ret; 318 int ret;
319 319
320 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 320 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
321 "Received REVOKE message from client\n"); 321 "Received REVOKE message from client\n");
322 rm = (const struct RevokeMessage *) message; 322 rm = (const struct RevokeMessage *) message;
323 if (GNUNET_SYSERR == (ret = publicize_rm (rm))) 323 if (GNUNET_SYSERR == (ret = publicize_rm (rm)))
@@ -329,7 +329,7 @@ handle_revoke_message (void *cls,
329 rrm.header.size = htons (sizeof (struct RevocationResponseMessage)); 329 rrm.header.size = htons (sizeof (struct RevocationResponseMessage));
330 rrm.header.type = htons (GNUNET_MESSAGE_TYPE_REVOCATION_REVOKE_RESPONSE); 330 rrm.header.type = htons (GNUNET_MESSAGE_TYPE_REVOCATION_REVOKE_RESPONSE);
331 rrm.is_valid = htons ((GNUNET_OK == ret) ? GNUNET_NO : GNUNET_YES); 331 rrm.is_valid = htons ((GNUNET_OK == ret) ? GNUNET_NO : GNUNET_YES);
332 GNUNET_SERVER_notification_context_add (nc, 332 GNUNET_SERVER_notification_context_add (nc,
333 client); 333 client);
334 GNUNET_SERVER_notification_context_unicast (nc, 334 GNUNET_SERVER_notification_context_unicast (nc,
335 client, 335 client,
@@ -347,13 +347,13 @@ handle_revoke_message (void *cls,
347 * @param peer peer identity this message is from (ignored) 347 * @param peer peer identity this message is from (ignored)
348 */ 348 */
349static int 349static int
350handle_p2p_revoke_message (void *cls, 350handle_p2p_revoke_message (void *cls,
351 const struct GNUNET_PeerIdentity *peer, 351 const struct GNUNET_PeerIdentity *peer,
352 const struct GNUNET_MessageHeader *message) 352 const struct GNUNET_MessageHeader *message)
353{ 353{
354 const struct RevokeMessage *rm; 354 const struct RevokeMessage *rm;
355 355
356 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 356 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
357 "Received REVOKE message from peer\n"); 357 "Received REVOKE message from peer\n");
358 rm = (const struct RevokeMessage *) message; 358 rm = (const struct RevokeMessage *) message;
359 GNUNET_break_op (GNUNET_SYSERR != publicize_rm (rm)); 359 GNUNET_break_op (GNUNET_SYSERR != publicize_rm (rm));
@@ -400,7 +400,7 @@ handle_core_connect (void *cls,
400 * @param peer peer identity this notification is about 400 * @param peer peer identity this notification is about
401 */ 401 */
402static void 402static void
403handle_core_disconnect (void *cls, 403handle_core_disconnect (void *cls,
404 const struct GNUNET_PeerIdentity *peer) 404 const struct GNUNET_PeerIdentity *peer)
405{ 405{
406 struct PeerEntry *pos; 406 struct PeerEntry *pos;
@@ -418,7 +418,7 @@ handle_core_disconnect (void *cls,
418 GNUNET_CONTAINER_multipeermap_remove (peers, peer, 418 GNUNET_CONTAINER_multipeermap_remove (peers, peer,
419 pos)); 419 pos));
420#if 0 420#if 0
421 if (pos->transmit_task != GNUNET_SCHEDULER_NO_TASK) 421 if (pos->transmit_task != GNUNET_SCHEDULER_NO_TASK)
422 { 422 {
423 GNUNET_SCHEDULER_cancel (pos->transmit_task); 423 GNUNET_SCHEDULER_cancel (pos->transmit_task);
424 pos->transmit_task = GNUNET_SCHEDULER_NO_TASK; 424 pos->transmit_task = GNUNET_SCHEDULER_NO_TASK;
@@ -436,7 +436,7 @@ handle_core_disconnect (void *cls,
436 436
437/** 437/**
438 * Free all values in a hash map. 438 * Free all values in a hash map.
439 * 439 *
440 * @param cls NULL 440 * @param cls NULL
441 * @param key the key 441 * @param key the key
442 * @param value value to free 442 * @param value value to free
@@ -506,12 +506,12 @@ shutdown_task (void *cls,
506 * @param identity the public identity of this peer 506 * @param identity the public identity of this peer
507 */ 507 */
508static void 508static void
509core_init (void *cls, 509core_init (void *cls,
510 const struct GNUNET_PeerIdentity *identity) 510 const struct GNUNET_PeerIdentity *identity)
511{ 511{
512 if (NULL == identity) 512 if (NULL == identity)
513 { 513 {
514 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 514 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
515 "Connection to core FAILED!\n"); 515 "Connection to core FAILED!\n");
516 GNUNET_SCHEDULER_shutdown (); 516 GNUNET_SCHEDULER_shutdown ();
517 return; 517 return;
@@ -528,7 +528,7 @@ core_init (void *cls,
528 * @param c configuration to use 528 * @param c configuration to use
529 */ 529 */
530static void 530static void
531run (void *cls, 531run (void *cls,
532 struct GNUNET_SERVER_Handle *server, 532 struct GNUNET_SERVER_Handle *server,
533 const struct GNUNET_CONFIGURATION_Handle *c) 533 const struct GNUNET_CONFIGURATION_Handle *c)
534{ 534{
@@ -562,7 +562,7 @@ run (void *cls,
562 return; 562 return;
563 } 563 }
564 cfg = c; 564 cfg = c;
565 srv = server; 565 srv = server;
566 revocation_map = GNUNET_CONTAINER_multihashmap_create (16, GNUNET_NO); 566 revocation_map = GNUNET_CONTAINER_multihashmap_create (16, GNUNET_NO);
567 nc = GNUNET_SERVER_notification_context_create (server, 1); 567 nc = GNUNET_SERVER_notification_context_create (server, 1);
568 if (GNUNET_OK != 568 if (GNUNET_OK !=
@@ -588,7 +588,7 @@ run (void *cls,
588 } 588 }
589 revocation_set = GNUNET_SET_create (cfg, 589 revocation_set = GNUNET_SET_create (cfg,
590 GNUNET_SET_OPERATION_UNION); 590 GNUNET_SET_OPERATION_UNION);
591 591
592 revocation_db = GNUNET_DISK_file_open (fn, 592 revocation_db = GNUNET_DISK_file_open (fn,
593 GNUNET_DISK_OPEN_READWRITE | 593 GNUNET_DISK_OPEN_READWRITE |
594 GNUNET_DISK_OPEN_CREATE, 594 GNUNET_DISK_OPEN_CREATE,
@@ -607,10 +607,10 @@ run (void *cls,
607 } 607 }
608 if (GNUNET_OK != 608 if (GNUNET_OK !=
609 GNUNET_DISK_file_size (fn, &left, GNUNET_YES, GNUNET_YES)) 609 GNUNET_DISK_file_size (fn, &left, GNUNET_YES, GNUNET_YES))
610 left = 0; 610 left = 0;
611 while (left > sizeof (struct RevokeMessage)) 611 while (left > sizeof (struct RevokeMessage))
612 { 612 {
613 rm = GNUNET_new (struct RevokeMessage); 613 rm = GNUNET_new (struct RevokeMessage);
614 if (sizeof (struct RevokeMessage) != 614 if (sizeof (struct RevokeMessage) !=
615 GNUNET_DISK_file_read (revocation_db, 615 GNUNET_DISK_file_read (revocation_db,
616 rm, 616 rm,
@@ -632,10 +632,10 @@ run (void *cls,
632 GNUNET_CONTAINER_multihashmap_put (revocation_map, 632 GNUNET_CONTAINER_multihashmap_put (revocation_map,
633 &hc, 633 &hc,
634 rm, 634 rm,
635 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); 635 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY));
636 } 636 }
637 GNUNET_free (fn); 637 GNUNET_free (fn);
638 638
639 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &shutdown_task, 639 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &shutdown_task,
640 NULL); 640 NULL);
641 peers = GNUNET_CONTAINER_multipeermap_create (128, GNUNET_NO); 641 peers = GNUNET_CONTAINER_multipeermap_create (128, GNUNET_NO);
@@ -668,7 +668,7 @@ run (void *cls,
668 * @return 0 ok, 1 on error 668 * @return 0 ok, 1 on error
669 */ 669 */
670int 670int
671main (int argc, 671main (int argc,
672 char *const *argv) 672 char *const *argv)
673{ 673{
674 return (GNUNET_OK == 674 return (GNUNET_OK ==
@@ -683,7 +683,7 @@ main (int argc,
683/** 683/**
684 * MINIMIZE heap size (way below 128k) since this process doesn't need much. 684 * MINIMIZE heap size (way below 128k) since this process doesn't need much.
685 */ 685 */
686void __attribute__ ((constructor)) 686void __attribute__ ((constructor))
687GNUNET_ARM_memory_init () 687GNUNET_ARM_memory_init ()
688{ 688{
689 mallopt (M_TRIM_THRESHOLD, 4 * 1024); 689 mallopt (M_TRIM_THRESHOLD, 4 * 1024);
diff --git a/src/revocation/revocation_api.c b/src/revocation/revocation_api.c
index 858649bbd..acc13ba67 100644
--- a/src/revocation/revocation_api.c
+++ b/src/revocation/revocation_api.c
@@ -40,7 +40,7 @@ struct GNUNET_REVOCATION_Query
40 * Connection to the service. 40 * Connection to the service.
41 */ 41 */
42 struct GNUNET_CLIENT_Connection *client; 42 struct GNUNET_CLIENT_Connection *client;
43 43
44 /** 44 /**
45 * Our configuration. 45 * Our configuration.
46 */ 46 */
@@ -196,12 +196,12 @@ GNUNET_REVOCATION_query_cancel (struct GNUNET_REVOCATION_Query *q)
196 */ 196 */
197struct GNUNET_REVOCATION_Handle 197struct GNUNET_REVOCATION_Handle
198{ 198{
199 199
200 /** 200 /**
201 * Connection to the service. 201 * Connection to the service.
202 */ 202 */
203 struct GNUNET_CLIENT_Connection *client; 203 struct GNUNET_CLIENT_Connection *client;
204 204
205 /** 205 /**
206 * Our configuration. 206 * Our configuration.
207 */ 207 */
@@ -265,7 +265,7 @@ handle_revocation_response (void *cls,
265 rrm = (const struct RevocationResponseMessage *) msg; 265 rrm = (const struct RevocationResponseMessage *) msg;
266 h->func (h->func_cls, ntohl (rrm->is_valid)); 266 h->func (h->func_cls, ntohl (rrm->is_valid));
267 GNUNET_REVOCATION_revoke_cancel (h); 267 GNUNET_REVOCATION_revoke_cancel (h);
268 268
269} 269}
270 270
271 271
@@ -337,7 +337,7 @@ GNUNET_REVOCATION_revoke (const struct GNUNET_CONFIGURATION_Handle *cfg,
337 struct GNUNET_REVOCATION_Handle *h; 337 struct GNUNET_REVOCATION_Handle *h;
338 unsigned long long matching_bits; 338 unsigned long long matching_bits;
339 339
340 if ( (GNUNET_OK == 340 if ( (GNUNET_OK ==
341 GNUNET_CONFIGURATION_get_value_number (cfg, 341 GNUNET_CONFIGURATION_get_value_number (cfg,
342 "REVOCATION", 342 "REVOCATION",
343 "WORKBITS", 343 "WORKBITS",
@@ -398,11 +398,11 @@ pow_hash (const void *buf,
398 size_t buf_len, 398 size_t buf_len,
399 struct GNUNET_HashCode *result) 399 struct GNUNET_HashCode *result)
400{ 400{
401 GNUNET_break (0 == 401 GNUNET_break (0 ==
402 gcry_kdf_derive (buf, buf_len, 402 gcry_kdf_derive (buf, buf_len,
403 GCRY_KDF_SCRYPT, 403 GCRY_KDF_SCRYPT,
404 1 /* subalgo */, 404 1 /* subalgo */,
405 "gnunet-revocation-proof-of-work", 405 "gnunet-revocation-proof-of-work",
406 strlen ("gnunet-revocation-proof-of-work"), 406 strlen ("gnunet-revocation-proof-of-work"),
407 2 /* iterations; keep cost of individual op small */, 407 2 /* iterations; keep cost of individual op small */,
408 sizeof (struct GNUNET_HashCode), result)); 408 sizeof (struct GNUNET_HashCode), result));