GNUnet 0.22.2
gnunet-gnsrecord-tvg.c File Reference
#include "platform.h"
#include "gnunet_util_lib.h"
#include "gnunet_gnsrecord_lib.h"
#include "gnsrecord_crypto.h"
#include <inttypes.h>
Include dependency graph for gnunet-gnsrecord-tvg.c:

Go to the source code of this file.

Functions

static int parsehex (const char *src, char *dst, size_t dstlen, int invert)
 
static void print_bytes_ (void *buf, size_t buf_len, int fold, int in_be)
 
static void print_bytes (void *buf, size_t buf_len, int fold)
 
static void print_record (const struct GNUNET_GNSRECORD_Data *rd)
 
static void run_pkey (struct GNUNET_GNSRECORD_Data *rd, int rd_count, const char *label)
 Main function that will be run. More...
 
static void run_edkey (struct GNUNET_GNSRECORD_Data *rd, int rd_count, const char *label)
 Main function that will be run. More...
 
static void run (void *cls, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg)
 Main function that will be run. More...
 
int main (int argc, char *const *argv)
 The main function of the test vector generation tool. More...
 

Variables

static const char * d_pkey
 
static const char * d_edkey
 

Function Documentation

◆ parsehex()

static int parsehex ( const char *  src,
char *  dst,
size_t  dstlen,
int  invert 
)
static

Definition at line 41 of file gnunet-gnsrecord-tvg.c.

42{
43 const char *line = src;
44 const char *data = line;
45 int off;
46 int read_byte;
47 int data_len = 0;
48
49 while (sscanf (data, " %02x%n", &read_byte, &off) == 1)
50 {
51 if (invert)
52 dst[dstlen - 1 - data_len++] = read_byte;
53 else
54 dst[data_len++] = read_byte;
55 data += off;
56 }
57 return data_len;
58}
static char * line
Desired phone line (string to be converted to a hash).
static char * data
The data to insert into the dht.

References data, and line.

Referenced by run(), run_edkey(), and run_pkey().

Here is the caller graph for this function:

◆ print_bytes_()

static void print_bytes_ ( void *  buf,
size_t  buf_len,
int  fold,
int  in_be 
)
static

Definition at line 62 of file gnunet-gnsrecord-tvg.c.

66{
67 int i;
68
69 for (i = 0; i < buf_len; i++)
70 {
71 if (0 != i)
72 {
73 if ((0 != fold) && (i % fold == 0))
74 printf ("\n ");
75 else
76 printf (" ");
77 }
78 else
79 {
80 printf (" ");
81 }
82 if (in_be)
83 printf ("%02x", ((unsigned char*) buf)[buf_len - 1 - i]);
84 else
85 printf ("%02x", ((unsigned char*) buf)[i]);
86 }
87 printf ("\n");
88}

Referenced by print_bytes(), and run_pkey().

Here is the caller graph for this function:

◆ print_bytes()

static void print_bytes ( void *  buf,
size_t  buf_len,
int  fold 
)
static

Definition at line 92 of file gnunet-gnsrecord-tvg.c.

95{
96 print_bytes_ (buf, buf_len, fold, 0);
97}
static void print_bytes_(void *buf, size_t buf_len, int fold, int in_be)

References print_bytes_().

Referenced by print_record(), run_edkey(), and run_pkey().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ print_record()

static void print_record ( const struct GNUNET_GNSRECORD_Data rd)
static

Definition at line 101 of file gnunet-gnsrecord-tvg.c.

