diff options
author | Martin Schanzenbach <mschanzenbach@posteo.de> | 2012-06-13 17:36:47 +0000 |
---|---|---|
committer | Martin Schanzenbach <mschanzenbach@posteo.de> | 2012-06-13 17:36:47 +0000 |
commit | 1f5326cd1032cbcc914c7809df1a64994eeebbe9 (patch) | |
tree | bd04389845d0b3096d98e3e97033040486108830 /src/gns/gnunet-gns-proxy.c | |
parent | a8c5598ba43fcd61a5a340f14a3bab1613adbe7c (diff) | |
download | gnunet-1f5326cd1032cbcc914c7809df1a64994eeebbe9.tar.gz gnunet-1f5326cd1032cbcc914c7809df1a64994eeebbe9.zip |
- big shorten algorithm rewrite
- API change for lookup
- tests fixed
- introduces 3 zone system: root, private and shortened
Diffstat (limited to 'src/gns/gnunet-gns-proxy.c')
-rw-r--r-- | src/gns/gnunet-gns-proxy.c | 85 |
1 files changed, 24 insertions, 61 deletions
diff --git a/src/gns/gnunet-gns-proxy.c b/src/gns/gnunet-gns-proxy.c index 4effc0f04..a2c7d181e 100644 --- a/src/gns/gnunet-gns-proxy.c +++ b/src/gns/gnunet-gns-proxy.c | |||
@@ -292,17 +292,14 @@ static regex_t re_dotplus; | |||
292 | /* The users local GNS zone hash */ | 292 | /* The users local GNS zone hash */ |
293 | static struct GNUNET_CRYPTO_ShortHashCode local_gns_zone; | 293 | static struct GNUNET_CRYPTO_ShortHashCode local_gns_zone; |
294 | 294 | ||
295 | /* The users local shorten zone hash */ | ||
296 | static struct GNUNET_CRYPTO_ShortHashCode local_shorten_zone; | ||
297 | |||
298 | /* The CA for SSL certificate generation */ | 295 | /* The CA for SSL certificate generation */ |
299 | static struct ProxyCA proxy_ca; | 296 | static struct ProxyCA proxy_ca; |
300 | 297 | ||
301 | /* UNIX domain socket for mhd */ | 298 | /* UNIX domain socket for mhd */ |
302 | struct GNUNET_NETWORK_Handle *mhd_unix_socket; | 299 | struct GNUNET_NETWORK_Handle *mhd_unix_socket; |
303 | 300 | ||
304 | /* Shorten names? */ | 301 | /* Shorten zone private key */ |
305 | int use_shorten; | 302 | struct GNUNET_CRYPTO_RsaPrivateKey *shorten_zonekey; |
306 | 303 | ||
307 | /** | 304 | /** |
308 | * Checks if name is in tld | 305 | * Checks if name is in tld |
@@ -1110,9 +1107,9 @@ process_get_authority (void *cls, | |||
1110 | GNUNET_GNS_lookup_zone (gns_handle, | 1107 | GNUNET_GNS_lookup_zone (gns_handle, |
1111 | ctask->host, | 1108 | ctask->host, |
1112 | &local_gns_zone, | 1109 | &local_gns_zone, |
1113 | &local_shorten_zone, | ||
1114 | GNUNET_GNS_RECORD_LEHO, | 1110 | GNUNET_GNS_RECORD_LEHO, |
1115 | GNUNET_YES, //Only cached for performance | 1111 | GNUNET_YES, //Only cached for performance |
1112 | shorten_zonekey, | ||
1116 | &process_leho_lookup, | 1113 | &process_leho_lookup, |
1117 | ctask); | 1114 | ctask); |
1118 | } | 1115 | } |
@@ -2366,58 +2363,6 @@ load_local_zone_key (const struct GNUNET_CONFIGURATION_Handle *cfg) | |||
2366 | } | 2363 | } |
2367 | 2364 | ||
2368 | /** | 2365 | /** |
2369 | * Loads the users local shorten zone key | ||
2370 | * | ||
2371 | * @return GNUNET_YES on success | ||
2372 | */ | ||
2373 | static int | ||
2374 | load_local_shorten_key (const struct GNUNET_CONFIGURATION_Handle *cfg) | ||
2375 | { | ||
2376 | char *keyfile; | ||
2377 | struct GNUNET_CRYPTO_RsaPrivateKey *key = NULL; | ||
2378 | struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded pkey; | ||
2379 | struct GNUNET_CRYPTO_ShortHashCode *zone = NULL; | ||
2380 | struct GNUNET_CRYPTO_ShortHashAsciiEncoded zonename; | ||
2381 | |||
2382 | if (GNUNET_NO == GNUNET_CONFIGURATION_get_value_yesno (cfg, "gns", | ||
2383 | "AUTO_IMPORT_PKEY")) | ||
2384 | { | ||
2385 | return GNUNET_NO; | ||
2386 | } | ||
2387 | |||
2388 | if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_filename (cfg, "gns", | ||
2389 | "AUTO_IMPORT_ZONEKEY", | ||
2390 | &keyfile)) | ||
2391 | { | ||
2392 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
2393 | "Unable to load shorten key config value! (not fatal)\n"); | ||
2394 | return GNUNET_NO; | ||
2395 | } | ||
2396 | |||
2397 | if (GNUNET_NO == GNUNET_DISK_file_test (keyfile)) | ||
2398 | { | ||
2399 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
2400 | "Unable to load shorten key %s! (not fatal)\n", keyfile); | ||
2401 | GNUNET_free(keyfile); | ||
2402 | return GNUNET_NO; | ||
2403 | } | ||
2404 | |||
2405 | key = GNUNET_CRYPTO_rsa_key_create_from_file (keyfile); | ||
2406 | GNUNET_CRYPTO_rsa_key_get_public (key, &pkey); | ||
2407 | GNUNET_CRYPTO_short_hash(&pkey, | ||
2408 | sizeof(struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), | ||
2409 | &local_shorten_zone); | ||
2410 | zone = &local_gns_zone; | ||
2411 | GNUNET_CRYPTO_short_hash_to_enc (zone, &zonename); | ||
2412 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
2413 | "Using shorten zone: %s!\n", &zonename); | ||
2414 | GNUNET_CRYPTO_rsa_key_free(key); | ||
2415 | GNUNET_free(keyfile); | ||
2416 | |||
2417 | return GNUNET_YES; | ||
2418 | } | ||
2419 | |||
2420 | /** | ||
2421 | * Main function that will be run | 2366 | * Main function that will be run |
2422 | * | 2367 | * |
2423 | * @param cls closure | 2368 | * @param cls closure |
@@ -2436,6 +2381,7 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
2436 | char* proxy_sockfile; | 2381 | char* proxy_sockfile; |
2437 | char* cafile_cfg = NULL; | 2382 | char* cafile_cfg = NULL; |
2438 | char* cafile; | 2383 | char* cafile; |
2384 | char* shorten_keyfile; | ||
2439 | 2385 | ||
2440 | curl_multi = NULL; | 2386 | curl_multi = NULL; |
2441 | 2387 | ||
@@ -2471,7 +2417,26 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
2471 | 2417 | ||
2472 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 2418 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
2473 | "Loading Template\n"); | 2419 | "Loading Template\n"); |
2474 | 2420 | ||
2421 | if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_filename (cfg, "gns-proxy", | ||
2422 | "PROXY_CACERT", | ||
2423 | &shorten_keyfile)) | ||
2424 | { | ||
2425 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
2426 | "Unable to load shorten zonekey config value!\n"); | ||
2427 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
2428 | "No shorten key provided!\n"); | ||
2429 | return; | ||
2430 | } | ||
2431 | else | ||
2432 | { | ||
2433 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
2434 | "Loading shorten zonekey %s!\n", | ||
2435 | shorten_keyfile); | ||
2436 | shorten_zonekey = GNUNET_CRYPTO_rsa_key_create_from_file (shorten_keyfile); | ||
2437 | GNUNET_free (shorten_keyfile); | ||
2438 | } | ||
2439 | |||
2475 | compile_regex (&re_dotplus, (char*) RE_A_HREF); | 2440 | compile_regex (&re_dotplus, (char*) RE_A_HREF); |
2476 | 2441 | ||
2477 | gns_handle = GNUNET_GNS_connect (cfg); | 2442 | gns_handle = GNUNET_GNS_connect (cfg); |
@@ -2483,8 +2448,6 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
2483 | return; | 2448 | return; |
2484 | } | 2449 | } |
2485 | 2450 | ||
2486 | use_shorten = load_local_shorten_key (cfg); | ||
2487 | |||
2488 | if (NULL == gns_handle) | 2451 | if (NULL == gns_handle) |
2489 | { | 2452 | { |
2490 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 2453 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |