diff options
-rw-r--r-- | src/gns/gnunet-gns-import.c | 9 | ||||
-rw-r--r-- | src/gns/gnunet-service-gns_resolver.c | 28 | ||||
-rw-r--r-- | src/gns/plugin_gnsrecord_gns.c | 29 | ||||
-rw-r--r-- | src/gnsrecord/gnsrecord_misc.c | 47 | ||||
-rw-r--r-- | src/gnsrecord/gnunet-gnsrecord-tvg.c | 12 | ||||
-rw-r--r-- | src/include/gnunet_gnsrecord_lib.h | 46 | ||||
-rw-r--r-- | src/namestore/gnunet-namestore-fcfsd.c | 22 | ||||
-rw-r--r-- | src/namestore/gnunet-namestore.c | 10 | ||||
-rw-r--r-- | src/namestore/plugin_namestore_flat.c | 7 | ||||
-rw-r--r-- | src/namestore/plugin_namestore_postgres.c | 13 | ||||
-rw-r--r-- | src/namestore/plugin_namestore_sqlite.c | 12 | ||||
-rw-r--r-- | src/revocation/gnunet-revocation-tvg.c | 14 |
12 files changed, 195 insertions, 54 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 }, |
diff --git a/src/gnsrecord/gnsrecord_misc.c b/src/gnsrecord/gnsrecord_misc.c index 4b1695d69..ba8803850 100644 --- a/src/gnsrecord/gnsrecord_misc.c +++ b/src/gnsrecord/gnsrecord_misc.c | |||
@@ -272,6 +272,51 @@ GNUNET_GNSRECORD_zkey_to_pkey (const char *zkey, | |||
272 | } | 272 | } |
273 | 273 | ||
274 | 274 | ||
275 | enum GNUNET_GenericReturnValue | ||
276 | GNUNET_GNSRECORD_identity_from_data (const char *data, | ||
277 | size_t data_size, | ||
278 | uint32_t type, | ||
279 | struct GNUNET_IDENTITY_PublicKey *key) | ||
280 | { | ||
281 | if (GNUNET_NO == GNUNET_GNSRECORD_is_zonekey_type (type)) | ||
282 | return GNUNET_SYSERR; | ||
283 | if (data_size > sizeof (struct GNUNET_IDENTITY_PublicKey)) | ||
284 | return GNUNET_SYSERR; | ||
285 | key->type = type; | ||
286 | memcpy (key, data, data_size); | ||
287 | return GNUNET_OK; | ||
288 | } | ||
289 | |||
290 | enum GNUNET_GenericReturnValue | ||
291 | GNUNET_GNSRECORD_data_from_identity (const struct | ||
292 | GNUNET_IDENTITY_PublicKey *key, | ||
293 | char **data, | ||
294 | size_t *data_size, | ||
295 | uint32_t *type) | ||
296 | { | ||
297 | *type = key->type; | ||
298 | *data_size = GNUNET_IDENTITY_key_get_length (key); | ||
299 | if (0 == *data_size) | ||
300 | return GNUNET_SYSERR; | ||
301 | *data = GNUNET_malloc (*data_size); | ||
302 | memcpy (*data, key, *data_size); | ||
303 | return GNUNET_OK; | ||
304 | } | ||
305 | |||
306 | |||
307 | enum GNUNET_GenericReturnValue | ||
308 | GNUNET_GNSRECORD_is_zonekey_type (uint32_t type) | ||
309 | { | ||
310 | switch (type) | ||
311 | { | ||
312 | case GNUNET_GNSRECORD_TYPE_PKEY: | ||
313 | case GNUNET_GNSRECORD_TYPE_EDKEY: | ||
314 | return GNUNET_YES; | ||
315 | default: | ||
316 | return GNUNET_NO; | ||
317 | } | ||
318 | } | ||
319 | |||
275 | size_t | 320 | size_t |
276 | GNUNET_GNSRECORD_block_get_size (const struct GNUNET_GNSRECORD_Block *block) | 321 | GNUNET_GNSRECORD_block_get_size (const struct GNUNET_GNSRECORD_Block *block) |
277 | { | 322 | { |
@@ -325,6 +370,7 @@ GNUNET_GNSRECORD_query_from_block (const struct GNUNET_GNSRECORD_Block *block, | |||
325 | 370 | ||
326 | } | 371 | } |
327 | 372 | ||
373 | |||
328 | enum GNUNET_GenericReturnValue | 374 | enum GNUNET_GenericReturnValue |
329 | GNUNET_GNSRECORD_record_to_identity_key (const struct GNUNET_GNSRECORD_Data *rd, | 375 | GNUNET_GNSRECORD_record_to_identity_key (const struct GNUNET_GNSRECORD_Data *rd, |
330 | struct GNUNET_IDENTITY_PublicKey *key) | 376 | struct GNUNET_IDENTITY_PublicKey *key) |
@@ -346,4 +392,5 @@ GNUNET_GNSRECORD_record_to_identity_key (const struct GNUNET_GNSRECORD_Data *rd, | |||
346 | 392 | ||
347 | } | 393 | } |
348 | 394 | ||
395 | |||
349 | /* end of gnsrecord_misc.c */ | 396 | /* end of gnsrecord_misc.c */ |
diff --git a/src/gnsrecord/gnunet-gnsrecord-tvg.c b/src/gnsrecord/gnunet-gnsrecord-tvg.c index c29f377bc..47b13bdab 100644 --- a/src/gnsrecord/gnunet-gnsrecord-tvg.c +++ b/src/gnsrecord/gnunet-gnsrecord-tvg.c | |||
@@ -98,16 +98,24 @@ run (void *cls, | |||
98 | size_t data_size; | 98 | size_t data_size; |
99 | char *rdata; | 99 | char *rdata; |
100 | size_t rdata_size; | 100 | size_t rdata_size; |
101 | char ztld[128]; | ||
101 | 102 | ||
102 | id_priv.type = htonl (GNUNET_GNSRECORD_TYPE_PKEY); | 103 | id_priv.type = htonl (GNUNET_GNSRECORD_TYPE_PKEY); |
103 | GNUNET_CRYPTO_ecdsa_key_create (&id_priv.ecdsa_key); | 104 | GNUNET_CRYPTO_ecdsa_key_create (&id_priv.ecdsa_key); |
104 | GNUNET_IDENTITY_key_get_public (&id_priv, | 105 | GNUNET_IDENTITY_key_get_public (&id_priv, |
105 | &id_pub); | 106 | &id_pub); |
106 | fprintf (stdout, "Zone private key (d, little-endian scalar):\n"); | 107 | fprintf (stdout, "Zone private key (d, little-endian, with ztype prepended):\n"); |
107 | print_bytes (&id_priv, GNUNET_IDENTITY_key_get_length (&id_pub), 8); //FIXME length for privkey? | 108 | print_bytes (&id_priv, GNUNET_IDENTITY_key_get_length (&id_pub), 8); //FIXME length for privkey? |
108 | fprintf (stdout, "\n"); | 109 | fprintf (stdout, "\n"); |
109 | fprintf (stdout, "Zone public key (zk):\n"); | 110 | fprintf (stdout, "Zone identifier (zid):\n"); |
110 | print_bytes (&id_pub, GNUNET_IDENTITY_key_get_length (&id_pub), 8); | 111 | print_bytes (&id_pub, GNUNET_IDENTITY_key_get_length (&id_pub), 8); |
112 | GNUNET_STRINGS_data_to_string (&id_pub, | ||
113 | GNUNET_IDENTITY_key_get_length (&id_pub), | ||
114 | ztld, | ||
115 | sizeof (ztld)); | ||
116 | fprintf (stdout, "\n"); | ||
117 | fprintf (stdout, "Encoded zone identifier (zkl = zTLD):\n"); | ||
118 | fprintf (stdout, "%s\n", ztld); | ||
111 | fprintf (stdout, "\n"); | 119 | fprintf (stdout, "\n"); |
112 | 120 | ||
113 | pkey_data_p.type = htonl (GNUNET_GNSRECORD_TYPE_PKEY); | 121 | pkey_data_p.type = htonl (GNUNET_GNSRECORD_TYPE_PKEY); |
diff --git a/src/include/gnunet_gnsrecord_lib.h b/src/include/gnunet_gnsrecord_lib.h index 530879b21..0bf2ceed7 100644 --- a/src/include/gnunet_gnsrecord_lib.h +++ b/src/include/gnunet_gnsrecord_lib.h | |||
@@ -686,16 +686,48 @@ GNUNET_GNSRECORD_query_from_block (const struct GNUNET_GNSRECORD_Block *block, | |||
686 | 686 | ||
687 | 687 | ||
688 | /** | 688 | /** |
689 | * Build a #GNUNET_GNSRECORD_PublicKey from a | 689 | * Build a #GNUNET_GNSRECORD_PublicKey from |
690 | * zone delegation resource record set. | 690 | * zone delegation resource record data. |
691 | * | 691 | * |
692 | * @param the resource record set. MUST be a delegation record. | 692 | * @param data the record data- |
693 | * @param key where to write the identtiy key. | 693 | * @param data_size the data size. |
694 | * @return GNUNET_SYSERR on error or if the zone is not a delegation zone. | 694 | * @param type the record type |
695 | * @param key the identity key to store the data in (must be allocated). | ||
696 | * @return GNUNET_OK if successful. | ||
695 | */ | 697 | */ |
696 | enum GNUNET_GenericReturnValue | 698 | enum GNUNET_GenericReturnValue |
697 | GNUNET_GNSRECORD_record_to_identity_key (const struct GNUNET_GNSRECORD_Data *rd, | 699 | GNUNET_GNSRECORD_identity_from_data (const char *data, |
698 | struct GNUNET_IDENTITY_PublicKey *key); | 700 | size_t data_size, |
701 | uint32_t type, | ||
702 | struct GNUNET_IDENTITY_PublicKey *key); | ||
703 | |||
704 | |||
705 | /** | ||
706 | * Create record data and size from an identity key. | ||
707 | * | ||
708 | * @param key the identity key to use. | ||
709 | * @param data the record data (will be allocated) | ||
710 | * @param data_size the allocated data size. | ||
711 | * @param type the resulting record type | ||
712 | * @return GNUNET_OK if successful. | ||
713 | */ | ||
714 | enum GNUNET_GenericReturnValue | ||
715 | GNUNET_GNSRECORD_data_from_identity (const struct GNUNET_IDENTITY_PublicKey *key, | ||
716 | char **data, | ||
717 | size_t *data_size, | ||
718 | uint32_t *type); | ||
719 | |||
720 | |||
721 | /** | ||
722 | * Check if this type is one of the supported GNS zone | ||
723 | * types. | ||
724 | * | ||
725 | * @param type the type to check | ||
726 | * @return GNUNET_YES if it is one of the supported types. | ||
727 | */ | ||
728 | enum GNUNET_GenericReturnValue | ||
729 | GNUNET_GNSRECORD_is_zonekey_type (uint32_t type); | ||
730 | |||
699 | 731 | ||
700 | #if 0 /* keep Emacsens' auto-indent happy */ | 732 | #if 0 /* keep Emacsens' auto-indent happy */ |
701 | { | 733 | { |
diff --git a/src/namestore/gnunet-namestore-fcfsd.c b/src/namestore/gnunet-namestore-fcfsd.c index 844f4a990..22d108067 100644 --- a/src/namestore/gnunet-namestore-fcfsd.c +++ b/src/namestore/gnunet-namestore-fcfsd.c | |||
@@ -349,7 +349,8 @@ iterate_cb (void *cls, | |||
349 | return; | 349 | return; |
350 | } | 350 | } |
351 | 351 | ||
352 | if (GNUNET_GNSRECORD_TYPE_PKEY != rd->record_type) | 352 | if ((GNUNET_GNSRECORD_TYPE_PKEY != rd->record_type) && |
353 | (GNUNET_GNSRECORD_TYPE_EDKEY != rd->record_type)) | ||
353 | { | 354 | { |
354 | GNUNET_NAMESTORE_zone_iterator_next (zr->list_it, | 355 | GNUNET_NAMESTORE_zone_iterator_next (zr->list_it, |
355 | 1); | 356 | 1); |
@@ -621,6 +622,7 @@ zone_to_name_cb (void *cls, | |||
621 | { | 622 | { |
622 | struct Request *request = cls; | 623 | struct Request *request = cls; |
623 | struct GNUNET_GNSRECORD_Data r; | 624 | struct GNUNET_GNSRECORD_Data r; |
625 | char *rdata; | ||
624 | 626 | ||
625 | (void) rd; | 627 | (void) rd; |
626 | (void) zone_key; | 628 | (void) zone_key; |
@@ -635,10 +637,21 @@ zone_to_name_cb (void *cls, | |||
635 | run_httpd_now (); | 637 | run_httpd_now (); |
636 | return; | 638 | return; |
637 | } | 639 | } |
638 | r.data = &request->pub; | 640 | if (GNUNET_OK != GNUNET_GNSRECORD_data_from_identity (&request->pub, |
639 | r.data_size = sizeof(request->pub); | 641 | &rdata, |
642 | &r.data_size, | ||
643 | &r.record_type)) | ||
644 | { | ||
645 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | ||
646 | _ ("Error creating record data.\n")); | ||
647 | request->phase = RP_FAIL; | ||
648 | MHD_resume_connection (request->con); | ||
649 | run_httpd_now (); | ||
650 | return; | ||
651 | } | ||
652 | |||
653 | r.data = rdata; | ||
640 | r.expiration_time = UINT64_MAX; | 654 | r.expiration_time = UINT64_MAX; |
641 | r.record_type = GNUNET_GNSRECORD_TYPE_PKEY; | ||
642 | r.flags = GNUNET_GNSRECORD_RF_NONE; | 655 | r.flags = GNUNET_GNSRECORD_RF_NONE; |
643 | request->qe = GNUNET_NAMESTORE_records_store (ns, | 656 | request->qe = GNUNET_NAMESTORE_records_store (ns, |
644 | &fcfs_zone_pkey, | 657 | &fcfs_zone_pkey, |
@@ -646,6 +659,7 @@ zone_to_name_cb (void *cls, | |||
646 | 1, &r, | 659 | 1, &r, |
647 | &put_continuation, | 660 | &put_continuation, |
648 | request); | 661 | request); |
662 | GNUNET_free (rdata); | ||
649 | } | 663 | } |
650 | 664 | ||
651 | 665 | ||
diff --git a/src/namestore/gnunet-namestore.c b/src/namestore/gnunet-namestore.c index 345d76910..92d2cf627 100644 --- a/src/namestore/gnunet-namestore.c +++ b/src/namestore/gnunet-namestore.c | |||
@@ -661,11 +661,11 @@ get_existing_record (void *cls, | |||
661 | return; | 661 | return; |
662 | 662 | ||
663 | case GNUNET_GNSRECORD_TYPE_PKEY: | 663 | case GNUNET_GNSRECORD_TYPE_PKEY: |
664 | case GNUNET_GNSRECORD_TYPE_EDKEY: | ||
664 | fprintf ( | 665 | fprintf ( |
665 | stderr, | 666 | stderr, |
666 | _ ( | 667 | _ ( |
667 | "A %s record exists already under `%s', no other records can be added.\n"), | 668 | "A zone key record exists already under `%s', no other records can be added.\n"), |
668 | "PKEY", | ||
669 | rec_name); | 669 | rec_name); |
670 | ret = 1; | 670 | ret = 1; |
671 | test_finished (); | 671 | test_finished (); |
@@ -703,13 +703,13 @@ get_existing_record (void *cls, | |||
703 | break; | 703 | break; |
704 | 704 | ||
705 | case GNUNET_GNSRECORD_TYPE_PKEY: | 705 | case GNUNET_GNSRECORD_TYPE_PKEY: |
706 | case GNUNET_GNSRECORD_TYPE_EDKEY: | ||
706 | if (0 != rd_count) | 707 | if (0 != rd_count) |
707 | { | 708 | { |
708 | fprintf (stderr, | 709 | fprintf (stderr, |
709 | _ ( | 710 | _ ( |
710 | "Records already exist under `%s', cannot add `%s' record.\n"), | 711 | "Records already exist under `%s', cannot add record.\n"), |
711 | rec_name, | 712 | rec_name); |
712 | "PKEY"); | ||
713 | ret = 1; | 713 | ret = 1; |
714 | test_finished (); | 714 | test_finished (); |
715 | return; | 715 | return; |
diff --git a/src/namestore/plugin_namestore_flat.c b/src/namestore/plugin_namestore_flat.c index 1a071fd80..9ccc90cfd 100644 --- a/src/namestore/plugin_namestore_flat.c +++ b/src/namestore/plugin_namestore_flat.c | |||
@@ -698,11 +698,14 @@ zone_to_name (void *cls, | |||
698 | 698 | ||
699 | for (unsigned int i = 0; i < entry->record_count; i++) | 699 | for (unsigned int i = 0; i < entry->record_count; i++) |
700 | { | 700 | { |
701 | if (GNUNET_GNSRECORD_TYPE_PKEY != entry->record_data[i].record_type) | 701 | if (GNUNET_NO == |
702 | GNUNET_GNSRECORD_is_zonekey_type (entry->record_data[i].record_type)) | ||
703 | continue; | ||
704 | if (ztn->value_zone->type != entry->record_data[i].record_type) | ||
702 | continue; | 705 | continue; |
703 | if (0 == memcmp (ztn->value_zone, | 706 | if (0 == memcmp (ztn->value_zone, |
704 | entry->record_data[i].data, | 707 | entry->record_data[i].data, |
705 | sizeof(struct GNUNET_IDENTITY_PublicKey))) | 708 | entry->record_data[i].data_size)) |
706 | { | 709 | { |
707 | ztn->iter (ztn->iter_cls, | 710 | ztn->iter (ztn->iter_cls, |
708 | i + 1, /* zero is illegal! */ | 711 | i + 1, /* zero is illegal! */ |
diff --git a/src/namestore/plugin_namestore_postgres.c b/src/namestore/plugin_namestore_postgres.c index 358fd35d6..bdbaf96b3 100644 --- a/src/namestore/plugin_namestore_postgres.c +++ b/src/namestore/plugin_namestore_postgres.c | |||
@@ -195,13 +195,14 @@ namestore_postgres_store_records (void *cls, | |||
195 | 0, | 195 | 0, |
196 | sizeof(pkey)); | 196 | sizeof(pkey)); |
197 | for (unsigned int i = 0; i < rd_count; i++) | 197 | for (unsigned int i = 0; i < rd_count; i++) |
198 | if (GNUNET_GNSRECORD_TYPE_PKEY == rd[i].record_type) | 198 | if (GNUNET_YES == |
199 | GNUNET_GNSRECORD_is_zonekey_type (rd[i].record_type)) | ||
199 | { | 200 | { |
200 | GNUNET_break (sizeof(struct GNUNET_IDENTITY_PublicKey) == | 201 | GNUNET_break (GNUNET_OK == |
201 | rd[i].data_size); | 202 | GNUNET_GNSRECORD_identity_from_data (rd[i].data, |
202 | GNUNET_memcpy (&pkey, | 203 | rd[i].data_size, |
203 | rd[i].data, | 204 | rd[i].record_type, |
204 | rd[i].data_size); | 205 | &pkey)); |
205 | break; | 206 | break; |
206 | } | 207 | } |
207 | rvalue = GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK, | 208 | rvalue = GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK, |
diff --git a/src/namestore/plugin_namestore_sqlite.c b/src/namestore/plugin_namestore_sqlite.c index 4a4ce3d8d..7cb9b7ed0 100644 --- a/src/namestore/plugin_namestore_sqlite.c +++ b/src/namestore/plugin_namestore_sqlite.c | |||
@@ -329,13 +329,13 @@ namestore_sqlite_store_records (void *cls, | |||
329 | 0, | 329 | 0, |
330 | sizeof(pkey)); | 330 | sizeof(pkey)); |
331 | for (unsigned int i = 0; i < rd_count; i++) | 331 | for (unsigned int i = 0; i < rd_count; i++) |
332 | if (GNUNET_GNSRECORD_TYPE_PKEY == rd[i].record_type) | 332 | if (GNUNET_YES == GNUNET_GNSRECORD_is_zonekey_type (rd[i].record_type)) |
333 | { | 333 | { |
334 | GNUNET_break (sizeof(struct GNUNET_IDENTITY_PublicKey) == | 334 | GNUNET_break (GNUNET_YES == |
335 | rd[i].data_size); | 335 | GNUNET_GNSRECORD_identity_from_data (rd[i].data, |
336 | GNUNET_memcpy (&pkey, | 336 | rd[i].data_size, |
337 | rd[i].data, | 337 | rd[i].record_type, |
338 | rd[i].data_size); | 338 | &pkey)); |
339 | break; | 339 | break; |
340 | } | 340 | } |
341 | rvalue = GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK, | 341 | rvalue = GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK, |
diff --git a/src/revocation/gnunet-revocation-tvg.c b/src/revocation/gnunet-revocation-tvg.c index 88117dd3f..cb5e31fcd 100644 --- a/src/revocation/gnunet-revocation-tvg.c +++ b/src/revocation/gnunet-revocation-tvg.c | |||
@@ -70,16 +70,24 @@ run (void *cls, | |||
70 | struct GNUNET_REVOCATION_PowP *pow; | 70 | struct GNUNET_REVOCATION_PowP *pow; |
71 | struct GNUNET_REVOCATION_PowCalculationHandle *ph; | 71 | struct GNUNET_REVOCATION_PowCalculationHandle *ph; |
72 | struct GNUNET_TIME_Relative exp; | 72 | struct GNUNET_TIME_Relative exp; |
73 | char ztld[128]; | ||
73 | 74 | ||
74 | id_priv.type = htonl (GNUNET_IDENTITY_TYPE_ECDSA); | 75 | id_priv.type = htonl (GNUNET_IDENTITY_TYPE_ECDSA); |
75 | GNUNET_CRYPTO_ecdsa_key_create (&id_priv.ecdsa_key); | 76 | GNUNET_CRYPTO_ecdsa_key_create (&id_priv.ecdsa_key); |
76 | GNUNET_IDENTITY_key_get_public (&id_priv, | 77 | GNUNET_IDENTITY_key_get_public (&id_priv, |
77 | &id_pub); | 78 | &id_pub); |
78 | fprintf (stdout, "Zone private key (d, little-endian scalar):\n"); | 79 | GNUNET_STRINGS_data_to_string (&id_pub, |
80 | GNUNET_IDENTITY_key_get_length (&id_pub), | ||
81 | ztld, | ||
82 | sizeof (ztld)); | ||
83 | fprintf (stdout, "Zone private key (d, little-endian scalar, with ztype prepended):\n"); | ||
79 | print_bytes (&id_priv, sizeof(id_priv), 8); | 84 | print_bytes (&id_priv, sizeof(id_priv), 8); |
80 | fprintf (stdout, "\n"); | 85 | fprintf (stdout, "\n"); |
81 | fprintf (stdout, "Zone public key (zk):\n"); | 86 | fprintf (stdout, "Zone identifier (zid):\n"); |
82 | print_bytes (&id_pub, sizeof(id_pub), 8); | 87 | print_bytes (&id_pub, GNUNET_IDENTITY_key_get_length (&id_pub), 8); |
88 | fprintf (stdout, "\n"); | ||
89 | fprintf (stdout, "Encoded zone identifier (zkl = zTLD):\n"); | ||
90 | fprintf (stdout, "%s\n", ztld); | ||
83 | fprintf (stdout, "\n"); | 91 | fprintf (stdout, "\n"); |
84 | pow = GNUNET_malloc (GNUNET_REVOCATION_MAX_PROOF_SIZE); | 92 | pow = GNUNET_malloc (GNUNET_REVOCATION_MAX_PROOF_SIZE); |
85 | GNUNET_REVOCATION_pow_init (&id_priv, | 93 | GNUNET_REVOCATION_pow_init (&id_priv, |