diff options
-rw-r--r-- | src/gns/gns_tld_api.c | 4 | ||||
-rw-r--r-- | src/gns/gnunet-service-gns_resolver.c | 36 | ||||
-rw-r--r-- | src/gns/plugin_block_gns.c | 12 | ||||
-rw-r--r-- | src/gns/plugin_gnsrecord_gns.c | 10 | ||||
-rwxr-xr-x | src/gns/test_gns_dht_lookup.sh | 1 | ||||
-rw-r--r-- | src/gnsrecord/gnsrecord_misc.c | 17 | ||||
-rw-r--r-- | src/identity/identity_api.c | 88 | ||||
-rw-r--r-- | src/include/gnunet_gnsrecord_lib.h | 3 | ||||
-rw-r--r-- | src/zonemaster/gnunet-service-zonemaster-monitor.c | 8 | ||||
-rw-r--r-- | src/zonemaster/gnunet-service-zonemaster.c | 8 |
10 files changed, 98 insertions, 89 deletions
diff --git a/src/gns/gns_tld_api.c b/src/gns/gns_tld_api.c index 3eab6c109..b883662ad 100644 --- a/src/gns/gns_tld_api.c +++ b/src/gns/gns_tld_api.c | |||
@@ -263,6 +263,8 @@ GNUNET_GNS_lookup_with_tld (struct GNUNET_GNS_Handle *handle, | |||
263 | if (GNUNET_OK == | 263 | if (GNUNET_OK == |
264 | GNUNET_IDENTITY_public_key_from_string (tld, &pkey)) | 264 | GNUNET_IDENTITY_public_key_from_string (tld, &pkey)) |
265 | { | 265 | { |
266 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
267 | "`%s' seems to be a valid zone key\n", tld); | ||
266 | eat_tld (ltr->name, tld); | 268 | eat_tld (ltr->name, tld); |
267 | lookup_with_public_key (ltr, &pkey); | 269 | lookup_with_public_key (ltr, &pkey); |
268 | return ltr; | 270 | return ltr; |
@@ -303,6 +305,8 @@ GNUNET_GNS_lookup_with_tld (struct GNUNET_GNS_Handle *handle, | |||
303 | } | 305 | } |
304 | GNUNET_free (dot_tld); | 306 | GNUNET_free (dot_tld); |
305 | } | 307 | } |
308 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
309 | "`%s' should be a valid ego\n", ltr->name); | ||
306 | ltr->id_co = | 310 | ltr->id_co = |
307 | GNUNET_IDENTITY_ego_lookup_by_suffix (ltr->gns_handle->cfg, | 311 | GNUNET_IDENTITY_ego_lookup_by_suffix (ltr->gns_handle->cfg, |
308 | ltr->name, | 312 | ltr->name, |
diff --git a/src/gns/gnunet-service-gns_resolver.c b/src/gns/gnunet-service-gns_resolver.c index b34402f81..09b7a0a85 100644 --- a/src/gns/gnunet-service-gns_resolver.c +++ b/src/gns/gnunet-service-gns_resolver.c | |||
@@ -1709,9 +1709,8 @@ recursive_pkey_resolution (struct GNS_ResolverHandle *rh, | |||
1709 | ac = GNUNET_new (struct AuthorityChain); | 1709 | ac = GNUNET_new (struct AuthorityChain); |
1710 | ac->rh = rh; | 1710 | ac->rh = rh; |
1711 | ac->gns_authority = GNUNET_YES; | 1711 | ac->gns_authority = GNUNET_YES; |
1712 | GNUNET_memcpy (&ac->authority_info.gns_authority, | 1712 | GNUNET_GNSRECORD_record_to_identity_key (rd, |
1713 | rd->data, | 1713 | &ac->authority_info.gns_authority); |
1714 | sizeof(struct GNUNET_IDENTITY_PublicKey)); | ||
1715 | ac->label = resolver_lookup_get_next_label (rh); | 1714 | ac->label = resolver_lookup_get_next_label (rh); |
1716 | /* add AC to tail */ | 1715 | /* add AC to tail */ |
1717 | GNUNET_CONTAINER_DLL_insert_tail (rh->ac_head, | 1716 | GNUNET_CONTAINER_DLL_insert_tail (rh->ac_head, |
@@ -2258,16 +2257,11 @@ handle_gns_resolution_result (void *cls, | |||
2258 | 2257 | ||
2259 | case GNUNET_GNSRECORD_TYPE_PKEY: | 2258 | case GNUNET_GNSRECORD_TYPE_PKEY: |
2260 | { | 2259 | { |
2261 | struct GNUNET_IDENTITY_PublicKey pub; | 2260 | if (rd[i].data_size != sizeof(struct GNUNET_CRYPTO_EcdsaPublicKey)) |
2262 | |||
2263 | if (rd[i].data_size != sizeof(struct GNUNET_IDENTITY_PublicKey)) | ||
2264 | { | 2261 | { |
2265 | GNUNET_break_op (0); | 2262 | GNUNET_break_op (0); |
2266 | break; | 2263 | break; |
2267 | } | 2264 | } |
2268 | GNUNET_memcpy (&pub, | ||
2269 | rd[i].data, | ||
2270 | rd[i].data_size); | ||
2271 | rd_off++; | 2265 | rd_off++; |
2272 | if (GNUNET_GNSRECORD_TYPE_PKEY != rh->record_type) | 2266 | if (GNUNET_GNSRECORD_TYPE_PKEY != rh->record_type) |
2273 | { | 2267 | { |
@@ -2277,7 +2271,8 @@ handle_gns_resolution_result (void *cls, | |||
2277 | ac = GNUNET_new (struct AuthorityChain); | 2271 | ac = GNUNET_new (struct AuthorityChain); |
2278 | ac->rh = rh; | 2272 | ac->rh = rh; |
2279 | ac->gns_authority = GNUNET_YES; | 2273 | ac->gns_authority = GNUNET_YES; |
2280 | ac->authority_info.gns_authority = pub; | 2274 | GNUNET_GNSRECORD_record_to_identity_key (&rd[i], |
2275 | &ac->authority_info.gns_authority); | ||
2281 | ac->label = GNUNET_strdup (GNUNET_GNS_EMPTY_LABEL_AT); | 2276 | ac->label = GNUNET_strdup (GNUNET_GNS_EMPTY_LABEL_AT); |
2282 | GNUNET_CONTAINER_DLL_insert_tail (rh->ac_head, | 2277 | GNUNET_CONTAINER_DLL_insert_tail (rh->ac_head, |
2283 | rh->ac_tail, | 2278 | rh->ac_tail, |
@@ -2469,10 +2464,7 @@ handle_dht_response (void *cls, | |||
2469 | return; | 2464 | return; |
2470 | } | 2465 | } |
2471 | block = data; | 2466 | block = data; |
2472 | if (size != | 2467 | if (size != GNUNET_GNSRECORD_block_get_size (block)) |
2473 | ntohl (block->purpose.size) | ||
2474 | + sizeof(struct GNUNET_IDENTITY_PublicKey) | ||
2475 | + sizeof(struct GNUNET_CRYPTO_EcdsaSignature)) | ||
2476 | { | 2468 | { |
2477 | /* how did this pass DHT block validation!? */ | 2469 | /* how did this pass DHT block validation!? */ |
2478 | GNUNET_break (0); | 2470 | GNUNET_break (0); |
@@ -2480,8 +2472,8 @@ handle_dht_response (void *cls, | |||
2480 | return; | 2472 | return; |
2481 | } | 2473 | } |
2482 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 2474 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
2483 | "Decrypting DHT block of size %u for `%s', expires %s\n", | 2475 | "Decrypting DHT block of size %lu for `%s', expires %s\n", |
2484 | ntohl (block->purpose.size), | 2476 | GNUNET_GNSRECORD_block_get_size (block), |
2485 | rh->name, | 2477 | rh->name, |
2486 | GNUNET_STRINGS_absolute_time_to_string (exp)); | 2478 | GNUNET_STRINGS_absolute_time_to_string (exp)); |
2487 | if (GNUNET_OK != | 2479 | if (GNUNET_OK != |
@@ -2495,8 +2487,8 @@ handle_dht_response (void *cls, | |||
2495 | fail_resolution (rh); | 2487 | fail_resolution (rh); |
2496 | return; | 2488 | return; |
2497 | } | 2489 | } |
2498 | if (0 == GNUNET_TIME_absolute_get_remaining (GNUNET_TIME_absolute_ntoh ( | 2490 | if (0 == GNUNET_TIME_absolute_get_remaining ( |
2499 | block->expiration_time)). | 2491 | GNUNET_GNSRECORD_block_get_expiration (block)). |
2500 | rel_value_us) | 2492 | rel_value_us) |
2501 | { | 2493 | { |
2502 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 2494 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
@@ -2604,8 +2596,8 @@ handle_namecache_block_response (void *cls, | |||
2604 | ((GNUNET_GNS_LO_LOCAL_MASTER == rh->options) && | 2596 | ((GNUNET_GNS_LO_LOCAL_MASTER == rh->options) && |
2605 | (ac != rh->ac_head))) && | 2597 | (ac != rh->ac_head))) && |
2606 | ((NULL == block) || | 2598 | ((NULL == block) || |
2607 | (0 == GNUNET_TIME_absolute_get_remaining (GNUNET_TIME_absolute_ntoh ( | 2599 | (0 == GNUNET_TIME_absolute_get_remaining ( |
2608 | block->expiration_time)). | 2600 | GNUNET_GNSRECORD_block_get_expiration (block)). |
2609 | rel_value_us))) | 2601 | rel_value_us))) |
2610 | { | 2602 | { |
2611 | /* namecache knows nothing; try DHT lookup */ | 2603 | /* namecache knows nothing; try DHT lookup */ |
@@ -2622,8 +2614,8 @@ handle_namecache_block_response (void *cls, | |||
2622 | } | 2614 | } |
2623 | 2615 | ||
2624 | if ((NULL == block) || | 2616 | if ((NULL == block) || |
2625 | (0 == GNUNET_TIME_absolute_get_remaining (GNUNET_TIME_absolute_ntoh ( | 2617 | (0 == GNUNET_TIME_absolute_get_remaining ( |
2626 | block->expiration_time)). | 2618 | GNUNET_GNSRECORD_block_get_expiration (block)). |
2627 | rel_value_us)) | 2619 | rel_value_us)) |
2628 | { | 2620 | { |
2629 | /* DHT not permitted and no local result, fail */ | 2621 | /* DHT not permitted and no local result, fail */ |
diff --git a/src/gns/plugin_block_gns.c b/src/gns/plugin_block_gns.c index 64390c5a0..9b58c9034 100644 --- a/src/gns/plugin_block_gns.c +++ b/src/gns/plugin_block_gns.c | |||
@@ -145,14 +145,13 @@ block_plugin_gns_evaluate (void *cls, | |||
145 | return GNUNET_BLOCK_EVALUATION_RESULT_INVALID; | 145 | return GNUNET_BLOCK_EVALUATION_RESULT_INVALID; |
146 | } | 146 | } |
147 | block = reply_block; | 147 | block = reply_block; |
148 | if (ntohl (block->purpose.size) >= reply_block_size) | 148 | if (GNUNET_GNSRECORD_block_get_size (block) > reply_block_size) |
149 | { | 149 | { |
150 | GNUNET_break_op (0); | 150 | GNUNET_break_op (0); |
151 | return GNUNET_BLOCK_EVALUATION_RESULT_INVALID; | 151 | return GNUNET_BLOCK_EVALUATION_RESULT_INVALID; |
152 | } | 152 | } |
153 | GNUNET_CRYPTO_hash (&block->derived_key, | 153 | GNUNET_GNSRECORD_query_from_block (block, |
154 | sizeof(block->derived_key), | 154 | &h); |
155 | &h); | ||
156 | if (0 != GNUNET_memcmp (&h, query)) | 155 | if (0 != GNUNET_memcmp (&h, query)) |
157 | { | 156 | { |
158 | GNUNET_break_op (0); | 157 | GNUNET_break_op (0); |
@@ -203,9 +202,8 @@ block_plugin_gns_get_key (void *cls, | |||
203 | return GNUNET_BLOCK_EVALUATION_RESULT_INVALID; | 202 | return GNUNET_BLOCK_EVALUATION_RESULT_INVALID; |
204 | } | 203 | } |
205 | block = reply_block; | 204 | block = reply_block; |
206 | GNUNET_CRYPTO_hash (&block->derived_key, | 205 | GNUNET_GNSRECORD_query_from_block (block, |
207 | sizeof(block->derived_key), | 206 | key); |
208 | key); | ||
209 | return GNUNET_OK; | 207 | return GNUNET_OK; |
210 | } | 208 | } |
211 | 209 | ||
diff --git a/src/gns/plugin_gnsrecord_gns.c b/src/gns/plugin_gnsrecord_gns.c index 81f2b9eff..0bd1d047f 100644 --- a/src/gns/plugin_gnsrecord_gns.c +++ b/src/gns/plugin_gnsrecord_gns.c | |||
@@ -50,13 +50,16 @@ gns_value_to_string (void *cls, | |||
50 | size_t data_size) | 50 | size_t data_size) |
51 | { | 51 | { |
52 | const char *cdata; | 52 | const char *cdata; |
53 | struct GNUNET_IDENTITY_PublicKey pk; | ||
53 | 54 | ||
54 | switch (type) | 55 | switch (type) |
55 | { | 56 | { |
56 | case GNUNET_GNSRECORD_TYPE_PKEY: | 57 | case GNUNET_GNSRECORD_TYPE_PKEY: |
57 | if (data_size != sizeof(struct GNUNET_CRYPTO_EcdsaPublicKey)) | 58 | if (data_size != sizeof(struct GNUNET_CRYPTO_EcdsaPublicKey)) |
58 | return NULL; | 59 | return NULL; |
59 | return GNUNET_CRYPTO_ecdsa_public_key_to_string (data); | 60 | pk.type = htonl (GNUNET_GNSRECORD_TYPE_PKEY); |
61 | memcpy (&pk.ecdsa_key, data, sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey)); | ||
62 | return GNUNET_IDENTITY_public_key_to_string (&pk); | ||
60 | 63 | ||
61 | case GNUNET_GNSRECORD_TYPE_NICK: | 64 | case GNUNET_GNSRECORD_TYPE_NICK: |
62 | return GNUNET_strndup (data, data_size); | 65 | return GNUNET_strndup (data, data_size); |
@@ -154,6 +157,7 @@ gns_string_to_value (void *cls, | |||
154 | size_t *data_size) | 157 | size_t *data_size) |
155 | { | 158 | { |
156 | struct GNUNET_CRYPTO_EcdsaPublicKey pkey; | 159 | struct GNUNET_CRYPTO_EcdsaPublicKey pkey; |
160 | struct GNUNET_IDENTITY_PublicKey pk; | ||
157 | 161 | ||
158 | if (NULL == s) | 162 | if (NULL == s) |
159 | return GNUNET_SYSERR; | 163 | return GNUNET_SYSERR; |
@@ -161,7 +165,7 @@ gns_string_to_value (void *cls, | |||
161 | { | 165 | { |
162 | case GNUNET_GNSRECORD_TYPE_PKEY: | 166 | case GNUNET_GNSRECORD_TYPE_PKEY: |
163 | if (GNUNET_OK != | 167 | if (GNUNET_OK != |
164 | GNUNET_CRYPTO_ecdsa_public_key_from_string (s, strlen (s), &pkey)) | 168 | GNUNET_IDENTITY_public_key_from_string (s, &pk)) |
165 | { | 169 | { |
166 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 170 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
167 | _ ("Unable to parse PKEY record `%s'\n"), | 171 | _ ("Unable to parse PKEY record `%s'\n"), |
@@ -169,7 +173,7 @@ gns_string_to_value (void *cls, | |||
169 | return GNUNET_SYSERR; | 173 | return GNUNET_SYSERR; |
170 | } | 174 | } |
171 | *data = GNUNET_new (struct GNUNET_CRYPTO_EcdsaPublicKey); | 175 | *data = GNUNET_new (struct GNUNET_CRYPTO_EcdsaPublicKey); |
172 | GNUNET_memcpy (*data, &pkey, sizeof(pkey)); | 176 | GNUNET_memcpy (*data, &pk.ecdsa_key, sizeof(pkey)); |
173 | *data_size = sizeof(struct GNUNET_CRYPTO_EcdsaPublicKey); | 177 | *data_size = sizeof(struct GNUNET_CRYPTO_EcdsaPublicKey); |
174 | return GNUNET_OK; | 178 | return GNUNET_OK; |
175 | 179 | ||
diff --git a/src/gns/test_gns_dht_lookup.sh b/src/gns/test_gns_dht_lookup.sh index d5516fd03..8d446c507 100755 --- a/src/gns/test_gns_dht_lookup.sh +++ b/src/gns/test_gns_dht_lookup.sh | |||
@@ -26,6 +26,7 @@ gnunet-arm -i datastore -c test_gns_lookup.conf | |||
26 | gnunet-identity -C $OTHER_EGO -c test_gns_lookup.conf | 26 | gnunet-identity -C $OTHER_EGO -c test_gns_lookup.conf |
27 | DELEGATED_PKEY=$(gnunet-identity -d -c test_gns_lookup.conf | grep $OTHER_EGO | awk '{print $3}') | 27 | DELEGATED_PKEY=$(gnunet-identity -d -c test_gns_lookup.conf | grep $OTHER_EGO | awk '{print $3}') |
28 | gnunet-identity -C $MY_EGO -c test_gns_lookup.conf | 28 | gnunet-identity -C $MY_EGO -c test_gns_lookup.conf |
29 | echo "MYEGO: $MY_EGO OTHER_EGO: $DELEGATED_PKEY" | ||
29 | gnunet-namestore -p -z $MY_EGO -a -n b -t PKEY -V $DELEGATED_PKEY -e never -c test_gns_lookup.conf | 30 | gnunet-namestore -p -z $MY_EGO -a -n b -t PKEY -V $DELEGATED_PKEY -e never -c test_gns_lookup.conf |
30 | #This works | 31 | #This works |
31 | gnunet-namestore -p -z $OTHER_EGO -a -n www -t A -V $TEST_IP -e never -c test_gns_lookup.conf | 32 | gnunet-namestore -p -z $OTHER_EGO -a -n www -t A -V $TEST_IP -e never -c test_gns_lookup.conf |
diff --git a/src/gnsrecord/gnsrecord_misc.c b/src/gnsrecord/gnsrecord_misc.c index baf13e963..cfe310422 100644 --- a/src/gnsrecord/gnsrecord_misc.c +++ b/src/gnsrecord/gnsrecord_misc.c | |||
@@ -325,5 +325,22 @@ GNUNET_GNSRECORD_query_from_block (const struct GNUNET_GNSRECORD_Block *block, | |||
325 | 325 | ||
326 | } | 326 | } |
327 | 327 | ||
328 | enum GNUNET_GenericReturnValue | ||
329 | GNUNET_GNSRECORD_record_to_identity_key (const struct GNUNET_GNSRECORD_Data *rd, | ||
330 | struct GNUNET_IDENTITY_PublicKey *key) | ||
331 | { | ||
332 | switch (ntohl (rd->record_type)) | ||
333 | { | ||
334 | case GNUNET_GNSRECORD_TYPE_PKEY: | ||
335 | key->type = htonl (rd->record_type); | ||
336 | memcpy (&key->ecdsa_key, rd->data, sizeof (key->ecdsa_key)); | ||
337 | return GNUNET_OK; | ||
338 | default: | ||
339 | return GNUNET_SYSERR; | ||
340 | } | ||
341 | return GNUNET_SYSERR; | ||
342 | |||
343 | |||
344 | } | ||
328 | 345 | ||
329 | /* end of gnsrecord_misc.c */ | 346 | /* end of gnsrecord_misc.c */ |
diff --git a/src/identity/identity_api.c b/src/identity/identity_api.c index 63fa4b919..213b6966e 100644 --- a/src/identity/identity_api.c +++ b/src/identity/identity_api.c | |||
@@ -953,6 +953,24 @@ GNUNET_IDENTITY_disconnect (struct GNUNET_IDENTITY_Handle *h) | |||
953 | GNUNET_free (h); | 953 | GNUNET_free (h); |
954 | } | 954 | } |
955 | 955 | ||
956 | ssize_t | ||
957 | private_key_get_length (const struct GNUNET_IDENTITY_PrivateKey *key) | ||
958 | { | ||
959 | switch (ntohl (key->type)) | ||
960 | { | ||
961 | case GNUNET_IDENTITY_TYPE_ECDSA: | ||
962 | return sizeof (key->type) + sizeof (key->ecdsa_key); | ||
963 | break; | ||
964 | case GNUNET_IDENTITY_TYPE_EDDSA: | ||
965 | return sizeof (key->type) + sizeof (key->eddsa_key); | ||
966 | break; | ||
967 | default: | ||
968 | GNUNET_break (0); | ||
969 | } | ||
970 | return -1; | ||
971 | } | ||
972 | |||
973 | |||
956 | 974 | ||
957 | ssize_t | 975 | ssize_t |
958 | GNUNET_IDENTITY_key_get_length (const struct GNUNET_IDENTITY_PublicKey *key) | 976 | GNUNET_IDENTITY_key_get_length (const struct GNUNET_IDENTITY_PublicKey *key) |
@@ -976,13 +994,9 @@ char * | |||
976 | GNUNET_IDENTITY_public_key_to_string (const struct | 994 | GNUNET_IDENTITY_public_key_to_string (const struct |
977 | GNUNET_IDENTITY_PublicKey *key) | 995 | GNUNET_IDENTITY_PublicKey *key) |
978 | { | 996 | { |
979 | size_t size = 0; | 997 | size_t size = GNUNET_IDENTITY_key_get_length (key); |
980 | char *res; | 998 | return GNUNET_STRINGS_data_to_string_alloc (key, |
981 | size = GNUNET_IDENTITY_key_get_length (key); | 999 | size); |
982 | GNUNET_STRINGS_base64_encode (key, | ||
983 | size, | ||
984 | &res); | ||
985 | return res; | ||
986 | } | 1000 | } |
987 | 1001 | ||
988 | 1002 | ||
@@ -990,22 +1004,9 @@ char * | |||
990 | GNUNET_IDENTITY_private_key_to_string (const struct | 1004 | GNUNET_IDENTITY_private_key_to_string (const struct |
991 | GNUNET_IDENTITY_PrivateKey *key) | 1005 | GNUNET_IDENTITY_PrivateKey *key) |
992 | { | 1006 | { |
993 | size_t size = 0; | 1007 | size_t size = private_key_get_length (key); |
994 | char *res; | 1008 | return GNUNET_STRINGS_data_to_string_alloc (key, |
995 | size += sizeof (key->type); | 1009 | size); |
996 | switch (ntohl (key->type)) | ||
997 | { | ||
998 | case GNUNET_IDENTITY_TYPE_ECDSA: | ||
999 | size += sizeof (key->ecdsa_key); | ||
1000 | break; | ||
1001 | case GNUNET_IDENTITY_TYPE_EDDSA: | ||
1002 | size += sizeof (key->eddsa_key); | ||
1003 | break; | ||
1004 | } | ||
1005 | size = GNUNET_STRINGS_base64_encode (key, | ||
1006 | size, | ||
1007 | &res); | ||
1008 | return res; | ||
1009 | } | 1010 | } |
1010 | 1011 | ||
1011 | 1012 | ||
@@ -1013,20 +1014,17 @@ enum GNUNET_GenericReturnValue | |||
1013 | GNUNET_IDENTITY_public_key_from_string (const char *str, | 1014 | GNUNET_IDENTITY_public_key_from_string (const char *str, |
1014 | struct GNUNET_IDENTITY_PublicKey *key) | 1015 | struct GNUNET_IDENTITY_PublicKey *key) |
1015 | { | 1016 | { |
1016 | char *data = NULL; | 1017 | enum GNUNET_GenericReturnValue ret; |
1017 | size_t size; | 1018 | enum GNUNET_IDENTITY_KeyType ktype; |
1018 | 1019 | ret = GNUNET_STRINGS_string_to_data (str, | |
1019 | size = GNUNET_STRINGS_base64_decode (str, | ||
1020 | strlen (str), | 1020 | strlen (str), |
1021 | (void*) &data); | 1021 | key, |
1022 | if ((NULL == data) || | 1022 | sizeof (*key)); |
1023 | (size > sizeof (*key))) | 1023 | if (GNUNET_OK != ret) |
1024 | { | ||
1025 | GNUNET_free (data); | ||
1026 | return GNUNET_SYSERR; | 1024 | return GNUNET_SYSERR; |
1027 | } | 1025 | ktype = ntohl (key->type); |
1028 | memcpy (key, data, size); | 1026 | return (GNUNET_IDENTITY_TYPE_ECDSA == ktype) ? GNUNET_OK : GNUNET_SYSERR; //FIXME other keys, cleaner way? |
1029 | return GNUNET_OK; | 1027 | |
1030 | } | 1028 | } |
1031 | 1029 | ||
1032 | 1030 | ||
@@ -1034,20 +1032,16 @@ enum GNUNET_GenericReturnValue | |||
1034 | GNUNET_IDENTITY_private_key_from_string (const char *str, | 1032 | GNUNET_IDENTITY_private_key_from_string (const char *str, |
1035 | struct GNUNET_IDENTITY_PrivateKey *key) | 1033 | struct GNUNET_IDENTITY_PrivateKey *key) |
1036 | { | 1034 | { |
1037 | char *data = NULL; | 1035 | enum GNUNET_GenericReturnValue ret; |
1038 | size_t size; | 1036 | enum GNUNET_IDENTITY_KeyType ktype; |
1039 | 1037 | ret = GNUNET_STRINGS_string_to_data (str, | |
1040 | size = GNUNET_STRINGS_base64_decode (str, | ||
1041 | strlen (str), | 1038 | strlen (str), |
1042 | (void*) &data); | 1039 | key, |
1043 | if ((NULL == data) || | 1040 | sizeof (*key)); |
1044 | (size > sizeof (*key))) | 1041 | if (GNUNET_OK != ret) |
1045 | { | ||
1046 | GNUNET_free (data); | ||
1047 | return GNUNET_SYSERR; | 1042 | return GNUNET_SYSERR; |
1048 | } | 1043 | ktype = ntohl (key->type); |
1049 | memcpy (key, data, size); | 1044 | return (GNUNET_IDENTITY_TYPE_ECDSA == ktype) ? GNUNET_OK : GNUNET_SYSERR; //FIXME other keys, cleaner way? |
1050 | return GNUNET_OK; | ||
1051 | } | 1045 | } |
1052 | 1046 | ||
1053 | 1047 | ||
diff --git a/src/include/gnunet_gnsrecord_lib.h b/src/include/gnunet_gnsrecord_lib.h index 20d8e2517..559208689 100644 --- a/src/include/gnunet_gnsrecord_lib.h +++ b/src/include/gnunet_gnsrecord_lib.h | |||
@@ -672,6 +672,9 @@ enum GNUNET_GenericReturnValue | |||
672 | GNUNET_GNSRECORD_query_from_block (const struct GNUNET_GNSRECORD_Block *block, | 672 | GNUNET_GNSRECORD_query_from_block (const struct GNUNET_GNSRECORD_Block *block, |
673 | struct GNUNET_HashCode *query); | 673 | struct GNUNET_HashCode *query); |
674 | 674 | ||
675 | enum GNUNET_GenericReturnValue | ||
676 | GNUNET_GNSRECORD_record_to_identity_key (const struct GNUNET_GNSRECORD_Data *rd, | ||
677 | struct GNUNET_IDENTITY_PublicKey *key); | ||
675 | 678 | ||
676 | #if 0 /* keep Emacsens' auto-indent happy */ | 679 | #if 0 /* keep Emacsens' auto-indent happy */ |
677 | { | 680 | { |
diff --git a/src/zonemaster/gnunet-service-zonemaster-monitor.c b/src/zonemaster/gnunet-service-zonemaster-monitor.c index 4a368048e..c6dd2b6ca 100644 --- a/src/zonemaster/gnunet-service-zonemaster-monitor.c +++ b/src/zonemaster/gnunet-service-zonemaster-monitor.c | |||
@@ -240,7 +240,7 @@ convert_records_for_export (const struct GNUNET_GNSRECORD_Data *rd, | |||
240 | * @return DHT PUT handle, NULL on error | 240 | * @return DHT PUT handle, NULL on error |
241 | */ | 241 | */ |
242 | static struct GNUNET_DHT_PutHandle * | 242 | static struct GNUNET_DHT_PutHandle * |
243 | perform_dht_put (const struct GNUNET_CRYPTO_EcdsaPrivateKey *key, | 243 | perform_dht_put (const struct GNUNET_IDENTITY_PrivateKey *key, |
244 | const char *label, | 244 | const char *label, |
245 | const struct GNUNET_GNSRECORD_Data *rd_public, | 245 | const struct GNUNET_GNSRECORD_Data *rd_public, |
246 | unsigned int rd_public_count, | 246 | unsigned int rd_public_count, |
@@ -271,9 +271,7 @@ perform_dht_put (const struct GNUNET_CRYPTO_EcdsaPrivateKey *key, | |||
271 | GNUNET_break (0); | 271 | GNUNET_break (0); |
272 | return NULL; /* whoops */ | 272 | return NULL; /* whoops */ |
273 | } | 273 | } |
274 | block_size = ntohl (block->purpose.size) | 274 | block_size = GNUNET_GNSRECORD_block_get_size (block); |
275 | + sizeof(struct GNUNET_CRYPTO_EcdsaSignature) | ||
276 | + sizeof(struct GNUNET_CRYPTO_EcdsaPublicKey); | ||
277 | GNUNET_GNSRECORD_query_from_private_key (key, | 275 | GNUNET_GNSRECORD_query_from_private_key (key, |
278 | label, | 276 | label, |
279 | &query); | 277 | &query); |
@@ -314,7 +312,7 @@ perform_dht_put (const struct GNUNET_CRYPTO_EcdsaPrivateKey *key, | |||
314 | */ | 312 | */ |
315 | static void | 313 | static void |
316 | handle_monitor_event (void *cls, | 314 | handle_monitor_event (void *cls, |
317 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, | 315 | const struct GNUNET_IDENTITY_PrivateKey *zone, |
318 | const char *label, | 316 | const char *label, |
319 | unsigned int rd_count, | 317 | unsigned int rd_count, |
320 | const struct GNUNET_GNSRECORD_Data *rd) | 318 | const struct GNUNET_GNSRECORD_Data *rd) |
diff --git a/src/zonemaster/gnunet-service-zonemaster.c b/src/zonemaster/gnunet-service-zonemaster.c index c5aab8d92..11fa9921d 100644 --- a/src/zonemaster/gnunet-service-zonemaster.c +++ b/src/zonemaster/gnunet-service-zonemaster.c | |||
@@ -579,7 +579,7 @@ convert_records_for_export (const struct GNUNET_GNSRECORD_Data *rd, | |||
579 | * @return DHT PUT handle, NULL on error | 579 | * @return DHT PUT handle, NULL on error |
580 | */ | 580 | */ |
581 | static struct GNUNET_DHT_PutHandle * | 581 | static struct GNUNET_DHT_PutHandle * |
582 | perform_dht_put (const struct GNUNET_CRYPTO_EcdsaPrivateKey *key, | 582 | perform_dht_put (const struct GNUNET_IDENTITY_PrivateKey *key, |
583 | const char *label, | 583 | const char *label, |
584 | const struct GNUNET_GNSRECORD_Data *rd_public, | 584 | const struct GNUNET_GNSRECORD_Data *rd_public, |
585 | unsigned int rd_public_count, | 585 | unsigned int rd_public_count, |
@@ -610,9 +610,7 @@ perform_dht_put (const struct GNUNET_CRYPTO_EcdsaPrivateKey *key, | |||
610 | GNUNET_break (0); | 610 | GNUNET_break (0); |
611 | return NULL; /* whoops */ | 611 | return NULL; /* whoops */ |
612 | } | 612 | } |
613 | block_size = ntohl (block->purpose.size) | 613 | block_size = GNUNET_GNSRECORD_block_get_size (block); |
614 | + sizeof(struct GNUNET_CRYPTO_EcdsaSignature) | ||
615 | + sizeof(struct GNUNET_CRYPTO_EcdsaPublicKey); | ||
616 | GNUNET_GNSRECORD_query_from_private_key (key, | 614 | GNUNET_GNSRECORD_query_from_private_key (key, |
617 | label, | 615 | label, |
618 | &query); | 616 | &query); |
@@ -725,7 +723,7 @@ zone_iteration_finished (void *cls) | |||
725 | */ | 723 | */ |
726 | static void | 724 | static void |
727 | put_gns_record (void *cls, | 725 | put_gns_record (void *cls, |
728 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *key, | 726 | const struct GNUNET_IDENTITY_PrivateKey *key, |
729 | const char *label, | 727 | const char *label, |
730 | unsigned int rd_count, | 728 | unsigned int rd_count, |
731 | const struct GNUNET_GNSRECORD_Data *rd) | 729 | const struct GNUNET_GNSRECORD_Data *rd) |