102{
103 struct GNUNET_TIME_Relative rt;
104 struct GNUNET_TIME_Absolute at;
105 uint16_t flags = htons (rd->flags);
106 uint64_t abs_nbo = GNUNET_htonll (rd->expiration_time);
107 uint16_t size_nbo = htons (rd->data_size);
108 uint32_t type_nbo = htonl (rd->record_type);
109 at.abs_value_us = GNUNET_ntohll (abs_nbo);
111 {
112 rt.rel_value_us = rd->expiration_time;
114 abs_nbo = GNUNET_htonll (at.abs_value_us);
115 }
116 printf (" EXPIRATION: %" PRIu64 " us\n", rd->expiration_time);
117 print_bytes (&abs_nbo, sizeof (abs_nbo), 8);
118 printf ("\n DATA_SIZE:\n");
119 print_bytes (&size_nbo, sizeof (size_nbo), 8);
120 printf ("\n TYPE:\n");
121 print_bytes (&type_nbo, sizeof (type_nbo), 8);
122 printf ("\n FLAGS: ");
123 print_bytes ((void*) &flags, sizeof (flags), 8);
124 printf ("\n");
125 fprintf (stdout,
126 " DATA:\n");
127 print_bytes ((char*) rd->data, rd->data_size, 8);
128 printf ("\n");
129}
static void print_bytes(void *buf, size_t buf_len, int fold)
static struct GNUNET_GNSRECORD_Data rd[50]
The record data under a single label.
@ GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION
This expiration time of the record is a relative time (not an absolute time).
uint64_t GNUNET_ntohll(uint64_t n)
Convert unsigned 64-bit integer to host byte order.
Definition: common_endian.c:54
uint64_t GNUNET_htonll(uint64_t n)
Convert unsigned 64-bit integer to network byte order.
Definition: common_endian.c:37
struct GNUNET_TIME_Absolute GNUNET_TIME_relative_to_absolute(struct GNUNET_TIME_Relative rel)
Convert relative time to an absolute time in the future.
Definition: time.c:316
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.
Time for absolute times used by GNUnet, in microseconds.
Time for relative time used by GNUnet, in microseconds.

References GNUNET_TIME_Absolute::abs_value_us, GNUNET_GNSRECORD_Data::data, GNUNET_GNSRECORD_Data::data_size, GNUNET_GNSRECORD_Data::expiration_time, GNUNET_GNSRECORD_Data::flags, GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION, GNUNET_htonll(), GNUNET_ntohll(), GNUNET_TIME_relative_to_absolute(), print_bytes(), rd, GNUNET_GNSRECORD_Data::record_type, and GNUNET_TIME_Relative::rel_value_us.

Referenced by run_edkey(), and run_pkey().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ run_pkey()

static void run_pkey ( struct GNUNET_GNSRECORD_Data rd,
int  rd_count,
const char *  label 
)
static

Main function that will be run.

Parameters
clsclosure
argsremaining command-line arguments
cfgfilename of the configuration file used (for saving, can be NULL!)
cfgconfiguration

Definition at line 141 of file gnunet-gnsrecord-tvg.c.

