aboutsummaryrefslogtreecommitdiff
path: root/src/gns/gnunet-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-gns.c
parentc4ea2585c71c4d619f3f24f32c277a5fa6b5772a (diff)
downloadgnunet-8338aebe1b4be9e8cb27be564851a14a9ebb6b14.tar.gz
gnunet-8338aebe1b4be9e8cb27be564851a14a9ebb6b14.zip
new API for shorten key
Diffstat (limited to 'src/gns/gnunet-gns.c')
-rw-r--r--src/gns/gnunet-gns.c43
1 files changed, 38 insertions, 5 deletions
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)