diff options
author | Martin Schanzenbach <mschanzenbach@posteo.de> | 2020-10-14 23:57:25 +0200 |
---|---|---|
committer | Martin Schanzenbach <mschanzenbach@posteo.de> | 2020-10-15 12:11:20 +0200 |
commit | dba32dc385bf922c7cd91eecc209e1a37b96c137 (patch) | |
tree | e894b28b71b7a7baec59e713fbda59f0c4edb624 /src/gns | |
parent | 25eb1fb2acbe92b418d8643c06107ce0ab2bfb9a (diff) | |
download | gnunet-dba32dc385bf922c7cd91eecc209e1a37b96c137.tar.gz gnunet-dba32dc385bf922c7cd91eecc209e1a37b96c137.zip |
- more fixes towards crypto agility
Diffstat (limited to 'src/gns')
-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 |
5 files changed, 31 insertions, 32 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 |