142{
144 struct GNUNET_GNSRECORD_Block *rrblock;
145 char *bdata;
146 struct GNUNET_CRYPTO_PrivateKey id_priv;
147 struct GNUNET_CRYPTO_PublicKey id_pub;
148 struct GNUNET_CRYPTO_PrivateKey pkey_data_p;
149 struct GNUNET_CRYPTO_PublicKey pkey_data;
150 struct GNUNET_HashCode query;
151 char *rdata;
152 char *conv_lbl;
153 size_t rdata_size;
154 char ztld[128];
155 unsigned char ctr[GNUNET_CRYPTO_AES_KEY_LENGTH / 2];
156 unsigned char skey[GNUNET_CRYPTO_AES_KEY_LENGTH];
157
158 id_priv.type = htonl (GNUNET_GNSRECORD_TYPE_PKEY);
159 GNUNET_CRYPTO_ecdsa_key_create (&id_priv.ecdsa_key);
161 (char*) &id_priv.ecdsa_key,
162 sizeof (id_priv.ecdsa_key), 1);
163
165 &id_pub);
166 printf ("Zone private key (d, big-endian):\n");
167 print_bytes_ (&id_priv.ecdsa_key,
168 sizeof (struct GNUNET_CRYPTO_EcdsaPrivateKey), 8, 1);
169 printf ("\n");
170 printf ("Zone identifier (ztype|zkey):\n");
172 print_bytes (&id_pub, GNUNET_CRYPTO_public_key_get_length (&id_pub), 8);
175 &id_pub),
176 ztld,
177 sizeof (ztld));
178 printf ("\n");
179 printf ("zTLD:\n");
180 printf ("%s\n", ztld);
181 printf ("\n");
182
183 pkey_data_p.type = htonl (GNUNET_GNSRECORD_TYPE_PKEY);
184 GNUNET_CRYPTO_ecdsa_key_create (&pkey_data_p.ecdsa_key);
185 GNUNET_CRYPTO_key_get_public (&pkey_data_p,
186 &pkey_data);
187 conv_lbl = GNUNET_GNSRECORD_string_normalize (label);
188 printf ("Label:\n");
189 print_bytes (conv_lbl, strlen (conv_lbl), 8);
190 GNUNET_free (conv_lbl);
191 printf ("\nNumber of records (integer): %d\n\n", rd_count);
192
193 for (int i = 0; i < rd_count; i++)
194 {
195 printf ("Record #%d := (\n", i);
196 print_record (&rd[i]);
197 printf (")\n\n");
198 }
199
201 rd);
202 rdata = GNUNET_malloc (rdata_size);
204 rd,
205 (size_t) rdata_size,
206 rdata);
207 printf ("RDATA:\n");
208 print_bytes (rdata,
209 (size_t) rdata_size,
210 8);
211 printf ("\n");
215 skey,
216 label,
218 expire).abs_value_us__,
219 &id_pub.ecdsa_key);
220
221 printf ("Encryption NONCE|EXPIRATION|BLOCK COUNTER:\n");
222 print_bytes (ctr, sizeof (ctr), 8);
223 printf ("\n");
224 printf ("Encryption key (K):\n");
225 print_bytes (skey, sizeof (skey), 8);
226 printf ("\n");
228 label,
229 &query);
230 printf ("Storage key (q):\n");
231 print_bytes (&query, sizeof (query), 8);
232 printf ("\n");
234 expire,
235 label,
236 rd,
237 rd_count,
238 &rrblock));
239 {
240 struct GNUNET_CRYPTO_EcdsaPublicKey derived_key;
241 struct GNUNET_CRYPTO_EcdsaPrivateKey *derived_privkey;
242 size_t bdata_size;
243
244 GNUNET_CRYPTO_ecdsa_public_key_derive (&id_pub.ecdsa_key,
245 label,
246 "gns",
247 &derived_key);
248 derived_privkey = GNUNET_CRYPTO_ecdsa_private_key_derive (&id_priv.ecdsa_key
249 ,
250 label,
251 "gns");
252 printf ("ZKDF(zkey):\n");
253 print_bytes (&derived_key, sizeof (derived_key), 8);
254 printf ("\n");
255 printf ("Derived private key (d', big-endian):\n");
256 print_bytes_ (derived_privkey, sizeof (*derived_privkey), 8, 1);
257 printf ("\n");
258 bdata_size = ntohl (rrblock->size) - sizeof (struct
260
261 GNUNET_free (derived_privkey);
262
263 bdata = (char*) &(&rrblock->ecdsa_block)[1];
264 printf ("BDATA:\n");
265 print_bytes (bdata, bdata_size, 8);
266 printf ("\n");
267 printf ("RRBLOCK:\n");
268 print_bytes (rrblock, ntohl (rrblock->size), 8);
269 printf ("\n");
270 GNUNET_free (rdata);
271 }
272}
void GNR_derive_block_aes_key(unsigned char *ctr, unsigned char *key, const char *label, uint64_t exp, const struct GNUNET_CRYPTO_EcdsaPublicKey *pub)
Derive session key and iv from label and public key.
#define GNUNET_GNSRECORD_TYPE_PKEY
WARNING: This header is generated! In order to add GNS record types, you must register them in GANA,...
static char * expire
DID Document expiration Date Attribute String.
Definition: gnunet-did.c:98
static int parsehex(const char *src, char *dst, size_t dstlen, int invert)
static void print_record(const struct GNUNET_GNSRECORD_Data *rd)
static const char * d_pkey
static unsigned int rd_count
Number of records for currently parsed set.
void GNUNET_CRYPTO_ecdsa_public_key_derive(const struct GNUNET_CRYPTO_EcdsaPublicKey *pub, const char *label, const char *context, struct GNUNET_CRYPTO_EcdsaPublicKey *result)
Derive a public key from a given public key and a label.
struct GNUNET_CRYPTO_EcdsaPrivateKey * GNUNET_CRYPTO_ecdsa_private_key_derive(const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv, const char *label, const char *context)
Derive a private key from a given private key and a label.
void GNUNET_CRYPTO_ecdsa_key_create(struct GNUNET_CRYPTO_EcdsaPrivateKey *pk)
Create a new private key.
Definition: crypto_ecc.c:465
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.
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_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.
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.
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.
char * GNUNET_GNSRECORD_string_normalize(const char *src)
Normalize a UTF-8 string to a GNS name.
ssize_t GNUNET_CRYPTO_public_key_get_length(const struct GNUNET_CRYPTO_PublicKey *key)
Get the compacted length of a GNUNET_CRYPTO_PublicKey.
Definition: crypto_pkey.c:85
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_key_get_public(const struct GNUNET_CRYPTO_PrivateKey *privkey, struct GNUNET_CRYPTO_PublicKey *key)
Retrieves the public key representation of a private key.
Definition: crypto_pkey.c:430
#define GNUNET_CRYPTO_AES_KEY_LENGTH
length of the sessionkey in bytes (256 BIT sessionkey)
@ GNUNET_OK
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_malloc(size)
Wrapper around malloc.
#define GNUNET_free(ptr)
Wrapper around free.
char * GNUNET_STRINGS_data_to_string(const void *data, size_t size, char *out, size_t out_size)
Convert binary data to ASCII encoding using CrockfordBase32.
Definition: strings.c:732
#define GNUNET_TIME_UNIT_ZERO_ABS
Absolute time zero.
struct GNUNET_TIME_AbsoluteNBO GNUNET_TIME_absolute_hton(struct GNUNET_TIME_Absolute a)
Convert absolute time to network byte order.
Definition: time.c:640
Private ECC key encoded for transmission.
Public ECC key (always for Curve25519) encoded in a format suitable for network transmission and ECDS...
A private key for an identity as per LSD0001.
An identity key as per LSD0001.
struct GNUNET_GNSRECORD_EcdsaBlock ecdsa_block
uint32_t size
Size of the block.
A 512-bit hashcode.

