diff options
Diffstat (limited to 'src/testing/testing.c')
-rw-r--r-- | src/testing/testing.c | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/src/testing/testing.c b/src/testing/testing.c index fca969b19..369bd4e51 100644 --- a/src/testing/testing.c +++ b/src/testing/testing.c | |||
@@ -441,9 +441,9 @@ reserve_path (struct GNUNET_TESTING_System *system) | |||
441 | * @param key_number desired pre-created hostkey to obtain | 441 | * @param key_number desired pre-created hostkey to obtain |
442 | * @param id set to the peer's identity (hash of the public | 442 | * @param id set to the peer's identity (hash of the public |
443 | * key; if NULL, GNUNET_SYSERR is returned immediately | 443 | * key; if NULL, GNUNET_SYSERR is returned immediately |
444 | * @return GNUNET_SYSERR on error (not enough keys) | 444 | * @return NULL on error (not enough keys) |
445 | */ | 445 | */ |
446 | int | 446 | struct GNUNET_CRYPTO_RsaPrivateKey * |
447 | GNUNET_TESTING_hostkey_get (const struct GNUNET_TESTING_System *system, | 447 | GNUNET_TESTING_hostkey_get (const struct GNUNET_TESTING_System *system, |
448 | uint32_t key_number, | 448 | uint32_t key_number, |
449 | struct GNUNET_PeerIdentity *id) | 449 | struct GNUNET_PeerIdentity *id) |
@@ -452,12 +452,12 @@ GNUNET_TESTING_hostkey_get (const struct GNUNET_TESTING_System *system, | |||
452 | struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded public_key; | 452 | struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded public_key; |
453 | 453 | ||
454 | if ((NULL == id) || (NULL == system->hostkeys_data)) | 454 | if ((NULL == id) || (NULL == system->hostkeys_data)) |
455 | return GNUNET_SYSERR; | 455 | return NULL; |
456 | if (key_number >= system->total_hostkeys) | 456 | if (key_number >= system->total_hostkeys) |
457 | { | 457 | { |
458 | LOG (GNUNET_ERROR_TYPE_ERROR, | 458 | LOG (GNUNET_ERROR_TYPE_ERROR, |
459 | _("Key number %u does not exist\n"), key_number); | 459 | _("Key number %u does not exist\n"), key_number); |
460 | return GNUNET_SYSERR; | 460 | return NULL; |
461 | } | 461 | } |
462 | private_key = GNUNET_CRYPTO_rsa_decode_key (system->hostkeys_data + | 462 | private_key = GNUNET_CRYPTO_rsa_decode_key (system->hostkeys_data + |
463 | (key_number * HOSTKEYFILESIZE), | 463 | (key_number * HOSTKEYFILESIZE), |
@@ -466,14 +466,13 @@ GNUNET_TESTING_hostkey_get (const struct GNUNET_TESTING_System *system, | |||
466 | { | 466 | { |
467 | LOG (GNUNET_ERROR_TYPE_ERROR, | 467 | LOG (GNUNET_ERROR_TYPE_ERROR, |
468 | _("Error while decoding key %u\n"), key_number); | 468 | _("Error while decoding key %u\n"), key_number); |
469 | return GNUNET_SYSERR; | 469 | return NULL; |
470 | } | 470 | } |
471 | GNUNET_CRYPTO_rsa_key_get_public (private_key, &public_key); | 471 | GNUNET_CRYPTO_rsa_key_get_public (private_key, &public_key); |
472 | GNUNET_CRYPTO_hash (&public_key, | 472 | GNUNET_CRYPTO_hash (&public_key, |
473 | sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), | 473 | sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), |
474 | &(id->hashPubKey)); | 474 | &(id->hashPubKey)); |
475 | GNUNET_CRYPTO_rsa_key_free (private_key); | 475 | return private_key; |
476 | return GNUNET_OK; | ||
477 | } | 476 | } |
478 | 477 | ||
479 | 478 | ||
@@ -698,6 +697,7 @@ GNUNET_TESTING_peer_configure (struct GNUNET_TESTING_System *system, | |||
698 | char hostkey_filename[128]; | 697 | char hostkey_filename[128]; |
699 | char *config_filename; | 698 | char *config_filename; |
700 | char *emsg_; | 699 | char *emsg_; |
700 | struct GNUNET_CRYPTO_RsaPrivateKey *pk; | ||
701 | 701 | ||
702 | if (NULL != emsg) | 702 | if (NULL != emsg) |
703 | *emsg = NULL; | 703 | *emsg = NULL; |
@@ -724,8 +724,9 @@ GNUNET_TESTING_peer_configure (struct GNUNET_TESTING_System *system, | |||
724 | GNUNET_free (emsg_); | 724 | GNUNET_free (emsg_); |
725 | return NULL; | 725 | return NULL; |
726 | } | 726 | } |
727 | pk = NULL; | ||
727 | if ((NULL != id) && | 728 | if ((NULL != id) && |
728 | (GNUNET_SYSERR == GNUNET_TESTING_hostkey_get (system, key_number, id))) | 729 | (NULL == (pk = GNUNET_TESTING_hostkey_get (system, key_number, id)))) |
729 | { | 730 | { |
730 | GNUNET_asprintf (&emsg_, | 731 | GNUNET_asprintf (&emsg_, |
731 | _("Failed to initialize hostkey for peer %u\n"), | 732 | _("Failed to initialize hostkey for peer %u\n"), |
@@ -737,6 +738,8 @@ GNUNET_TESTING_peer_configure (struct GNUNET_TESTING_System *system, | |||
737 | GNUNET_free (emsg_); | 738 | GNUNET_free (emsg_); |
738 | return NULL; | 739 | return NULL; |
739 | } | 740 | } |
741 | if (NULL != pk) | ||
742 | GNUNET_CRYPTO_rsa_key_free (pk); | ||
740 | GNUNET_assert (GNUNET_OK == | 743 | GNUNET_assert (GNUNET_OK == |
741 | GNUNET_CONFIGURATION_get_value_string (cfg, "PATHS", | 744 | GNUNET_CONFIGURATION_get_value_string (cfg, "PATHS", |
742 | "SERVICEHOME", | 745 | "SERVICEHOME", |