aboutsummaryrefslogtreecommitdiff
path: root/src/gnsrecord/gnsrecord_misc.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/gnsrecord/gnsrecord_misc.c')
-rw-r--r--src/gnsrecord/gnsrecord_misc.c47
1 files changed, 47 insertions, 0 deletions
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
275enum GNUNET_GenericReturnValue
276GNUNET_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
290enum GNUNET_GenericReturnValue
291GNUNET_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
307enum GNUNET_GenericReturnValue
308GNUNET_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
275size_t 320size_t
276GNUNET_GNSRECORD_block_get_size (const struct GNUNET_GNSRECORD_Block *block) 321GNUNET_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
328enum GNUNET_GenericReturnValue 374enum GNUNET_GenericReturnValue
329GNUNET_GNSRECORD_record_to_identity_key (const struct GNUNET_GNSRECORD_Data *rd, 375GNUNET_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 */