GNUnet 0.22.2
gnunet_gnsrecord_lib.h
Go to the documentation of this file.
1/*
2 This file is part of GNUnet
3 Copyright (C) 2012, 2013 GNUnet e.V.
4
5 GNUnet is free software: you can redistribute it and/or modify it
6 under the terms of the GNU Affero General Public License as published
7 by the Free Software Foundation, either version 3 of the License,
8 or (at your option) any later version.
9
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Affero General Public License for more details.
14
15 You should have received a copy of the GNU Affero General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18 SPDX-License-Identifier: AGPL3.0-or-later
19 */
20
37#ifndef GNUNET_GNSRECORD_LIB_H
38#define GNUNET_GNSRECORD_LIB_H
39
40
41#include "gnunet_common.h"
43
44#ifdef __cplusplus
45extern "C" {
46#if 0 /* keep Emacsens' auto-indent happy */
47}
48#endif
49#endif
50
55#define GNUNET_GNS_EMPTY_LABEL_AT "@"
56
60#define GNUNET_GNSRECORD_MAX_BLOCK_SIZE (63 * 1024)
61
62
66#define GNUNET_GNSRECORD_TYPE_ANY 0
67
71#include "gnu_name_system_record_types.h"
72
84#define GNUNET_GNSRECORD_RF_RCMP_FLAGS (GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION)
85
86
100{
105
106
111
112
117
118
123
128
133
134
139
140};
141
142
147{
154
159
164
169 // GNUNET_NAMESTORE_FILTER_OMIT_PUBLIC = 4,
170};
171
172
177{
183 const void *data;
184
191
195 size_t data_size;
196
200 uint32_t record_type;
201
206};
207
208
210
215{
220
225
230
231 /* Followed by struct GNUNET_PeerIdentity relays[relay_count] */
232};
233
238{
243
248
253
254 /* followed by encrypted data */
255};
256
257
262{
267
272
277
278
279 /* followed by encrypted data */
280};
281
282
284{
288 uint32_t size;
289
293 uint32_t type;
294
295 union
296 {
299 };
300};
301
302
314{
320
325
330
331 /* followed by the 'original' record */
332};
333
334
348{
353
354 /* followed by the zero terminated hostname prefix */
355 /* followed by the 'original' record */
356};
357
358
367{
372
377
378 /* followed by the name the delegator uses to refer to our namespace */
379};
380
381
390 void *cls, unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd);
391
392
393/* ***************** API related to GNSRECORD plugins ************** */
394
404char *
405GNUNET_GNSRECORD_value_to_string (uint32_t type, const void *data,
406 size_t data_size);
407
408
419int
420GNUNET_GNSRECORD_string_to_value (uint32_t type, const char *s, void **data,
421 size_t *data_size);
422
423
430uint32_t
431GNUNET_GNSRECORD_typename_to_number (const char *dns_typename);
432
433
440const char *
442
443
444/* convenience APIs for serializing / deserializing GNS records */
445
454ssize_t
456 const struct GNUNET_GNSRECORD_Data *rd);
457
458
468ssize_t
470 const struct GNUNET_GNSRECORD_Data *rd,
471 size_t dest_size, char *dest);
472
473unsigned int
475 const char *src);
476
486int
487GNUNET_GNSRECORD_records_deserialize (size_t len, const char *src,
488 unsigned int rd_count,
490
491
492/* ******* general APIs relating to blocks, records and labels ******** */
493
494
502int
504
505
512char *
513GNUNET_GNSRECORD_string_normalize (const char *src);
514
515
525const char *
527
528
539const char *
541
542
552int
553GNUNET_GNSRECORD_zkey_to_pkey (const char *zkey,
555
556
564void
566 const struct GNUNET_CRYPTO_PrivateKey *zone, const char *label,
567 struct GNUNET_HashCode *query);
568
569
578void
580 const struct GNUNET_CRYPTO_PublicKey *pub, const char *label,
581 struct GNUNET_HashCode *query);
582
583
592ssize_t
595 const struct GNUNET_GNSRECORD_Data *rd,
596 unsigned int rd_count);
597
607GNUNET_GNSRECORD_block_sign (const struct
609 const char *label,
610 struct GNUNET_GNSRECORD_Block *block);
611
626 const char *label,
627 const struct GNUNET_GNSRECORD_Data *rd,
628 unsigned int rd_count,
629 struct GNUNET_GNSRECORD_Block **block);
630
631
651 const char *label,
652 const struct GNUNET_GNSRECORD_Data *rd,
653 unsigned int rd_count,
655
656
673 const char *label,
674 const struct GNUNET_GNSRECORD_Data *rd,
675 unsigned int rd_count,
677
678
688
689
703 const struct GNUNET_GNSRECORD_Block *block,
704 const struct GNUNET_CRYPTO_PublicKey *zone_key, const char *label,
705 GNUNET_GNSRECORD_RecordCallback proc, void *proc_cls);
706
707
717 const struct GNUNET_GNSRECORD_Data *b);
718
719
732 const struct
735
736
744size_t
746
756
757
767 struct GNUNET_HashCode *query);
768
769
782 size_t data_size,
783 uint32_t type,
785
786
799 char **data,
800 size_t *data_size,
801 uint32_t *type);
802
803
813
822
843 const struct GNUNET_GNSRECORD_Data *rd,
844 unsigned int rd_count,
845 struct GNUNET_GNSRECORD_Data *rd_public,
846 unsigned int *rd_count_public,
847 struct GNUNET_TIME_Absolute *min_expiry,
849 char **emsg);
850
859GNUNET_GNSRECORD_label_check (const char*label, char **emsg);
860
864#define GNUNET_MAX_POW_SIZE sizeof(struct GNUNET_GNSRECORD_PowP) \
865 + sizeof(struct GNUNET_CRYPTO_PublicKey) \
866 + 1024 // FIXME max sig_len
867
872#define POW_COUNT 32
873
874
876
881{
886
891
896
898};
899
900
905{
910
915
917};
918
920
921
926
927
938 unsigned int matching_bits,
940
941
948void
950 struct GNUNET_GNSRECORD_PowP *pow);
951
952
964 int epochs,
965 unsigned int difficulty);
966
967
976
977size_t
979
987void
989
990#if 0 /* keep Emacsens' auto-indent happy */
991{
992#endif
993#ifdef __cplusplus
994}
995#endif
996
997#endif
998 /* end of group */
1000 /* end of group addition */
static char * data
The data to insert into the dht.
struct GNUNET_HashCode key
The key used in the DHT.
static char * expire
DID Document expiration Date Attribute String.
Definition: gnunet-did.c:97
static char * pkey
Public key of the zone to look in, in ASCII.
static unsigned int rd_count
Number of records for currently parsed set.
static struct GNUNET_GNSRECORD_Data rd[50]
The record data under a single label.
static uint32_t type
Type string converted to DNS type value.
static size_t data_size
Number of bytes in data.
static struct GNUNET_FS_PublishContext * pc
Handle to FS-publishing operation.
static int result
Global testing status.
static struct GNUNET_TIME_Relative epoch_duration
Epoch length.
static unsigned long long matching_bits
Number of matching bits required for revocation.
static unsigned int epochs
-e option.
static struct GNUNET_CRYPTO_EddsaPublicKey pub
Definition: gnunet-scrypt.c:47
static struct GNUNET_CONTAINER_BloomFilter * filter
Bloomfilter to quickly tell if we don't have the content.
commonly used definitions; globals in this file are exempt from the rule that the module name ("commo...
Identity service; implements identity management for GNUnet.
enum GNUNET_GenericReturnValue GNUNET_GNSRECORD_label_check(const char *label, char **emsg)
Check label for invalid characters.
GNUNET_GNSRECORD_Flags
Flags that can be set for a record.
void GNUNET_GNSRECORD_query_from_public_key(const struct GNUNET_CRYPTO_PublicKey *pub, const char *label, struct GNUNET_HashCode *query)
Calculate the DHT query for a given label in a given zone.
const char * GNUNET_GNSRECORD_number_to_typename(uint32_t type)
Convert a type number to the corresponding type string (e.g.
Definition: gnsrecord.c:219
const char * GNUNET_GNSRECORD_z2s(const struct GNUNET_CRYPTO_PublicKey *z)
Convert a zone to a string (for printing debug messages).
enum GNUNET_GenericReturnValue GNUNET_GNSRECORD_block_create(const struct GNUNET_CRYPTO_PrivateKey *key, struct GNUNET_TIME_Absolute expire, const char *label, const struct GNUNET_GNSRECORD_Data *rd, unsigned int rd_count, struct GNUNET_GNSRECORD_Block **block)
Sign name and records.
ssize_t GNUNET_GNSRECORD_block_calculate_size(const struct GNUNET_CRYPTO_PrivateKey *key, const struct GNUNET_GNSRECORD_Data *rd, unsigned int rd_count)
Get size of buffer for block creation.
int GNUNET_GNSRECORD_records_deserialize(size_t len, const char *src, unsigned int rd_count, struct GNUNET_GNSRECORD_Data *dest)
Deserialize the given records to the given destination.
size_t GNUNET_GNSRECORD_proof_get_size(const struct GNUNET_GNSRECORD_PowP *pow)
enum GNUNET_GenericReturnValue GNUNET_GNSRECORD_block_create_unsigned(const struct GNUNET_CRYPTO_PrivateKey *key, struct GNUNET_TIME_Absolute expire, const char *label, const struct GNUNET_GNSRECORD_Data *rd, unsigned int rd_count, struct GNUNET_GNSRECORD_Block **result)
Create name and records but do not sign! Sign later with GNUNET_GNSRECORD_block_sign().
uint32_t GNUNET_GNSRECORD_typename_to_number(const char *dns_typename)
Convert a type name (e.g.
Definition: gnsrecord.c:192
ssize_t GNUNET_GNSRECORD_records_serialize(unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd, size_t dest_size, char *dest)
Serialize the given records to the given destination buffer.
int GNUNET_GNSRECORD_string_to_value(uint32_t type, const char *s, void **data, size_t *data_size)
Convert human-readable version of the value s of a record of type type to the respective binary repre...
Definition: gnsrecord.c:169
void GNUNET_GNSRECORD_query_from_private_key(const struct GNUNET_CRYPTO_PrivateKey *zone, const char *label, struct GNUNET_HashCode *query)
Calculate the DHT query for a given label in a given zone.
int GNUNET_GNSRECORD_zkey_to_pkey(const char *zkey, struct GNUNET_CRYPTO_PublicKey *pkey)
Convert an absolute domain name to the respective public key.
enum GNUNET_GenericReturnValue GNUNET_GNSRECORD_data_from_identity(const struct GNUNET_CRYPTO_PublicKey *key, char **data, size_t *data_size, uint32_t *type)
Create record data and size from an identity key.
#define POW_COUNT
The proof-of-work narrowing factor.
struct GNUNET_TIME_Absolute GNUNET_GNSRECORD_record_get_expiration_time(unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd, struct GNUNET_TIME_Absolute min)
Returns the expiration time of the given block of records.
enum GNUNET_GenericReturnValue GNUNET_GNSRECORD_block_decrypt(const struct GNUNET_GNSRECORD_Block *block, const struct GNUNET_CRYPTO_PublicKey *zone_key, const char *label, GNUNET_GNSRECORD_RecordCallback proc, void *proc_cls)
Decrypt block.
const char * GNUNET_GNSRECORD_pkey_to_zkey(const struct GNUNET_CRYPTO_PublicKey *pkey)
Convert public key to the respective absolute domain name in the ".zkey" pTLD.
enum GNUNET_GenericReturnValue GNUNET_GNSRECORD_block_verify(const struct GNUNET_GNSRECORD_Block *block)
Check if a signature is valid.
size_t GNUNET_GNSRECORD_block_get_size(const struct GNUNET_GNSRECORD_Block *block)
Returns the length of this block in bytes.
unsigned int GNUNET_GNSRECORD_records_deserialize_get_size(size_t len, const char *src)
void(* GNUNET_GNSRECORD_RecordCallback)(void *cls, unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd)
Process a records that were decrypted from a block.
enum GNUNET_GenericReturnValue GNUNET_GNSRECORD_records_cmp(const struct GNUNET_GNSRECORD_Data *a, const struct GNUNET_GNSRECORD_Data *b)
Compares if two records are equal.
enum GNUNET_GenericReturnValue GNUNET_GNSRECORD_query_from_block(const struct GNUNET_GNSRECORD_Block *block, struct GNUNET_HashCode *query)
Builds the query hash from a block.
enum GNUNET_GenericReturnValue GNUNET_GNSRECORD_identity_from_data(const char *data, size_t data_size, uint32_t type, struct GNUNET_CRYPTO_PublicKey *key)
Build a #GNUNET_GNSRECORD_PublicKey from zone delegation resource record data.
void GNUNET_GNSRECORD_pow_stop(struct GNUNET_GNSRECORD_PowCalculationHandle *pc)
Stop a PoW calculation.
enum GNUNET_GenericReturnValue GNUNET_GNSRECORD_pow_round(struct GNUNET_GNSRECORD_PowCalculationHandle *pc)
Calculate a single round in the key revocation PoW.
void GNUNET_GNSRECORD_pow_init(const struct GNUNET_CRYPTO_PrivateKey *key, struct GNUNET_GNSRECORD_PowP *pow)
Initializes a fresh PoW computation.
struct GNUNET_GNSRECORD_PowCalculationHandle * GNUNET_GNSRECORD_pow_start(struct GNUNET_GNSRECORD_PowP *pow, int epochs, unsigned int difficulty)
Starts a proof-of-work calculation given the pow object as well as target epochs and difficulty.
int GNUNET_GNSRECORD_is_expired(const struct GNUNET_GNSRECORD_Data *rd)
Test if a given record is expired.
ssize_t GNUNET_GNSRECORD_records_get_size(unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd)
Calculate how many bytes we will need to serialize the given records.
enum GNUNET_GenericReturnValue GNUNET_GNSRECORD_is_critical(uint32_t type)
Check if this type is a critical record.
Definition: gnsrecord.c:239
enum GNUNET_GenericReturnValue GNUNET_GNSRECORD_block_sign(const struct GNUNET_CRYPTO_PrivateKey *key, const char *label, struct GNUNET_GNSRECORD_Block *block)
Sign a block create with GNUNET_GNSRECORD_block_create_unsigned.
enum GNUNET_GenericReturnValue GNUNET_GNSRECORD_block_create2(const struct GNUNET_CRYPTO_PrivateKey *key, struct GNUNET_TIME_Absolute expire, const char *label, const struct GNUNET_GNSRECORD_Data *rd, unsigned int rd_count, struct GNUNET_GNSRECORD_Block **result)
Sign name and records, cache derived public key (also keeps the private key in static memory,...
enum GNUNET_GenericReturnValue GNUNET_GNSRECORD_is_zonekey_type(uint32_t type)
Check if this type is one of the supported GNS zone types.
char * GNUNET_GNSRECORD_string_normalize(const char *src)
Normalize a UTF-8 string to a GNS name.
GNUNET_GNSRECORD_Filter
Filter for GNUNET_GNSRECORD_normalize_record_set().
enum GNUNET_GenericReturnValue GNUNET_GNSRECORD_normalize_record_set(const char *label, const struct GNUNET_GNSRECORD_Data *rd, unsigned int rd_count, struct GNUNET_GNSRECORD_Data *rd_public, unsigned int *rd_count_public, struct GNUNET_TIME_Absolute *min_expiry, enum GNUNET_GNSRECORD_Filter filter, char **emsg)
Normalize namestore records: Check for consistency and expirations.
char * GNUNET_GNSRECORD_value_to_string(uint32_t type, const void *data, size_t data_size)
Convert the binary value data of a record of type type to a human-readable string.
Definition: gnsrecord.c:147
enum GNUNET_GenericReturnValue GNUNET_GNSRECORD_check_pow(const struct GNUNET_GNSRECORD_PowP *pow, unsigned int matching_bits, struct GNUNET_TIME_Relative epoch_duration)
Check if the given proof-of-work is valid.
struct GNUNET_TIME_Absolute GNUNET_GNSRECORD_block_get_expiration(const struct GNUNET_GNSRECORD_Block *block)
Returns the expiration of a block.
@ GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION
This expiration time of the record is a relative time (not an absolute time).
@ GNUNET_GNSRECORD_RF_CRITICAL
This record is critical.
@ GNUNET_GNSRECORD_RF_SUPPLEMENTAL
This is a supplemental record.
@ GNUNET_GNSRECORD_RF_MAINTENANCE
Maintenance records.
@ GNUNET_GNSRECORD_RF_SHADOW
This record should not be used unless all (other) records in the set with an absolute expiration time...
@ GNUNET_GNSRECORD_RF_PRIVATE
This is a private record of this peer and it should thus not be published.
@ GNUNET_GNSRECORD_RF_NONE
Entry for no flags / cleared flags.
@ GNUNET_GNSRECORD_FILTER_NONE
No filter flags set.
@ GNUNET_GNSRECORD_FILTER_INCLUDE_MAINTENANCE
Include maintenance records (TOMBSTONE etc).
@ GNUNET_GNSRECORD_FILTER_OMIT_PRIVATE
Filter private records.
#define GNUNET_NETWORK_STRUCT_BEGIN
Define as empty, GNUNET_PACKED should suffice, but this won't work on W32.
#define GNUNET_NETWORK_STRUCT_END
Define as empty, GNUNET_PACKED should suffice, but this won't work on W32;.
GNUNET_GenericReturnValue
Named constants for return values.
#define GNUNET_PACKED
gcc-ism to get packed structs.
#define min(x, y)
header of what an ECC signature signs this must be followed by "size - 8" bytes of the actual signed ...
Public ECC key (always for Curve25519) encoded in a format suitable for network transmission and ECDS...
an ECC signature using ECDSA
Public ECC key (always for curve Ed25519) encoded in a format suitable for network transmission and E...
an ECC signature using EdDSA.
A private key for an identity as per LSD0001.
An identity key as per LSD0001.
uint32_t type
The zone type (GNUNET_GNSRECORD_TYPE_PKEY)
struct GNUNET_GNSRECORD_EcdsaBlock ecdsa_block
struct GNUNET_GNSRECORD_EddsaBlock eddsa_block
uint32_t size
Size of the block.
Record type used to box up SRV and TLSA records.
uint32_t record_type
GNS record type of the boxed record.
uint16_t service
Service of the boxed record (aka port number), in NBO.
uint16_t protocol
Protocol of the boxed record (6 = TCP, 17 = UDP, etc.).
uint32_t record_type
Type of the GNS/DNS record.
const void * data
Binary value stored in the DNS record.
size_t data_size
Number of bytes in data.
enum GNUNET_GNSRECORD_Flags flags
Flags for the record.
uint64_t expiration_time
Expiration time for the DNS record.
Information we have in an encrypted block with record data (i.e.
struct GNUNET_CRYPTO_EcdsaSignature signature
Signature of the block.
struct GNUNET_TIME_AbsoluteNBO expiration_time
Expiration time of the block.
struct GNUNET_CRYPTO_EcdsaPublicKey derived_key
Derived key used for signing; hash of this is the query.
Information we have in an encrypted block with record data (i.e.
struct GNUNET_CRYPTO_EddsaPublicKey derived_key
Derived key used for signing; hash of this is the query.
struct GNUNET_TIME_AbsoluteNBO expiration_time
Expiration time of the block.
struct GNUNET_CRYPTO_EddsaSignature signature
Signature of the block.
Data stored in a PLACE record.
uint32_t relay_count
Number of relays that follow.
struct GNUNET_PeerIdentity origin
Peer identity of the origin.
struct GNUNET_CRYPTO_EddsaPublicKey place_pub_key
Public key of the place.
The handle to a PoW calculation.
Definition: gnsrecord_pow.c:55
unsigned int difficulty
The difficulty (leading zeros) to achieve.
Definition: gnsrecord_pow.c:80
struct GNUNET_GNSRECORD_PowP * pow
The final PoW result data structure.
Definition: gnsrecord_pow.c:64
Struct for a proof of work as part of the revocation.
struct GNUNET_TIME_AbsoluteNBO timestamp
The timestamp of the revocation.
uint64_t pow[32]
The PoWs.
struct GNUNET_TIME_RelativeNBO ttl
The TTL of this revocation (purely informational)
Record type used internally to keep track of reverse mappings into a namespace.
struct GNUNET_TIME_Absolute expiration
The expiration time of the delegation.
struct GNUNET_CRYPTO_PublicKey pkey
The public key of the namespace the is delegating to our namespace.
Record type used to box up SMIMEA records.
uint32_t record_type
GNS record type of the boxed record.
The signature object we use for the PoW.
struct GNUNET_TIME_AbsoluteNBO timestamp
The timestamp of the revocation.
struct GNUNET_CRYPTO_EccSignaturePurpose purpose
The signature purpose.
A 512-bit hashcode.
The identity of the host (wraps the signing key of the peer).
Time for absolute time used by GNUnet, in microseconds and in network byte order.
Time for absolute times used by GNUnet, in microseconds.
Time for relative time used by GNUnet, in microseconds and in network byte order.
Time for relative time used by GNUnet, in microseconds.