aboutsummaryrefslogtreecommitdiff
path: root/src/gns
diff options
context:
space:
mode:
authorMartin Schanzenbach <mschanzenbach@posteo.de>2020-10-22 19:09:12 +0200
committerMartin Schanzenbach <mschanzenbach@posteo.de>2020-10-22 19:09:12 +0200
commitea1d3fd9f54879992fb997a1e94cfd6830085c4b (patch)
tree7a3fb2ad932a6ab0df3ae6bc5d5fea30575f5171 /src/gns
parentacc69a8e5c921e5bbb03260383936487ec9ce0ca (diff)
downloadgnunet-ea1d3fd9f54879992fb997a1e94cfd6830085c4b.tar.gz
gnunet-ea1d3fd9f54879992fb997a1e94cfd6830085c4b.zip
-more gnsrecord API
Diffstat (limited to 'src/gns')
-rw-r--r--src/gns/gnunet-gns-import.c9
-rw-r--r--src/gns/gnunet-service-gns_resolver.c28
-rw-r--r--src/gns/plugin_gnsrecord_gns.c29
3 files changed, 47 insertions, 19 deletions
diff --git a/src/gns/gnunet-gns-import.c b/src/gns/gnunet-gns-import.c
index 78db28cab..972fb49cd 100644
--- a/src/gns/gnunet-gns-import.c
+++ b/src/gns/gnunet-gns-import.c
@@ -168,12 +168,17 @@ check_pkey (unsigned int rd_len, const struct GNUNET_GNSRECORD_Data *rd,
168 char *pk, int *found_rec) 168 char *pk, int *found_rec)
169{ 169{
170 int i; 170 int i;
171 struct GNUNET_IDENTITY_PublicKey pubkey;
171 172
172 for (i = 0; i < rd_len; i++) 173 for (i = 0; i < rd_len; i++)
173 { 174 {
174 char *s; 175 char *s;
175 if ((GNUNET_GNSRECORD_TYPE_PKEY != rd[i].record_type) || 176 if (sizeof (uint32_t) > rd[i].data_size)
176 (rd[i].data_size != sizeof(struct GNUNET_CRYPTO_EcdsaPublicKey)) ) 177 continue;
178 if (GNUNET_OK != GNUNET_GNSRECORD_identity_from_data (rd[i].data,
179 rd[i].data_size,
180 rd[i].record_type,
181 &pubkey))
177 continue; 182 continue;
178 s = GNUNET_GNSRECORD_value_to_string (rd[i].record_type, 183 s = GNUNET_GNSRECORD_value_to_string (rd[i].record_type,
179 rd[i].data, 184 rd[i].data,
diff --git a/src/gns/gnunet-service-gns_resolver.c b/src/gns/gnunet-service-gns_resolver.c
index 1c13f4df1..d9d0d3099 100644
--- a/src/gns/gnunet-service-gns_resolver.c
+++ b/src/gns/gnunet-service-gns_resolver.c
@@ -1699,8 +1699,10 @@ recursive_pkey_resolution (struct GNS_ResolverHandle *rh,
1699 struct GNUNET_IDENTITY_PublicKey auth; 1699 struct GNUNET_IDENTITY_PublicKey auth;
1700 1700
1701 /* delegation to another zone */ 1701 /* delegation to another zone */
1702 if (GNUNET_OK != GNUNET_GNSRECORD_record_to_identity_key (rd, 1702 if (GNUNET_OK != GNUNET_GNSRECORD_identity_from_data (rd->data,
1703 &auth)) 1703 rd->data_size,
1704 rd->record_type,
1705 &auth))
1704 { 1706 {
1705 GNUNET_break_op (0); 1707 GNUNET_break_op (0);
1706 fail_resolution (rh); 1708 fail_resolution (rh);
@@ -1711,8 +1713,6 @@ recursive_pkey_resolution (struct GNS_ResolverHandle *rh,
1711 ac->rh = rh; 1713 ac->rh = rh;
1712 ac->gns_authority = GNUNET_YES; 1714 ac->gns_authority = GNUNET_YES;
1713 ac->authority_info.gns_authority = auth; 1715 ac->authority_info.gns_authority = auth;
1714 GNUNET_GNSRECORD_record_to_identity_key (rd,
1715 &ac->authority_info.gns_authority);
1716 ac->label = resolver_lookup_get_next_label (rh); 1716 ac->label = resolver_lookup_get_next_label (rh);
1717 /* add AC to tail */ 1717 /* add AC to tail */
1718 GNUNET_CONTAINER_DLL_insert_tail (rh->ac_head, 1718 GNUNET_CONTAINER_DLL_insert_tail (rh->ac_head,
@@ -2258,14 +2258,25 @@ handle_gns_resolution_result (void *cls,
2258 break; 2258 break;
2259 2259
2260 case GNUNET_GNSRECORD_TYPE_PKEY: 2260 case GNUNET_GNSRECORD_TYPE_PKEY:
2261 case GNUNET_GNSRECORD_TYPE_EDKEY:
2261 { 2262 {
2262 if (rd[i].data_size != sizeof(struct GNUNET_CRYPTO_EcdsaPublicKey)) 2263 struct GNUNET_IDENTITY_PublicKey pubkey;
2264 if (rd[i].data_size < sizeof(uint32_t))
2265 {
2266 GNUNET_break_op (0);
2267 break;
2268 }
2269 if (GNUNET_OK !=
2270 GNUNET_GNSRECORD_identity_from_data (rd[i].data,
2271 rd[i].data_size,
2272 rd[i].record_type,
2273 &pubkey))
2263 { 2274 {
2264 GNUNET_break_op (0); 2275 GNUNET_break_op (0);
2265 break; 2276 break;
2266 } 2277 }
2267 rd_off++; 2278 rd_off++;
2268 if (GNUNET_GNSRECORD_TYPE_PKEY != rh->record_type) 2279 if (rd[i].record_type != rh->record_type)
2269 { 2280 {
2270 /* try to resolve "@" */ 2281 /* try to resolve "@" */
2271 struct AuthorityChain *ac; 2282 struct AuthorityChain *ac;
@@ -2273,9 +2284,7 @@ handle_gns_resolution_result (void *cls,
2273 ac = GNUNET_new (struct AuthorityChain); 2284 ac = GNUNET_new (struct AuthorityChain);
2274 ac->rh = rh; 2285 ac->rh = rh;
2275 ac->gns_authority = GNUNET_YES; 2286 ac->gns_authority = GNUNET_YES;
2276 GNUNET_GNSRECORD_record_to_identity_key (&rd[i], 2287 ac->authority_info.gns_authority = pubkey;
2277 &ac->authority_info.
2278 gns_authority);
2279 ac->label = GNUNET_strdup (GNUNET_GNS_EMPTY_LABEL_AT); 2288 ac->label = GNUNET_strdup (GNUNET_GNS_EMPTY_LABEL_AT);
2280 GNUNET_CONTAINER_DLL_insert_tail (rh->ac_head, 2289 GNUNET_CONTAINER_DLL_insert_tail (rh->ac_head,
2281 rh->ac_tail, 2290 rh->ac_tail,
@@ -2365,6 +2374,7 @@ handle_gns_resolution_result (void *cls,
2365 return; 2374 return;
2366 2375
2367 case GNUNET_GNSRECORD_TYPE_PKEY: 2376 case GNUNET_GNSRECORD_TYPE_PKEY:
2377 case GNUNET_GNSRECORD_TYPE_EDKEY:
2368 GNUNET_break_op (1 == rd_count); /* PKEY should be unique */ 2378 GNUNET_break_op (1 == rd_count); /* PKEY should be unique */
2369 recursive_pkey_resolution (rh, 2379 recursive_pkey_resolution (rh,
2370 &rd[0]); 2380 &rd[0]);
diff --git a/src/gns/plugin_gnsrecord_gns.c b/src/gns/plugin_gnsrecord_gns.c
index 0bd1d047f..a2ad0b905 100644
--- a/src/gns/plugin_gnsrecord_gns.c
+++ b/src/gns/plugin_gnsrecord_gns.c
@@ -55,10 +55,12 @@ gns_value_to_string (void *cls,
55 switch (type) 55 switch (type)
56 { 56 {
57 case GNUNET_GNSRECORD_TYPE_PKEY: 57 case GNUNET_GNSRECORD_TYPE_PKEY:
58 if (data_size != sizeof(struct GNUNET_CRYPTO_EcdsaPublicKey)) 58 case GNUNET_GNSRECORD_TYPE_EDKEY:
59 if (GNUNET_OK != GNUNET_GNSRECORD_identity_from_data (data,
60 data_size,
61 type,
62 &pk))
59 return NULL; 63 return NULL;
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); 64 return GNUNET_IDENTITY_public_key_to_string (&pk);
63 65
64 case GNUNET_GNSRECORD_TYPE_NICK: 66 case GNUNET_GNSRECORD_TYPE_NICK:
@@ -156,25 +158,35 @@ gns_string_to_value (void *cls,
156 void **data, 158 void **data,
157 size_t *data_size) 159 size_t *data_size)
158{ 160{
159 struct GNUNET_CRYPTO_EcdsaPublicKey pkey;
160 struct GNUNET_IDENTITY_PublicKey pk; 161 struct GNUNET_IDENTITY_PublicKey pk;
162 uint32_t record_type;
161 163
162 if (NULL == s) 164 if (NULL == s)
163 return GNUNET_SYSERR; 165 return GNUNET_SYSERR;
164 switch (type) 166 switch (type)
165 { 167 {
166 case GNUNET_GNSRECORD_TYPE_PKEY: 168 case GNUNET_GNSRECORD_TYPE_PKEY:
169 case GNUNET_GNSRECORD_TYPE_EDKEY:
167 if (GNUNET_OK != 170 if (GNUNET_OK !=
168 GNUNET_IDENTITY_public_key_from_string (s, &pk)) 171 GNUNET_IDENTITY_public_key_from_string (s, &pk))
169 { 172 {
170 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 173 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
171 _ ("Unable to parse PKEY record `%s'\n"), 174 _ ("Unable to parse zone key record `%s'\n"),
172 s); 175 s);
173 return GNUNET_SYSERR; 176 return GNUNET_SYSERR;
174 } 177 }
175 *data = GNUNET_new (struct GNUNET_CRYPTO_EcdsaPublicKey); 178 *data_size = GNUNET_IDENTITY_key_get_length (&pk);
176 GNUNET_memcpy (*data, &pk.ecdsa_key, sizeof(pkey)); 179 if (GNUNET_OK != GNUNET_GNSRECORD_data_from_identity (&pk,
177 *data_size = sizeof(struct GNUNET_CRYPTO_EcdsaPublicKey); 180 (char **) data,
181 data_size,
182 &record_type))
183 return GNUNET_SYSERR;
184 if (record_type != type)
185 {
186 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
187 _("Record type does not match parsed record type\n"));
188 return GNUNET_SYSERR;
189 }
178 return GNUNET_OK; 190 return GNUNET_OK;
179 191
180 case GNUNET_GNSRECORD_TYPE_NICK: 192 case GNUNET_GNSRECORD_TYPE_NICK:
@@ -305,6 +317,7 @@ static struct
305 const char *name; 317 const char *name;
306 uint32_t number; 318 uint32_t number;
307} gns_name_map[] = { { "PKEY", GNUNET_GNSRECORD_TYPE_PKEY }, 319} gns_name_map[] = { { "PKEY", GNUNET_GNSRECORD_TYPE_PKEY },
320 { "EDKEY", GNUNET_GNSRECORD_TYPE_PKEY },
308 { "NICK", GNUNET_GNSRECORD_TYPE_NICK }, 321 { "NICK", GNUNET_GNSRECORD_TYPE_NICK },
309 { "LEHO", GNUNET_GNSRECORD_TYPE_LEHO }, 322 { "LEHO", GNUNET_GNSRECORD_TYPE_LEHO },
310 { "VPN", GNUNET_GNSRECORD_TYPE_VPN }, 323 { "VPN", GNUNET_GNSRECORD_TYPE_VPN },