diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/peerinfo-tool/plugin_rest_peerinfo.c | 4 | ||||
-rw-r--r-- | src/rest/plugin_rest_copying.c | 6 | ||||
-rw-r--r-- | src/revocation/gnunet-revocation.c | 14 | ||||
-rw-r--r-- | src/revocation/gnunet-service-revocation.c | 9 | ||||
-rw-r--r-- | src/revocation/plugin_block_revocation.c | 9 | ||||
-rw-r--r-- | src/revocation/revocation_api.c | 9 | ||||
-rw-r--r-- | src/transport/gnunet-communicator-tcp.c | 48 | ||||
-rw-r--r-- | src/transport/gnunet-communicator-udp.c | 13 | ||||
-rw-r--r-- | src/transport/gnunet-service-tng.c | 6 | ||||
-rw-r--r-- | src/transport/transport-testing-communicator.c | 5 | ||||
-rw-r--r-- | src/util/gnunet-crypto-tvg.c | 124 |
11 files changed, 162 insertions, 85 deletions
diff --git a/src/peerinfo-tool/plugin_rest_peerinfo.c b/src/peerinfo-tool/plugin_rest_peerinfo.c index 4bbc7442e..f969a175b 100644 --- a/src/peerinfo-tool/plugin_rest_peerinfo.c +++ b/src/peerinfo-tool/plugin_rest_peerinfo.c | |||
@@ -379,7 +379,9 @@ peerinfo_list_finished (void *cls) | |||
379 | result_str = json_dumps (handle->response, 0); | 379 | result_str = json_dumps (handle->response, 0); |
380 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Result %s\n", result_str); | 380 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Result %s\n", result_str); |
381 | resp = GNUNET_REST_create_response (result_str); | 381 | resp = GNUNET_REST_create_response (result_str); |
382 | MHD_add_response_header (resp, "Content-Type", "application/json"); | 382 | GNUNET_assert (MHD_NO != MHD_add_response_header (resp, |
383 | "Content-Type", | ||
384 | "application/json")); | ||
383 | handle->proc (handle->proc_cls, resp, MHD_HTTP_OK); | 385 | handle->proc (handle->proc_cls, resp, MHD_HTTP_OK); |
384 | GNUNET_free (result_str); | 386 | GNUNET_free (result_str); |
385 | GNUNET_SCHEDULER_add_now (&cleanup_handle, handle); | 387 | GNUNET_SCHEDULER_add_now (&cleanup_handle, handle); |
diff --git a/src/rest/plugin_rest_copying.c b/src/rest/plugin_rest_copying.c index 6d074d3d1..52783a81a 100644 --- a/src/rest/plugin_rest_copying.c +++ b/src/rest/plugin_rest_copying.c | |||
@@ -138,9 +138,9 @@ options_cont (struct GNUNET_REST_RequestHandle *con_handle, | |||
138 | struct RequestHandle *handle = cls; | 138 | struct RequestHandle *handle = cls; |
139 | 139 | ||
140 | resp = GNUNET_REST_create_response (NULL); | 140 | resp = GNUNET_REST_create_response (NULL); |
141 | MHD_add_response_header (resp, | 141 | GNUNET_assert (MHD_NO != MHD_add_response_header (resp, |
142 | "Access-Control-Allow-Methods", | 142 | "Access-Control-Allow-Methods", |
143 | MHD_HTTP_METHOD_GET); | 143 | MHD_HTTP_METHOD_GET)); |
144 | handle->proc (handle->proc_cls, | 144 | handle->proc (handle->proc_cls, |
145 | resp, | 145 | resp, |
146 | MHD_HTTP_OK); | 146 | MHD_HTTP_OK); |
diff --git a/src/revocation/gnunet-revocation.c b/src/revocation/gnunet-revocation.c index b5737158b..99fecdd35 100644 --- a/src/revocation/gnunet-revocation.c +++ b/src/revocation/gnunet-revocation.c | |||
@@ -307,17 +307,9 @@ calculate_pow (void *cls) | |||
307 | return; | 307 | return; |
308 | } | 308 | } |
309 | pow_passes++; | 309 | pow_passes++; |
310 | /** | 310 | pow_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_MILLISECONDS, |
311 | * Otherwise CTRL-C does not work | 311 | &calculate_pow, |
312 | */ | 312 | ph); |
313 | if (0 == pow_passes % 128) | ||
314 | pow_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_MILLISECONDS, | ||
315 | &calculate_pow, | ||
316 | ph); | ||
317 | else | ||
318 | pow_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_MILLISECONDS, | ||
319 | &calculate_pow, | ||
320 | ph); | ||
321 | 313 | ||
322 | } | 314 | } |
323 | 315 | ||
diff --git a/src/revocation/gnunet-service-revocation.c b/src/revocation/gnunet-service-revocation.c index 7032921c6..6f70720ba 100644 --- a/src/revocation/gnunet-service-revocation.c +++ b/src/revocation/gnunet-service-revocation.c | |||
@@ -306,12 +306,19 @@ publicize_rm (const struct RevokeMessage *rm) | |||
306 | struct RevokeMessage *cp; | 306 | struct RevokeMessage *cp; |
307 | struct GNUNET_HashCode hc; | 307 | struct GNUNET_HashCode hc; |
308 | struct GNUNET_SETU_Element e; | 308 | struct GNUNET_SETU_Element e; |
309 | ssize_t pklen; | ||
309 | const struct GNUNET_IDENTITY_PublicKey *pk; | 310 | const struct GNUNET_IDENTITY_PublicKey *pk; |
310 | 311 | ||
311 | struct GNUNET_REVOCATION_PowP *pow = (struct GNUNET_REVOCATION_PowP *) &rm[1]; | 312 | struct GNUNET_REVOCATION_PowP *pow = (struct GNUNET_REVOCATION_PowP *) &rm[1]; |
312 | pk = (const struct GNUNET_IDENTITY_PublicKey *) &pow[1]; | 313 | pk = (const struct GNUNET_IDENTITY_PublicKey *) &pow[1]; |
314 | pklen = GNUNET_IDENTITY_key_get_length (pk); | ||
315 | if (0 > pklen) | ||
316 | { | ||
317 | GNUNET_break_op (0); | ||
318 | return GNUNET_SYSERR; | ||
319 | } | ||
313 | GNUNET_CRYPTO_hash (pk, | 320 | GNUNET_CRYPTO_hash (pk, |
314 | GNUNET_IDENTITY_key_get_length (pk), | 321 | pklen, |
315 | &hc); | 322 | &hc); |
316 | if (GNUNET_YES == | 323 | if (GNUNET_YES == |
317 | GNUNET_CONTAINER_multihashmap_contains (revocation_map, | 324 | GNUNET_CONTAINER_multihashmap_contains (revocation_map, |
diff --git a/src/revocation/plugin_block_revocation.c b/src/revocation/plugin_block_revocation.c index 3c9344a49..1928d09cd 100644 --- a/src/revocation/plugin_block_revocation.c +++ b/src/revocation/plugin_block_revocation.c | |||
@@ -134,6 +134,7 @@ block_plugin_revocation_evaluate (void *cls, | |||
134 | { | 134 | { |
135 | struct InternalContext *ic = cls; | 135 | struct InternalContext *ic = cls; |
136 | struct GNUNET_HashCode chash; | 136 | struct GNUNET_HashCode chash; |
137 | ssize_t pklen; | ||
137 | const struct RevokeMessage *rm = reply_block; | 138 | const struct RevokeMessage *rm = reply_block; |
138 | 139 | ||
139 | if (NULL == reply_block) | 140 | if (NULL == reply_block) |
@@ -153,8 +154,14 @@ block_plugin_revocation_evaluate (void *cls, | |||
153 | GNUNET_break_op (0); | 154 | GNUNET_break_op (0); |
154 | return GNUNET_BLOCK_EVALUATION_RESULT_INVALID; | 155 | return GNUNET_BLOCK_EVALUATION_RESULT_INVALID; |
155 | } | 156 | } |
157 | pklen = GNUNET_IDENTITY_key_get_length (pk); | ||
158 | if (0 > pklen) | ||
159 | { | ||
160 | GNUNET_break_op (0); | ||
161 | return GNUNET_BLOCK_EVALUATION_RESULT_INVALID; | ||
162 | } | ||
156 | GNUNET_CRYPTO_hash (pk, | 163 | GNUNET_CRYPTO_hash (pk, |
157 | GNUNET_IDENTITY_key_get_length (pk), | 164 | pklen, |
158 | &chash); | 165 | &chash); |
159 | if (GNUNET_YES == | 166 | if (GNUNET_YES == |
160 | GNUNET_BLOCK_GROUP_bf_test_and_set (group, | 167 | GNUNET_BLOCK_GROUP_bf_test_and_set (group, |
diff --git a/src/revocation/revocation_api.c b/src/revocation/revocation_api.c index 5cf191847..e2f871c23 100644 --- a/src/revocation/revocation_api.c +++ b/src/revocation/revocation_api.c | |||
@@ -492,6 +492,7 @@ GNUNET_REVOCATION_check_pow (const struct GNUNET_REVOCATION_PowP *pow, | |||
492 | unsigned int tmp_score = 0; | 492 | unsigned int tmp_score = 0; |
493 | unsigned int epochs; | 493 | unsigned int epochs; |
494 | uint64_t pow_val; | 494 | uint64_t pow_val; |
495 | ssize_t pklen; | ||
495 | const struct GNUNET_IDENTITY_PublicKey *pk; | 496 | const struct GNUNET_IDENTITY_PublicKey *pk; |
496 | 497 | ||
497 | pk = (const struct GNUNET_IDENTITY_PublicKey *) &pow[1]; | 498 | pk = (const struct GNUNET_IDENTITY_PublicKey *) &pow[1]; |
@@ -517,9 +518,15 @@ GNUNET_REVOCATION_check_pow (const struct GNUNET_REVOCATION_PowP *pow, | |||
517 | GNUNET_memcpy (&buf[sizeof(uint64_t)], | 518 | GNUNET_memcpy (&buf[sizeof(uint64_t)], |
518 | &pow->timestamp, | 519 | &pow->timestamp, |
519 | sizeof (uint64_t)); | 520 | sizeof (uint64_t)); |
521 | pklen = GNUNET_IDENTITY_key_get_length (pk); | ||
522 | if (0 > pklen) | ||
523 | { | ||
524 | GNUNET_break (0); | ||
525 | return GNUNET_NO; | ||
526 | } | ||
520 | GNUNET_memcpy (&buf[sizeof(uint64_t) * 2], | 527 | GNUNET_memcpy (&buf[sizeof(uint64_t) * 2], |
521 | pk, | 528 | pk, |
522 | GNUNET_IDENTITY_key_get_length (pk)); | 529 | pklen); |
523 | for (unsigned int i = 0; i < POW_COUNT; i++) | 530 | for (unsigned int i = 0; i < POW_COUNT; i++) |
524 | { | 531 | { |
525 | pow_val = GNUNET_ntohll (pow->pow[i]); | 532 | pow_val = GNUNET_ntohll (pow->pow[i]); |
diff --git a/src/transport/gnunet-communicator-tcp.c b/src/transport/gnunet-communicator-tcp.c index c8a4c0375..9dd2797df 100644 --- a/src/transport/gnunet-communicator-tcp.c +++ b/src/transport/gnunet-communicator-tcp.c | |||
@@ -877,12 +877,14 @@ queue_destroy (struct Queue *queue) | |||
877 | { | 877 | { |
878 | struct ListenTask *lt = NULL; | 878 | struct ListenTask *lt = NULL; |
879 | struct GNUNET_HashCode h_sock; | 879 | struct GNUNET_HashCode h_sock; |
880 | int sockfd; | ||
880 | 881 | ||
881 | GNUNET_CRYPTO_hash (queue->listen_sock, | 882 | sockfd = GNUNET_NETWORK_get_fd (queue->listen_sock); |
882 | sizeof(queue->listen_sock), | 883 | GNUNET_CRYPTO_hash (&sockfd, |
884 | sizeof(int), | ||
883 | &h_sock); | 885 | &h_sock); |
884 | 886 | ||
885 | lt = GNUNET_CONTAINER_multihashmap_get (lt_map, &h_sock); | 887 | lt = GNUNET_CONTAINER_multihashmap_get (lt_map, &h_sock); |
886 | 888 | ||
887 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 889 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
888 | "Disconnecting queue for peer `%s'\n", | 890 | "Disconnecting queue for peer `%s'\n", |
@@ -1263,7 +1265,8 @@ rekey_monotime_cb (void *cls, | |||
1263 | pid, | 1265 | pid, |
1264 | GNUNET_PEERSTORE_TRANSPORT_TCP_COMMUNICATOR_REKEY, | 1266 | GNUNET_PEERSTORE_TRANSPORT_TCP_COMMUNICATOR_REKEY, |
1265 | rekey_monotonic_time, | 1267 | rekey_monotonic_time, |
1266 | sizeof(rekey_monotonic_time), | 1268 | sizeof(* |
1269 | rekey_monotonic_time), | ||
1267 | GNUNET_TIME_UNIT_FOREVER_ABS, | 1270 | GNUNET_TIME_UNIT_FOREVER_ABS, |
1268 | GNUNET_PEERSTORE_STOREOPTION_REPLACE, | 1271 | GNUNET_PEERSTORE_STOREOPTION_REPLACE, |
1269 | &rekey_monotime_store_cb, | 1272 | &rekey_monotime_store_cb, |
@@ -1413,18 +1416,18 @@ handshake_ack_monotime_cb (void *cls, | |||
1413 | queue_finish (queue); | 1416 | queue_finish (queue); |
1414 | return; | 1417 | return; |
1415 | } | 1418 | } |
1416 | queue->handshake_ack_monotime_sc = GNUNET_PEERSTORE_store (peerstore, | 1419 | queue->handshake_ack_monotime_sc = |
1417 | "transport_tcp_communicator", | 1420 | GNUNET_PEERSTORE_store (peerstore, |
1418 | pid, | 1421 | "transport_tcp_communicator", |
1419 | GNUNET_PEERSTORE_TRANSPORT_TCP_COMMUNICATOR_HANDSHAKE_ACK, | 1422 | pid, |
1420 | handshake_ack_monotonic_time, | 1423 | GNUNET_PEERSTORE_TRANSPORT_TCP_COMMUNICATOR_HANDSHAKE_ACK, |
1421 | sizeof( | 1424 | handshake_ack_monotonic_time, |
1422 | handshake_ack_monotonic_time), | 1425 | sizeof(*handshake_ack_monotonic_time), |
1423 | GNUNET_TIME_UNIT_FOREVER_ABS, | 1426 | GNUNET_TIME_UNIT_FOREVER_ABS, |
1424 | GNUNET_PEERSTORE_STOREOPTION_REPLACE, | 1427 | GNUNET_PEERSTORE_STOREOPTION_REPLACE, |
1425 | & | 1428 | & |
1426 | handshake_ack_monotime_store_cb, | 1429 | handshake_ack_monotime_store_cb, |
1427 | queue); | 1430 | queue); |
1428 | } | 1431 | } |
1429 | 1432 | ||
1430 | 1433 | ||
@@ -3255,6 +3258,7 @@ init_socket (struct sockaddr *addr, | |||
3255 | socklen_t sto_len; | 3258 | socklen_t sto_len; |
3256 | struct GNUNET_NETWORK_Handle *listen_sock; | 3259 | struct GNUNET_NETWORK_Handle *listen_sock; |
3257 | struct ListenTask *lt; | 3260 | struct ListenTask *lt; |
3261 | int sockfd; | ||
3258 | struct GNUNET_HashCode h_sock; | 3262 | struct GNUNET_HashCode h_sock; |
3259 | 3263 | ||
3260 | if (NULL == addr) | 3264 | if (NULL == addr) |
@@ -3343,8 +3347,9 @@ init_socket (struct sockaddr *addr, | |||
3343 | 3347 | ||
3344 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 3348 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
3345 | "creating hash\n"); | 3349 | "creating hash\n"); |
3346 | GNUNET_CRYPTO_hash (lt->listen_sock, | 3350 | sockfd = GNUNET_NETWORK_get_fd (lt->listen_sock); |
3347 | sizeof(lt->listen_sock), | 3351 | GNUNET_CRYPTO_hash (&sockfd, |
3352 | sizeof(int), | ||
3348 | &h_sock); | 3353 | &h_sock); |
3349 | 3354 | ||
3350 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 3355 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
@@ -3564,6 +3569,7 @@ run (void *cls, | |||
3564 | peerstore = GNUNET_PEERSTORE_connect (cfg); | 3569 | peerstore = GNUNET_PEERSTORE_connect (cfg); |
3565 | if (NULL == peerstore) | 3570 | if (NULL == peerstore) |
3566 | { | 3571 | { |
3572 | GNUNET_free (bindto); | ||
3567 | GNUNET_break (0); | 3573 | GNUNET_break (0); |
3568 | GNUNET_SCHEDULER_shutdown (); | 3574 | GNUNET_SCHEDULER_shutdown (); |
3569 | return; | 3575 | return; |
@@ -3596,7 +3602,6 @@ run (void *cls, | |||
3596 | GNUNET_free (po); | 3602 | GNUNET_free (po); |
3597 | nat_register (); | 3603 | nat_register (); |
3598 | GNUNET_free (bindto); | 3604 | GNUNET_free (bindto); |
3599 | |||
3600 | return; | 3605 | return; |
3601 | } | 3606 | } |
3602 | 3607 | ||
@@ -3609,8 +3614,8 @@ run (void *cls, | |||
3609 | in = tcp_address_to_sockaddr_numeric_v4 (&in_len, v4, bind_port); | 3614 | in = tcp_address_to_sockaddr_numeric_v4 (&in_len, v4, bind_port); |
3610 | init_socket (in, in_len); | 3615 | init_socket (in, in_len); |
3611 | nat_register (); | 3616 | nat_register (); |
3617 | GNUNET_free (start); | ||
3612 | GNUNET_free (bindto); | 3618 | GNUNET_free (bindto); |
3613 | |||
3614 | return; | 3619 | return; |
3615 | } | 3620 | } |
3616 | 3621 | ||
@@ -3620,8 +3625,8 @@ run (void *cls, | |||
3620 | in = tcp_address_to_sockaddr_numeric_v6 (&in_len, v6, bind_port); | 3625 | in = tcp_address_to_sockaddr_numeric_v6 (&in_len, v6, bind_port); |
3621 | init_socket (in, in_len); | 3626 | init_socket (in, in_len); |
3622 | nat_register (); | 3627 | nat_register (); |
3628 | GNUNET_free (start); | ||
3623 | GNUNET_free (bindto); | 3629 | GNUNET_free (bindto); |
3624 | |||
3625 | return; | 3630 | return; |
3626 | } | 3631 | } |
3627 | 3632 | ||
@@ -3635,6 +3640,7 @@ run (void *cls, | |||
3635 | &init_socket_resolv, | 3640 | &init_socket_resolv, |
3636 | &port); | 3641 | &port); |
3637 | GNUNET_free (bindto); | 3642 | GNUNET_free (bindto); |
3643 | GNUNET_free (start); | ||
3638 | } | 3644 | } |
3639 | 3645 | ||
3640 | 3646 | ||
diff --git a/src/transport/gnunet-communicator-udp.c b/src/transport/gnunet-communicator-udp.c index 415dc4b48..d75f4ae00 100644 --- a/src/transport/gnunet-communicator-udp.c +++ b/src/transport/gnunet-communicator-udp.c | |||
@@ -1492,16 +1492,9 @@ add_acks (struct SharedSecret *ss, int acks_to_add) | |||
1492 | 1492 | ||
1493 | struct ReceiverAddress *receiver = ss->receiver; | 1493 | struct ReceiverAddress *receiver = ss->receiver; |
1494 | 1494 | ||
1495 | if (NULL == ss) | 1495 | GNUNET_assert (NULL != ss); |
1496 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1496 | GNUNET_assert (NULL != receiver); |
1497 | "secret NULL!\n"); | 1497 | GNUNET_assert (NULL != receiver->d_qh); |
1498 | |||
1499 | if (NULL == receiver) | ||
1500 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1501 | "Receiver NULL!\n"); | ||
1502 | if (NULL == receiver->d_qh) | ||
1503 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1504 | "Queue NULL!\n"); | ||
1505 | 1498 | ||
1506 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1499 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1507 | "Tell transport we have %u more acks!\n", | 1500 | "Tell transport we have %u more acks!\n", |
diff --git a/src/transport/gnunet-service-tng.c b/src/transport/gnunet-service-tng.c index 468048bec..cbf795eea 100644 --- a/src/transport/gnunet-service-tng.c +++ b/src/transport/gnunet-service-tng.c | |||
@@ -9639,11 +9639,13 @@ handle_add_queue_message (void *cls, | |||
9639 | { | 9639 | { |
9640 | if (queue->qid != aqm->qid) | 9640 | if (queue->qid != aqm->qid) |
9641 | continue; | 9641 | continue; |
9642 | neighbour = queue->neighbour; | ||
9643 | break; | 9642 | break; |
9644 | } | 9643 | } |
9645 | if (NULL == queue) | 9644 | |
9645 | if (NULL != queue) | ||
9646 | { | 9646 | { |
9647 | neighbour = queue->neighbour; | ||
9648 | } else { | ||
9647 | neighbour = lookup_neighbour (&aqm->receiver); | 9649 | neighbour = lookup_neighbour (&aqm->receiver); |
9648 | if (NULL == neighbour) | 9650 | if (NULL == neighbour) |
9649 | { | 9651 | { |
diff --git a/src/transport/transport-testing-communicator.c b/src/transport/transport-testing-communicator.c index de356fb9c..040f16d5d 100644 --- a/src/transport/transport-testing-communicator.c +++ b/src/transport/transport-testing-communicator.c | |||
@@ -548,6 +548,11 @@ handle_update_queue_message (void *cls, | |||
548 | tc_queue = tc_queue->next; | 548 | tc_queue = tc_queue->next; |
549 | } | 549 | } |
550 | } | 550 | } |
551 | if (NULL == tc_queue) | ||
552 | { | ||
553 | GNUNET_SERVICE_client_continue (client->client); | ||
554 | return; | ||
555 | } | ||
551 | GNUNET_assert (tc_queue->qid == msg->qid); | 556 | GNUNET_assert (tc_queue->qid == msg->qid); |
552 | GNUNET_assert (0 == GNUNET_memcmp (&tc_queue->peer_id, &msg->receiver)); | 557 | GNUNET_assert (0 == GNUNET_memcmp (&tc_queue->peer_id, &msg->receiver)); |
553 | tc_queue->nt = msg->nt; | 558 | tc_queue->nt = msg->nt; |
diff --git a/src/util/gnunet-crypto-tvg.c b/src/util/gnunet-crypto-tvg.c index 8949f427c..28e44e28b 100644 --- a/src/util/gnunet-crypto-tvg.c +++ b/src/util/gnunet-crypto-tvg.c | |||
@@ -128,6 +128,7 @@ d2j (json_t *vec, | |||
128 | json_object_set_new (vec, label, json); | 128 | json_object_set_new (vec, label, json); |
129 | } | 129 | } |
130 | 130 | ||
131 | |||
131 | /** | 132 | /** |
132 | * Add a number to a test vector. | 133 | * Add a number to a test vector. |
133 | * | 134 | * |
@@ -138,8 +139,8 @@ d2j (json_t *vec, | |||
138 | */ | 139 | */ |
139 | static void | 140 | static void |
140 | uint2j (json_t *vec, | 141 | uint2j (json_t *vec, |
141 | const char *label, | 142 | const char *label, |
142 | unsigned int num) | 143 | unsigned int num) |
143 | { | 144 | { |
144 | json_t *json = json_integer (num); | 145 | json_t *json = json_integer (num); |
145 | 146 | ||
@@ -154,7 +155,7 @@ expect_data_fixed (json_t *vec, | |||
154 | size_t expect_len) | 155 | size_t expect_len) |
155 | { | 156 | { |
156 | const char *s = json_string_value (json_object_get (vec, name)); | 157 | const char *s = json_string_value (json_object_get (vec, name)); |
157 | 158 | ||
158 | if (NULL == s) | 159 | if (NULL == s) |
159 | return GNUNET_NO; | 160 | return GNUNET_NO; |
160 | 161 | ||
@@ -166,6 +167,7 @@ expect_data_fixed (json_t *vec, | |||
166 | return GNUNET_OK; | 167 | return GNUNET_OK; |
167 | } | 168 | } |
168 | 169 | ||
170 | |||
169 | static int | 171 | static int |
170 | expect_data_dynamic (json_t *vec, | 172 | expect_data_dynamic (json_t *vec, |
171 | const char *name, | 173 | const char *name, |
@@ -173,6 +175,7 @@ expect_data_dynamic (json_t *vec, | |||
173 | size_t *ret_len) | 175 | size_t *ret_len) |
174 | { | 176 | { |
175 | const char *s = json_string_value (json_object_get (vec, name)); | 177 | const char *s = json_string_value (json_object_get (vec, name)); |
178 | char *tmp; | ||
176 | size_t len; | 179 | size_t len; |
177 | 180 | ||
178 | if (NULL == s) | 181 | if (NULL == s) |
@@ -181,10 +184,14 @@ expect_data_dynamic (json_t *vec, | |||
181 | len = (strlen (s) * 5) / 8; | 184 | len = (strlen (s) * 5) / 8; |
182 | if (NULL != ret_len) | 185 | if (NULL != ret_len) |
183 | *ret_len = len; | 186 | *ret_len = len; |
184 | *data = GNUNET_malloc (len); | 187 | tmp = GNUNET_malloc (len); |
185 | 188 | ||
186 | if (GNUNET_OK != GNUNET_STRINGS_string_to_data (s, strlen (s), *data, len)) | 189 | if (GNUNET_OK != GNUNET_STRINGS_string_to_data (s, strlen (s), tmp, len)) |
190 | { | ||
191 | GNUNET_free (tmp); | ||
187 | return GNUNET_NO; | 192 | return GNUNET_NO; |
193 | } | ||
194 | *data = tmp; | ||
188 | return GNUNET_OK; | 195 | return GNUNET_OK; |
189 | } | 196 | } |
190 | 197 | ||
@@ -197,7 +204,7 @@ expect_data_dynamic (json_t *vec, | |||
197 | * | 204 | * |
198 | * @returns GNUNET_OK if the vector is okay | 205 | * @returns GNUNET_OK if the vector is okay |
199 | */ | 206 | */ |
200 | static int | 207 | static int |
201 | checkvec (const char *operation, | 208 | checkvec (const char *operation, |
202 | json_t *vec) | 209 | json_t *vec) |
203 | { | 210 | { |
@@ -220,10 +227,11 @@ checkvec (const char *operation, | |||
220 | return GNUNET_SYSERR; | 227 | return GNUNET_SYSERR; |
221 | } | 228 | } |
222 | if (GNUNET_OK != expect_data_fixed (vec, | 229 | if (GNUNET_OK != expect_data_fixed (vec, |
223 | "output", | 230 | "output", |
224 | &hash_out, | 231 | &hash_out, |
225 | sizeof (hash_out))) | 232 | sizeof (hash_out))) |
226 | { | 233 | { |
234 | GNUNET_free (data); | ||
227 | GNUNET_break (0); | 235 | GNUNET_break (0); |
228 | return GNUNET_NO; | 236 | return GNUNET_NO; |
229 | } | 237 | } |
@@ -232,9 +240,11 @@ checkvec (const char *operation, | |||
232 | 240 | ||
233 | if (0 != GNUNET_memcmp (&hc, &hash_out)) | 241 | if (0 != GNUNET_memcmp (&hc, &hash_out)) |
234 | { | 242 | { |
243 | GNUNET_free (data); | ||
235 | GNUNET_break (0); | 244 | GNUNET_break (0); |
236 | return GNUNET_NO; | 245 | return GNUNET_NO; |
237 | } | 246 | } |
247 | GNUNET_free (data); | ||
238 | } | 248 | } |
239 | else if (0 == strcmp (operation, "ecc_ecdh")) | 249 | else if (0 == strcmp (operation, "ecc_ecdh")) |
240 | { | 250 | { |
@@ -245,33 +255,33 @@ checkvec (const char *operation, | |||
245 | struct GNUNET_HashCode skm_comp; | 255 | struct GNUNET_HashCode skm_comp; |
246 | 256 | ||
247 | if (GNUNET_OK != expect_data_fixed (vec, | 257 | if (GNUNET_OK != expect_data_fixed (vec, |
248 | "priv1", | 258 | "priv1", |
249 | &priv1, | 259 | &priv1, |
250 | sizeof (priv1))) | 260 | sizeof (priv1))) |
251 | { | 261 | { |
252 | GNUNET_break (0); | 262 | GNUNET_break (0); |
253 | return GNUNET_NO; | 263 | return GNUNET_NO; |
254 | } | 264 | } |
255 | if (GNUNET_OK != expect_data_fixed (vec, | 265 | if (GNUNET_OK != expect_data_fixed (vec, |
256 | "priv2", | 266 | "priv2", |
257 | &priv2, | 267 | &priv2, |
258 | sizeof (priv2))) | 268 | sizeof (priv2))) |
259 | { | 269 | { |
260 | GNUNET_break (0); | 270 | GNUNET_break (0); |
261 | return GNUNET_NO; | 271 | return GNUNET_NO; |
262 | } | 272 | } |
263 | if (GNUNET_OK != expect_data_fixed (vec, | 273 | if (GNUNET_OK != expect_data_fixed (vec, |
264 | "pub1", | 274 | "pub1", |
265 | &pub1, | 275 | &pub1, |
266 | sizeof (pub1))) | 276 | sizeof (pub1))) |
267 | { | 277 | { |
268 | GNUNET_break (0); | 278 | GNUNET_break (0); |
269 | return GNUNET_NO; | 279 | return GNUNET_NO; |
270 | } | 280 | } |
271 | if (GNUNET_OK != expect_data_fixed (vec, | 281 | if (GNUNET_OK != expect_data_fixed (vec, |
272 | "skm", | 282 | "skm", |
273 | &skm, | 283 | &skm, |
274 | sizeof (skm))) | 284 | sizeof (skm))) |
275 | { | 285 | { |
276 | GNUNET_break (0); | 286 | GNUNET_break (0); |
277 | return GNUNET_NO; | 287 | return GNUNET_NO; |
@@ -407,6 +417,8 @@ checkvec (const char *operation, | |||
407 | &ikm, | 417 | &ikm, |
408 | &ikm_len)) | 418 | &ikm_len)) |
409 | { | 419 | { |
420 | GNUNET_free (out); | ||
421 | GNUNET_free (out_comp); | ||
410 | GNUNET_break (0); | 422 | GNUNET_break (0); |
411 | return GNUNET_SYSERR; | 423 | return GNUNET_SYSERR; |
412 | } | 424 | } |
@@ -416,6 +428,9 @@ checkvec (const char *operation, | |||
416 | &salt, | 428 | &salt, |
417 | &salt_len)) | 429 | &salt_len)) |
418 | { | 430 | { |
431 | GNUNET_free (out); | ||
432 | GNUNET_free (out_comp); | ||
433 | GNUNET_free (ikm); | ||
419 | GNUNET_break (0); | 434 | GNUNET_break (0); |
420 | return GNUNET_SYSERR; | 435 | return GNUNET_SYSERR; |
421 | } | 436 | } |
@@ -425,6 +440,10 @@ checkvec (const char *operation, | |||
425 | &ctx, | 440 | &ctx, |
426 | &ctx_len)) | 441 | &ctx_len)) |
427 | { | 442 | { |
443 | GNUNET_free (out); | ||
444 | GNUNET_free (out_comp); | ||
445 | GNUNET_free (ikm); | ||
446 | GNUNET_free (salt); | ||
428 | GNUNET_break (0); | 447 | GNUNET_break (0); |
429 | return GNUNET_SYSERR; | 448 | return GNUNET_SYSERR; |
430 | } | 449 | } |
@@ -442,10 +461,19 @@ checkvec (const char *operation, | |||
442 | 461 | ||
443 | if (0 != memcmp (out, out_comp, out_len)) | 462 | if (0 != memcmp (out, out_comp, out_len)) |
444 | { | 463 | { |
464 | GNUNET_free (out); | ||
465 | GNUNET_free (out_comp); | ||
466 | GNUNET_free (ikm); | ||
467 | GNUNET_free (salt); | ||
468 | GNUNET_free (ctx); | ||
445 | GNUNET_break (0); | 469 | GNUNET_break (0); |
446 | return GNUNET_NO; | 470 | return GNUNET_NO; |
447 | } | 471 | } |
448 | 472 | GNUNET_free (out); | |
473 | GNUNET_free (out_comp); | ||
474 | GNUNET_free (ikm); | ||
475 | GNUNET_free (salt); | ||
476 | GNUNET_free (ctx); | ||
449 | } | 477 | } |
450 | else if (0 == strcmp (operation, "eddsa_ecdh")) | 478 | else if (0 == strcmp (operation, "eddsa_ecdh")) |
451 | { | 479 | { |
@@ -562,6 +590,7 @@ checkvec (const char *operation, | |||
562 | &public_enc_data, | 590 | &public_enc_data, |
563 | &public_enc_len)) | 591 | &public_enc_len)) |
564 | { | 592 | { |
593 | GNUNET_free (blinded_data); | ||
565 | GNUNET_break (0); | 594 | GNUNET_break (0); |
566 | return GNUNET_SYSERR; | 595 | return GNUNET_SYSERR; |
567 | } | 596 | } |
@@ -571,6 +600,8 @@ checkvec (const char *operation, | |||
571 | &secret_enc_data, | 600 | &secret_enc_data, |
572 | &secret_enc_len)) | 601 | &secret_enc_len)) |
573 | { | 602 | { |
603 | GNUNET_free (blinded_data); | ||
604 | GNUNET_free (public_enc_data); | ||
574 | GNUNET_break (0); | 605 | GNUNET_break (0); |
575 | return GNUNET_SYSERR; | 606 | return GNUNET_SYSERR; |
576 | } | 607 | } |
@@ -580,6 +611,9 @@ checkvec (const char *operation, | |||
580 | &sig_enc_data, | 611 | &sig_enc_data, |
581 | &sig_enc_length)) | 612 | &sig_enc_length)) |
582 | { | 613 | { |
614 | GNUNET_free (blinded_data); | ||
615 | GNUNET_free (public_enc_data); | ||
616 | GNUNET_free (secret_enc_data); | ||
583 | GNUNET_break (0); | 617 | GNUNET_break (0); |
584 | return GNUNET_SYSERR; | 618 | return GNUNET_SYSERR; |
585 | } | 619 | } |
@@ -601,6 +635,11 @@ checkvec (const char *operation, | |||
601 | blinded_data_comp, | 635 | blinded_data_comp, |
602 | blinded_len)) ) | 636 | blinded_len)) ) |
603 | { | 637 | { |
638 | GNUNET_free (blinded_data); | ||
639 | GNUNET_free (public_enc_data); | ||
640 | GNUNET_free (secret_enc_data); | ||
641 | GNUNET_free (sig_enc_data); | ||
642 | GNUNET_free (skey); | ||
604 | GNUNET_break (0); | 643 | GNUNET_break (0); |
605 | return GNUNET_NO; | 644 | return GNUNET_NO; |
606 | } | 645 | } |
@@ -611,14 +650,27 @@ checkvec (const char *operation, | |||
611 | pkey)); | 650 | pkey)); |
612 | public_enc_len = GNUNET_CRYPTO_rsa_public_key_encode (pkey, | 651 | public_enc_len = GNUNET_CRYPTO_rsa_public_key_encode (pkey, |
613 | &public_enc_data); | 652 | &public_enc_data); |
614 | sig_enc_length_comp = GNUNET_CRYPTO_rsa_signature_encode (sig, &sig_enc_data_comp); | 653 | sig_enc_length_comp = GNUNET_CRYPTO_rsa_signature_encode (sig, |
654 | &sig_enc_data_comp); | ||
615 | 655 | ||
616 | if ( (sig_enc_length != sig_enc_length_comp) || | 656 | if ( (sig_enc_length != sig_enc_length_comp) || |
617 | (0 != memcmp (sig_enc_data, sig_enc_data_comp, sig_enc_length) )) | 657 | (0 != memcmp (sig_enc_data, sig_enc_data_comp, sig_enc_length) )) |
618 | { | 658 | { |
659 | GNUNET_free (blinded_sig); | ||
660 | GNUNET_free (blinded_data); | ||
661 | GNUNET_free (public_enc_data); | ||
662 | GNUNET_free (secret_enc_data); | ||
663 | GNUNET_free (sig_enc_data); | ||
664 | GNUNET_free (skey); | ||
619 | GNUNET_break (0); | 665 | GNUNET_break (0); |
620 | return GNUNET_NO; | 666 | return GNUNET_NO; |
621 | } | 667 | } |
668 | GNUNET_free (blinded_sig); | ||
669 | GNUNET_free (blinded_data); | ||
670 | GNUNET_free (public_enc_data); | ||
671 | GNUNET_free (secret_enc_data); | ||
672 | GNUNET_free (sig_enc_data); | ||
673 | GNUNET_free (skey); | ||
622 | } | 674 | } |
623 | else | 675 | else |
624 | { | 676 | { |
@@ -629,6 +681,7 @@ checkvec (const char *operation, | |||
629 | return GNUNET_OK; | 681 | return GNUNET_OK; |
630 | } | 682 | } |
631 | 683 | ||
684 | |||
632 | /** | 685 | /** |
633 | * Check test vectors from stdin. | 686 | * Check test vectors from stdin. |
634 | * | 687 | * |
@@ -656,7 +709,7 @@ check_vectors () | |||
656 | return 1; | 709 | return 1; |
657 | } | 710 | } |
658 | vectors = json_object_get (vecfile, "vectors"); | 711 | vectors = json_object_get (vecfile, "vectors"); |
659 | if (!json_is_array (vectors)) | 712 | if (! json_is_array (vectors)) |
660 | { | 713 | { |
661 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "bad vectors\n"); | 714 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "bad vectors\n"); |
662 | json_decref (vecfile); | 715 | json_decref (vecfile); |
@@ -692,6 +745,7 @@ check_vectors () | |||
692 | } | 745 | } |
693 | } | 746 | } |
694 | 747 | ||
748 | |||
695 | /** | 749 | /** |
696 | * Output test vectors. | 750 | * Output test vectors. |
697 | * | 751 | * |
@@ -868,20 +922,20 @@ output_vectors () | |||
868 | GNUNET_CRYPTO_ecdh_eddsa (&priv_ecdhe, &pub_eddsa, &key_material); | 922 | GNUNET_CRYPTO_ecdh_eddsa (&priv_ecdhe, &pub_eddsa, &key_material); |
869 | 923 | ||
870 | d2j (vec, "priv_ecdhe", | 924 | d2j (vec, "priv_ecdhe", |
871 | &priv_ecdhe, | 925 | &priv_ecdhe, |
872 | sizeof (struct GNUNET_CRYPTO_EcdhePrivateKey)); | 926 | sizeof (struct GNUNET_CRYPTO_EcdhePrivateKey)); |
873 | d2j (vec, "pub_ecdhe", | 927 | d2j (vec, "pub_ecdhe", |
874 | &pub_ecdhe, | 928 | &pub_ecdhe, |
875 | sizeof (struct GNUNET_CRYPTO_EcdhePublicKey)); | 929 | sizeof (struct GNUNET_CRYPTO_EcdhePublicKey)); |
876 | d2j (vec, "priv_eddsa", | 930 | d2j (vec, "priv_eddsa", |
877 | &priv_eddsa, | 931 | &priv_eddsa, |
878 | sizeof (struct GNUNET_CRYPTO_EddsaPrivateKey)); | 932 | sizeof (struct GNUNET_CRYPTO_EddsaPrivateKey)); |
879 | d2j (vec, "pub_eddsa", | 933 | d2j (vec, "pub_eddsa", |
880 | &pub_eddsa, | 934 | &pub_eddsa, |
881 | sizeof (struct GNUNET_CRYPTO_EddsaPublicKey)); | 935 | sizeof (struct GNUNET_CRYPTO_EddsaPublicKey)); |
882 | d2j (vec, "key_material", | 936 | d2j (vec, "key_material", |
883 | &key_material, | 937 | &key_material, |
884 | sizeof (struct GNUNET_HashCode)); | 938 | sizeof (struct GNUNET_HashCode)); |
885 | } | 939 | } |
886 | 940 | ||
887 | { | 941 | { |
@@ -968,6 +1022,7 @@ output_vectors () | |||
968 | GNUNET_free (blinded_data); | 1022 | GNUNET_free (blinded_data); |
969 | GNUNET_free (sig_enc_data); | 1023 | GNUNET_free (sig_enc_data); |
970 | GNUNET_free (blinded_sig_enc_data); | 1024 | GNUNET_free (blinded_sig_enc_data); |
1025 | GNUNET_free (secret_enc_data); | ||
971 | } | 1026 | } |
972 | 1027 | ||
973 | json_dumpf (vecfile, stdout, JSON_INDENT (2)); | 1028 | json_dumpf (vecfile, stdout, JSON_INDENT (2)); |
@@ -977,6 +1032,7 @@ output_vectors () | |||
977 | return 0; | 1032 | return 0; |
978 | } | 1033 | } |
979 | 1034 | ||
1035 | |||
980 | /** | 1036 | /** |
981 | * Main function that will be run. | 1037 | * Main function that will be run. |
982 | * | 1038 | * |