aboutsummaryrefslogtreecommitdiff
path: root/src/gns/gnunet-gns.c
diff options
context:
space:
mode:
authorMartin Schanzenbach <mschanzenbach@posteo.de>2012-06-13 17:36:47 +0000
committerMartin Schanzenbach <mschanzenbach@posteo.de>2012-06-13 17:36:47 +0000
commit1f5326cd1032cbcc914c7809df1a64994eeebbe9 (patch)
treebd04389845d0b3096d98e3e97033040486108830 /src/gns/gnunet-gns.c
parenta8c5598ba43fcd61a5a340f14a3bab1613adbe7c (diff)
downloadgnunet-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.c')
-rw-r--r--src/gns/gnunet-gns.c27
1 files changed, 8 insertions, 19 deletions
diff --git a/src/gns/gnunet-gns.c b/src/gns/gnunet-gns.c
index 6b0ae5dca..a1614e7dd 100644
--- a/src/gns/gnunet-gns.c
+++ b/src/gns/gnunet-gns.c
@@ -149,10 +149,9 @@ 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;
153 struct GNUNET_CRYPTO_ShortHashCode user_zone; 152 struct GNUNET_CRYPTO_ShortHashCode user_zone;
154 struct GNUNET_CRYPTO_ShortHashCode user_shorten_zone;
155 struct GNUNET_CRYPTO_ShortHashAsciiEncoded zonename; 153 struct GNUNET_CRYPTO_ShortHashAsciiEncoded zonename;
154 struct GNUNET_CRYPTO_RsaPrivateKey *shorten_key = NULL;
156 155
157 if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_filename (cfg, "gns", 156 if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_filename (cfg, "gns",
158 "ZONEKEY", &keyfile)) 157 "ZONEKEY", &keyfile))
@@ -182,29 +181,18 @@ run (void *cls, char *const *args, const char *cfgfile,
182 } 181 }
183 182
184 if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_filename (cfg, "gns", 183 if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_filename (cfg, "gns",
185 "AUTO_IMPORT_ZONEKEY", 184 "SHORTEN_ZONEKEY", &keyfile))
186 &keyfile))
187 { 185 {
188 if (!raw) 186 if (!raw)
189 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 187 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
190 "No private key for shorten zone found!\n"); 188 "No shorten key found!\n");
191 shorten_zone = NULL; 189 shorten_key = NULL;
192 } 190 }
193 else 191 else
194 { 192 {
195 if (GNUNET_YES == GNUNET_DISK_file_test (keyfile)) 193 if (GNUNET_YES == GNUNET_DISK_file_test (keyfile))
196 { 194 {
197 key = GNUNET_CRYPTO_rsa_key_create_from_file (keyfile); 195 shorten_key = GNUNET_CRYPTO_rsa_key_create_from_file (keyfile);
198 GNUNET_CRYPTO_rsa_key_get_public (key, &pkey);
199 GNUNET_CRYPTO_short_hash(&pkey,
200 sizeof(struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded),
201 &user_shorten_zone);
202 shorten_zone = &user_shorten_zone;
203 GNUNET_CRYPTO_short_hash_to_enc (shorten_zone, &zonename);
204 if (!raw)
205 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
206 "Using shorten zone: %s!\n", &zonename);
207 GNUNET_CRYPTO_rsa_key_free(key);
208 } 196 }
209 GNUNET_free(keyfile); 197 GNUNET_free(keyfile);
210 } 198 }
@@ -226,7 +214,7 @@ run (void *cls, char *const *args, const char *cfgfile,
226 { 214 {
227 /** shorten name */ 215 /** shorten name */
228 GNUNET_GNS_shorten_zone (gns, shorten_name, 216 GNUNET_GNS_shorten_zone (gns, shorten_name,
229 zone, shorten_zone, 217 zone,
230 &process_shorten_result, 218 &process_shorten_result,
231 shorten_name); 219 shorten_name);
232 } 220 }
@@ -236,9 +224,10 @@ run (void *cls, char *const *args, const char *cfgfile,
236 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 224 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
237 "Lookup\n"); 225 "Lookup\n");
238 GNUNET_GNS_lookup_zone (gns, lookup_name, 226 GNUNET_GNS_lookup_zone (gns, lookup_name,
239 zone, shorten_zone, 227 zone,
240 rtype, 228 rtype,
241 GNUNET_YES, //Use DHT 229 GNUNET_YES, //Use DHT
230 shorten_key,
242 &process_lookup_result, lookup_name); 231 &process_lookup_result, lookup_name);
243 } 232 }
244 233