34 "50d7b652a4efeadff37396909785e5952171a02178c8e7d450fa907925fafd98";
37 "5af7020ee19160328832352bbc6a68a8d71a7cbe1b929969a7c66d415a0d8f65";
41parsehex (
const char *src,
char *dst,
size_t dstlen,
int invert)
43 const char *
line = src;
49 while (sscanf (
data,
" %02x%n", &read_byte, &off) == 1)
52 dst[dstlen - 1 - data_len++] = read_byte;
54 dst[data_len++] = read_byte;
69 for (i = 0; i < buf_len; i++)
73 if ((0 != fold) && (i % fold == 0))
83 printf (
"%02x", ((
unsigned char*) buf)[buf_len - 1 - i]);
85 printf (
"%02x", ((
unsigned char*) buf)[i]);
105 uint16_t flags = htons (
rd->
flags);
118 printf (
"\n DATA_SIZE:\n");
120 printf (
"\n TYPE:\n");
122 printf (
"\n FLAGS: ");
166 printf (
"Zone private key (d, big-endian):\n");
170 printf (
"Zone identifier (ztype|zkey):\n");
180 printf (
"%s\n", ztld);
191 printf (
"\nNumber of records (integer): %d\n\n",
rd_count);
195 printf (
"Record #%d := (\n", i);
221 printf (
"Encryption NONCE|EXPIRATION|BLOCK COUNTER:\n");
224 printf (
"Encryption key (K):\n");
230 printf (
"Storage key (q):\n");
252 printf (
"ZKDF(zkey):\n");
253 print_bytes (&derived_key,
sizeof (derived_key), 8);
255 printf (
"Derived private key (d', big-endian):\n");
256 print_bytes_ (derived_privkey,
sizeof (*derived_privkey), 8, 1);
258 bdata_size = ntohl (rrblock->
size) -
sizeof (
struct
267 printf (
"RRBLOCK:\n");
299 unsigned char nonce[crypto_secretbox_NONCEBYTES];
300 unsigned char skey[crypto_secretbox_KEYBYTES];
315 "Zone private key (d):\n");
319 printf (
"Zone identifier (ztype|zkey):\n");
329 printf (
"%s\n", ztld);
341 "\nNumber of records (integer): %d\n\n",
rd_count);
345 printf (
"Record #%d := (\n", i);
372 printf (
"Encryption NONCE|EXPIRATION:\n");
375 printf (
"Encryption key (K):\n");
381 printf (
"Storage key (q):\n");
394 char derived_privkeyNBO[32];
402 "gns", &derived_privkey);
403 printf (
"ZKDF(zkey):\n");
404 print_bytes (&derived_key,
sizeof (derived_key), 8);
406 printf (
"nonce := SHA-256 (dh[32..63] || h):\n");
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);
415 bdata_size = ntohl (rrblock->
size) -
sizeof (
struct
423 printf (
"RRBLOCK:\n");
453 size_t pkey_data_size;
461 parsehex (
"001cee8c10e25980", (
char*) &exp1nbo,
sizeof (exp1nbo), 0);
462 parsehex (
"003ff2aa5408db40", (
char*) &exp2nbo,
sizeof (exp2nbo), 0);
463 parsehex (
"0028bb13ff371940", (
char*) &exp3nbo,
sizeof (exp3nbo), 0);
471 "000G0011WESGZY9VRV9NNJ66W3GKNZFZF56BFD2BQF3MHMJST2G2GKDYGG",
474 rd_pkey.
data = pkey_data;
491 rd[1].
data =
"\u611b\u79f0";
497 rd[2].
data =
"Hello World";
503 run_pkey (&rd_pkey, 1,
"testdelegation");
505 run_edkey (&rd_pkey, 1,
"testdelegation");
535 "Generate test vectors for GNS",
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_OPTION_END
struct GNUNET_GETOPT_CommandLineOption options[]
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.
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.
API for GNS record-related crypto.
static struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
static char * line
Desired phone line (string to be converted to a hash).
static char * data
The data to insert into the dht.
static char * expire
DID Document expiration Date Attribute String.
static void print_bytes_(void *buf, size_t buf_len, int fold, int in_be)
static int parsehex(const char *src, char *dst, size_t dstlen, int invert)
static const char * d_edkey
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(void *cls, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg)
Main function that will be run.
static const char * d_pkey
int main(int argc, char *const *argv)
The main function of the test vector generation tool.
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.
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.
API that can be used to manipulate GNS record data.
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_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.
void GNUNET_CRYPTO_ecdsa_key_create(struct GNUNET_CRYPTO_EcdsaPrivateKey *pk)
Create a new private key.
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.
#define GNUNET_DNSPARSER_TYPE_AAAA
#define GNUNET_DNSPARSER_TYPE_TXT
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.
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...
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.
@ 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_NONE
Entry for no flags / cleared flags.
ssize_t GNUNET_CRYPTO_public_key_get_length(const struct GNUNET_CRYPTO_PublicKey *key)
Get the compacted length of a GNUNET_CRYPTO_PublicKey.
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.
uint64_t GNUNET_ntohll(uint64_t n)
Convert unsigned 64-bit integer to host byte order.
#define GNUNET_CRYPTO_AES_KEY_LENGTH
length of the sessionkey in bytes (256 BIT sessionkey)
uint64_t GNUNET_htonll(uint64_t n)
Convert unsigned 64-bit integer to network byte order.
@ GNUNET_PUBLIC_KEY_TYPE_EDDSA
EDDSA identity.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
enum GNUNET_GenericReturnValue GNUNET_log_setup(const char *comp, const char *loglevel, const char *logfile)
Setup logging.
#define GNUNET_malloc(size)
Wrapper around malloc.
#define GNUNET_free(ptr)
Wrapper around free.
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,...
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.
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_ntoh(struct GNUNET_TIME_AbsoluteNBO a)
Convert absolute time from network byte order.
struct GNUNET_TIME_Absolute GNUNET_TIME_relative_to_absolute(struct GNUNET_TIME_Relative rel)
Convert relative time to an absolute time in the future.
#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.
#define GNUNET_GNSRECORD_TYPE_NICK
GNS zone nickname.
#define GNUNET_GNSRECORD_TYPE_PKEY
WARNING: This header is generated! In order to add GNS record types, you must register them in GANA,...
#define GNUNET_GNSRECORD_TYPE_EDKEY
GNS zone delegation (EDKEY)
Private ECC key encoded for transmission.
Public ECC key (always for Curve25519) encoded in a format suitable for network transmission and ECDS...
Private ECC key encoded for transmission.
Private ECC scalar encoded for transmission.
unsigned char s[512/8]
s is the expandedprivate 512-bit scalar of a private key.
Public ECC key (always for curve Ed25519) encoded in a format suitable for network transmission and E...
A private key for an identity as per LSD0001.
uint32_t type
Type of public key.
struct GNUNET_CRYPTO_EddsaPrivateKey eddsa_key
AN EdDSA identtiy key.
struct GNUNET_CRYPTO_EcdsaPrivateKey ecdsa_key
An ECDSA identity key.
An identity key as per LSD0001.
struct GNUNET_CRYPTO_EcdsaPublicKey ecdsa_key
An ECDSA identity key.
struct GNUNET_CRYPTO_EddsaPublicKey eddsa_key
AN EdDSA identtiy key.
Definition of a command line option.
struct GNUNET_GNSRECORD_EcdsaBlock ecdsa_block
struct GNUNET_GNSRECORD_EddsaBlock eddsa_block
uint32_t size
Size of the block.
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 time used by GNUnet, in microseconds and in network byte order.
Time for absolute times used by GNUnet, in microseconds.
uint64_t abs_value_us
The actual value.
Time for relative time used by GNUnet, in microseconds.
uint64_t rel_value_us
The actual value.