References d_pkey, GNUNET_GNSRECORD_Block::ecdsa_block, GNUNET_CRYPTO_PrivateKey::ecdsa_key, GNUNET_CRYPTO_PublicKey::ecdsa_key, expire, GNR_derive_block_aes_key(), GNUNET_assert, GNUNET_CRYPTO_AES_KEY_LENGTH, GNUNET_CRYPTO_ecdsa_key_create(), GNUNET_CRYPTO_ecdsa_private_key_derive(), GNUNET_CRYPTO_ecdsa_public_key_derive(), GNUNET_CRYPTO_key_get_public(), GNUNET_CRYPTO_public_key_get_length(), GNUNET_free, GNUNET_GNSRECORD_block_create(), GNUNET_GNSRECORD_query_from_public_key(), GNUNET_GNSRECORD_record_get_expiration_time(), GNUNET_GNSRECORD_records_get_size(), GNUNET_GNSRECORD_records_serialize(), GNUNET_GNSRECORD_string_normalize(), GNUNET_GNSRECORD_TYPE_PKEY, GNUNET_malloc, GNUNET_OK, GNUNET_STRINGS_data_to_string(), GNUNET_TIME_absolute_hton(), GNUNET_TIME_UNIT_ZERO_ABS, parsehex(), print_bytes(), print_bytes_(), print_record(), rd, rd_count, GNUNET_GNSRECORD_Block::size, and GNUNET_CRYPTO_PrivateKey::type.

Referenced by run().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ run_edkey()

static void run_edkey ( struct GNUNET_GNSRECORD_Data rd,
int  rd_count,
const char *  label 
)
static

Main function that will be run.

Parameters
clsclosure
argsremaining command-line arguments
cfgfilename of the configuration file used (for saving, can be NULL!)
cfgconfiguration

Definition at line 284 of file gnunet-gnsrecord-tvg.c.

