diff options
author | Martin Schanzenbach <mschanzenbach@posteo.de> | 2020-10-14 19:47:32 +0200 |
---|---|---|
committer | Martin Schanzenbach <mschanzenbach@posteo.de> | 2020-10-15 12:11:18 +0200 |
commit | 96c802b46be51e5c45f34e2de823f787d26c2929 (patch) | |
tree | 457ccfd8f9a61563af86318739c4a8f964a57025 /src/revocation/gnunet-service-revocation.c | |
parent | c14e3a2769ff0f15fdbb32797e37e43ce2344fa3 (diff) | |
download | gnunet-96c802b46be51e5c45f34e2de823f787d26c2929.tar.gz gnunet-96c802b46be51e5c45f34e2de823f787d26c2929.zip |
- towards crypto agility; wip
Diffstat (limited to 'src/revocation/gnunet-service-revocation.c')
-rw-r--r-- | src/revocation/gnunet-service-revocation.c | 71 |
1 files changed, 55 insertions, 16 deletions
diff --git a/src/revocation/gnunet-service-revocation.c b/src/revocation/gnunet-service-revocation.c index ddebb38ad..56ec9f489 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)); |
@@ -304,8 +307,9 @@ publicize_rm (const struct RevokeMessage *rm) | |||
304 | struct GNUNET_HashCode hc; | 307 | struct GNUNET_HashCode hc; |
305 | struct GNUNET_SETU_Element e; | 308 | struct GNUNET_SETU_Element e; |
306 | 309 | ||
307 | GNUNET_CRYPTO_hash (&rm->proof_of_work.key, | 310 | struct GNUNET_REVOCATION_PowP *pow = (struct GNUNET_REVOCATION_PowP *) &rm[1]; |
308 | sizeof(struct GNUNET_CRYPTO_EcdsaPublicKey), | 311 | GNUNET_CRYPTO_hash (&pow->key, |
312 | sizeof(struct GNUNET_IDENTITY_PublicKey), | ||
309 | &hc); | 313 | &hc); |
310 | if (GNUNET_YES == | 314 | if (GNUNET_YES == |
311 | GNUNET_CONTAINER_multihashmap_contains (revocation_map, | 315 | GNUNET_CONTAINER_multihashmap_contains (revocation_map, |
@@ -371,6 +375,23 @@ publicize_rm (const struct RevokeMessage *rm) | |||
371 | } | 375 | } |
372 | 376 | ||
373 | 377 | ||
378 | static int | ||
379 | check_revoke_message (void *cls, | ||
380 | const struct RevokeMessage *rm) | ||
381 | { | ||
382 | uint16_t size; | ||
383 | |||
384 | size = ntohs (rm->header.size); | ||
385 | if (size <= sizeof(struct RevokeMessage)) | ||
386 | { | ||
387 | GNUNET_break (0); | ||
388 | return GNUNET_SYSERR; | ||
389 | } | ||
390 | return GNUNET_OK; | ||
391 | |||
392 | } | ||
393 | |||
394 | |||
374 | /** | 395 | /** |
375 | * Handle REVOKE message from client. | 396 | * Handle REVOKE message from client. |
376 | * | 397 | * |
@@ -403,6 +424,23 @@ handle_revoke_message (void *cls, | |||
403 | } | 424 | } |
404 | 425 | ||
405 | 426 | ||
427 | static int | ||
428 | check_p2p_revoke (void *cls, | ||
429 | const struct RevokeMessage *rm) | ||
430 | { | ||
431 | uint16_t size; | ||
432 | |||
433 | size = ntohs (rm->header.size); | ||
434 | if (size <= sizeof(struct RevokeMessage)) | ||
435 | { | ||
436 | GNUNET_break (0); | ||
437 | return GNUNET_SYSERR; | ||
438 | } | ||
439 | return GNUNET_OK; | ||
440 | |||
441 | } | ||
442 | |||
443 | |||
406 | /** | 444 | /** |
407 | * Core handler for flooded revocation messages. | 445 | * Core handler for flooded revocation messages. |
408 | * | 446 | * |
@@ -784,10 +822,10 @@ run (void *cls, | |||
784 | struct GNUNET_SERVICE_Handle *service) | 822 | struct GNUNET_SERVICE_Handle *service) |
785 | { | 823 | { |
786 | struct GNUNET_MQ_MessageHandler core_handlers[] = { | 824 | struct GNUNET_MQ_MessageHandler core_handlers[] = { |
787 | GNUNET_MQ_hd_fixed_size (p2p_revoke, | 825 | GNUNET_MQ_hd_var_size (p2p_revoke, |
788 | GNUNET_MESSAGE_TYPE_REVOCATION_REVOKE, | 826 | GNUNET_MESSAGE_TYPE_REVOCATION_REVOKE, |
789 | struct RevokeMessage, | 827 | struct RevokeMessage, |
790 | NULL), | 828 | NULL), |
791 | GNUNET_MQ_handler_end () | 829 | GNUNET_MQ_handler_end () |
792 | }; | 830 | }; |
793 | char *fn; | 831 | char *fn; |
@@ -892,9 +930,10 @@ run (void *cls, | |||
892 | GNUNET_free (fn); | 930 | GNUNET_free (fn); |
893 | return; | 931 | return; |
894 | } | 932 | } |
895 | GNUNET_break (0 == ntohl (rm->reserved)); | 933 | struct GNUNET_REVOCATION_PowP *pow = (struct |
896 | GNUNET_CRYPTO_hash (&rm->proof_of_work.key, | 934 | GNUNET_REVOCATION_PowP *) &rm[1]; |
897 | sizeof(struct GNUNET_CRYPTO_EcdsaPublicKey), | 935 | GNUNET_CRYPTO_hash (&pow->key, |
936 | sizeof(struct GNUNET_IDENTITY_PublicKey), | ||
898 | &hc); | 937 | &hc); |
899 | GNUNET_break (GNUNET_OK == | 938 | GNUNET_break (GNUNET_OK == |
900 | GNUNET_CONTAINER_multihashmap_put (revocation_map, | 939 | GNUNET_CONTAINER_multihashmap_put (revocation_map, |
@@ -939,10 +978,10 @@ GNUNET_SERVICE_MAIN | |||
939 | GNUNET_MESSAGE_TYPE_REVOCATION_QUERY, | 978 | GNUNET_MESSAGE_TYPE_REVOCATION_QUERY, |
940 | struct QueryMessage, | 979 | struct QueryMessage, |
941 | NULL), | 980 | NULL), |
942 | GNUNET_MQ_hd_fixed_size (revoke_message, | 981 | GNUNET_MQ_hd_var_size (revoke_message, |
943 | GNUNET_MESSAGE_TYPE_REVOCATION_REVOKE, | 982 | GNUNET_MESSAGE_TYPE_REVOCATION_REVOKE, |
944 | struct RevokeMessage, | 983 | struct RevokeMessage, |
945 | NULL), | 984 | NULL), |
946 | GNUNET_MQ_handler_end ()); | 985 | GNUNET_MQ_handler_end ()); |
947 | 986 | ||
948 | 987 | ||