aboutsummaryrefslogtreecommitdiff
path: root/src/include/gnunet_gnsrecord_lib.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/include/gnunet_gnsrecord_lib.h')
-rw-r--r--src/include/gnunet_gnsrecord_lib.h125
1 files changed, 109 insertions, 16 deletions
diff --git a/src/include/gnunet_gnsrecord_lib.h b/src/include/gnunet_gnsrecord_lib.h
index 960203fb1..0bf2ceed7 100644
--- a/src/include/gnunet_gnsrecord_lib.h
+++ b/src/include/gnunet_gnsrecord_lib.h
@@ -34,6 +34,8 @@
34#ifndef GNUNET_GNSRECORD_LIB_H 34#ifndef GNUNET_GNSRECORD_LIB_H
35#define GNUNET_GNSRECORD_LIB_H 35#define GNUNET_GNSRECORD_LIB_H
36 36
37#include "gnunet_identity_service.h"
38
37#ifdef __cplusplus 39#ifdef __cplusplus
38extern "C" { 40extern "C" {
39#if 0 /* keep Emacsens' auto-indent happy */ 41#if 0 /* keep Emacsens' auto-indent happy */
@@ -55,7 +57,7 @@ extern "C" {
55/** 57/**
56 * Record type for GNS zone transfer ("PKEY"). 58 * Record type for GNS zone transfer ("PKEY").
57 */ 59 */
58#define GNUNET_GNSRECORD_TYPE_PKEY 65536 60#define GNUNET_GNSRECORD_TYPE_PKEY GNUNET_IDENTITY_TYPE_ECDSA
59 61
60/** 62/**
61 * Record type for GNS nick names ("NICK"). 63 * Record type for GNS nick names ("NICK").
@@ -151,6 +153,11 @@ extern "C" {
151 */ 153 */
152#define GNUNET_GNSRECORD_TYPE_RECLAIM_PRESENTATION 65555 154#define GNUNET_GNSRECORD_TYPE_RECLAIM_PRESENTATION 65555
153 155
156/**
157 * Record type for EDKEY delegations.
158 */
159#define GNUNET_GNSRECORD_TYPE_EDKEY GNUNET_IDENTITY_TYPE_EDDSA
160
154 161
155/** 162/**
156 * Flags that can be set for a record. 163 * Flags that can be set for a record.
@@ -261,21 +268,20 @@ struct GNUNET_GNSRECORD_PlaceData
261 /* Followed by struct GNUNET_PeerIdentity relays[relay_count] */ 268 /* Followed by struct GNUNET_PeerIdentity relays[relay_count] */
262}; 269};
263 270
264
265/** 271/**
266 * Information we have in an encrypted block with record data (i.e. in the DHT). 272 * Information we have in an encrypted block with record data (i.e. in the DHT).
267 */ 273 */
268struct GNUNET_GNSRECORD_Block 274struct GNUNET_GNSRECORD_EcdsaBlock
269{ 275{
270 /** 276 /**
271 * Signature of the block. 277 * Derived key used for signing; hash of this is the query.
272 */ 278 */
273 struct GNUNET_CRYPTO_EcdsaSignature signature; 279 struct GNUNET_CRYPTO_EcdsaPublicKey derived_key;
274 280
275 /** 281 /**
276 * Derived key used for signing; hash of this is the query. 282 * Signature of the block.
277 */ 283 */
278 struct GNUNET_CRYPTO_EcdsaPublicKey derived_key; 284 struct GNUNET_CRYPTO_EcdsaSignature signature;
279 285
280 /** 286 /**
281 * Number of bytes signed; also specifies the number of bytes 287 * Number of bytes signed; also specifies the number of bytes
@@ -291,6 +297,17 @@ struct GNUNET_GNSRECORD_Block
291 /* followed by encrypted data */ 297 /* followed by encrypted data */
292}; 298};
293 299
300struct GNUNET_GNSRECORD_Block
301{
302 uint32_t type;
303
304 union
305 {
306 struct GNUNET_GNSRECORD_EcdsaBlock ecdsa_block;
307 //struct GNUNET_GNSRECORD_EddsaBlock eddsa_block;
308 };
309};
310
294 311
295/** 312/**
296 * Record type used to box up SRV and TLSA records. For example, a 313 * Record type used to box up SRV and TLSA records. For example, a
@@ -335,7 +352,7 @@ struct GNUNET_GNSRECORD_ReverseRecord
335 /** 352 /**
336 * The public key of the namespace the is delegating to our namespace 353 * The public key of the namespace the is delegating to our namespace
337 */ 354 */
338 struct GNUNET_CRYPTO_EcdsaPublicKey pkey; 355 struct GNUNET_IDENTITY_PublicKey pkey;
339 356
340 /** 357 /**
341 * The expiration time of the delegation 358 * The expiration time of the delegation
@@ -488,7 +505,7 @@ GNUNET_GNSRECORD_string_to_lowercase (const char *src);
488 * #GNUNET_GNSRECORD_z2s. 505 * #GNUNET_GNSRECORD_z2s.
489 */ 506 */
490const char * 507const char *
491GNUNET_GNSRECORD_z2s (const struct GNUNET_CRYPTO_EcdsaPublicKey *z); 508GNUNET_GNSRECORD_z2s (const struct GNUNET_IDENTITY_PublicKey *z);
492 509
493 510
494/** 511/**
@@ -502,7 +519,7 @@ GNUNET_GNSRECORD_z2s (const struct GNUNET_CRYPTO_EcdsaPublicKey *z);
502 * key in an encoding suitable for DNS labels. 519 * key in an encoding suitable for DNS labels.
503 */ 520 */
504const char * 521const char *
505GNUNET_GNSRECORD_pkey_to_zkey (const struct GNUNET_CRYPTO_EcdsaPublicKey *pkey); 522GNUNET_GNSRECORD_pkey_to_zkey (const struct GNUNET_IDENTITY_PublicKey *pkey);
506 523
507 524
508/** 525/**
@@ -516,7 +533,7 @@ GNUNET_GNSRECORD_pkey_to_zkey (const struct GNUNET_CRYPTO_EcdsaPublicKey *pkey);
516 */ 533 */
517int 534int
518GNUNET_GNSRECORD_zkey_to_pkey (const char *zkey, 535GNUNET_GNSRECORD_zkey_to_pkey (const char *zkey,
519 struct GNUNET_CRYPTO_EcdsaPublicKey *pkey); 536 struct GNUNET_IDENTITY_PublicKey *pkey);
520 537
521 538
522/** 539/**
@@ -528,7 +545,7 @@ GNUNET_GNSRECORD_zkey_to_pkey (const char *zkey,
528 */ 545 */
529void 546void
530GNUNET_GNSRECORD_query_from_private_key ( 547GNUNET_GNSRECORD_query_from_private_key (
531 const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, const char *label, 548 const struct GNUNET_IDENTITY_PrivateKey *zone, const char *label,
532 struct GNUNET_HashCode *query); 549 struct GNUNET_HashCode *query);
533 550
534 551
@@ -541,7 +558,7 @@ GNUNET_GNSRECORD_query_from_private_key (
541 */ 558 */
542void 559void
543GNUNET_GNSRECORD_query_from_public_key ( 560GNUNET_GNSRECORD_query_from_public_key (
544 const struct GNUNET_CRYPTO_EcdsaPublicKey *pub, const char *label, 561 const struct GNUNET_IDENTITY_PublicKey *pub, const char *label,
545 struct GNUNET_HashCode *query); 562 struct GNUNET_HashCode *query);
546 563
547 564
@@ -555,7 +572,7 @@ GNUNET_GNSRECORD_query_from_public_key (
555 * @param rd_count number of records in @a rd 572 * @param rd_count number of records in @a rd
556 */ 573 */
557struct GNUNET_GNSRECORD_Block * 574struct GNUNET_GNSRECORD_Block *
558GNUNET_GNSRECORD_block_create (const struct GNUNET_CRYPTO_EcdsaPrivateKey *key, 575GNUNET_GNSRECORD_block_create (const struct GNUNET_IDENTITY_PrivateKey *key,
559 struct GNUNET_TIME_Absolute expire, 576 struct GNUNET_TIME_Absolute expire,
560 const char *label, 577 const char *label,
561 const struct GNUNET_GNSRECORD_Data *rd, 578 const struct GNUNET_GNSRECORD_Data *rd,
@@ -574,7 +591,7 @@ GNUNET_GNSRECORD_block_create (const struct GNUNET_CRYPTO_EcdsaPrivateKey *key,
574 * @param rd_count number of records in @a rd 591 * @param rd_count number of records in @a rd
575 */ 592 */
576struct GNUNET_GNSRECORD_Block * 593struct GNUNET_GNSRECORD_Block *
577GNUNET_GNSRECORD_block_create2 (const struct GNUNET_CRYPTO_EcdsaPrivateKey *key, 594GNUNET_GNSRECORD_block_create2 (const struct GNUNET_IDENTITY_PrivateKey *key,
578 struct GNUNET_TIME_Absolute expire, 595 struct GNUNET_TIME_Absolute expire,
579 const char *label, 596 const char *label,
580 const struct GNUNET_GNSRECORD_Data *rd, 597 const struct GNUNET_GNSRECORD_Data *rd,
@@ -606,7 +623,7 @@ GNUNET_GNSRECORD_block_verify (const struct GNUNET_GNSRECORD_Block *block);
606int 623int
607GNUNET_GNSRECORD_block_decrypt ( 624GNUNET_GNSRECORD_block_decrypt (
608 const struct GNUNET_GNSRECORD_Block *block, 625 const struct GNUNET_GNSRECORD_Block *block,
609 const struct GNUNET_CRYPTO_EcdsaPublicKey *zone_key, const char *label, 626 const struct GNUNET_IDENTITY_PublicKey *zone_key, const char *label,
610 GNUNET_GNSRECORD_RecordCallback proc, void *proc_cls); 627 GNUNET_GNSRECORD_RecordCallback proc, void *proc_cls);
611 628
612 629
@@ -636,6 +653,82 @@ GNUNET_GNSRECORD_record_get_expiration_time (
636 unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd); 653 unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd);
637 654
638 655
656/**
657 * Returns the length of this block in bytes.
658 * Block length strongly depends on the zone type.
659 *
660 * @param block the block.
661 * @return the length of this block in bytes
662 */
663size_t
664GNUNET_GNSRECORD_block_get_size (const struct GNUNET_GNSRECORD_Block *block);
665
666/**
667 * Returns the expiration of a block.
668 *
669 * @param block the block.
670 * @return the block expiration.
671 */
672struct GNUNET_TIME_Absolute
673GNUNET_GNSRECORD_block_get_expiration (const struct GNUNET_GNSRECORD_Block *block);
674
675
676/**
677 * Builds the query hash from a block.
678 *
679 * @param block the block.
680 * @param query where to write the query hash.
681 * @return GNUNET_SYSERR on error.
682 */
683enum GNUNET_GenericReturnValue
684GNUNET_GNSRECORD_query_from_block (const struct GNUNET_GNSRECORD_Block *block,
685 struct GNUNET_HashCode *query);
686
687
688/**
689 * Build a #GNUNET_GNSRECORD_PublicKey from
690 * zone delegation resource record data.
691 *
692 * @param data the record data-
693 * @param data_size the data size.
694 * @param type the record type
695 * @param key the identity key to store the data in (must be allocated).
696 * @return GNUNET_OK if successful.
697 */
698enum GNUNET_GenericReturnValue
699GNUNET_GNSRECORD_identity_from_data (const char *data,
700 size_t data_size,
701 uint32_t type,
702 struct GNUNET_IDENTITY_PublicKey *key);
703
704
705/**
706 * Create record data and size from an identity key.
707 *
708 * @param key the identity key to use.
709 * @param data the record data (will be allocated)
710 * @param data_size the allocated data size.
711 * @param type the resulting record type
712 * @return GNUNET_OK if successful.
713 */
714enum GNUNET_GenericReturnValue
715GNUNET_GNSRECORD_data_from_identity (const struct GNUNET_IDENTITY_PublicKey *key,
716 char **data,
717 size_t *data_size,
718 uint32_t *type);
719
720
721/**
722 * Check if this type is one of the supported GNS zone
723 * types.
724 *
725 * @param type the type to check
726 * @return GNUNET_YES if it is one of the supported types.
727 */
728enum GNUNET_GenericReturnValue
729GNUNET_GNSRECORD_is_zonekey_type (uint32_t type);
730
731
639#if 0 /* keep Emacsens' auto-indent happy */ 732#if 0 /* keep Emacsens' auto-indent happy */
640{ 733{
641#endif 734#endif