diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2012-07-16 13:10:25 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2012-07-16 13:10:25 +0000 |
commit | 173438a7660f0173c317a9a1de905f2355732a40 (patch) | |
tree | 84a90cdcb57fa057eb05700921aab22e41cba285 /src/namestore/gnunet-namestore.c | |
parent | ca2e9417277e02ea70628a0f85ab71ae19ee82d8 (diff) | |
download | gnunet-173438a7660f0173c317a9a1de905f2355732a40.tar.gz gnunet-173438a7660f0173c317a9a1de905f2355732a40.zip |
- new rsa api
Diffstat (limited to 'src/namestore/gnunet-namestore.c')
-rw-r--r-- | src/namestore/gnunet-namestore.c | 85 |
1 files changed, 59 insertions, 26 deletions
diff --git a/src/namestore/gnunet-namestore.c b/src/namestore/gnunet-namestore.c index ed6d37244..7fc3ad45f 100644 --- a/src/namestore/gnunet-namestore.c +++ b/src/namestore/gnunet-namestore.c | |||
@@ -34,6 +34,11 @@ | |||
34 | 34 | ||
35 | 35 | ||
36 | /** | 36 | /** |
37 | * Hostkey generation context | ||
38 | */ | ||
39 | struct GNUNET_CRYPTO_RsaKeyGenerationContext * keygen; | ||
40 | |||
41 | /** | ||
37 | * Handle to the namestore. | 42 | * Handle to the namestore. |
38 | */ | 43 | */ |
39 | static struct GNUNET_NAMESTORE_Handle *ns; | 44 | static struct GNUNET_NAMESTORE_Handle *ns; |
@@ -139,6 +144,12 @@ static void | |||
139 | do_shutdown (void *cls, | 144 | do_shutdown (void *cls, |
140 | const struct GNUNET_SCHEDULER_TaskContext *tc) | 145 | const struct GNUNET_SCHEDULER_TaskContext *tc) |
141 | { | 146 | { |
147 | if (NULL != keygen) | ||
148 | { | ||
149 | GNUNET_CRYPTO_rsa_key_create_stop (keygen); | ||
150 | keygen = NULL; | ||
151 | } | ||
152 | |||
142 | if (NULL != list_it) | 153 | if (NULL != list_it) |
143 | { | 154 | { |
144 | GNUNET_NAMESTORE_zone_iteration_stop (list_it); | 155 | GNUNET_NAMESTORE_zone_iteration_stop (list_it); |
@@ -316,11 +327,12 @@ display_record (void *cls, | |||
316 | GNUNET_NAMESTORE_zone_iterator_next (list_it); | 327 | GNUNET_NAMESTORE_zone_iterator_next (list_it); |
317 | } | 328 | } |
318 | 329 | ||
319 | |||
320 | static void | 330 | static void |
321 | testservice_task (void *cls, | 331 | key_generation_cb (void *cls, |
322 | const struct GNUNET_SCHEDULER_TaskContext *tc) | 332 | struct GNUNET_CRYPTO_RsaPrivateKey *pk, |
333 | const char *emsg) | ||
323 | { | 334 | { |
335 | struct GNUNET_CONFIGURATION_Handle *cfg = cls; | ||
324 | struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded pub; | 336 | struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded pub; |
325 | uint32_t type; | 337 | uint32_t type; |
326 | void *data = NULL; | 338 | void *data = NULL; |
@@ -330,32 +342,14 @@ testservice_task (void *cls, | |||
330 | int etime_is_rel = GNUNET_SYSERR; | 342 | int etime_is_rel = GNUNET_SYSERR; |
331 | struct GNUNET_NAMESTORE_RecordData rd; | 343 | struct GNUNET_NAMESTORE_RecordData rd; |
332 | 344 | ||
333 | struct GNUNET_CONFIGURATION_Handle *cfg = cls; | 345 | keygen = NULL; |
334 | 346 | if (NULL == pk) | |
335 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_TIMEOUT)) | ||
336 | { | 347 | { |
337 | FPRINTF (stderr, _("Service `%s' is not running\n"), "namestore"); | 348 | GNUNET_SCHEDULER_shutdown (); |
338 | return; | 349 | return; |
339 | } | 350 | } |
351 | zone_pkey = pk; | ||
340 | 352 | ||
341 | |||
342 | if (NULL == keyfile) | ||
343 | { | ||
344 | if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_filename (cfg, "gns", | ||
345 | "ZONEKEY", &keyfile)) | ||
346 | { | ||
347 | fprintf (stderr, | ||
348 | _("Option `%s' not given, but I need a zone key file!\n"), | ||
349 | "z"); | ||
350 | return; | ||
351 | } | ||
352 | fprintf (stderr, | ||
353 | _("Using default zone file `%s'\n"), | ||
354 | keyfile); | ||
355 | } | ||
356 | zone_pkey = GNUNET_CRYPTO_rsa_key_create_from_file (keyfile); | ||
357 | GNUNET_free (keyfile); | ||
358 | keyfile = NULL; | ||
359 | if (! (add|del|list|(NULL != uri))) | 353 | if (! (add|del|list|(NULL != uri))) |
360 | { | 354 | { |
361 | /* nothing more to be done */ | 355 | /* nothing more to be done */ |
@@ -602,6 +596,45 @@ testservice_task (void *cls, | |||
602 | &add_qe_uri); | 596 | &add_qe_uri); |
603 | } | 597 | } |
604 | GNUNET_free_non_null (data); | 598 | GNUNET_free_non_null (data); |
599 | |||
600 | } | ||
601 | |||
602 | |||
603 | static void | ||
604 | testservice_task (void *cls, | ||
605 | const struct GNUNET_SCHEDULER_TaskContext *tc) | ||
606 | { | ||
607 | struct GNUNET_CONFIGURATION_Handle *cfg = cls; | ||
608 | |||
609 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_TIMEOUT)) | ||
610 | { | ||
611 | FPRINTF (stderr, _("Service `%s' is not running\n"), "namestore"); | ||
612 | return; | ||
613 | } | ||
614 | |||
615 | |||
616 | if (NULL == keyfile) | ||
617 | { | ||
618 | if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_filename (cfg, "gns", | ||
619 | "ZONEKEY", &keyfile)) | ||
620 | { | ||
621 | fprintf (stderr, | ||
622 | _("Option `%s' not given, but I need a zone key file!\n"), | ||
623 | "z"); | ||
624 | return; | ||
625 | } | ||
626 | fprintf (stderr, | ||
627 | _("Using default zone file `%s'\n"), | ||
628 | keyfile); | ||
629 | } | ||
630 | keygen = GNUNET_CRYPTO_rsa_key_create_start (keyfile, key_generation_cb, cfg); | ||
631 | GNUNET_free (keyfile); | ||
632 | keyfile = NULL; | ||
633 | if (NULL == keygen) | ||
634 | { | ||
635 | GNUNET_SCHEDULER_shutdown (); | ||
636 | ret = 1; | ||
637 | } | ||
605 | } | 638 | } |
606 | 639 | ||
607 | 640 | ||