diff options
Diffstat (limited to 'src/gnsrecord/gnsrecord_misc.c')
-rw-r--r-- | src/gnsrecord/gnsrecord_misc.c | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/src/gnsrecord/gnsrecord_misc.c b/src/gnsrecord/gnsrecord_misc.c index fe6af44c0..662c64713 100644 --- a/src/gnsrecord/gnsrecord_misc.c +++ b/src/gnsrecord/gnsrecord_misc.c | |||
@@ -266,10 +266,20 @@ GNUNET_GNSRECORD_identity_from_data (const char *data, | |||
266 | return GNUNET_SYSERR; | 266 | return GNUNET_SYSERR; |
267 | if (data_size > sizeof (struct GNUNET_IDENTITY_PublicKey)) | 267 | if (data_size > sizeof (struct GNUNET_IDENTITY_PublicKey)) |
268 | return GNUNET_SYSERR; | 268 | return GNUNET_SYSERR; |
269 | return (GNUNET_IDENTITY_read_key_from_buffer (key, data, data_size) == | 269 | switch (type) |
270 | data_size? | 270 | { |
271 | GNUNET_OK : | 271 | case GNUNET_GNSRECORD_TYPE_PKEY: |
272 | GNUNET_SYSERR); | 272 | memcpy (&key->ecdsa_key, data, data_size); |
273 | break; | ||
274 | case GNUNET_GNSRECORD_TYPE_EDKEY: | ||
275 | memcpy (&key->eddsa_key, data, data_size); | ||
276 | break; | ||
277 | default: | ||
278 | return GNUNET_NO; | ||
279 | } | ||
280 | key->type = htonl (type); | ||
281 | |||
282 | return GNUNET_YES; | ||
273 | } | 283 | } |
274 | 284 | ||
275 | 285 | ||
@@ -282,17 +292,11 @@ GNUNET_GNSRECORD_data_from_identity (const struct | |||
282 | { | 292 | { |
283 | char *tmp; | 293 | char *tmp; |
284 | *type = ntohl (key->type); | 294 | *type = ntohl (key->type); |
285 | *data_size = GNUNET_IDENTITY_key_get_length (key); | 295 | *data_size = GNUNET_IDENTITY_key_get_length (key) - sizeof (key->type); |
286 | if (0 == *data_size) | 296 | if (0 == *data_size) |
287 | return GNUNET_SYSERR; | 297 | return GNUNET_SYSERR; |
288 | tmp = GNUNET_malloc (*data_size); | 298 | tmp = GNUNET_malloc (*data_size); |
289 | if (GNUNET_IDENTITY_write_key_to_buffer (key, tmp, *data_size) | 299 | memcpy (tmp, ((char*)key) + sizeof (key->type), *data_size); |
290 | != *data_size) | ||
291 | { | ||
292 | GNUNET_free (tmp); | ||
293 | *data_size = 0; | ||
294 | return GNUNET_SYSERR; | ||
295 | } | ||
296 | *data = tmp; | 300 | *data = tmp; |
297 | return GNUNET_OK; | 301 | return GNUNET_OK; |
298 | } | 302 | } |