aboutsummaryrefslogtreecommitdiff
path: root/src/gnsrecord
diff options
context:
space:
mode:
authorMartin Schanzenbach <mschanzenbach@posteo.de>2022-02-25 08:45:00 +0100
committerMartin Schanzenbach <mschanzenbach@posteo.de>2022-02-25 08:48:59 +0100
commit86e73d58ffc79ea706a5bc83867de3def4eaba48 (patch)
tree54cba66ad309dab2523bcff41ac29e79450fd64f /src/gnsrecord
parent6a7b95964b53d6ae4e7a7c54e08070bd6ddaa95e (diff)
downloadgnunet-86e73d58ffc79ea706a5bc83867de3def4eaba48.tar.gz
gnunet-86e73d58ffc79ea706a5bc83867de3def4eaba48.zip
-gix record handling
Diffstat (limited to 'src/gnsrecord')
-rw-r--r--src/gnsrecord/gnsrecord_misc.c28
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}