aboutsummaryrefslogtreecommitdiff
path: root/src/gns/plugin_gnsrecord_gns.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/gns/plugin_gnsrecord_gns.c')
-rw-r--r--src/gns/plugin_gnsrecord_gns.c33
1 files changed, 25 insertions, 8 deletions
diff --git a/src/gns/plugin_gnsrecord_gns.c b/src/gns/plugin_gnsrecord_gns.c
index 81f2b9eff..a2ad0b905 100644
--- a/src/gns/plugin_gnsrecord_gns.c
+++ b/src/gns/plugin_gnsrecord_gns.c
@@ -50,13 +50,18 @@ 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 case GNUNET_GNSRECORD_TYPE_EDKEY:
59 if (GNUNET_OK != GNUNET_GNSRECORD_identity_from_data (data,
60 data_size,
61 type,
62 &pk))
58 return NULL; 63 return NULL;
59 return GNUNET_CRYPTO_ecdsa_public_key_to_string (data); 64 return GNUNET_IDENTITY_public_key_to_string (&pk);
60 65
61 case GNUNET_GNSRECORD_TYPE_NICK: 66 case GNUNET_GNSRECORD_TYPE_NICK:
62 return GNUNET_strndup (data, data_size); 67 return GNUNET_strndup (data, data_size);
@@ -153,24 +158,35 @@ gns_string_to_value (void *cls,
153 void **data, 158 void **data,
154 size_t *data_size) 159 size_t *data_size)
155{ 160{
156 struct GNUNET_CRYPTO_EcdsaPublicKey pkey; 161 struct GNUNET_IDENTITY_PublicKey pk;
162 uint32_t record_type;
157 163
158 if (NULL == s) 164 if (NULL == s)
159 return GNUNET_SYSERR; 165 return GNUNET_SYSERR;
160 switch (type) 166 switch (type)
161 { 167 {
162 case GNUNET_GNSRECORD_TYPE_PKEY: 168 case GNUNET_GNSRECORD_TYPE_PKEY:
169 case GNUNET_GNSRECORD_TYPE_EDKEY:
163 if (GNUNET_OK != 170 if (GNUNET_OK !=
164 GNUNET_CRYPTO_ecdsa_public_key_from_string (s, strlen (s), &pkey)) 171 GNUNET_IDENTITY_public_key_from_string (s, &pk))
165 { 172 {
166 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 173 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
167 _ ("Unable to parse PKEY record `%s'\n"), 174 _ ("Unable to parse zone key record `%s'\n"),
168 s); 175 s);
169 return GNUNET_SYSERR; 176 return GNUNET_SYSERR;
170 } 177 }
171 *data = GNUNET_new (struct GNUNET_CRYPTO_EcdsaPublicKey); 178 *data_size = GNUNET_IDENTITY_key_get_length (&pk);
172 GNUNET_memcpy (*data, &pkey, sizeof(pkey)); 179 if (GNUNET_OK != GNUNET_GNSRECORD_data_from_identity (&pk,
173 *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 }
174 return GNUNET_OK; 190 return GNUNET_OK;
175 191
176 case GNUNET_GNSRECORD_TYPE_NICK: 192 case GNUNET_GNSRECORD_TYPE_NICK:
@@ -301,6 +317,7 @@ static struct
301 const char *name; 317 const char *name;
302 uint32_t number; 318 uint32_t number;
303} gns_name_map[] = { { "PKEY", GNUNET_GNSRECORD_TYPE_PKEY }, 319} gns_name_map[] = { { "PKEY", GNUNET_GNSRECORD_TYPE_PKEY },
320 { "EDKEY", GNUNET_GNSRECORD_TYPE_PKEY },
304 { "NICK", GNUNET_GNSRECORD_TYPE_NICK }, 321 { "NICK", GNUNET_GNSRECORD_TYPE_NICK },
305 { "LEHO", GNUNET_GNSRECORD_TYPE_LEHO }, 322 { "LEHO", GNUNET_GNSRECORD_TYPE_LEHO },
306 { "VPN", GNUNET_GNSRECORD_TYPE_VPN }, 323 { "VPN", GNUNET_GNSRECORD_TYPE_VPN },