diff options
author | Martin Schanzenbach <mschanzenbach@posteo.de> | 2020-10-14 22:31:38 +0200 |
---|---|---|
committer | Martin Schanzenbach <mschanzenbach@posteo.de> | 2020-10-15 12:11:19 +0200 |
commit | 25eb1fb2acbe92b418d8643c06107ce0ab2bfb9a (patch) | |
tree | 97ba1f700217697979449cec7528b4eab5e22a22 /src/gnsrecord/gnsrecord_misc.c | |
parent | 96c802b46be51e5c45f34e2de823f787d26c2929 (diff) | |
download | gnunet-25eb1fb2acbe92b418d8643c06107ce0ab2bfb9a.tar.gz gnunet-25eb1fb2acbe92b418d8643c06107ce0ab2bfb9a.zip |
- better wire format for rrblocks
Diffstat (limited to 'src/gnsrecord/gnsrecord_misc.c')
-rw-r--r-- | src/gnsrecord/gnsrecord_misc.c | 54 |
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 | ||
275 | size_t | ||
276 | GNUNET_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 | |||
293 | struct GNUNET_TIME_Absolute | ||
294 | GNUNET_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 | |||
310 | enum GNUNET_GenericReturnValue | ||
311 | GNUNET_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 */ |