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.c54
1 files changed, 54 insertions, 0 deletions
diff --git a/src/gnsrecord/gnsrecord_misc.c b/src/gnsrecord/gnsrecord_misc.c
index 8b590e35f..baf13e963 100644
--- a/src/gnsrecord/gnsrecord_misc.c
+++ b/src/gnsrecord/gnsrecord_misc.c
@@ -272,4 +272,58 @@ GNUNET_GNSRECORD_zkey_to_pkey (const char *zkey,
272} 272}
273 273
274 274
275size_t
276GNUNET_GNSRECORD_block_get_size (const struct GNUNET_GNSRECORD_Block *block)
277{
278 switch (ntohl (block->type))
279 {
280 case GNUNET_GNSRECORD_TYPE_PKEY:
281 return sizeof (uint32_t) /* zone type */
282 + sizeof (block->ecdsa_block) /* EcdsaBlock */
283 + ntohl (block->ecdsa_block.purpose.size) /* Length of signed data */
284 - sizeof (block->ecdsa_block.purpose); /* Purpose already in EcdsaBlock */
285 break;
286 default:
287 return 0;
288 }
289 return 0;
290}
291
292
293struct GNUNET_TIME_Absolute
294GNUNET_GNSRECORD_block_get_expiration (const struct
295 GNUNET_GNSRECORD_Block *block)
296{
297
298 switch (ntohl (block->type))
299 {
300 case GNUNET_GNSRECORD_TYPE_PKEY:
301 return GNUNET_TIME_absolute_ntoh (block->ecdsa_block.expiration_time);
302 default:
303 return GNUNET_TIME_absolute_get_zero_ ();
304 }
305 return GNUNET_TIME_absolute_get_zero_ ();
306
307}
308
309
310enum GNUNET_GenericReturnValue
311GNUNET_GNSRECORD_query_from_block (const struct GNUNET_GNSRECORD_Block *block,
312 struct GNUNET_HashCode *query)
313{
314 switch (ntohl (block->type))
315 {
316 case GNUNET_GNSRECORD_TYPE_PKEY:
317 GNUNET_CRYPTO_hash (&block->ecdsa_block.derived_key,
318 sizeof (block->ecdsa_block.derived_key),
319 query);
320 return GNUNET_OK;
321 default:
322 return GNUNET_SYSERR;
323 }
324 return GNUNET_SYSERR;
325
326}
327
328
275/* end of gnsrecord_misc.c */ 329/* end of gnsrecord_misc.c */