285{
287 struct GNUNET_GNSRECORD_Block *rrblock;
288 char *bdata;
289 struct GNUNET_CRYPTO_PrivateKey id_priv;
290 struct GNUNET_CRYPTO_PublicKey id_pub;
291 struct GNUNET_CRYPTO_PrivateKey pkey_data_p;
292 struct GNUNET_CRYPTO_PublicKey pkey_data;
293 struct GNUNET_HashCode query;
294 char *rdata;
295 char *conv_lbl;
296 size_t rdata_size;
297
298 char ztld[128];
299 unsigned char nonce[crypto_secretbox_NONCEBYTES];
300 unsigned char skey[crypto_secretbox_KEYBYTES];
301
302 id_priv.type = htonl (GNUNET_GNSRECORD_TYPE_PKEY);
303 GNUNET_CRYPTO_ecdsa_key_create (&id_priv.ecdsa_key);
305 &id_pub);
306
307 id_priv.type = htonl (GNUNET_PUBLIC_KEY_TYPE_EDDSA);
308 GNUNET_CRYPTO_eddsa_key_create (&id_priv.eddsa_key);
310 (char*) &id_priv.eddsa_key,
311 sizeof (id_priv.eddsa_key), 0);
313 &id_pub);
314 fprintf (stdout,
315 "Zone private key (d):\n");
316 print_bytes (&id_priv.eddsa_key, sizeof (struct
318 printf ("\n");
319 printf ("Zone identifier (ztype|zkey):\n");
321 print_bytes (&id_pub, GNUNET_CRYPTO_public_key_get_length (&id_pub), 8);
324 &id_pub),
325 ztld,
326 sizeof (ztld));
327 printf ("\n");
328 printf ("zTLD:\n");
329 printf ("%s\n", ztld);
330 printf ("\n");
331
332 pkey_data_p.type = htonl (GNUNET_GNSRECORD_TYPE_EDKEY);
333 GNUNET_CRYPTO_eddsa_key_create (&pkey_data_p.eddsa_key);
334 GNUNET_CRYPTO_key_get_public (&pkey_data_p,
335 &pkey_data);
336 conv_lbl = GNUNET_GNSRECORD_string_normalize (label);
337 printf ("Label:\n");
338 print_bytes (conv_lbl, strlen (conv_lbl), 8);
339 GNUNET_free (conv_lbl);
340 fprintf (stdout,
341 "\nNumber of records (integer): %d\n\n", rd_count);
342
343 for (int i = 0; i < rd_count; i++)
344 {
345 printf ("Record #%d := (\n", i);
346 print_record (&rd[i]);
347 printf (")\n\n");
348 }
349
351 rd);
353 rd,
355 GNUNET_assert (0 < rdata_size);
356 rdata = GNUNET_malloc ((size_t) rdata_size);
358 rd,
359 (size_t) rdata_size,
360 rdata);
361 printf ("RDATA:\n");
362 print_bytes (rdata,
363 (size_t) rdata_size,
364 8);
365 printf ("\n");
367 skey,
368 label,
370 expire).abs_value_us__,
371 &id_pub.eddsa_key);
372 printf ("Encryption NONCE|EXPIRATION:\n");
373 print_bytes (nonce, sizeof (nonce), 8);
374 printf ("\n");
375 printf ("Encryption key (K):\n");
376 print_bytes (skey, sizeof (skey), 8);
377 printf ("\n");
379 label,
380 &query);
381 printf ("Storage key (q):\n");
382 print_bytes (&query, sizeof (query), 8);
383 printf ("\n");
384
386 expire,
387 label,
388 rd,
389 rd_count,
390 &rrblock));
391 {
392 struct GNUNET_CRYPTO_EddsaPublicKey derived_key;
393 struct GNUNET_CRYPTO_EddsaPrivateScalar derived_privkey;
394 char derived_privkeyNBO[32];
395 size_t bdata_size;
396 GNUNET_CRYPTO_eddsa_public_key_derive (&id_pub.eddsa_key,
397 label,
398 "gns",
399 &derived_key);
400 GNUNET_CRYPTO_eddsa_private_key_derive (&id_priv.eddsa_key,
401 label,
402 "gns", &derived_privkey);
403 printf ("ZKDF(zkey):\n");
404 print_bytes (&derived_key, sizeof (derived_key), 8);
405 printf ("\n");
406 printf ("nonce := SHA-256 (dh[32..63] || h):\n");
407 print_bytes (derived_privkey.s + 32, 32, 8);
408 printf ("\n");
409 /* Convert from little endian */
410 for (size_t i = 0; i < 32; i++)
411 derived_privkeyNBO[i] = derived_privkey.s[31 - i];
412 printf ("Derived private key (d', big-endian):\n");
413 print_bytes (derived_privkeyNBO, sizeof (derived_privkeyNBO), 8);
414 printf ("\n");
415 bdata_size = ntohl (rrblock->size) - sizeof (struct
417
418
419 bdata = (char*) &(&rrblock->eddsa_block)[1];
420 printf ("BDATA:\n");
421 print_bytes (bdata, bdata_size, 8);
422 printf ("\n");
423 printf ("RRBLOCK:\n");
424 print_bytes (rrblock, ntohl (rrblock->size), 8);
425 printf ("\n");
426 GNUNET_free (rdata);
427 }
428}
void GNR_derive_block_xsalsa_key(unsigned char *nonce, unsigned char *key, const char *label, uint64_t exp, const struct GNUNET_CRYPTO_EddsaPublicKey *pub)
Derive session key and iv from label and public key.
#define GNUNET_GNSRECORD_TYPE_EDKEY
GNS zone delegation (EDKEY)
static const char * d_edkey
void GNUNET_CRYPTO_eddsa_private_key_derive(const struct GNUNET_CRYPTO_EddsaPrivateKey *priv, const char *label, const char *context, struct GNUNET_CRYPTO_EddsaPrivateScalar *result)
Derive a private scalar from a given private key and a label.
void GNUNET_CRYPTO_eddsa_key_create(struct GNUNET_CRYPTO_EddsaPrivateKey *pk)
Create a new private key.
Definition: crypto_ecc.c:480
void GNUNET_CRYPTO_eddsa_public_key_derive(const struct GNUNET_CRYPTO_EddsaPublicKey *pub, const char *label, const char *context, struct GNUNET_CRYPTO_EddsaPublicKey *result)
Derive a public key from a given public key and a label.
@ GNUNET_PUBLIC_KEY_TYPE_EDDSA
EDDSA identity.
Private ECC key encoded for transmission.
Private ECC scalar encoded for transmission.
Public ECC key (always for curve Ed25519) encoded in a format suitable for network transmission and E...
struct GNUNET_GNSRECORD_EddsaBlock eddsa_block

