diff options
author | Christian Grothoff <christian@grothoff.org> | 2012-06-19 07:57:02 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2012-06-19 07:57:02 +0000 |
commit | eb622a145a0018907ff79d1b332482c7a3ebb8c3 (patch) | |
tree | b5841be415d0cfcc5b72bffe1ee9c27b133413c0 /src | |
parent | e8f7afdcd0b0ac78001e19a85f45f3a09288d759 (diff) | |
download | gnunet-eb622a145a0018907ff79d1b332482c7a3ebb8c3.tar.gz gnunet-eb622a145a0018907ff79d1b332482c7a3ebb8c3.zip |
-fixes
Diffstat (limited to 'src')
-rw-r--r-- | src/include/gnunet_crypto_lib.h | 5 | ||||
-rw-r--r-- | src/testing/gnunet-testing.c | 12 |
2 files changed, 13 insertions, 4 deletions
diff --git a/src/include/gnunet_crypto_lib.h b/src/include/gnunet_crypto_lib.h index 879b1cae2..33842fc27 100644 --- a/src/include/gnunet_crypto_lib.h +++ b/src/include/gnunet_crypto_lib.h | |||
@@ -895,12 +895,12 @@ GNUNET_CRYPTO_rsa_public_key_from_string (const char *enc, | |||
895 | /** | 895 | /** |
896 | * Encode the private key in a format suitable for | 896 | * Encode the private key in a format suitable for |
897 | * storing it into a file. | 897 | * storing it into a file. |
898 | * @returns encoding of the private key. | 898 | * @return encoding of the private key |
899 | * The first 4 bytes give the size of the array, as usual. | ||
900 | */ | 899 | */ |
901 | struct GNUNET_CRYPTO_RsaPrivateKeyBinaryEncoded * | 900 | struct GNUNET_CRYPTO_RsaPrivateKeyBinaryEncoded * |
902 | GNUNET_CRYPTO_rsa_encode_key (const struct GNUNET_CRYPTO_RsaPrivateKey *hostkey); | 901 | GNUNET_CRYPTO_rsa_encode_key (const struct GNUNET_CRYPTO_RsaPrivateKey *hostkey); |
903 | 902 | ||
903 | |||
904 | /** | 904 | /** |
905 | * Decode the private key from the data-format back | 905 | * Decode the private key from the data-format back |
906 | * to the "normal", internal format. | 906 | * to the "normal", internal format. |
@@ -911,6 +911,7 @@ GNUNET_CRYPTO_rsa_encode_key (const struct GNUNET_CRYPTO_RsaPrivateKey *hostkey) | |||
911 | struct GNUNET_CRYPTO_RsaPrivateKey * | 911 | struct GNUNET_CRYPTO_RsaPrivateKey * |
912 | GNUNET_CRYPTO_rsa_decode_key (const char *buf, uint16_t len); | 912 | GNUNET_CRYPTO_rsa_decode_key (const char *buf, uint16_t len); |
913 | 913 | ||
914 | |||
914 | /** | 915 | /** |
915 | * Create a new private key by reading it from a file. If the | 916 | * Create a new private key by reading it from a file. If the |
916 | * files does not exist, create a new key and write it to the | 917 | * files does not exist, create a new key and write it to the |
diff --git a/src/testing/gnunet-testing.c b/src/testing/gnunet-testing.c index a84c512a7..bce0c7522 100644 --- a/src/testing/gnunet-testing.c +++ b/src/testing/gnunet-testing.c | |||
@@ -27,8 +27,8 @@ | |||
27 | #include "gnunet_util_lib.h" | 27 | #include "gnunet_util_lib.h" |
28 | #include "gnunet_testing_lib-new.h" | 28 | #include "gnunet_testing_lib-new.h" |
29 | 29 | ||
30 | #define HOSTKEYFILESIZE 914 | ||
31 | 30 | ||
31 | #define HOSTKEYFILESIZE 914 | ||
32 | 32 | ||
33 | /** | 33 | /** |
34 | * Final status code. | 34 | * Final status code. |
@@ -122,20 +122,28 @@ create_hostkeys (const unsigned int no) | |||
122 | struct GNUNET_PeerIdentity id; | 122 | struct GNUNET_PeerIdentity id; |
123 | struct GNUNET_DISK_FileHandle *fd; | 123 | struct GNUNET_DISK_FileHandle *fd; |
124 | struct GNUNET_CRYPTO_RsaPrivateKey *pk; | 124 | struct GNUNET_CRYPTO_RsaPrivateKey *pk; |
125 | struct GNUNET_CRYPTO_RsaPrivateKeyBinaryEncoded *pkb; | ||
125 | 126 | ||
126 | system = GNUNET_TESTING_system_create ("testing", NULL); | 127 | system = GNUNET_TESTING_system_create ("testing", NULL); |
127 | pk = GNUNET_TESTING_hostkey_get (system, create_no, &id); | 128 | pk = GNUNET_TESTING_hostkey_get (system, create_no, &id); |
129 | if (NULL == pk) | ||
130 | { | ||
131 | fprintf (stderr, _("Could not extract hostkey %u (offset too large?)\n"), create_no); | ||
132 | return 1; | ||
133 | } | ||
128 | fd = GNUNET_DISK_file_open (create_hostkey, | 134 | fd = GNUNET_DISK_file_open (create_hostkey, |
129 | GNUNET_DISK_OPEN_READWRITE | | 135 | GNUNET_DISK_OPEN_READWRITE | |
130 | GNUNET_DISK_OPEN_CREATE, | 136 | GNUNET_DISK_OPEN_CREATE, |
131 | GNUNET_DISK_PERM_USER_READ | | 137 | GNUNET_DISK_PERM_USER_READ | |
132 | GNUNET_DISK_PERM_USER_WRITE); | 138 | GNUNET_DISK_PERM_USER_WRITE); |
133 | GNUNET_assert (fd != NULL); | 139 | GNUNET_assert (fd != NULL); |
140 | pkb = GNUNET_CRYPTO_rsa_encode_key (pk); | ||
134 | GNUNET_assert (HOSTKEYFILESIZE == | 141 | GNUNET_assert (HOSTKEYFILESIZE == |
135 | GNUNET_DISK_file_write (fd, pk, HOSTKEYFILESIZE)); | 142 | GNUNET_DISK_file_write (fd, pkb, ntohs (pkb->len))); |
136 | GNUNET_assert (GNUNET_OK == GNUNET_DISK_file_close (fd)); | 143 | GNUNET_assert (GNUNET_OK == GNUNET_DISK_file_close (fd)); |
137 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "transport-testing", | 144 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "transport-testing", |
138 | "Wrote hostkey to file: `%s'\n", create_hostkey); | 145 | "Wrote hostkey to file: `%s'\n", create_hostkey); |
146 | GNUNET_free (pkb); | ||
139 | GNUNET_CRYPTO_rsa_key_free (pk); | 147 | GNUNET_CRYPTO_rsa_key_free (pk); |
140 | return 0; | 148 | return 0; |
141 | } | 149 | } |