GNUnet  0.11.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 
38 
39 #ifdef __cplusplus
40 extern "C" {
41 #if 0 /* keep Emacsens' auto-indent happy */
42 }
43 #endif
44 #endif
45 
49 #define GNUNET_GNSRECORD_MAX_BLOCK_SIZE (63 * 1024)
50 
51 
55 #define GNUNET_GNSRECORD_TYPE_ANY 0
56 
60 #define GNUNET_GNSRECORD_TYPE_PKEY GNUNET_IDENTITY_TYPE_ECDSA
61 
65 #define GNUNET_GNSRECORD_TYPE_NICK 65537
66 
70 #define GNUNET_GNSRECORD_TYPE_LEHO 65538
71 
75 #define GNUNET_GNSRECORD_TYPE_VPN 65539
76 
80 #define GNUNET_GNSRECORD_TYPE_GNS2DNS 65540
81 
85 #define GNUNET_GNSRECORD_TYPE_BOX 65541
86 
90 #define GNUNET_GNSRECORD_TYPE_PLACE 65542
91 
95 #define GNUNET_GNSRECORD_TYPE_PHONE 65543
96 
100 #define GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE 65544
101 
105 #define GNUNET_GNSRECORD_TYPE_RECLAIM_TICKET 65545
106 
118 #define GNUNET_GNSRECORD_TYPE_DELEGATE 65548
119 
123 #define GNUNET_GNSRECORD_TYPE_ATTRIBUTE 65549
124 
128 #define GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE_REF 65550
129 
133 #define GNUNET_GNSRECORD_TYPE_RECLAIM_MASTER 65551
134 
138 #define GNUNET_GNSRECORD_TYPE_RECLAIM_OIDC_CLIENT 65552
139 
143 #define GNUNET_GNSRECORD_TYPE_RECLAIM_OIDC_REDIRECT 65553
144 
148 #define GNUNET_GNSRECORD_TYPE_RECLAIM_CREDENTIAL 65554
149 
154 #define GNUNET_GNSRECORD_TYPE_RECLAIM_PRESENTATION 65555
155 
159 #define GNUNET_GNSRECORD_TYPE_EDKEY GNUNET_IDENTITY_TYPE_EDDSA
160 
161 
166 {
171 
177 
182 
188 
194 
206 #define GNUNET_GNSRECORD_RF_RCMP_FLAGS (GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION)
207 };
208 
209 
214 {
220  const void *data;
221 
227  uint64_t expiration_time;
228 
232  size_t data_size;
233 
237  uint32_t record_type;
238 
243 };
244 
245 
247 
252 {
256  struct GNUNET_CRYPTO_EddsaPublicKey place_pub_key;
257 
261  struct GNUNET_PeerIdentity origin;
262 
266  uint32_t relay_count GNUNET_PACKED;
267 
268  /* Followed by struct GNUNET_PeerIdentity relays[relay_count] */
269 };
270 
275 {
279  struct GNUNET_CRYPTO_EcdsaPublicKey derived_key;
280 
285 
291 
296 
297  /* followed by encrypted data */
298 };
299 
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 
311 
323 {
328  uint16_t protocol GNUNET_PACKED;
329 
334 
339 
340  /* followed by the 'original' record */
341 };
342 
351 {
356 
361 
362  /* followed by the name the delegator uses to refer to our namespace */
363 };
364 
366 
367 
376  void *cls, unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd);
377 
378 
379 /* ***************** API related to GNSRECORD plugins ************** */
380 
390 char *
391 GNUNET_GNSRECORD_value_to_string (uint32_t type, const void *data,
392  size_t data_size);
393 
394 
405 int
406 GNUNET_GNSRECORD_string_to_value (uint32_t type, const char *s, void **data,
407  size_t *data_size);
408 
409 
416 uint32_t
417 GNUNET_GNSRECORD_typename_to_number (const char *dns_typename);
418 
419 
426 const char *
428 
429 
430 /* convenience APIs for serializing / deserializing GNS records */
431 
440 ssize_t
441 GNUNET_GNSRECORD_records_get_size (unsigned int rd_count,
442  const struct GNUNET_GNSRECORD_Data *rd);
443 
444 
454 ssize_t
455 GNUNET_GNSRECORD_records_serialize (unsigned int rd_count,
456  const struct GNUNET_GNSRECORD_Data *rd,
457  size_t dest_size, char *dest);
458 
459 
469 int
470 GNUNET_GNSRECORD_records_deserialize (size_t len, const char *src,
471  unsigned int rd_count,
472  struct GNUNET_GNSRECORD_Data *dest);
473 
474 
475 /* ******* general APIs relating to blocks, records and labels ******** */
476 
477 
485 int
487 
488 
494 char *
495 GNUNET_GNSRECORD_string_to_lowercase (const char *src);
496 
497 
507 const char *
509 
510 
521 const char *
523 
524 
534 int
535 GNUNET_GNSRECORD_zkey_to_pkey (const char *zkey,
537 
538 
546 void
548  const struct GNUNET_IDENTITY_PrivateKey *zone, const char *label,
549  struct GNUNET_HashCode *query);
550 
551 
559 void
561  const struct GNUNET_IDENTITY_PublicKey *pub, const char *label,
562  struct GNUNET_HashCode *query);
563 
564 
574 struct GNUNET_GNSRECORD_Block *
577  const char *label,
578  const struct GNUNET_GNSRECORD_Data *rd,
579  unsigned int rd_count);
580 
581 
593 struct GNUNET_GNSRECORD_Block *
596  const char *label,
597  const struct GNUNET_GNSRECORD_Data *rd,
598  unsigned int rd_count);
599 
600 
608 int
610 
611 
623 int
625  const struct GNUNET_GNSRECORD_Block *block,
626  const struct GNUNET_IDENTITY_PublicKey *zone_key, const char *label,
627  GNUNET_GNSRECORD_RecordCallback proc, void *proc_cls);
628 
629 
637 int
639  const struct GNUNET_GNSRECORD_Data *b);
640 
641 
653  unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd);
654 
655 
663 size_t
665 
674 
675 
685  struct GNUNET_HashCode *query);
686 
687 
700  size_t data_size,
701  uint32_t type,
703 
704 
716  char **data,
717  size_t *data_size,
718  uint32_t *type);
719 
720 
730 
731 
732 #if 0 /* keep Emacsens' auto-indent happy */
733 {
734 #endif
735 #ifdef __cplusplus
736 }
737 #endif
738 
739 #endif
740  /* end of group */
Information we have in an encrypted block with record data (i.e.
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.
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.
uint32_t purpose
What does this signature vouch for? This must contain a GNUNET_SIGNATURE_PURPOSE_XXX constant (from g...
int GNUNET_GNSRECORD_zkey_to_pkey(const char *zkey, struct GNUNET_IDENTITY_PublicKey *pkey)
Convert an absolute domain name to the respective public key.
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:220
A private key for an identity as per LSD0001.
GNUNET_GenericReturnValue
Named constants for return values.
Definition: gnunet_common.h:83
This is a supplemental record.
size_t data_size
Number of bytes in data.
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.
Time for absolute time used by GNUnet, in microseconds and in network byte order. ...
struct GNUNET_GNSRECORD_Block * GNUNET_GNSRECORD_block_create(const struct GNUNET_IDENTITY_PrivateKey *key, struct GNUNET_TIME_Absolute expire, const char *label, const struct GNUNET_GNSRECORD_Data *rd, unsigned int rd_count)
Sign name and records.
#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.
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.
enum GNUNET_GenericReturnValue GNUNET_GNSRECORD_is_zonekey_type(uint32_t type)
Check if this type is one of the supported GNS zone types.
size_t GNUNET_GNSRECORD_block_get_size(const struct GNUNET_GNSRECORD_Block *block)
Returns the length of this block in bytes.
uint64_t expiration_time
Expiration time for the DNS record.
struct GNUNET_GNSRECORD_Block * GNUNET_GNSRECORD_block_create2(const struct GNUNET_IDENTITY_PrivateKey *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...
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:191
static char * expiration
Credential TTL.
Definition: gnunet-abd.c:96
enum GNUNET_GenericReturnValue GNUNET_GNSRECORD_identity_from_data(const char *data, size_t data_size, uint32_t type, struct GNUNET_IDENTITY_PublicKey *key)
Build a #GNUNET_GNSRECORD_PublicKey from zone delegation resource record data.
void GNUNET_GNSRECORD_query_from_public_key(const struct GNUNET_IDENTITY_PublicKey *pub, const char *label, struct GNUNET_HashCode *query)
Calculate the DHT query for a given label in a given zone.
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.
int GNUNET_GNSRECORD_block_decrypt(const struct GNUNET_GNSRECORD_Block *block, const struct GNUNET_IDENTITY_PublicKey *zone_key, const char *label, GNUNET_GNSRECORD_RecordCallback proc, void *proc_cls)
Decrypt block.
void GNUNET_GNSRECORD_query_from_private_key(const struct GNUNET_IDENTITY_PrivateKey *zone, const char *label, struct GNUNET_HashCode *query)
Calculate the DHT query for a given label in a given zone.
const char * GNUNET_GNSRECORD_pkey_to_zkey(const struct GNUNET_IDENTITY_PublicKey *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).
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.
An identity key as per LSD0001.
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:46
Public ECC key (always for Curve25519) encoded in a format suitable for network transmission and ECDS...
Data stored in a PLACE record.
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_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.
enum GNUNET_GNSRECORD_Flags flags
Flags for the record.
This expiration time of the record is a relative time (not an absolute time).
struct GNUNET_TIME_Absolute GNUNET_GNSRECORD_block_get_expiration(const struct GNUNET_GNSRECORD_Block *block)
Returns the expiration of a block.
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:159
const char * GNUNET_GNSRECORD_z2s(const struct GNUNET_IDENTITY_PublicKey *z)
Convert a zone to a string (for printing debug messages).
const char * GNUNET_GNSRECORD_number_to_typename(uint32_t type)
Convert a type number (i.e.
Definition: gnsrecord.c:247
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...
enum GNUNET_GenericReturnValue GNUNET_GNSRECORD_data_from_identity(const struct GNUNET_IDENTITY_PublicKey *key, char **data, size_t *data_size, uint32_t *type)
Create record data and size from an identity key.
Public ECC key (always for curve Ed25519) encoded in a format suitable for network transmission and E...