References d_edkey, GNUNET_CRYPTO_PrivateKey::ecdsa_key, GNUNET_GNSRECORD_Block::eddsa_block, GNUNET_CRYPTO_PrivateKey::eddsa_key, GNUNET_CRYPTO_PublicKey::eddsa_key, expire, GNR_derive_block_xsalsa_key(), GNUNET_assert, GNUNET_CRYPTO_ecdsa_key_create(), GNUNET_CRYPTO_eddsa_key_create(), GNUNET_CRYPTO_eddsa_private_key_derive(), GNUNET_CRYPTO_eddsa_public_key_derive(), GNUNET_CRYPTO_key_get_public(), GNUNET_CRYPTO_public_key_get_length(), GNUNET_free, GNUNET_GNSRECORD_block_create(), GNUNET_GNSRECORD_query_from_public_key(), GNUNET_GNSRECORD_record_get_expiration_time(), GNUNET_GNSRECORD_records_get_size(), GNUNET_GNSRECORD_records_serialize(), GNUNET_GNSRECORD_string_normalize(), GNUNET_GNSRECORD_TYPE_EDKEY, GNUNET_GNSRECORD_TYPE_PKEY, GNUNET_malloc, GNUNET_OK, GNUNET_PUBLIC_KEY_TYPE_EDDSA, GNUNET_STRINGS_data_to_string(), GNUNET_TIME_absolute_hton(), GNUNET_TIME_UNIT_ZERO_ABS, parsehex(), print_bytes(), print_record(), rd, rd_count, GNUNET_CRYPTO_EddsaPrivateScalar::s, GNUNET_GNSRECORD_Block::size, and GNUNET_CRYPTO_PrivateKey::type.

