GNUnet  0.10.x
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 
34 #ifndef GNUNET_GNSRECORD_LIB_H
35 #define GNUNET_GNSRECORD_LIB_H
36 
37 #ifdef __cplusplus
38 extern "C" {
39 #if 0 /* keep Emacsens' auto-indent happy */
40 }
41 #endif
42 #endif
43 
47 #define GNUNET_GNSRECORD_MAX_BLOCK_SIZE (63 * 1024)
48 
49 
53 #define GNUNET_GNSRECORD_TYPE_ANY 0
54 
58 #define GNUNET_GNSRECORD_TYPE_PKEY 65536
59 
63 #define GNUNET_GNSRECORD_TYPE_NICK 65537
64 
68 #define GNUNET_GNSRECORD_TYPE_LEHO 65538
69 
73 #define GNUNET_GNSRECORD_TYPE_VPN 65539
74 
78 #define GNUNET_GNSRECORD_TYPE_GNS2DNS 65540
79 
83 #define GNUNET_GNSRECORD_TYPE_BOX 65541
84 
88 #define GNUNET_GNSRECORD_TYPE_PLACE 65542
89 
93 #define GNUNET_GNSRECORD_TYPE_PHONE 65543
94 
98 #define GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR 65544
99 
103 #define GNUNET_GNSRECORD_TYPE_RECLAIM_TICKET 65545
104 
112 #define GNUNET_GNSRECORD_TYPE_CREDENTIAL 65547
113 
117 #define GNUNET_GNSRECORD_TYPE_POLICY 65548
118 
122 #define GNUNET_GNSRECORD_TYPE_ATTRIBUTE 65549
123 
127 #define GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF 65550
128 
132 #define GNUNET_GNSRECORD_TYPE_RECLAIM_MASTER 65551
133 
137 #define GNUNET_GNSRECORD_TYPE_RECLAIM_OIDC_CLIENT 65552
138 
142 #define GNUNET_GNSRECORD_TYPE_RECLAIM_OIDC_REDIRECT 65553
143 
152 
158 
170 
176 
188 #define GNUNET_GNSRECORD_RF_RCMP_FLAGS (GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION)
189 };
190 
191 
201  const void *data;
202 
208  uint64_t expiration_time;
209 
213  size_t data_size;
214 
218  uint32_t record_type;
219 
224 };
225 
226 
228 
236  struct GNUNET_CRYPTO_EddsaPublicKey place_pub_key;
237 
241  struct GNUNET_PeerIdentity origin;
242 
246  uint32_t relay_count GNUNET_PACKED;
247 
248  /* Followed by struct GNUNET_PeerIdentity relays[relay_count] */
249 };
250 
251 
260 
264  struct GNUNET_CRYPTO_EcdsaPublicKey derived_key;
265 
271 
276 
277  /* followed by encrypted data */
278 };
279 
280 
296  uint16_t protocol GNUNET_PACKED;
297 
302 
307 
308  /* followed by the 'original' record */
309 };
310 
323 
328 
329  /* followed by the name the delegator uses to refer to our namespace */
330 };
331 
333 
334 
343  void *cls, unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd);
344 
345 
346 /* ***************** API related to GNSRECORD plugins ************** */
347 
357 char *
358 GNUNET_GNSRECORD_value_to_string(uint32_t type, const void *data,
359  size_t data_size);
360 
361 
372 int
373 GNUNET_GNSRECORD_string_to_value(uint32_t type, const char *s, void **data,
374  size_t *data_size);
375 
376 
383 uint32_t
384 GNUNET_GNSRECORD_typename_to_number(const char *dns_typename);
385 
386 
393 const char *
395 
396 
397 /* convenience APIs for serializing / deserializing GNS records */
398 
407 ssize_t
408 GNUNET_GNSRECORD_records_get_size(unsigned int rd_count,
409  const struct GNUNET_GNSRECORD_Data *rd);
410 
411 
421 ssize_t
422 GNUNET_GNSRECORD_records_serialize(unsigned int rd_count,
423  const struct GNUNET_GNSRECORD_Data *rd,
424  size_t dest_size, char *dest);
425 
426 
436 int
437 GNUNET_GNSRECORD_records_deserialize(size_t len, const char *src,
438  unsigned int rd_count,
439  struct GNUNET_GNSRECORD_Data *dest);
440 
441 
442 /* ******* general APIs relating to blocks, records and labels ******** */
443 
444 
452 int
454 
455 
461 char *
462 GNUNET_GNSRECORD_string_to_lowercase(const char *src);
463 
464 
474 const char *
476 
477 
488 const char *
490 
491 
501 int
502 GNUNET_GNSRECORD_zkey_to_pkey(const char *zkey,
504 
505 
513 void
515  const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, const char *label,
516  struct GNUNET_HashCode *query);
517 
518 
526 void
528  const struct GNUNET_CRYPTO_EcdsaPublicKey *pub, const char *label,
529  struct GNUNET_HashCode *query);
530 
531 
541 struct GNUNET_GNSRECORD_Block *
544  const char *label,
545  const struct GNUNET_GNSRECORD_Data *rd,
546  unsigned int rd_count);
547 
548 
560 struct GNUNET_GNSRECORD_Block *
563  const char *label,
564  const struct GNUNET_GNSRECORD_Data *rd,
565  unsigned int rd_count);
566 
567 
575 int
577 
578 
590 int
592  const struct GNUNET_GNSRECORD_Block *block,
593  const struct GNUNET_CRYPTO_EcdsaPublicKey *zone_key, const char *label,
594  GNUNET_GNSRECORD_RecordCallback proc, void *proc_cls);
595 
596 
604 int
606  const struct GNUNET_GNSRECORD_Data *b);
607 
608 
620  unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd);
621 
622 
623 #if 0 /* keep Emacsens' auto-indent happy */
624 {
625 #endif
626 #ifdef __cplusplus
627 }
628 #endif
629 
630 #endif
631  /* end of group */
GNUNET_NETWORK_STRUCT_END typedef 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.
This record should not be used unless all (other) records with an absolute expiration time have expir...
static struct GNUNET_SERVICE_Handle * service
Handle to our service instance.
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.
static char * expiration
Credential TTL.
Record type used to box up SRV and TLSA records.
char * GNUNET_GNSRECORD_string_to_lowercase(const char *src)
Convert a UTF-8 string to UTF-8 lowercase.
static char * pkey
Public key of the zone to look in, in ASCII.
struct GNUNET_GNSRECORD_Block * GNUNET_GNSRECORD_block_create(const struct GNUNET_CRYPTO_EcdsaPrivateKey *key, struct GNUNET_TIME_Absolute expire, const char *label, const struct GNUNET_GNSRECORD_Data *rd, unsigned int rd_count)
Sign name and records.
uint32_t purpose
What does this signature vouch for? This must contain a GNUNET_SIGNATURE_PURPOSE_XXX constant (from g...
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.
static void expire(void *cls)
Expire a PooledConnection object.
uint32_t GNUNET_GNSRECORD_typename_to_number(const char *dns_typename)
Convert a type name (i.e.
Definition: gnsrecord.c:203
struct GNUNET_GNSRECORD_Block * GNUNET_GNSRECORD_block_create2(const struct GNUNET_CRYPTO_EcdsaPrivateKey *key, struct GNUNET_TIME_Absolute expire, const char *label, const struct GNUNET_GNSRECORD_Data *rd, unsigned int rd_count)
Sign name and records, cache derived public key (also keeps the private key in static memory...
int GNUNET_GNSRECORD_zkey_to_pkey(const char *zkey, struct GNUNET_CRYPTO_EcdsaPublicKey *pkey)
Convert an absolute domain name to the respective public key.
size_t data_size
Number of bytes in data.
Private ECC key encoded for transmission.
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.
Information we have in an encrypted block with record data (i.e.
Time for absolute time used by GNUnet, in microseconds and in network byte order. ...
#define GNUNET_NETWORK_STRUCT_BEGIN
Define as empty, GNUNET_PACKED should suffice, but this won&#39;t work on W32.
static char * zone
Name of the zone we manage.
void GNUNET_GNSRECORD_query_from_private_key(const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, const char *label, struct GNUNET_HashCode *query)
Calculate the DHT query for a given label in a given zone.
header of what an ECC signature signs this must be followed by "size - 8" bytes of the actual signed ...
const void * data
Binary value stored in the DNS record.
uint64_t expiration_time
Expiration time for the DNS record.
an ECC signature using ECDSA
This is a private record of this peer and it should thus not be handed out to other peers...
A 512-bit hashcode.
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:174
const char * GNUNET_GNSRECORD_z2s(const struct GNUNET_CRYPTO_EcdsaPublicKey *z)
Convert a zone to a string (for printing debug messages).
struct GNUNET_TIME_Absolute GNUNET_GNSRECORD_record_get_expiration_time(unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd)
Returns the expiration time of the given block of records.
int GNUNET_GNSRECORD_block_verify(const struct GNUNET_GNSRECORD_Block *block)
Check if a signature is valid.
struct GNUNET_HashCode key
The key used in the DHT.
int GNUNET_GNSRECORD_records_cmp(const struct GNUNET_GNSRECORD_Data *a, const struct GNUNET_GNSRECORD_Data *b)
Compares if two records are equal.
const char * GNUNET_GNSRECORD_pkey_to_zkey(const struct GNUNET_CRYPTO_EcdsaPublicKey *pkey)
Convert public key to the respective absolute domain name in the ".zkey" pTLD.
#define GNUNET_NETWORK_STRUCT_END
Define as empty, GNUNET_PACKED should suffice, but this won&#39;t work on W32;.
int GNUNET_GNSRECORD_is_expired(const struct GNUNET_GNSRECORD_Data *rd)
Test if a given record is expired.
The identity of the host (wraps the signing key of the peer).
uint32_t record_type
Type of the GNS/DNS record.
#define GNUNET_PACKED
gcc-ism to get packed structs.
static struct GNUNET_CRYPTO_EddsaPublicKey pub
Definition: gnunet-scrypt.c:39
int GNUNET_GNSRECORD_block_decrypt(const struct GNUNET_GNSRECORD_Block *block, const struct GNUNET_CRYPTO_EcdsaPublicKey *zone_key, const char *label, GNUNET_GNSRECORD_RecordCallback proc, void *proc_cls)
Decrypt block.
Public ECC key (always for Curve25519) encoded in a format suitable for network transmission and ECDS...
Data stored in a PLACE record.
enum GNUNET_TESTBED_UnderlayLinkModelType type
the type of this model
Time for absolute times used by GNUnet, in microseconds.
GNUNET_GNSRECORD_Flags
Flags that can be set for a record.
void GNUNET_GNSRECORD_query_from_public_key(const struct GNUNET_CRYPTO_EcdsaPublicKey *pub, const char *label, struct GNUNET_HashCode *query)
Calculate the DHT query for a given label in a given zone.
enum GNUNET_GNSRECORD_Flags flags
Flags for the record.
This flag is currently unused; former RF_PENDING flag.
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:142
const char * GNUNET_GNSRECORD_number_to_typename(uint32_t type)
Convert a type number (i.e.
Definition: gnsrecord.c:230
Record type used internally to keep track of reverse mappings into a namespace.
uint16_t len
length of data (which is always a uint32_t, but presumably this can be used to specify that fewer byt...
Public ECC key (always for curve Ed25519) encoded in a format suitable for network transmission and E...