GNUnet debian-0.24.3-23-g589b01d60
gnunet-pils-tvg.c File Reference
#include "platform.h"
#include "gnunet_util_lib.h"
#include "gnunet_hello_uri_lib.h"
#include "gnunet_pils_service.h"
#include "pils.h"
#include <inttypes.h>
Include dependency graph for gnunet-pils-tvg.c:

Go to the source code of this file.

Functions

static void print_addr (void *cls, const struct GNUNET_PeerIdentity *pid, const char *uri)
 
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_seed
 
static uint8_t seed_key [256/8]
 

Function Documentation

◆ print_addr()

static void print_addr ( void *  cls,
const struct GNUNET_PeerIdentity pid,
const char *  uri 
)
static

Definition at line 39 of file gnunet-pils-tvg.c.

42{
43 printf ("%s\n", uri);
44}
static struct GNUNET_FS_Uri * uri
Value of URI provided on command-line (when not publishing a file but just creating UBlocks to refer ...

References uri.

Referenced by run().

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 55 of file gnunet-pils-tvg.c.

60{
61 struct GNUNET_HELLO_Builder *b;
62 struct GNUNET_HashCode hash;
63 struct GNUNET_CRYPTO_EddsaPrivateKey derived_key;
64
67 "gnunet+tcp://1.2.3.4"));
69 "gnunet+udp://6.7.8.9"));
71 "gnunet+https://example.gnu"));
72
73 printf ("Addresses (sorted):\n");
75 printf ("\n");
77 printf ("Address hash:\n");
78 GNUNET_print_bytes (&hash, sizeof hash, 8, 0);
79 printf ("\n");
80
82 printf("Seed key:\n");
84 printf ("\n");
85
86 printf("Derived key:\n");
87 GNUNET_PILS_derive_pid(sizeof seed_key, seed_key, &hash, &derived_key);
88 GNUNET_print_bytes(&derived_key, sizeof derived_key, 8, 0);
89}
static void print_addr(void *cls, const struct GNUNET_PeerIdentity *pid, const char *uri)
static uint8_t seed_key[256/8]
static const char * d_seed
void GNUNET_PILS_derive_pid(size_t seed_key_bytes, const uint8_t seed_key[seed_key_bytes], const struct GNUNET_HashCode *addrs_hash, struct GNUNET_CRYPTO_EddsaPrivateKey *outkey)
Generate the peer id from the addresses hash and the initial secret key.
Definition: pils_api.c:507
struct GNUNET_HELLO_Builder * GNUNET_HELLO_builder_new()
Allocate builder.
Definition: hello-uri.c:343
void GNUNET_HELLO_builder_iterate(const struct GNUNET_HELLO_Builder *builder, GNUNET_HELLO_UriCallback uc, void *uc_cls)
Iterate over URIs in a builder.
Definition: hello-uri.c:956
enum GNUNET_GenericReturnValue GNUNET_HELLO_builder_add_address(struct GNUNET_HELLO_Builder *builder, const char *address)
Add individual address to the builder.
Definition: hello-uri.c:624
void GNUNET_HELLO_builder_hash_addresses(const struct GNUNET_HELLO_Builder *builder, struct GNUNET_HashCode *hash)
Compute hash over addresses in builder.
Definition: hello-uri.c:1134
@ GNUNET_OK
void GNUNET_print_bytes(const void *buf, size_t buf_len, int fold, int in_be)
Print a byte string in hexadecimal ascii notation.
size_t GNUNET_hex2b(const char *src, void *dst, size_t dstlen, int invert)
Parse an ascii-encoded hexadecimal string into the buffer.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
Private ECC key encoded for transmission.
Context for building (or parsing) HELLO URIs.
Definition: hello-uri.c:184
A 512-bit hashcode.

References d_seed, GNUNET_assert, GNUNET_HELLO_builder_add_address(), GNUNET_HELLO_builder_hash_addresses(), GNUNET_HELLO_builder_iterate(), GNUNET_HELLO_builder_new(), GNUNET_hex2b(), GNUNET_OK, GNUNET_PILS_derive_pid(), GNUNET_print_bytes(), print_addr(), and seed_key.

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 100 of file gnunet-pils-tvg.c.

103{
106 };
107
108 GNUNET_assert (GNUNET_OK ==GNUNET_log_setup ("gnunet-gns-tvg", "INFO", NULL));
109 // gcry_control (GCRYCTL_SET_DEBUG_FLAGS, 1u, 0);
110 // gcry_control (GCRYCTL_SET_VERBOSITY, 99);
112 argc,
113 argv,
114 "gnunet-pils-tvg",
115 "Generate test vectors for PILS",
116 options,
117 &run,
118 NULL))
119 return 1;
120 return 0;
121}
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_seed

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

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

Referenced by run().

◆ seed_key

uint8_t seed_key[256/8]
static

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

Referenced by GNUNET_PILS_derive_pid(), and run().