diff options
Diffstat (limited to 'src/revocation/gnunet-service-revocation.c')
-rw-r--r-- | src/revocation/gnunet-service-revocation.c | 75 |
1 files changed, 59 insertions, 16 deletions
diff --git a/src/revocation/gnunet-service-revocation.c b/src/revocation/gnunet-service-revocation.c index ddebb38ad..0fa92f4a6 100644 --- a/src/revocation/gnunet-service-revocation.c +++ b/src/revocation/gnunet-service-revocation.c | |||
@@ -172,7 +172,8 @@ new_peer_entry (const struct GNUNET_PeerIdentity *peer) | |||
172 | static int | 172 | static int |
173 | verify_revoke_message (const struct RevokeMessage *rm) | 173 | verify_revoke_message (const struct RevokeMessage *rm) |
174 | { | 174 | { |
175 | if (GNUNET_YES != GNUNET_REVOCATION_check_pow (&rm->proof_of_work, | 175 | struct GNUNET_REVOCATION_PowP *pow = (struct GNUNET_REVOCATION_PowP *) &rm[1]; |
176 | if (GNUNET_YES != GNUNET_REVOCATION_check_pow (pow, | ||
176 | (unsigned | 177 | (unsigned |
177 | int) revocation_work_required, | 178 | int) revocation_work_required, |
178 | epoch_duration)) | 179 | epoch_duration)) |
@@ -236,7 +237,7 @@ handle_query_message (void *cls, | |||
236 | int res; | 237 | int res; |
237 | 238 | ||
238 | GNUNET_CRYPTO_hash (&qm->key, | 239 | GNUNET_CRYPTO_hash (&qm->key, |
239 | sizeof(struct GNUNET_CRYPTO_EcdsaPublicKey), | 240 | sizeof(struct GNUNET_IDENTITY_PublicKey), |
240 | &hc); | 241 | &hc); |
241 | res = GNUNET_CONTAINER_multihashmap_contains (revocation_map, | 242 | res = GNUNET_CONTAINER_multihashmap_contains (revocation_map, |
242 | &hc); | 243 | &hc); |
@@ -276,9 +277,11 @@ do_flood (void *cls, | |||
276 | return GNUNET_OK; /* peer connected to us via SET, | 277 | return GNUNET_OK; /* peer connected to us via SET, |
277 | but we have no direct CORE | 278 | but we have no direct CORE |
278 | connection for flooding */ | 279 | connection for flooding */ |
279 | e = GNUNET_MQ_msg (cp, | 280 | e = GNUNET_MQ_msg_extra (cp, |
281 | htonl (rm->pow_size), | ||
280 | GNUNET_MESSAGE_TYPE_REVOCATION_REVOKE); | 282 | GNUNET_MESSAGE_TYPE_REVOCATION_REVOKE); |
281 | *cp = *rm; | 283 | *cp = *rm; |
284 | memcpy (&cp[1], &rm[1], htonl (rm->pow_size)); | ||
282 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 285 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
283 | "Flooding revocation to `%s'\n", | 286 | "Flooding revocation to `%s'\n", |
284 | GNUNET_i2s (target)); | 287 | GNUNET_i2s (target)); |
@@ -303,9 +306,12 @@ publicize_rm (const struct RevokeMessage *rm) | |||
303 | struct RevokeMessage *cp; | 306 | struct RevokeMessage *cp; |
304 | struct GNUNET_HashCode hc; | 307 | struct GNUNET_HashCode hc; |
305 | struct GNUNET_SETU_Element e; | 308 | struct GNUNET_SETU_Element e; |
309 | const struct GNUNET_IDENTITY_PublicKey *pk; | ||
306 | 310 | ||
307 | GNUNET_CRYPTO_hash (&rm->proof_of_work.key, | 311 | struct GNUNET_REVOCATION_PowP *pow = (struct GNUNET_REVOCATION_PowP *) &rm[1]; |
308 | sizeof(struct GNUNET_CRYPTO_EcdsaPublicKey), | 312 | pk = (const struct GNUNET_IDENTITY_PublicKey *) &pow[1]; |
313 | GNUNET_CRYPTO_hash (pk, | ||
314 | GNUNET_IDENTITY_key_get_length (pk), | ||
309 | &hc); | 315 | &hc); |
310 | if (GNUNET_YES == | 316 | if (GNUNET_YES == |
311 | GNUNET_CONTAINER_multihashmap_contains (revocation_map, | 317 | GNUNET_CONTAINER_multihashmap_contains (revocation_map, |
@@ -371,6 +377,23 @@ publicize_rm (const struct RevokeMessage *rm) | |||
371 | } | 377 | } |
372 | 378 | ||
373 | 379 | ||
380 | static int | ||
381 | check_revoke_message (void *cls, | ||
382 | const struct RevokeMessage *rm) | ||
383 | { | ||
384 | uint16_t size; | ||
385 | |||
386 | size = ntohs (rm->header.size); | ||
387 | if (size <= sizeof(struct RevokeMessage)) | ||
388 | { | ||
389 | GNUNET_break (0); | ||
390 | return GNUNET_SYSERR; | ||
391 | } | ||
392 | return GNUNET_OK; | ||
393 | |||
394 | } | ||
395 | |||
396 | |||
374 | /** | 397 | /** |
375 | * Handle REVOKE message from client. | 398 | * Handle REVOKE message from client. |
376 | * | 399 | * |
@@ -403,6 +426,23 @@ handle_revoke_message (void *cls, | |||
403 | } | 426 | } |
404 | 427 | ||
405 | 428 | ||
429 | static int | ||
430 | check_p2p_revoke (void *cls, | ||
431 | const struct RevokeMessage *rm) | ||
432 | { | ||
433 | uint16_t size; | ||
434 | |||
435 | size = ntohs (rm->header.size); | ||
436 | if (size <= sizeof(struct RevokeMessage)) | ||
437 | { | ||
438 | GNUNET_break (0); | ||
439 | return GNUNET_SYSERR; | ||
440 | } | ||
441 | return GNUNET_OK; | ||
442 | |||
443 | } | ||
444 | |||
445 | |||
406 | /** | 446 | /** |
407 | * Core handler for flooded revocation messages. | 447 | * Core handler for flooded revocation messages. |
408 | * | 448 | * |
@@ -784,16 +824,17 @@ run (void *cls, | |||
784 | struct GNUNET_SERVICE_Handle *service) | 824 | struct GNUNET_SERVICE_Handle *service) |
785 | { | 825 | { |
786 | struct GNUNET_MQ_MessageHandler core_handlers[] = { | 826 | struct GNUNET_MQ_MessageHandler core_handlers[] = { |
787 | GNUNET_MQ_hd_fixed_size (p2p_revoke, | 827 | GNUNET_MQ_hd_var_size (p2p_revoke, |
788 | GNUNET_MESSAGE_TYPE_REVOCATION_REVOKE, | 828 | GNUNET_MESSAGE_TYPE_REVOCATION_REVOKE, |
789 | struct RevokeMessage, | 829 | struct RevokeMessage, |
790 | NULL), | 830 | NULL), |
791 | GNUNET_MQ_handler_end () | 831 | GNUNET_MQ_handler_end () |
792 | }; | 832 | }; |
793 | char *fn; | 833 | char *fn; |
794 | uint64_t left; | 834 | uint64_t left; |
795 | struct RevokeMessage *rm; | 835 | struct RevokeMessage *rm; |
796 | struct GNUNET_HashCode hc; | 836 | struct GNUNET_HashCode hc; |
837 | const struct GNUNET_IDENTITY_PublicKey *pk; | ||
797 | 838 | ||
798 | GNUNET_CRYPTO_hash ("revocation-set-union-application-id", | 839 | GNUNET_CRYPTO_hash ("revocation-set-union-application-id", |
799 | strlen ("revocation-set-union-application-id"), | 840 | strlen ("revocation-set-union-application-id"), |
@@ -892,9 +933,11 @@ run (void *cls, | |||
892 | GNUNET_free (fn); | 933 | GNUNET_free (fn); |
893 | return; | 934 | return; |
894 | } | 935 | } |
895 | GNUNET_break (0 == ntohl (rm->reserved)); | 936 | struct GNUNET_REVOCATION_PowP *pow = (struct |
896 | GNUNET_CRYPTO_hash (&rm->proof_of_work.key, | 937 | GNUNET_REVOCATION_PowP *) &rm[1]; |
897 | sizeof(struct GNUNET_CRYPTO_EcdsaPublicKey), | 938 | pk = (const struct GNUNET_IDENTITY_PublicKey *) &pow[1]; |
939 | GNUNET_CRYPTO_hash (pk, | ||
940 | GNUNET_IDENTITY_key_get_length (pk), | ||
898 | &hc); | 941 | &hc); |
899 | GNUNET_break (GNUNET_OK == | 942 | GNUNET_break (GNUNET_OK == |
900 | GNUNET_CONTAINER_multihashmap_put (revocation_map, | 943 | GNUNET_CONTAINER_multihashmap_put (revocation_map, |
@@ -939,10 +982,10 @@ GNUNET_SERVICE_MAIN | |||
939 | GNUNET_MESSAGE_TYPE_REVOCATION_QUERY, | 982 | GNUNET_MESSAGE_TYPE_REVOCATION_QUERY, |
940 | struct QueryMessage, | 983 | struct QueryMessage, |
941 | NULL), | 984 | NULL), |
942 | GNUNET_MQ_hd_fixed_size (revoke_message, | 985 | GNUNET_MQ_hd_var_size (revoke_message, |
943 | GNUNET_MESSAGE_TYPE_REVOCATION_REVOKE, | 986 | GNUNET_MESSAGE_TYPE_REVOCATION_REVOKE, |
944 | struct RevokeMessage, | 987 | struct RevokeMessage, |
945 | NULL), | 988 | NULL), |
946 | GNUNET_MQ_handler_end ()); | 989 | GNUNET_MQ_handler_end ()); |
947 | 990 | ||
948 | 991 | ||