Referenced by run().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ run()

static void run ( void *  cls,
char *const *  args,
const char *  cfgfile,
const struct GNUNET_CONFIGURATION_Handle cfg 
)
static

Main function that will be run.

Parameters
clsclosure
argsremaining command-line arguments
cfgfilename of the configuration file used (for saving, can be NULL!)
cfgconfiguration

Definition at line 440 of file gnunet-gnsrecord-tvg.c.

444{
445 struct GNUNET_GNSRECORD_Data rd_pkey;
446 struct GNUNET_GNSRECORD_Data rd[3];
447 struct GNUNET_TIME_Absolute exp1;
448 struct GNUNET_TIME_Absolute exp2;
449 struct GNUNET_TIME_Absolute exp3;
450 struct GNUNET_TIME_AbsoluteNBO exp1nbo;
451 struct GNUNET_TIME_AbsoluteNBO exp2nbo;
452 struct GNUNET_TIME_AbsoluteNBO exp3nbo;
453 size_t pkey_data_size;
454 size_t ip_data_size;
455 char *pkey_data;
456 char *ip_data;
457
458 /*
459 * Make different expiration times
460 */
461 parsehex ("001cee8c10e25980", (char*) &exp1nbo, sizeof (exp1nbo), 0);
462 parsehex ("003ff2aa5408db40", (char*) &exp2nbo, sizeof (exp2nbo), 0);
463 parsehex ("0028bb13ff371940", (char*) &exp3nbo, sizeof (exp3nbo), 0);
464 exp1 = GNUNET_TIME_absolute_ntoh (exp1nbo);
465 exp2 = GNUNET_TIME_absolute_ntoh (exp2nbo);
466 exp3 = GNUNET_TIME_absolute_ntoh (exp3nbo);
467
468 memset (&rd_pkey, 0, sizeof (struct GNUNET_GNSRECORD_Data));
471 "000G0011WESGZY9VRV9NNJ66W3GKNZFZF56BFD2BQF3MHMJST2G2GKDYGG",
472 (void**) &pkey_data,
473 &pkey_data_size));
474 rd_pkey.data = pkey_data;
475 rd_pkey.data_size = pkey_data_size;
476 rd_pkey.expiration_time = exp1.abs_value_us;
477 rd_pkey.record_type = GNUNET_GNSRECORD_TYPE_PKEY;
478 rd_pkey.flags = GNUNET_GNSRECORD_RF_CRITICAL;
481 "::dead:beef",
482 (void**) &ip_data,
483 &ip_data_size));
484
485 rd[0].data = ip_data;
486 rd[0].data_size = ip_data_size;
487 rd[0].expiration_time = exp1.abs_value_us;
490
491 rd[1].data = "\u611b\u79f0";
492 rd[1].data_size = strlen (rd[1].data);
493 rd[1].expiration_time = exp2.abs_value_us;
496
497 rd[2].data = "Hello World";
498 rd[2].data_size = strlen (rd[2].data);
499 rd[2].expiration_time = exp3.abs_value_us;
502
503 run_pkey (&rd_pkey, 1, "testdelegation");
504 run_pkey (rd, 3, "\u5929\u4e0b\u7121\u6575");
505 run_edkey (&rd_pkey, 1, "testdelegation");
506 run_edkey (rd, 3, "\u5929\u4e0b\u7121\u6575");
507}
#define GNUNET_GNSRECORD_TYPE_NICK
GNS zone nickname.
static void run_pkey(struct GNUNET_GNSRECORD_Data *rd, int rd_count, const char *label)
Main function that will be run.
static void run_edkey(struct GNUNET_GNSRECORD_Data *rd, int rd_count, const char *label)
Main function that will be run.
#define GNUNET_DNSPARSER_TYPE_AAAA
#define GNUNET_DNSPARSER_TYPE_TXT
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
@ GNUNET_GNSRECORD_RF_CRITICAL
This record is critical.
@ GNUNET_GNSRECORD_RF_SUPPLEMENTAL
This is a supplemental record.
@ GNUNET_GNSRECORD_RF_NONE
Entry for no flags / cleared flags.
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_ntoh(struct GNUNET_TIME_AbsoluteNBO a)
Convert absolute time from network byte order.
Definition: time.c:741
Time for absolute time used by GNUnet, in microseconds and in network byte order.

