diff options
Diffstat (limited to 'src/include/gnunet_gnsrecord_lib.h')
-rw-r--r-- | src/include/gnunet_gnsrecord_lib.h | 93 |
1 files changed, 77 insertions, 16 deletions
diff --git a/src/include/gnunet_gnsrecord_lib.h b/src/include/gnunet_gnsrecord_lib.h index 960203fb1..530879b21 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 |
38 | extern "C" { | 40 | extern "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 | */ |
268 | struct GNUNET_GNSRECORD_Block | 274 | struct 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 | ||
300 | struct 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 | */ |
490 | const char * | 507 | const char * |
491 | GNUNET_GNSRECORD_z2s (const struct GNUNET_CRYPTO_EcdsaPublicKey *z); | 508 | GNUNET_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 | */ |
504 | const char * | 521 | const char * |
505 | GNUNET_GNSRECORD_pkey_to_zkey (const struct GNUNET_CRYPTO_EcdsaPublicKey *pkey); | 522 | GNUNET_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 | */ |
517 | int | 534 | int |
518 | GNUNET_GNSRECORD_zkey_to_pkey (const char *zkey, | 535 | GNUNET_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 | */ |
529 | void | 546 | void |
530 | GNUNET_GNSRECORD_query_from_private_key ( | 547 | GNUNET_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 | */ |
542 | void | 559 | void |
543 | GNUNET_GNSRECORD_query_from_public_key ( | 560 | GNUNET_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 | */ |
557 | struct GNUNET_GNSRECORD_Block * | 574 | struct GNUNET_GNSRECORD_Block * |
558 | GNUNET_GNSRECORD_block_create (const struct GNUNET_CRYPTO_EcdsaPrivateKey *key, | 575 | GNUNET_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 | */ |
576 | struct GNUNET_GNSRECORD_Block * | 593 | struct GNUNET_GNSRECORD_Block * |
577 | GNUNET_GNSRECORD_block_create2 (const struct GNUNET_CRYPTO_EcdsaPrivateKey *key, | 594 | GNUNET_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); | |||
606 | int | 623 | int |
607 | GNUNET_GNSRECORD_block_decrypt ( | 624 | GNUNET_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,50 @@ 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 | */ | ||
663 | size_t | ||
664 | GNUNET_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 | */ | ||
672 | struct GNUNET_TIME_Absolute | ||
673 | GNUNET_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 | */ | ||
683 | enum GNUNET_GenericReturnValue | ||
684 | GNUNET_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 a | ||
690 | * zone delegation resource record set. | ||
691 | * | ||
692 | * @param the resource record set. MUST be a delegation record. | ||
693 | * @param key where to write the identtiy key. | ||
694 | * @return GNUNET_SYSERR on error or if the zone is not a delegation zone. | ||
695 | */ | ||
696 | enum GNUNET_GenericReturnValue | ||
697 | GNUNET_GNSRECORD_record_to_identity_key (const struct GNUNET_GNSRECORD_Data *rd, | ||
698 | struct GNUNET_IDENTITY_PublicKey *key); | ||
699 | |||
639 | #if 0 /* keep Emacsens' auto-indent happy */ | 700 | #if 0 /* keep Emacsens' auto-indent happy */ |
640 | { | 701 | { |
641 | #endif | 702 | #endif |