diff options
author | Martin Schanzenbach <mschanzenbach@posteo.de> | 2012-06-11 14:59:04 +0000 |
---|---|---|
committer | Martin Schanzenbach <mschanzenbach@posteo.de> | 2012-06-11 14:59:04 +0000 |
commit | 8338aebe1b4be9e8cb27be564851a14a9ebb6b14 (patch) | |
tree | d9b37c09a7bf1226d899671765548d5fe0bad145 /src/gns | |
parent | c4ea2585c71c4d619f3f24f32c277a5fa6b5772a (diff) | |
download | gnunet-8338aebe1b4be9e8cb27be564851a14a9ebb6b14.tar.gz gnunet-8338aebe1b4be9e8cb27be564851a14a9ebb6b14.zip |
new API for shorten key
Diffstat (limited to 'src/gns')
-rw-r--r-- | src/gns/gns.conf.in | 1 | ||||
-rw-r--r-- | src/gns/gns.h | 20 | ||||
-rw-r--r-- | src/gns/gns_api.c | 40 | ||||
-rw-r--r-- | src/gns/gnunet-gns-proxy.c | 61 | ||||
-rw-r--r-- | src/gns/gnunet-gns.c | 43 | ||||
-rw-r--r-- | src/gns/gnunet-service-gns.c | 42 | ||||
-rw-r--r-- | src/gns/test_gns_pseu_shorten.c | 10 |
7 files changed, 184 insertions, 33 deletions
diff --git a/src/gns/gns.conf.in b/src/gns/gns.conf.in index 6a44ae40c..2fe10ca34 100644 --- a/src/gns/gns.conf.in +++ b/src/gns/gns.conf.in | |||
@@ -8,6 +8,7 @@ UNIXPATH = /tmp/gnunet-service-gns.sock | |||
8 | ZONEKEY = $SERVICEHOME/gns/zonekey.zkey | 8 | ZONEKEY = $SERVICEHOME/gns/zonekey.zkey |
9 | HIJACK_DNS = NO | 9 | HIJACK_DNS = NO |
10 | AUTO_IMPORT_PKEY = YES | 10 | AUTO_IMPORT_PKEY = YES |
11 | AUTO_IMPORT_ZONEKEY = $SERVICEHOME/gns/shorten_zonekey.zkey | ||
11 | AUTO_IMPORT_CONFIRMATION_REQ = NO | 12 | AUTO_IMPORT_CONFIRMATION_REQ = NO |
12 | MAX_PARALLEL_BACKGROUND_QUERIES = 25 | 13 | MAX_PARALLEL_BACKGROUND_QUERIES = 25 |
13 | DEFAULT_LOOKUP_TIMEOUT = 10 | 14 | DEFAULT_LOOKUP_TIMEOUT = 10 |
diff --git a/src/gns/gns.h b/src/gns/gns.h index 408b68606..80ebb1288 100644 --- a/src/gns/gns.h +++ b/src/gns/gns.h | |||
@@ -63,6 +63,16 @@ struct GNUNET_GNS_ClientLookupMessage | |||
63 | struct GNUNET_CRYPTO_ShortHashCode zone; | 63 | struct GNUNET_CRYPTO_ShortHashCode zone; |
64 | 64 | ||
65 | /** | 65 | /** |
66 | * Should we use a shorten zone? | ||
67 | */ | ||
68 | uint32_t use_shorten_zone GNUNET_PACKED; | ||
69 | |||
70 | /** | ||
71 | * If use_shorten_zone is set use this zone for shortening | ||
72 | */ | ||
73 | struct GNUNET_CRYPTO_ShortHashCode shorten_zone; | ||
74 | |||
75 | /** | ||
66 | * the type of record to look up | 76 | * the type of record to look up |
67 | */ | 77 | */ |
68 | enum GNUNET_GNS_RecordType type; | 78 | enum GNUNET_GNS_RecordType type; |
@@ -120,7 +130,17 @@ struct GNUNET_GNS_ClientShortenMessage | |||
120 | * If use_default_zone is empty this zone is used for lookup | 130 | * If use_default_zone is empty this zone is used for lookup |
121 | */ | 131 | */ |
122 | struct GNUNET_CRYPTO_ShortHashCode zone; | 132 | struct GNUNET_CRYPTO_ShortHashCode zone; |
133 | |||
134 | /** | ||
135 | * Should we use a shorten zone? | ||
136 | */ | ||
137 | uint32_t use_shorten_zone GNUNET_PACKED; | ||
123 | 138 | ||
139 | /** | ||
140 | * If use_shorten_zone is set use this zone for shortening | ||
141 | */ | ||
142 | struct GNUNET_CRYPTO_ShortHashCode shorten_zone; | ||
143 | |||
124 | /* Followed by the name to shorten up */ | 144 | /* Followed by the name to shorten up */ |
125 | }; | 145 | }; |
126 | 146 | ||
diff --git a/src/gns/gns_api.c b/src/gns/gns_api.c index a92280f25..2cdb58a31 100644 --- a/src/gns/gns_api.c +++ b/src/gns/gns_api.c | |||
@@ -640,6 +640,7 @@ get_request_id (struct GNUNET_GNS_Handle *h) | |||
640 | * @param handle handle to the GNS service | 640 | * @param handle handle to the GNS service |
641 | * @param name the name to look up | 641 | * @param name the name to look up |
642 | * @param zone the zone to start the resolution in | 642 | * @param zone the zone to start the resolution in |
643 | * @param shorten_zone the zone where to shorten names into | ||
643 | * @param type the record type to look up | 644 | * @param type the record type to look up |
644 | * @param proc processor to call on result | 645 | * @param proc processor to call on result |
645 | * @param proc_cls closure for processor | 646 | * @param proc_cls closure for processor |
@@ -649,6 +650,7 @@ struct GNUNET_GNS_QueueEntry * | |||
649 | GNUNET_GNS_lookup_zone (struct GNUNET_GNS_Handle *handle, | 650 | GNUNET_GNS_lookup_zone (struct GNUNET_GNS_Handle *handle, |
650 | const char * name, | 651 | const char * name, |
651 | struct GNUNET_CRYPTO_ShortHashCode *zone, | 652 | struct GNUNET_CRYPTO_ShortHashCode *zone, |
653 | struct GNUNET_CRYPTO_ShortHashCode *shorten_zone, | ||
652 | enum GNUNET_GNS_RecordType type, | 654 | enum GNUNET_GNS_RecordType type, |
653 | GNUNET_GNS_LookupResultProcessor proc, | 655 | GNUNET_GNS_LookupResultProcessor proc, |
654 | void *proc_cls) | 656 | void *proc_cls) |
@@ -695,7 +697,20 @@ GNUNET_GNS_lookup_zone (struct GNUNET_GNS_Handle *handle, | |||
695 | lookup_msg->use_default_zone = htonl(1); | 697 | lookup_msg->use_default_zone = htonl(1); |
696 | memset(&lookup_msg->zone, 0, sizeof(struct GNUNET_CRYPTO_ShortHashCode)); | 698 | memset(&lookup_msg->zone, 0, sizeof(struct GNUNET_CRYPTO_ShortHashCode)); |
697 | } | 699 | } |
698 | 700 | ||
701 | if (NULL != shorten_zone) | ||
702 | { | ||
703 | lookup_msg->use_shorten_zone = htonl(1); | ||
704 | memcpy(&lookup_msg->shorten_zone, shorten_zone, | ||
705 | sizeof(struct GNUNET_CRYPTO_ShortHashCode)); | ||
706 | } | ||
707 | else | ||
708 | { | ||
709 | lookup_msg->use_shorten_zone = htonl(0); | ||
710 | memset(&lookup_msg->shorten_zone, 0, | ||
711 | sizeof(struct GNUNET_CRYPTO_ShortHashCode)); | ||
712 | } | ||
713 | |||
699 | lookup_msg->type = htonl(type); | 714 | lookup_msg->type = htonl(type); |
700 | 715 | ||
701 | memcpy(&lookup_msg[1], name, strlen(name)); | 716 | memcpy(&lookup_msg[1], name, strlen(name)); |
@@ -724,7 +739,9 @@ GNUNET_GNS_lookup (struct GNUNET_GNS_Handle *handle, | |||
724 | GNUNET_GNS_LookupResultProcessor proc, | 739 | GNUNET_GNS_LookupResultProcessor proc, |
725 | void *proc_cls) | 740 | void *proc_cls) |
726 | { | 741 | { |
727 | return GNUNET_GNS_lookup_zone (handle, name, NULL, type, proc, proc_cls); | 742 | return GNUNET_GNS_lookup_zone (handle, name, |
743 | NULL, NULL, | ||
744 | type, proc, proc_cls); | ||
728 | } | 745 | } |
729 | 746 | ||
730 | /** | 747 | /** |
@@ -733,6 +750,7 @@ GNUNET_GNS_lookup (struct GNUNET_GNS_Handle *handle, | |||
733 | * @param handle handle to the GNS service | 750 | * @param handle handle to the GNS service |
734 | * @param name the name to look up | 751 | * @param name the name to look up |
735 | * @param zone the zone to start the resolution in | 752 | * @param zone the zone to start the resolution in |
753 | * @param shorten_zone the zone where to shorten names into | ||
736 | * @param proc function to call on result | 754 | * @param proc function to call on result |
737 | * @param proc_cls closure for processor | 755 | * @param proc_cls closure for processor |
738 | * @return handle to the operation | 756 | * @return handle to the operation |
@@ -741,6 +759,7 @@ struct GNUNET_GNS_QueueEntry * | |||
741 | GNUNET_GNS_shorten_zone (struct GNUNET_GNS_Handle *handle, | 759 | GNUNET_GNS_shorten_zone (struct GNUNET_GNS_Handle *handle, |
742 | const char * name, | 760 | const char * name, |
743 | struct GNUNET_CRYPTO_ShortHashCode *zone, | 761 | struct GNUNET_CRYPTO_ShortHashCode *zone, |
762 | struct GNUNET_CRYPTO_ShortHashCode *shorten_zone, | ||
744 | GNUNET_GNS_ShortenResultProcessor proc, | 763 | GNUNET_GNS_ShortenResultProcessor proc, |
745 | void *proc_cls) | 764 | void *proc_cls) |
746 | { | 765 | { |
@@ -787,7 +806,20 @@ GNUNET_GNS_shorten_zone (struct GNUNET_GNS_Handle *handle, | |||
787 | shorten_msg->use_default_zone = htonl(1); | 806 | shorten_msg->use_default_zone = htonl(1); |
788 | memset(&shorten_msg->zone, 0, sizeof(struct GNUNET_CRYPTO_ShortHashCode)); | 807 | memset(&shorten_msg->zone, 0, sizeof(struct GNUNET_CRYPTO_ShortHashCode)); |
789 | } | 808 | } |
790 | 809 | ||
810 | if (NULL != shorten_zone) | ||
811 | { | ||
812 | shorten_msg->use_shorten_zone = htonl(1); | ||
813 | memcpy(&shorten_msg->shorten_zone, shorten_zone, | ||
814 | sizeof(struct GNUNET_CRYPTO_ShortHashCode)); | ||
815 | } | ||
816 | else | ||
817 | { | ||
818 | shorten_msg->use_shorten_zone = htonl(0); | ||
819 | memset(&shorten_msg->shorten_zone, 0, | ||
820 | sizeof(struct GNUNET_CRYPTO_ShortHashCode)); | ||
821 | } | ||
822 | |||
791 | memcpy(&shorten_msg[1], name, strlen(name)); | 823 | memcpy(&shorten_msg[1], name, strlen(name)); |
792 | 824 | ||
793 | GNUNET_CONTAINER_DLL_insert_tail (handle->pending_head, handle->pending_tail, | 825 | GNUNET_CONTAINER_DLL_insert_tail (handle->pending_head, handle->pending_tail, |
@@ -812,7 +844,7 @@ GNUNET_GNS_shorten (struct GNUNET_GNS_Handle *handle, | |||
812 | GNUNET_GNS_ShortenResultProcessor proc, | 844 | GNUNET_GNS_ShortenResultProcessor proc, |
813 | void *proc_cls) | 845 | void *proc_cls) |
814 | { | 846 | { |
815 | return GNUNET_GNS_shorten_zone (handle, name, NULL, proc, proc_cls); | 847 | return GNUNET_GNS_shorten_zone (handle, name, NULL, NULL, proc, proc_cls); |
816 | } | 848 | } |
817 | /** | 849 | /** |
818 | * Perform an authority lookup for a given name. | 850 | * Perform an authority lookup for a given name. |
diff --git a/src/gns/gnunet-gns-proxy.c b/src/gns/gnunet-gns-proxy.c index 367eb02ec..eff7fbfbd 100644 --- a/src/gns/gnunet-gns-proxy.c +++ b/src/gns/gnunet-gns-proxy.c | |||
@@ -269,12 +269,18 @@ static regex_t re_dotplus; | |||
269 | /* The users local GNS zone hash */ | 269 | /* The users local GNS zone hash */ |
270 | static struct GNUNET_CRYPTO_ShortHashCode local_gns_zone; | 270 | static struct GNUNET_CRYPTO_ShortHashCode local_gns_zone; |
271 | 271 | ||
272 | /* The users local shorten zone hash */ | ||
273 | static struct GNUNET_CRYPTO_ShortHashCode local_shorten_zone; | ||
274 | |||
272 | /* The CA for SSL certificate generation */ | 275 | /* The CA for SSL certificate generation */ |
273 | static struct ProxyCA proxy_ca; | 276 | static struct ProxyCA proxy_ca; |
274 | 277 | ||
275 | /* UNIX domain socket for mhd */ | 278 | /* UNIX domain socket for mhd */ |
276 | struct GNUNET_NETWORK_Handle *mhd_unix_socket; | 279 | struct GNUNET_NETWORK_Handle *mhd_unix_socket; |
277 | 280 | ||
281 | /* Shorten names? */ | ||
282 | int use_shorten; | ||
283 | |||
278 | /** | 284 | /** |
279 | * Checks if name is in tld | 285 | * Checks if name is in tld |
280 | * | 286 | * |
@@ -1059,6 +1065,7 @@ process_get_authority (void *cls, | |||
1059 | GNUNET_GNS_lookup_zone (gns_handle, | 1065 | GNUNET_GNS_lookup_zone (gns_handle, |
1060 | ctask->host, | 1066 | ctask->host, |
1061 | &local_gns_zone, | 1067 | &local_gns_zone, |
1068 | &local_shorten_zone, | ||
1062 | GNUNET_GNS_RECORD_LEHO, | 1069 | GNUNET_GNS_RECORD_LEHO, |
1063 | &process_leho_lookup, | 1070 | &process_leho_lookup, |
1064 | ctask); | 1071 | ctask); |
@@ -2254,7 +2261,57 @@ load_local_zone_key (const struct GNUNET_CONFIGURATION_Handle *cfg) | |||
2254 | return GNUNET_YES; | 2261 | return GNUNET_YES; |
2255 | } | 2262 | } |
2256 | 2263 | ||
2264 | /** | ||
2265 | * Loads the users local shorten zone key | ||
2266 | * | ||
2267 | * @return GNUNET_YES on success | ||
2268 | */ | ||
2269 | static int | ||
2270 | load_local_shorten_key (const struct GNUNET_CONFIGURATION_Handle *cfg) | ||
2271 | { | ||
2272 | char *keyfile; | ||
2273 | struct GNUNET_CRYPTO_RsaPrivateKey *key = NULL; | ||
2274 | struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded pkey; | ||
2275 | struct GNUNET_CRYPTO_ShortHashCode *zone = NULL; | ||
2276 | struct GNUNET_CRYPTO_ShortHashAsciiEncoded zonename; | ||
2277 | |||
2278 | if (GNUNET_NO == GNUNET_CONFIGURATION_get_value_yesno (cfg, "gns", | ||
2279 | "AUTO_IMPORT_PKEY")) | ||
2280 | { | ||
2281 | return GNUNET_NO; | ||
2282 | } | ||
2257 | 2283 | ||
2284 | if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_filename (cfg, "gns", | ||
2285 | "AUTO_IMPORT_ZONEKEY", | ||
2286 | &keyfile)) | ||
2287 | { | ||
2288 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
2289 | "Unable to load zone key config value!\n"); | ||
2290 | return GNUNET_NO; | ||
2291 | } | ||
2292 | |||
2293 | if (GNUNET_NO == GNUNET_DISK_file_test (keyfile)) | ||
2294 | { | ||
2295 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
2296 | "Unable to load zone key!\n"); | ||
2297 | GNUNET_free(keyfile); | ||
2298 | return GNUNET_NO; | ||
2299 | } | ||
2300 | |||
2301 | key = GNUNET_CRYPTO_rsa_key_create_from_file (keyfile); | ||
2302 | GNUNET_CRYPTO_rsa_key_get_public (key, &pkey); | ||
2303 | GNUNET_CRYPTO_short_hash(&pkey, | ||
2304 | sizeof(struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), | ||
2305 | &local_shorten_zone); | ||
2306 | zone = &local_gns_zone; | ||
2307 | GNUNET_CRYPTO_short_hash_to_enc (zone, &zonename); | ||
2308 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
2309 | "Using shorten zone: %s!\n", &zonename); | ||
2310 | GNUNET_CRYPTO_rsa_key_free(key); | ||
2311 | GNUNET_free(keyfile); | ||
2312 | |||
2313 | return GNUNET_YES; | ||
2314 | } | ||
2258 | 2315 | ||
2259 | /** | 2316 | /** |
2260 | * Main function that will be run | 2317 | * Main function that will be run |
@@ -2299,6 +2356,8 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
2299 | return; | 2356 | return; |
2300 | } | 2357 | } |
2301 | 2358 | ||
2359 | use_shorten = load_local_shorten_key (cfg); | ||
2360 | |||
2302 | if (NULL == gns_handle) | 2361 | if (NULL == gns_handle) |
2303 | { | 2362 | { |
2304 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 2363 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
@@ -2364,7 +2423,7 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
2364 | &proxy_sockfile)) | 2423 | &proxy_sockfile)) |
2365 | { | 2424 | { |
2366 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 2425 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
2367 | "Specify PROXY_UNIX_SOCK in gns-proxy config section!\n"); | 2426 | "Specify PROXY_UNIXPATH in gns-proxy config section!\n"); |
2368 | return; | 2427 | return; |
2369 | } | 2428 | } |
2370 | 2429 | ||
diff --git a/src/gns/gnunet-gns.c b/src/gns/gnunet-gns.c index 1efe74842..78fe513ec 100644 --- a/src/gns/gnunet-gns.c +++ b/src/gns/gnunet-gns.c | |||
@@ -149,6 +149,7 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
149 | struct GNUNET_CRYPTO_RsaPrivateKey *key = NULL; | 149 | struct GNUNET_CRYPTO_RsaPrivateKey *key = NULL; |
150 | struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded pkey; | 150 | struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded pkey; |
151 | struct GNUNET_CRYPTO_ShortHashCode *zone = NULL; | 151 | struct GNUNET_CRYPTO_ShortHashCode *zone = NULL; |
152 | struct GNUNET_CRYPTO_ShortHashCode *shorten_zone = NULL; | ||
152 | struct GNUNET_CRYPTO_ShortHashCode user_zone; | 153 | struct GNUNET_CRYPTO_ShortHashCode user_zone; |
153 | struct GNUNET_CRYPTO_ShortHashAsciiEncoded zonename; | 154 | struct GNUNET_CRYPTO_ShortHashAsciiEncoded zonename; |
154 | 155 | ||
@@ -178,7 +179,35 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
178 | } | 179 | } |
179 | GNUNET_free(keyfile); | 180 | GNUNET_free(keyfile); |
180 | } | 181 | } |
181 | 182 | ||
183 | if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_filename (cfg, "gns", | ||
184 | "AUTO_IMPORT_ZONEKEY", | ||
185 | &keyfile)) | ||
186 | { | ||
187 | if (!raw) | ||
188 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | ||
189 | "No private key for shorten zone found!\n"); | ||
190 | shorten_zone = NULL; | ||
191 | } | ||
192 | else | ||
193 | { | ||
194 | if (GNUNET_YES == GNUNET_DISK_file_test (keyfile)) | ||
195 | { | ||
196 | key = GNUNET_CRYPTO_rsa_key_create_from_file (keyfile); | ||
197 | GNUNET_CRYPTO_rsa_key_get_public (key, &pkey); | ||
198 | GNUNET_CRYPTO_short_hash(&pkey, | ||
199 | sizeof(struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), | ||
200 | &user_zone); | ||
201 | shorten_zone = &user_zone; | ||
202 | GNUNET_CRYPTO_short_hash_to_enc (shorten_zone, &zonename); | ||
203 | if (!raw) | ||
204 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
205 | "Using zone: %s!\n", &zonename); | ||
206 | GNUNET_CRYPTO_rsa_key_free(key); | ||
207 | } | ||
208 | GNUNET_free(keyfile); | ||
209 | } | ||
210 | |||
182 | gns = GNUNET_GNS_connect (cfg); | 211 | gns = GNUNET_GNS_connect (cfg); |
183 | if (lookup_type != NULL) | 212 | if (lookup_type != NULL) |
184 | rtype = GNUNET_NAMESTORE_typename_to_number(lookup_type); | 213 | rtype = GNUNET_NAMESTORE_typename_to_number(lookup_type); |
@@ -195,16 +224,20 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
195 | if (shorten_name != NULL) | 224 | if (shorten_name != NULL) |
196 | { | 225 | { |
197 | /** shorten name */ | 226 | /** shorten name */ |
198 | GNUNET_GNS_shorten_zone (gns, shorten_name, zone, &process_shorten_result, | 227 | GNUNET_GNS_shorten_zone (gns, shorten_name, |
199 | shorten_name); | 228 | zone, shorten_zone, |
229 | &process_shorten_result, | ||
230 | shorten_name); | ||
200 | } | 231 | } |
201 | 232 | ||
202 | if (lookup_name != NULL) | 233 | if (lookup_name != NULL) |
203 | { | 234 | { |
204 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 235 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
205 | "Lookup\n"); | 236 | "Lookup\n"); |
206 | GNUNET_GNS_lookup_zone (gns, lookup_name, zone, rtype, | 237 | GNUNET_GNS_lookup_zone (gns, lookup_name, |
207 | &process_lookup_result, lookup_name); | 238 | zone, shorten_zone, |
239 | rtype, | ||
240 | &process_lookup_result, lookup_name); | ||
208 | } | 241 | } |
209 | 242 | ||
210 | if (auth_name != NULL) | 243 | if (auth_name != NULL) |
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 | */ |
433 | struct GNUNET_CRYPTO_RsaPrivateKey* | 433 | struct GNUNET_CRYPTO_RsaPrivateKey* |
434 | lookup_private_key(struct GNUNET_CRYPTO_ShortHashCode *zone) | 434 | lookup_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, |
diff --git a/src/gns/test_gns_pseu_shorten.c b/src/gns/test_gns_pseu_shorten.c index 3c2d20420..c6fd28884 100644 --- a/src/gns/test_gns_pseu_shorten.c +++ b/src/gns/test_gns_pseu_shorten.c | |||
@@ -90,6 +90,7 @@ struct GNUNET_CRYPTO_RsaPrivateKey *bob_key; | |||
90 | struct GNUNET_CRYPTO_RsaPrivateKey *our_key; | 90 | struct GNUNET_CRYPTO_RsaPrivateKey *our_key; |
91 | struct GNUNET_CRYPTO_ShortHashCode alice_hash; | 91 | struct GNUNET_CRYPTO_ShortHashCode alice_hash; |
92 | struct GNUNET_CRYPTO_ShortHashCode bob_hash; | 92 | struct GNUNET_CRYPTO_ShortHashCode bob_hash; |
93 | struct GNUNET_CRYPTO_ShortHashCode our_zone; | ||
93 | 94 | ||
94 | /** | 95 | /** |
95 | * Check whether peers successfully shut down. | 96 | * Check whether peers successfully shut down. |
@@ -161,7 +162,9 @@ process_shorten_result(void* cls, const char* sname) | |||
161 | static void | 162 | static void |
162 | do_shorten(void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 163 | do_shorten(void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
163 | { | 164 | { |
164 | GNUNET_GNS_shorten(gns_handle, TEST_DOMAIN, &process_shorten_result, | 165 | GNUNET_GNS_shorten_zone (gns_handle, TEST_DOMAIN, |
166 | &our_zone, &our_zone, | ||
167 | &process_shorten_result, | ||
165 | TEST_DOMAIN); | 168 | TEST_DOMAIN); |
166 | } | 169 | } |
167 | 170 | ||
@@ -231,7 +234,9 @@ commence_testing (void *cls, int success) | |||
231 | "Failed to connect to GNS!\n"); | 234 | "Failed to connect to GNS!\n"); |
232 | } | 235 | } |
233 | 236 | ||
234 | GNUNET_GNS_lookup(gns_handle, TEST_DOMAIN, GNUNET_GNS_RECORD_TYPE_A, | 237 | GNUNET_GNS_lookup_zone (gns_handle, TEST_DOMAIN, |
238 | &our_zone, &our_zone, | ||
239 | GNUNET_GNS_RECORD_TYPE_A, | ||
235 | &on_lookup_result, TEST_DOMAIN); | 240 | &on_lookup_result, TEST_DOMAIN); |
236 | } | 241 | } |
237 | 242 | ||
@@ -545,6 +550,7 @@ do_lookup(void *cls, const struct GNUNET_PeerIdentity *id, | |||
545 | GNUNET_CRYPTO_rsa_key_get_public (alice_key, &alice_pkey); | 550 | GNUNET_CRYPTO_rsa_key_get_public (alice_key, &alice_pkey); |
546 | GNUNET_CRYPTO_short_hash(&bob_pkey, sizeof(bob_pkey), &bob_hash); | 551 | GNUNET_CRYPTO_short_hash(&bob_pkey, sizeof(bob_pkey), &bob_hash); |
547 | GNUNET_CRYPTO_short_hash(&alice_pkey, sizeof(alice_pkey), &alice_hash); | 552 | GNUNET_CRYPTO_short_hash(&alice_pkey, sizeof(alice_pkey), &alice_hash); |
553 | GNUNET_CRYPTO_short_hash(&our_pkey, sizeof(our_pkey), &our_zone); | ||
548 | 554 | ||
549 | struct GNUNET_NAMESTORE_RecordData rd; | 555 | struct GNUNET_NAMESTORE_RecordData rd; |
550 | rd.expiration = GNUNET_TIME_UNIT_FOREVER_ABS; | 556 | rd.expiration = GNUNET_TIME_UNIT_FOREVER_ABS; |