References GNUNET_TIME_Absolute::abs_value_us, data, GNUNET_GNSRECORD_Data::data, GNUNET_GNSRECORD_Data::data_size, GNUNET_GNSRECORD_Data::expiration_time, GNUNET_GNSRECORD_Data::flags, GNUNET_assert, GNUNET_DNSPARSER_TYPE_AAAA, GNUNET_DNSPARSER_TYPE_TXT, GNUNET_GNSRECORD_RF_CRITICAL, GNUNET_GNSRECORD_RF_NONE, GNUNET_GNSRECORD_RF_SUPPLEMENTAL, GNUNET_GNSRECORD_string_to_value(), GNUNET_GNSRECORD_TYPE_NICK, GNUNET_GNSRECORD_TYPE_PKEY, GNUNET_OK, GNUNET_TIME_absolute_ntoh(), parsehex(), rd, GNUNET_GNSRECORD_Data::record_type, run_edkey(), and run_pkey().

Referenced by main().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ main()

int main ( int  argc,
char *const *  argv 
)

The main function of the test vector generation tool.

Parameters
argcnumber of arguments from the command line
argvcommand line arguments
Returns
0 ok, 1 on error

Definition at line 518 of file gnunet-gnsrecord-tvg.c.

520{
523 };
524
526 GNUNET_log_setup ("gnunet-gns-tvg",
527 "INFO",
528 NULL));
529 // gcry_control (GCRYCTL_SET_DEBUG_FLAGS, 1u, 0);
530 // gcry_control (GCRYCTL_SET_VERBOSITY, 99);
531 if (GNUNET_OK !=
533 argc, argv,
534 "gnunet-gns-tvg",
535 "Generate test vectors for GNS",
536 options,
537 &run, NULL))
538 return 1;
539 return 0;
540}
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_OPTION_END
Definition: 002.c:13
struct GNUNET_GETOPT_CommandLineOption options[]
Definition: 002.c:5
static void run(void *cls, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg)
Main function that will be run.
enum GNUNET_GenericReturnValue GNUNET_log_setup(const char *comp, const char *loglevel, const char *logfile)
Setup logging.
const struct GNUNET_OS_ProjectData * GNUNET_OS_project_data_gnunet(void)
Return default project data used by 'libgnunetutil' for GNUnet.
enum GNUNET_GenericReturnValue GNUNET_PROGRAM_run(const struct GNUNET_OS_ProjectData *pd, int argc, char *const *argv, const char *binaryName, const char *binaryHelp, const struct GNUNET_GETOPT_CommandLineOption *options, GNUNET_PROGRAM_Main task, void *task_cls)
Run a standard GNUnet command startup sequence (initialize loggers and configuration,...
Definition: program.c:407
Definition of a command line option.

References GNUNET_assert, GNUNET_GETOPT_OPTION_END, GNUNET_log_setup(), GNUNET_OK, GNUNET_OS_project_data_gnunet(), GNUNET_PROGRAM_run(), options, and run().

Here is the call graph for this function:

Variable Documentation

◆ d_pkey

const char* d_pkey
static
Initial value:
=
"50d7b652a4efeadff37396909785e5952171a02178c8e7d450fa907925fafd98"

Definition at line 33 of file gnunet-gnsrecord-tvg.c.

Referenced by run_pkey().

◆ d_edkey

const char* d_edkey
static
Initial value:
=
"5af7020ee19160328832352bbc6a68a8d71a7cbe1b929969a7c66d415a0d8f65"

Definition at line 36 of file gnunet-gnsrecord-tvg.c.

Referenced by run_edkey().