diff options
Diffstat (limited to 'src/gns/plugin_gnsrecord_gns.c')
-rw-r--r-- | src/gns/plugin_gnsrecord_gns.c | 29 |
1 files changed, 21 insertions, 8 deletions
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 }, |