diff options
author | Martin Schanzenbach <mschanzenbach@posteo.de> | 2012-06-29 14:36:19 +0000 |
---|---|---|
committer | Martin Schanzenbach <mschanzenbach@posteo.de> | 2012-06-29 14:36:19 +0000 |
commit | e6d0c3119a3348eeb539a7e52113e12a7bb37a5f (patch) | |
tree | 87d6b6489ac64fc94b801391e5d6c8151f99a1f6 /src/gns/gnunet-gns.c | |
parent | 33891883bf2fdd6430de2c5beded9aa5be151179 (diff) | |
download | gnunet-e6d0c3119a3348eeb539a7e52113e12a7bb37a5f.tar.gz gnunet-e6d0c3119a3348eeb539a7e52113e12a7bb37a5f.zip |
-fix 2447
Diffstat (limited to 'src/gns/gnunet-gns.c')
-rw-r--r-- | src/gns/gnunet-gns.c | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/src/gns/gnunet-gns.c b/src/gns/gnunet-gns.c index 069dc2121..95733618c 100644 --- a/src/gns/gnunet-gns.c +++ b/src/gns/gnunet-gns.c | |||
@@ -152,6 +152,9 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
152 | struct GNUNET_CRYPTO_ShortHashCode user_zone; | 152 | struct GNUNET_CRYPTO_ShortHashCode user_zone; |
153 | struct GNUNET_CRYPTO_ShortHashAsciiEncoded zonename; | 153 | struct GNUNET_CRYPTO_ShortHashAsciiEncoded zonename; |
154 | struct GNUNET_CRYPTO_RsaPrivateKey *shorten_key = NULL; | 154 | struct GNUNET_CRYPTO_RsaPrivateKey *shorten_key = NULL; |
155 | struct GNUNET_CRYPTO_RsaPrivateKey *private_key = NULL; | ||
156 | struct GNUNET_CRYPTO_ShortHashCode private_zone; | ||
157 | struct GNUNET_CRYPTO_ShortHashCode shorten_zone; | ||
155 | 158 | ||
156 | if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_filename (cfg, "gns", | 159 | if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_filename (cfg, "gns", |
157 | "ZONEKEY", &keyfile)) | 160 | "ZONEKEY", &keyfile)) |
@@ -193,10 +196,48 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
193 | if (GNUNET_YES == GNUNET_DISK_file_test (keyfile)) | 196 | if (GNUNET_YES == GNUNET_DISK_file_test (keyfile)) |
194 | { | 197 | { |
195 | shorten_key = GNUNET_CRYPTO_rsa_key_create_from_file (keyfile); | 198 | shorten_key = GNUNET_CRYPTO_rsa_key_create_from_file (keyfile); |
199 | GNUNET_CRYPTO_rsa_key_get_public (key, &pkey); | ||
200 | GNUNET_CRYPTO_short_hash(&pkey, | ||
201 | sizeof(struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), | ||
202 | &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 | |||
208 | } | ||
209 | GNUNET_free(keyfile); | ||
210 | } | ||
211 | |||
212 | |||
213 | if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_filename (cfg, "gns", | ||
214 | "PRIVATE_ZONEKEY", &keyfile)) | ||
215 | { | ||
216 | if (!raw) | ||
217 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | ||
218 | "No private zone key found!\n"); | ||
219 | shorten_key = NULL; | ||
220 | } | ||
221 | else | ||
222 | { | ||
223 | if (GNUNET_YES == GNUNET_DISK_file_test (keyfile)) | ||
224 | { | ||
225 | private_key = GNUNET_CRYPTO_rsa_key_create_from_file (keyfile); | ||
226 | GNUNET_CRYPTO_rsa_key_get_public (key, &pkey); | ||
227 | GNUNET_CRYPTO_short_hash(&pkey, | ||
228 | sizeof(struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), | ||
229 | &private_zone); | ||
230 | GNUNET_CRYPTO_short_hash_to_enc (&private_zone, &zonename); | ||
231 | if (!raw) | ||
232 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
233 | "Using private zone: %s!\n", &zonename); | ||
234 | |||
196 | } | 235 | } |
197 | GNUNET_free(keyfile); | 236 | GNUNET_free(keyfile); |
237 | GNUNET_CRYPTO_rsa_key_free (private_key); | ||
198 | } | 238 | } |
199 | 239 | ||
240 | |||
200 | gns = GNUNET_GNS_connect (cfg); | 241 | gns = GNUNET_GNS_connect (cfg); |
201 | if (lookup_type != NULL) | 242 | if (lookup_type != NULL) |
202 | rtype = GNUNET_NAMESTORE_typename_to_number(lookup_type); | 243 | rtype = GNUNET_NAMESTORE_typename_to_number(lookup_type); |
@@ -214,6 +255,8 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
214 | { | 255 | { |
215 | /** shorten name */ | 256 | /** shorten name */ |
216 | GNUNET_GNS_shorten_zone (gns, shorten_name, | 257 | GNUNET_GNS_shorten_zone (gns, shorten_name, |
258 | &private_zone, | ||
259 | &shorten_zone, | ||
217 | zone, | 260 | zone, |
218 | &process_shorten_result, | 261 | &process_shorten_result, |
219 | shorten_name); | 262 | shorten_name); |