diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2012-07-16 13:56:55 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2012-07-16 13:56:55 +0000 |
commit | 315beeea8ed2660629bdd2a3346b74584b9939bc (patch) | |
tree | 060d8a09f4c76439a72364e6de68bc442fa434aa /src/namestore | |
parent | 173438a7660f0173c317a9a1de905f2355732a40 (diff) | |
download | gnunet-315beeea8ed2660629bdd2a3346b74584b9939bc.tar.gz gnunet-315beeea8ed2660629bdd2a3346b74584b9939bc.zip |
- namestore uses new rsa api
Diffstat (limited to 'src/namestore')
-rw-r--r-- | src/namestore/gnunet-service-namestore.c | 74 |
1 files changed, 65 insertions, 9 deletions
diff --git a/src/namestore/gnunet-service-namestore.c b/src/namestore/gnunet-service-namestore.c index 7609c73a3..e3d99e2bd 100644 --- a/src/namestore/gnunet-service-namestore.c +++ b/src/namestore/gnunet-service-namestore.c | |||
@@ -191,6 +191,26 @@ static struct GNUNET_NAMESTORE_Client *client_tail; | |||
191 | */ | 191 | */ |
192 | static struct GNUNET_CONTAINER_MultiHashMap *zonekeys; | 192 | static struct GNUNET_CONTAINER_MultiHashMap *zonekeys; |
193 | 193 | ||
194 | /** | ||
195 | * DLL head for key loading contexts | ||
196 | */ | ||
197 | static struct KeyLoadContext *kl_head; | ||
198 | |||
199 | /** | ||
200 | * DLL tail for key loading contexts | ||
201 | */ | ||
202 | static struct KeyLoadContext *kl_tail; | ||
203 | |||
204 | struct KeyLoadContext | ||
205 | { | ||
206 | struct KeyLoadContext *next; | ||
207 | struct KeyLoadContext *prev; | ||
208 | struct GNUNET_CRYPTO_RsaKeyGenerationContext *keygen; | ||
209 | char *filename; | ||
210 | unsigned int *counter; | ||
211 | }; | ||
212 | |||
213 | |||
194 | 214 | ||
195 | /** | 215 | /** |
196 | * Writes the encrypted private key of a zone in a file | 216 | * Writes the encrypted private key of a zone in a file |
@@ -382,6 +402,7 @@ cleanup_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
382 | { | 402 | { |
383 | struct GNUNET_NAMESTORE_ZoneIteration *no; | 403 | struct GNUNET_NAMESTORE_ZoneIteration *no; |
384 | struct GNUNET_NAMESTORE_Client *nc; | 404 | struct GNUNET_NAMESTORE_Client *nc; |
405 | struct KeyLoadContext *kl; | ||
385 | 406 | ||
386 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Stopping namestore service\n"); | 407 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Stopping namestore service\n"); |
387 | if (NULL != snc) | 408 | if (NULL != snc) |
@@ -389,6 +410,16 @@ cleanup_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
389 | GNUNET_SERVER_notification_context_destroy (snc); | 410 | GNUNET_SERVER_notification_context_destroy (snc); |
390 | snc = NULL; | 411 | snc = NULL; |
391 | } | 412 | } |
413 | |||
414 | while (NULL != (kl = kl_head)) | ||
415 | { | ||
416 | GNUNET_CONTAINER_DLL_remove (kl_head, kl_tail, kl); | ||
417 | if (NULL != kl->keygen) | ||
418 | GNUNET_CRYPTO_rsa_key_create_stop (kl->keygen); | ||
419 | GNUNET_free (kl->filename); | ||
420 | GNUNET_free (kl); | ||
421 | } | ||
422 | |||
392 | GNUNET_CONTAINER_multihashmap_iterate (zonekeys, &zone_to_disk_it, NULL); | 423 | GNUNET_CONTAINER_multihashmap_iterate (zonekeys, &zone_to_disk_it, NULL); |
393 | GNUNET_CONTAINER_multihashmap_destroy (zonekeys); | 424 | GNUNET_CONTAINER_multihashmap_destroy (zonekeys); |
394 | zonekeys = NULL; | 425 | zonekeys = NULL; |
@@ -2088,6 +2119,29 @@ handle_iteration_next (void *cls, | |||
2088 | GNUNET_SERVER_receive_done (client, GNUNET_OK); | 2119 | GNUNET_SERVER_receive_done (client, GNUNET_OK); |
2089 | } | 2120 | } |
2090 | 2121 | ||
2122 | static void | ||
2123 | zonekey_it_key_cb (void *cls, | ||
2124 | struct GNUNET_CRYPTO_RsaPrivateKey *pk, | ||
2125 | const char *emsg) | ||
2126 | { | ||
2127 | struct KeyLoadContext *kl = cls; | ||
2128 | |||
2129 | kl->keygen = NULL; | ||
2130 | if (NULL == pk) | ||
2131 | { | ||
2132 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | ||
2133 | _("Could not parse zone key file `%s'\n"), | ||
2134 | kl->filename); | ||
2135 | return; | ||
2136 | } | ||
2137 | learn_private_key (pk); | ||
2138 | (*kl->counter) ++; | ||
2139 | |||
2140 | GNUNET_CONTAINER_DLL_remove (kl_head, kl_tail, kl); | ||
2141 | GNUNET_free (kl->filename); | ||
2142 | GNUNET_free (kl); | ||
2143 | } | ||
2144 | |||
2091 | 2145 | ||
2092 | /** | 2146 | /** |
2093 | * Load zone keys from directory by reading all .zkey files in this directory | 2147 | * Load zone keys from directory by reading all .zkey files in this directory |
@@ -2099,22 +2153,24 @@ handle_iteration_next (void *cls, | |||
2099 | static int | 2153 | static int |
2100 | zonekey_file_it (void *cls, const char *filename) | 2154 | zonekey_file_it (void *cls, const char *filename) |
2101 | { | 2155 | { |
2102 | unsigned int *counter = cls; | 2156 | struct KeyLoadContext *kl; |
2103 | struct GNUNET_CRYPTO_RsaPrivateKey *privkey; | ||
2104 | 2157 | ||
2105 | if ((NULL == filename) || | 2158 | if ((NULL == filename) || |
2106 | (NULL == strstr(filename, ".zkey"))) | 2159 | (NULL == strstr(filename, ".zkey"))) |
2107 | return GNUNET_OK; | 2160 | return GNUNET_OK; |
2108 | privkey = GNUNET_CRYPTO_rsa_key_create_from_file (filename); | 2161 | |
2109 | if (NULL == privkey) | 2162 | kl = GNUNET_malloc (sizeof (struct KeyLoadContext)); |
2163 | kl->filename = strdup (filename); | ||
2164 | kl->counter = cls; | ||
2165 | kl->keygen = GNUNET_CRYPTO_rsa_key_create_start (filename, zonekey_it_key_cb, kl); | ||
2166 | if (NULL == kl->keygen) | ||
2110 | { | 2167 | { |
2111 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 2168 | GNUNET_free (kl); |
2112 | _("Could not parse zone key file `%s'\n"), | 2169 | GNUNET_free (kl->filename); |
2113 | filename); | ||
2114 | return GNUNET_OK; | 2170 | return GNUNET_OK; |
2115 | } | 2171 | } |
2116 | learn_private_key (privkey); | 2172 | |
2117 | (*counter)++; | 2173 | GNUNET_CONTAINER_DLL_insert (kl_head, kl_tail, kl); |
2118 | return GNUNET_OK; | 2174 | return GNUNET_OK; |
2119 | } | 2175 | } |
2120 | 2176 | ||