diff options
author | Schanzenbach, Martin <martin.schanzenbach@aisec.fraunhofer.de> | 2017-12-02 22:34:21 +0100 |
---|---|---|
committer | Schanzenbach, Martin <martin.schanzenbach@aisec.fraunhofer.de> | 2017-12-02 22:34:21 +0100 |
commit | b16fa2d88aabb18f222b40136d6ace68ffc104c6 (patch) | |
tree | 6d46f086f018b6e6c169a8d8312b5990c33c3561 /src/util | |
parent | a9a7ac802811e76e33b54040bf31f00ea9438cea (diff) | |
parent | 862e488e08ca71db56dedd59059c5bb1a8c130a5 (diff) | |
download | gnunet-b16fa2d88aabb18f222b40136d6ace68ffc104c6.tar.gz gnunet-b16fa2d88aabb18f222b40136d6ace68ffc104c6.zip |
Merge remote-tracking branch 'origin/master' into identity_abe
Diffstat (limited to 'src/util')
-rw-r--r-- | src/util/crypto_ecc.c | 45 | ||||
-rw-r--r-- | src/util/crypto_paillier.c | 2 | ||||
-rw-r--r-- | src/util/crypto_rsa.c | 2 | ||||
-rw-r--r-- | src/util/gnunet-ecc.c | 22 | ||||
-rw-r--r-- | src/util/resolver_api.c | 1 | ||||
-rw-r--r-- | src/util/scheduler.c | 48 | ||||
-rw-r--r-- | src/util/test_crypto_paillier.c | 35 | ||||
-rw-r--r-- | src/util/test_mq.c | 1 |
8 files changed, 121 insertions, 35 deletions
diff --git a/src/util/crypto_ecc.c b/src/util/crypto_ecc.c index eaa49a991..7845932ee 100644 --- a/src/util/crypto_ecc.c +++ b/src/util/crypto_ecc.c | |||
@@ -354,6 +354,37 @@ GNUNET_CRYPTO_eddsa_public_key_to_string (const struct GNUNET_CRYPTO_EddsaPublic | |||
354 | 354 | ||
355 | 355 | ||
356 | /** | 356 | /** |
357 | * Convert a private key to a string. | ||
358 | * | ||
359 | * @param priv key to convert | ||
360 | * @return string representing @a pub | ||
361 | */ | ||
362 | char * | ||
363 | GNUNET_CRYPTO_eddsa_private_key_to_string (const struct GNUNET_CRYPTO_EddsaPrivateKey *priv) | ||
364 | { | ||
365 | char *privkeybuf; | ||
366 | size_t keylen = (sizeof (struct GNUNET_CRYPTO_EddsaPrivateKey)) * 8; | ||
367 | char *end; | ||
368 | |||
369 | if (keylen % 5 > 0) | ||
370 | keylen += 5 - keylen % 5; | ||
371 | keylen /= 5; | ||
372 | privkeybuf = GNUNET_malloc (keylen + 1); | ||
373 | end = GNUNET_STRINGS_data_to_string ((unsigned char *) priv, | ||
374 | sizeof (struct GNUNET_CRYPTO_EddsaPrivateKey), | ||
375 | privkeybuf, | ||
376 | keylen); | ||
377 | if (NULL == end) | ||
378 | { | ||
379 | GNUNET_free (privkeybuf); | ||
380 | return NULL; | ||
381 | } | ||
382 | *end = '\0'; | ||
383 | return privkeybuf; | ||
384 | } | ||
385 | |||
386 | |||
387 | /** | ||
357 | * Convert a string representing a public key to a public key. | 388 | * Convert a string representing a public key to a public key. |
358 | * | 389 | * |
359 | * @param enc encoded public key | 390 | * @param enc encoded public key |
@@ -374,9 +405,10 @@ GNUNET_CRYPTO_ecdsa_public_key_from_string (const char *enc, | |||
374 | if (enclen != keylen) | 405 | if (enclen != keylen) |
375 | return GNUNET_SYSERR; | 406 | return GNUNET_SYSERR; |
376 | 407 | ||
377 | if (GNUNET_OK != GNUNET_STRINGS_string_to_data (enc, enclen, | 408 | if (GNUNET_OK != |
378 | pub, | 409 | GNUNET_STRINGS_string_to_data (enc, enclen, |
379 | sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey))) | 410 | pub, |
411 | sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey))) | ||
380 | return GNUNET_SYSERR; | 412 | return GNUNET_SYSERR; |
381 | return GNUNET_OK; | 413 | return GNUNET_OK; |
382 | } | 414 | } |
@@ -403,9 +435,10 @@ GNUNET_CRYPTO_eddsa_public_key_from_string (const char *enc, | |||
403 | if (enclen != keylen) | 435 | if (enclen != keylen) |
404 | return GNUNET_SYSERR; | 436 | return GNUNET_SYSERR; |
405 | 437 | ||
406 | if (GNUNET_OK != GNUNET_STRINGS_string_to_data (enc, enclen, | 438 | if (GNUNET_OK != |
407 | pub, | 439 | GNUNET_STRINGS_string_to_data (enc, enclen, |
408 | sizeof (struct GNUNET_CRYPTO_EddsaPublicKey))) | 440 | pub, |
441 | sizeof (struct GNUNET_CRYPTO_EddsaPublicKey))) | ||
409 | return GNUNET_SYSERR; | 442 | return GNUNET_SYSERR; |
410 | return GNUNET_OK; | 443 | return GNUNET_OK; |
411 | } | 444 | } |
diff --git a/src/util/crypto_paillier.c b/src/util/crypto_paillier.c index 3ed025a2a..530a2957f 100644 --- a/src/util/crypto_paillier.c +++ b/src/util/crypto_paillier.c | |||
@@ -370,9 +370,11 @@ GNUNET_CRYPTO_paillier_decrypt (const struct GNUNET_CRYPTO_PaillierPrivateKey *p | |||
370 | /* mod = cmum1 / n (mod n) */ | 370 | /* mod = cmum1 / n (mod n) */ |
371 | GNUNET_assert (0 != (mod = gcry_mpi_new (0))); | 371 | GNUNET_assert (0 != (mod = gcry_mpi_new (0))); |
372 | gcry_mpi_div (mod, NULL, cmum1, n, 0); | 372 | gcry_mpi_div (mod, NULL, cmum1, n, 0); |
373 | gcry_mpi_release (cmum1); | ||
373 | 374 | ||
374 | /* m = mod * mu mod n */ | 375 | /* m = mod * mu mod n */ |
375 | gcry_mpi_mulm (m, mod, mu, n); | 376 | gcry_mpi_mulm (m, mod, mu, n); |
377 | gcry_mpi_release (mod); | ||
376 | gcry_mpi_release (mu); | 378 | gcry_mpi_release (mu); |
377 | gcry_mpi_release (n); | 379 | gcry_mpi_release (n); |
378 | } | 380 | } |
diff --git a/src/util/crypto_rsa.c b/src/util/crypto_rsa.c index 7a108c21b..a985d8e59 100644 --- a/src/util/crypto_rsa.c +++ b/src/util/crypto_rsa.c | |||
@@ -1046,7 +1046,7 @@ GNUNET_CRYPTO_rsa_public_key_dup (const struct GNUNET_CRYPTO_RsaPublicKey *key) | |||
1046 | * @return unblinded signature on success, NULL if RSA key is bad or malicious. | 1046 | * @return unblinded signature on success, NULL if RSA key is bad or malicious. |
1047 | */ | 1047 | */ |
1048 | struct GNUNET_CRYPTO_RsaSignature * | 1048 | struct GNUNET_CRYPTO_RsaSignature * |
1049 | GNUNET_CRYPTO_rsa_unblind (struct GNUNET_CRYPTO_RsaSignature *sig, | 1049 | GNUNET_CRYPTO_rsa_unblind (const struct GNUNET_CRYPTO_RsaSignature *sig, |
1050 | const struct GNUNET_CRYPTO_RsaBlindingKeySecret *bks, | 1050 | const struct GNUNET_CRYPTO_RsaBlindingKeySecret *bks, |
1051 | struct GNUNET_CRYPTO_RsaPublicKey *pkey) | 1051 | struct GNUNET_CRYPTO_RsaPublicKey *pkey) |
1052 | { | 1052 | { |
diff --git a/src/util/gnunet-ecc.c b/src/util/gnunet-ecc.c index 42ecc2101..66a4bd3e9 100644 --- a/src/util/gnunet-ecc.c +++ b/src/util/gnunet-ecc.c | |||
@@ -49,6 +49,11 @@ static unsigned int list_keys_count; | |||
49 | static int print_public_key; | 49 | static int print_public_key; |
50 | 50 | ||
51 | /** | 51 | /** |
52 | * Flag for printing private key. | ||
53 | */ | ||
54 | static int print_private_key; | ||
55 | |||
56 | /** | ||
52 | * Flag for printing public key in hex. | 57 | * Flag for printing public key in hex. |
53 | */ | 58 | */ |
54 | static int print_public_key_hex; | 59 | static int print_public_key_hex; |
@@ -377,7 +382,7 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
377 | create_keys (args[0], args[1]); | 382 | create_keys (args[0], args[1]); |
378 | return; | 383 | return; |
379 | } | 384 | } |
380 | if (print_public_key || print_public_key_hex) | 385 | if (print_public_key || print_public_key_hex || print_private_key) |
381 | { | 386 | { |
382 | char *str; | 387 | char *str; |
383 | struct GNUNET_DISK_FileHandle *keyfile; | 388 | struct GNUNET_DISK_FileHandle *keyfile; |
@@ -388,19 +393,26 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
388 | GNUNET_DISK_PERM_NONE); | 393 | GNUNET_DISK_PERM_NONE); |
389 | if (NULL == keyfile) | 394 | if (NULL == keyfile) |
390 | return; | 395 | return; |
391 | while (sizeof (pk) == GNUNET_DISK_file_read (keyfile, &pk, sizeof (pk))) | 396 | while (sizeof (pk) == |
397 | GNUNET_DISK_file_read (keyfile, &pk, sizeof (pk))) | ||
392 | { | 398 | { |
393 | GNUNET_CRYPTO_eddsa_key_get_public (&pk, &pub); | 399 | GNUNET_CRYPTO_eddsa_key_get_public (&pk, &pub); |
394 | if (print_public_key_hex) | 400 | if (print_public_key_hex) |
395 | { | 401 | { |
396 | print_hex ("HEX:", &pub, sizeof (pub)); | 402 | print_hex ("HEX:", &pub, sizeof (pub)); |
397 | } | 403 | } |
398 | else | 404 | else if (print_public_key) |
399 | { | 405 | { |
400 | str = GNUNET_CRYPTO_eddsa_public_key_to_string (&pub); | 406 | str = GNUNET_CRYPTO_eddsa_public_key_to_string (&pub); |
401 | FPRINTF (stdout, "%s\n", str); | 407 | FPRINTF (stdout, "%s\n", str); |
402 | GNUNET_free (str); | 408 | GNUNET_free (str); |
403 | } | 409 | } |
410 | else if (print_private_key) | ||
411 | { | ||
412 | str = GNUNET_CRYPTO_eddsa_private_key_to_string (&pk); | ||
413 | FPRINTF (stdout, "%s\n", str); | ||
414 | GNUNET_free (str); | ||
415 | } | ||
404 | } | 416 | } |
405 | GNUNET_DISK_file_close (keyfile); | 417 | GNUNET_DISK_file_close (keyfile); |
406 | } | 418 | } |
@@ -438,6 +450,10 @@ main (int argc, | |||
438 | "print-public-key", | 450 | "print-public-key", |
439 | gettext_noop ("print the public key in ASCII format"), | 451 | gettext_noop ("print the public key in ASCII format"), |
440 | &print_public_key), | 452 | &print_public_key), |
453 | GNUNET_GETOPT_option_flag ('P', | ||
454 | "print-private-key", | ||
455 | gettext_noop ("print the private key in ASCII format"), | ||
456 | &print_private_key), | ||
441 | GNUNET_GETOPT_option_flag ('x', | 457 | GNUNET_GETOPT_option_flag ('x', |
442 | "print-hex", | 458 | "print-hex", |
443 | gettext_noop ("print the public key in HEX format"), | 459 | gettext_noop ("print the public key in HEX format"), |
diff --git a/src/util/resolver_api.c b/src/util/resolver_api.c index 33a340729..11b8134d6 100644 --- a/src/util/resolver_api.c +++ b/src/util/resolver_api.c | |||
@@ -469,6 +469,7 @@ handle_response (void *cls, | |||
469 | uint16_t size; | 469 | uint16_t size; |
470 | char *nret; | 470 | char *nret; |
471 | 471 | ||
472 | GNUNET_assert (NULL != rh); | ||
472 | size = ntohs (msg->size); | 473 | size = ntohs (msg->size); |
473 | if (size == sizeof (struct GNUNET_MessageHeader)) | 474 | if (size == sizeof (struct GNUNET_MessageHeader)) |
474 | { | 475 | { |
diff --git a/src/util/scheduler.c b/src/util/scheduler.c index e9c25d68a..540a60557 100644 --- a/src/util/scheduler.c +++ b/src/util/scheduler.c | |||
@@ -787,6 +787,14 @@ void | |||
787 | GNUNET_SCHEDULER_run (GNUNET_SCHEDULER_TaskCallback task, | 787 | GNUNET_SCHEDULER_run (GNUNET_SCHEDULER_TaskCallback task, |
788 | void *task_cls) | 788 | void *task_cls) |
789 | { | 789 | { |
790 | GNUNET_SCHEDULER_run_with_optional_signals(GNUNET_YES, task, task_cls); | ||
791 | } | ||
792 | |||
793 | void | ||
794 | GNUNET_SCHEDULER_run_with_optional_signals (int install_signals, | ||
795 | GNUNET_SCHEDULER_TaskCallback task, | ||
796 | void *task_cls) | ||
797 | { | ||
790 | struct GNUNET_NETWORK_FDSet *rs; | 798 | struct GNUNET_NETWORK_FDSet *rs; |
791 | struct GNUNET_NETWORK_FDSet *ws; | 799 | struct GNUNET_NETWORK_FDSet *ws; |
792 | struct GNUNET_TIME_Relative timeout; | 800 | struct GNUNET_TIME_Relative timeout; |
@@ -820,24 +828,29 @@ GNUNET_SCHEDULER_run (GNUNET_SCHEDULER_TaskCallback task, | |||
820 | GNUNET_DISK_PIPE_END_READ); | 828 | GNUNET_DISK_PIPE_END_READ); |
821 | GNUNET_assert (NULL != pr); | 829 | GNUNET_assert (NULL != pr); |
822 | my_pid = getpid (); | 830 | my_pid = getpid (); |
823 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 831 | |
824 | "Registering signal handlers\n"); | 832 | if (GNUNET_YES == install_signals) |
825 | shc_int = GNUNET_SIGNAL_handler_install (SIGINT, | 833 | { |
834 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
835 | "Registering signal handlers\n"); | ||
836 | shc_int = GNUNET_SIGNAL_handler_install (SIGINT, | ||
837 | &sighandler_shutdown); | ||
838 | shc_term = GNUNET_SIGNAL_handler_install (SIGTERM, | ||
826 | &sighandler_shutdown); | 839 | &sighandler_shutdown); |
827 | shc_term = GNUNET_SIGNAL_handler_install (SIGTERM, | ||
828 | &sighandler_shutdown); | ||
829 | #if (SIGTERM != GNUNET_TERM_SIG) | 840 | #if (SIGTERM != GNUNET_TERM_SIG) |
830 | shc_gterm = GNUNET_SIGNAL_handler_install (GNUNET_TERM_SIG, | 841 | shc_gterm = GNUNET_SIGNAL_handler_install (GNUNET_TERM_SIG, |
831 | &sighandler_shutdown); | 842 | &sighandler_shutdown); |
832 | #endif | 843 | #endif |
833 | #ifndef MINGW | 844 | #ifndef MINGW |
834 | shc_pipe = GNUNET_SIGNAL_handler_install (SIGPIPE, | 845 | shc_pipe = GNUNET_SIGNAL_handler_install (SIGPIPE, |
835 | &sighandler_pipe); | 846 | &sighandler_pipe); |
836 | shc_quit = GNUNET_SIGNAL_handler_install (SIGQUIT, | 847 | shc_quit = GNUNET_SIGNAL_handler_install (SIGQUIT, |
837 | &sighandler_shutdown); | 848 | &sighandler_shutdown); |
838 | shc_hup = GNUNET_SIGNAL_handler_install (SIGHUP, | 849 | shc_hup = GNUNET_SIGNAL_handler_install (SIGHUP, |
839 | &sighandler_shutdown); | 850 | &sighandler_shutdown); |
840 | #endif | 851 | #endif |
852 | } | ||
853 | |||
841 | current_priority = GNUNET_SCHEDULER_PRIORITY_DEFAULT; | 854 | current_priority = GNUNET_SCHEDULER_PRIORITY_DEFAULT; |
842 | current_lifeness = GNUNET_YES; | 855 | current_lifeness = GNUNET_YES; |
843 | GNUNET_SCHEDULER_add_with_reason_and_priority (task, | 856 | GNUNET_SCHEDULER_add_with_reason_and_priority (task, |
@@ -953,16 +966,21 @@ GNUNET_SCHEDULER_run (GNUNET_SCHEDULER_TaskCallback task, | |||
953 | busy_wait_warning = 0; | 966 | busy_wait_warning = 0; |
954 | } | 967 | } |
955 | } | 968 | } |
956 | GNUNET_SIGNAL_handler_uninstall (shc_int); | 969 | |
957 | GNUNET_SIGNAL_handler_uninstall (shc_term); | 970 | if (GNUNET_YES == install_signals) |
971 | { | ||
972 | GNUNET_SIGNAL_handler_uninstall (shc_int); | ||
973 | GNUNET_SIGNAL_handler_uninstall (shc_term); | ||
958 | #if (SIGTERM != GNUNET_TERM_SIG) | 974 | #if (SIGTERM != GNUNET_TERM_SIG) |
959 | GNUNET_SIGNAL_handler_uninstall (shc_gterm); | 975 | GNUNET_SIGNAL_handler_uninstall (shc_gterm); |
960 | #endif | 976 | #endif |
961 | #ifndef MINGW | 977 | #ifndef MINGW |
962 | GNUNET_SIGNAL_handler_uninstall (shc_pipe); | 978 | GNUNET_SIGNAL_handler_uninstall (shc_pipe); |
963 | GNUNET_SIGNAL_handler_uninstall (shc_quit); | 979 | GNUNET_SIGNAL_handler_uninstall (shc_quit); |
964 | GNUNET_SIGNAL_handler_uninstall (shc_hup); | 980 | GNUNET_SIGNAL_handler_uninstall (shc_hup); |
965 | #endif | 981 | #endif |
982 | } | ||
983 | |||
966 | GNUNET_DISK_pipe_close (shutdown_pipe_handle); | 984 | GNUNET_DISK_pipe_close (shutdown_pipe_handle); |
967 | shutdown_pipe_handle = NULL; | 985 | shutdown_pipe_handle = NULL; |
968 | GNUNET_NETWORK_fdset_destroy (rs); | 986 | GNUNET_NETWORK_fdset_destroy (rs); |
diff --git a/src/util/test_crypto_paillier.c b/src/util/test_crypto_paillier.c index 9950978c1..1e7e0b301 100644 --- a/src/util/test_crypto_paillier.c +++ b/src/util/test_crypto_paillier.c | |||
@@ -37,6 +37,7 @@ test_crypto () | |||
37 | struct GNUNET_CRYPTO_PaillierCiphertext ciphertext; | 37 | struct GNUNET_CRYPTO_PaillierCiphertext ciphertext; |
38 | struct GNUNET_CRYPTO_PaillierPublicKey public_key; | 38 | struct GNUNET_CRYPTO_PaillierPublicKey public_key; |
39 | struct GNUNET_CRYPTO_PaillierPrivateKey private_key; | 39 | struct GNUNET_CRYPTO_PaillierPrivateKey private_key; |
40 | int ret = 0; | ||
40 | 41 | ||
41 | GNUNET_CRYPTO_paillier_create (&public_key, | 42 | GNUNET_CRYPTO_paillier_create (&public_key, |
42 | &private_key); | 43 | &private_key); |
@@ -54,7 +55,6 @@ test_crypto () | |||
54 | &public_key, | 55 | &public_key, |
55 | &ciphertext, | 56 | &ciphertext, |
56 | plaintext_result); | 57 | plaintext_result); |
57 | |||
58 | if (0 != gcry_mpi_cmp (plaintext, | 58 | if (0 != gcry_mpi_cmp (plaintext, |
59 | plaintext_result)) | 59 | plaintext_result)) |
60 | { | 60 | { |
@@ -65,9 +65,11 @@ test_crypto () | |||
65 | plaintext); | 65 | plaintext); |
66 | gcry_log_debugmpi ("\n", | 66 | gcry_log_debugmpi ("\n", |
67 | plaintext_result); | 67 | plaintext_result); |
68 | return 1; | 68 | ret = 1; |
69 | } | 69 | } |
70 | return 0; | 70 | gcry_mpi_release (plaintext); |
71 | gcry_mpi_release (plaintext_result); | ||
72 | return ret; | ||
71 | } | 73 | } |
72 | 74 | ||
73 | 75 | ||
@@ -84,6 +86,7 @@ test_hom_simple (unsigned int a, | |||
84 | struct GNUNET_CRYPTO_PaillierCiphertext c_result; | 86 | struct GNUNET_CRYPTO_PaillierCiphertext c_result; |
85 | struct GNUNET_CRYPTO_PaillierPublicKey public_key; | 87 | struct GNUNET_CRYPTO_PaillierPublicKey public_key; |
86 | struct GNUNET_CRYPTO_PaillierPrivateKey private_key; | 88 | struct GNUNET_CRYPTO_PaillierPrivateKey private_key; |
89 | int ret = 0; | ||
87 | 90 | ||
88 | GNUNET_CRYPTO_paillier_create (&public_key, | 91 | GNUNET_CRYPTO_paillier_create (&public_key, |
89 | &private_key); | 92 | &private_key); |
@@ -119,9 +122,13 @@ test_hom_simple (unsigned int a, | |||
119 | "GNUNET_CRYPTO_paillier failed simple math!\n"); | 122 | "GNUNET_CRYPTO_paillier failed simple math!\n"); |
120 | gcry_log_debugmpi ("got ", hom_result); | 123 | gcry_log_debugmpi ("got ", hom_result); |
121 | gcry_log_debugmpi ("wanted ", result); | 124 | gcry_log_debugmpi ("wanted ", result); |
122 | return 1; | 125 | ret = 1; |
123 | } | 126 | } |
124 | return 0; | 127 | gcry_mpi_release (m1); |
128 | gcry_mpi_release (m2); | ||
129 | gcry_mpi_release (result); | ||
130 | gcry_mpi_release (hom_result); | ||
131 | return ret; | ||
125 | } | 132 | } |
126 | 133 | ||
127 | 134 | ||
@@ -168,7 +175,8 @@ test_hom () | |||
168 | fprintf (stderr, | 175 | fprintf (stderr, |
169 | "GNUNET_CRYPTO_paillier_encrypt 1 failed, should return 1 allowed operation, got %d!\n", | 176 | "GNUNET_CRYPTO_paillier_encrypt 1 failed, should return 1 allowed operation, got %d!\n", |
170 | ret); | 177 | ret); |
171 | return 1; | 178 | ret = 1; |
179 | goto out; | ||
172 | } | 180 | } |
173 | if (2 != (ret = GNUNET_CRYPTO_paillier_encrypt (&public_key, | 181 | if (2 != (ret = GNUNET_CRYPTO_paillier_encrypt (&public_key, |
174 | m2, | 182 | m2, |
@@ -178,7 +186,8 @@ test_hom () | |||
178 | fprintf (stderr, | 186 | fprintf (stderr, |
179 | "GNUNET_CRYPTO_paillier_encrypt 2 failed, should return 2 allowed operation, got %d!\n", | 187 | "GNUNET_CRYPTO_paillier_encrypt 2 failed, should return 2 allowed operation, got %d!\n", |
180 | ret); | 188 | ret); |
181 | return 1; | 189 | ret = 1; |
190 | goto out; | ||
182 | } | 191 | } |
183 | 192 | ||
184 | if (0 != (ret = GNUNET_CRYPTO_paillier_hom_add (&public_key, | 193 | if (0 != (ret = GNUNET_CRYPTO_paillier_hom_add (&public_key, |
@@ -189,7 +198,8 @@ test_hom () | |||
189 | fprintf (stderr, | 198 | fprintf (stderr, |
190 | "GNUNET_CRYPTO_paillier_hom_add failed, expected 0 remaining operations, got %d!\n", | 199 | "GNUNET_CRYPTO_paillier_hom_add failed, expected 0 remaining operations, got %d!\n", |
191 | ret); | 200 | ret); |
192 | return 1; | 201 | ret = 1; |
202 | goto out; | ||
193 | } | 203 | } |
194 | 204 | ||
195 | GNUNET_CRYPTO_paillier_decrypt (&private_key, | 205 | GNUNET_CRYPTO_paillier_decrypt (&private_key, |
@@ -203,9 +213,14 @@ test_hom () | |||
203 | "GNUNET_CRYPTO_paillier miscalculated with large numbers!\n"); | 213 | "GNUNET_CRYPTO_paillier miscalculated with large numbers!\n"); |
204 | gcry_log_debugmpi ("got", hom_result); | 214 | gcry_log_debugmpi ("got", hom_result); |
205 | gcry_log_debugmpi ("wanted", result); | 215 | gcry_log_debugmpi ("wanted", result); |
206 | return 1; | 216 | ret = 1; |
207 | } | 217 | } |
208 | return 0; | 218 | out: |
219 | gcry_mpi_release (m1); | ||
220 | gcry_mpi_release (m2); | ||
221 | gcry_mpi_release (result); | ||
222 | gcry_mpi_release (hom_result); | ||
223 | return ret; | ||
209 | } | 224 | } |
210 | 225 | ||
211 | 226 | ||
diff --git a/src/util/test_mq.c b/src/util/test_mq.c index 442c110db..9e8fc844e 100644 --- a/src/util/test_mq.c +++ b/src/util/test_mq.c | |||
@@ -51,6 +51,7 @@ test1 () | |||
51 | GNUNET_assert (NULL != mm); | 51 | GNUNET_assert (NULL != mm); |
52 | GNUNET_assert (42 == ntohs (mm->header.type)); | 52 | GNUNET_assert (42 == ntohs (mm->header.type)); |
53 | GNUNET_assert (sizeof (struct MyMessage) == ntohs (mm->header.size)); | 53 | GNUNET_assert (sizeof (struct MyMessage) == ntohs (mm->header.size)); |
54 | GNUNET_MQ_discard (mqm); | ||
54 | } | 55 | } |
55 | 56 | ||
56 | 57 | ||