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/testing | |
parent | e8f7afdcd0b0ac78001e19a85f45f3a09288d759 (diff) | |
download | gnunet-eb622a145a0018907ff79d1b332482c7a3ebb8c3.tar.gz gnunet-eb622a145a0018907ff79d1b332482c7a3ebb8c3.zip |
-fixes
Diffstat (limited to 'src/testing')
-rw-r--r-- | src/testing/gnunet-testing.c | 12 |
1 files changed, 10 insertions, 2 deletions
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 | } |