aboutsummaryrefslogtreecommitdiff
path: root/src/gns/gnunet-service-gns.c
diff options
context:
space:
mode:
authorMartin Schanzenbach <mschanzenbach@posteo.de>2012-06-11 14:59:04 +0000
committerMartin Schanzenbach <mschanzenbach@posteo.de>2012-06-11 14:59:04 +0000
commit8338aebe1b4be9e8cb27be564851a14a9ebb6b14 (patch)
treed9b37c09a7bf1226d899671765548d5fe0bad145 /src/gns/gnunet-service-gns.c
parentc4ea2585c71c4d619f3f24f32c277a5fa6b5772a (diff)
downloadgnunet-8338aebe1b4be9e8cb27be564851a14a9ebb6b14.tar.gz
gnunet-8338aebe1b4be9e8cb27be564851a14a9ebb6b14.zip
new API for shorten key
Diffstat (limited to 'src/gns/gnunet-service-gns.c')
-rw-r--r--src/gns/gnunet-service-gns.c42
1 files changed, 21 insertions, 21 deletions
diff --git a/src/gns/gnunet-service-gns.c b/src/gns/gnunet-service-gns.c
index 5e2280111..8f8fbe41b 100644
--- a/src/gns/gnunet-service-gns.c
+++ b/src/gns/gnunet-service-gns.c
@@ -60,8 +60,8 @@ struct ClientShortenHandle
60 /* request type */ 60 /* request type */
61 enum GNUNET_GNS_RecordType type; 61 enum GNUNET_GNS_RecordType type;
62 62
63 /* optional zone private key used for lookup */ 63 /* optional zone private key used for shorten */
64 struct GNUNET_CRYPTO_RsaPrivateKey *zone_key; 64 struct GNUNET_CRYPTO_RsaPrivateKey *shorten_key;
65 65
66 /* name to shorten */ 66 /* name to shorten */
67 char* name; 67 char* name;
@@ -100,8 +100,8 @@ struct ClientLookupHandle
100 /* request type */ 100 /* request type */
101 enum GNUNET_GNS_RecordType type; 101 enum GNUNET_GNS_RecordType type;
102 102
103 /* optional zone private key used for lookup */ 103 /* optional zone private key used for shorten */
104 struct GNUNET_CRYPTO_RsaPrivateKey *zone_key; 104 struct GNUNET_CRYPTO_RsaPrivateKey *shorten_key;
105 105
106 /* the name to look up */ 106 /* the name to look up */
107 char* name; //Needed? 107 char* name; //Needed?
@@ -425,13 +425,13 @@ update_zone_dht_start(void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
425} 425}
426 426
427/** 427/**
428 * Lookup the private key for the zone 428 * Lookup the shorten key for the zone
429 * 429 *
430 * @param zone the zone we want a private key for 430 * @param zone the zone we want a private key for
431 * @return NULL of not found else the key 431 * @return NULL of not found else the key
432 */ 432 */
433struct GNUNET_CRYPTO_RsaPrivateKey* 433struct GNUNET_CRYPTO_RsaPrivateKey*
434lookup_private_key(struct GNUNET_CRYPTO_ShortHashCode *zone) 434lookup_shorten_key(struct GNUNET_CRYPTO_ShortHashCode *short_zone)
435{ 435{
436 char* keydir; 436 char* keydir;
437 struct GNUNET_CRYPTO_ShortHashAsciiEncoded zonename; 437 struct GNUNET_CRYPTO_ShortHashAsciiEncoded zonename;
@@ -439,7 +439,7 @@ lookup_private_key(struct GNUNET_CRYPTO_ShortHashCode *zone)
439 struct GNUNET_CRYPTO_RsaPrivateKey *key = NULL; 439 struct GNUNET_CRYPTO_RsaPrivateKey *key = NULL;
440 440
441 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 441 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
442 "Looking for private key\n"); 442 "Looking for shorten zonekey\n");
443 443
444 if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_filename (GNS_cfg, 444 if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_filename (GNS_cfg,
445 "namestore", 445 "namestore",
@@ -453,10 +453,10 @@ lookup_private_key(struct GNUNET_CRYPTO_ShortHashCode *zone)
453 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 453 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
454 "Zonefile directory is %s\n", keydir); 454 "Zonefile directory is %s\n", keydir);
455 455
456 GNUNET_CRYPTO_short_hash_to_enc (zone, &zonename); 456 GNUNET_CRYPTO_short_hash_to_enc (short_zone, &zonename);
457 457
458 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 458 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
459 "Zonefile is %s.zkey\n", &zonename); 459 "Zonefile for shorten is %s.zkey\n", &zonename);
460 460
461 GNUNET_asprintf(&location, "%s%s%s.zkey", keydir, 461 GNUNET_asprintf(&location, "%s%s%s.zkey", keydir,
462 DIR_SEPARATOR_STR, &zonename); 462 DIR_SEPARATOR_STR, &zonename);
@@ -513,7 +513,7 @@ send_shorten_response(void* cls, const char* name)
513 513
514 GNUNET_free(rmsg); 514 GNUNET_free(rmsg);
515 GNUNET_free_non_null(csh->name); 515 GNUNET_free_non_null(csh->name);
516 GNUNET_free_non_null(csh->zone_key); 516 GNUNET_free_non_null(csh->shorten_key);
517 GNUNET_free(csh); 517 GNUNET_free(csh);
518 518
519} 519}
@@ -561,7 +561,7 @@ static void handle_shorten(void *cls,
561 csh = GNUNET_malloc(sizeof(struct ClientShortenHandle)); 561 csh = GNUNET_malloc(sizeof(struct ClientShortenHandle));
562 csh->client = client; 562 csh->client = client;
563 csh->unique_id = sh_msg->id; 563 csh->unique_id = sh_msg->id;
564 csh->zone_key = NULL; 564 csh->shorten_key = NULL;
565 565
566 GNUNET_STRINGS_utf8_tolower((char*)&sh_msg[1], &nameptr); 566 GNUNET_STRINGS_utf8_tolower((char*)&sh_msg[1], &nameptr);
567 567
@@ -600,12 +600,12 @@ static void handle_shorten(void *cls,
600 /* Start shortening */ 600 /* Start shortening */
601 if (GNUNET_YES == auto_import_pkey) 601 if (GNUNET_YES == auto_import_pkey)
602 { 602 {
603 if (1 == ntohl(sh_msg->use_default_zone)) 603 if (0 == ntohl(sh_msg->use_shorten_zone))
604 key = zone_key; 604 key = NULL;
605 else 605 else
606 { 606 {
607 key = lookup_private_key(&sh_msg->zone); 607 key = lookup_shorten_key(&sh_msg->shorten_zone);
608 csh->zone_key = key; 608 csh->shorten_key = key;
609 } 609 }
610 gns_resolver_shorten_name(zone, zone, name, key, 610 gns_resolver_shorten_name(zone, zone, name, key,
611 &send_shorten_response, csh); 611 &send_shorten_response, csh);
@@ -796,8 +796,8 @@ send_lookup_response(void* cls,
796 GNUNET_free(rmsg); 796 GNUNET_free(rmsg);
797 GNUNET_free(clh->name); 797 GNUNET_free(clh->name);
798 798
799 if (NULL != clh->zone_key) 799 if (NULL != clh->shorten_key)
800 GNUNET_free(clh->zone_key); 800 GNUNET_free(clh->shorten_key);
801 801
802 GNUNET_free(clh); 802 GNUNET_free(clh);
803 803
@@ -855,7 +855,7 @@ handle_lookup(void *cls,
855 strcpy(clh->name, name); 855 strcpy(clh->name, name);
856 clh->unique_id = sh_msg->id; 856 clh->unique_id = sh_msg->id;
857 clh->type = ntohl(sh_msg->type); 857 clh->type = ntohl(sh_msg->type);
858 clh->zone_key = NULL; 858 clh->shorten_key = NULL;
859 859
860 if (strlen (name) > MAX_DNS_NAME_LENGTH) { 860 if (strlen (name) > MAX_DNS_NAME_LENGTH) {
861 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, 861 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
@@ -872,12 +872,12 @@ handle_lookup(void *cls,
872 872
873 if (GNUNET_YES == auto_import_pkey) 873 if (GNUNET_YES == auto_import_pkey)
874 { 874 {
875 if (1 == ntohl(sh_msg->use_default_zone)) 875 if (1 == ntohl(sh_msg->use_shorten_zone))
876 key = zone_key; 876 key = zone_key;
877 else 877 else
878 { 878 {
879 key = lookup_private_key(&zone); 879 key = lookup_shorten_key(&sh_msg->shorten_zone);
880 clh->zone_key = key; 880 clh->shorten_key = key;
881 } 881 }
882 882
883 gns_resolver_lookup_record(zone, zone, clh->type, name, 883 gns_resolver_lookup_record(zone, zone, clh->type, name,