GNUnet  0.11.x
Macros | Functions | Variables
gnunet-identity.c File Reference

IDENTITY management command line tool. More...

#include "platform.h"
#include "gnunet_util_lib.h"
#include "gnunet_identity_service.h"
Include dependency graph for gnunet-identity.c:

Go to the source code of this file.

Macros

#define TIMEOUT_STATUS_CODE   40
 Return value from main on timeout. More...
 

Functions

static void shutdown_task (void *cls)
 Task run on shutdown. More...
 
static void test_finished (void)
 Test if we are finished yet. More...
 
static void delete_finished (void *cls, const char *emsg)
 Deletion operation finished. More...
 
static void create_finished (void *cls, const struct GNUNET_IDENTITY_PrivateKey *pk, const char *emsg)
 Creation operation finished. More...
 
static void set_done (void *cls, const char *emsg)
 Function called by GNUNET_IDENTITY_set up on completion. More...
 
static void write_encrypted_message (void)
 Encrypt a message given with -W, encrypted using public key of an identity given with -k. More...
 
static void read_encrypted_message (struct GNUNET_IDENTITY_Ego *ego)
 Decrypt a message given with -R, encrypted using public key of ego and ephemeral key given with -k. More...
 
static void print_ego (void *cls, struct GNUNET_IDENTITY_Ego *ego, void **ctx, const char *identifier)
 If listing is enabled, prints information about the egos. More...
 
static void run (void *cls, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg)
 Main function that will be run by the scheduler. More...
 
int main (int argc, char *const *argv)
 The main function. More...
 

Variables

static struct GNUNET_IDENTITY_Handlesh
 Handle to IDENTITY service. More...
 
static int list
 Was "list" specified? More...
 
static int monitor
 Was "monitor" specified? More...
 
static int private_keys
 Was "private" specified? More...
 
static unsigned int verbose
 Was "verbose" specified? More...
 
static int quiet
 Was "quiet" specified? More...
 
static int type_eddsa
 Was "eddsa" specified? More...
 
static char * write_msg
 -W option More...
 
static char * read_msg
 -R option More...
 
static char * create_ego
 -C option More...
 
static char * delete_ego
 -D option More...
 
static char * privkey_ego
 -P option More...
 
static char * pubkey_msg
 -k option More...
 
static char * set_ego
 -s option. More...
 
static char * set_subsystem
 -S option. More...
 
static struct GNUNET_IDENTITY_Operationset_op
 Operation handle for set operation. More...
 
static struct GNUNET_IDENTITY_Operationcreate_op
 Handle for create operation. More...
 
static struct GNUNET_IDENTITY_Operationdelete_op
 Handle for delete operation. More...
 
struct GNUNET_IDENTITY_PrivateKey pk
 Private key from command line option, or NULL. More...
 
static int global_ret
 Value to return from main(). More...
 

Detailed Description

IDENTITY management command line tool.

Author
Christian Grothoff

Todo:

Definition in file gnunet-identity.c.

Macro Definition Documentation

◆ TIMEOUT_STATUS_CODE

#define TIMEOUT_STATUS_CODE   40

Return value from main on timeout.

Definition at line 36 of file gnunet-identity.c.

Function Documentation

◆ shutdown_task()

static void shutdown_task ( void *  cls)
static

Task run on shutdown.

Parameters
clsNULL

Definition at line 145 of file gnunet-identity.c.

146 {
147  if (NULL != set_op)
148  {
150  set_op = NULL;
151  }
152  if (NULL != create_op)
153  {
155  create_op = NULL;
156  }
157  if (NULL != delete_op)
158  {
160  delete_op = NULL;
161  }
162  if (NULL != set_ego)
163  {
165  set_ego = NULL;
166  }
168  sh = NULL;
169 }
static struct GNUNET_IDENTITY_Operation * set_op
Operation handle for set operation.
static struct GNUNET_IDENTITY_Operation * create_op
Handle for create operation.
static struct GNUNET_IDENTITY_Handle * sh
Handle to IDENTITY service.
static struct GNUNET_IDENTITY_Operation * delete_op
Handle for delete operation.
static char * set_ego
-s option.
void GNUNET_IDENTITY_cancel(struct GNUNET_IDENTITY_Operation *op)
Cancel an identity operation.
Definition: identity_api.c:904
void GNUNET_IDENTITY_disconnect(struct GNUNET_IDENTITY_Handle *h)
Disconnect from identity service.
Definition: identity_api.c:921
#define GNUNET_free(ptr)
Wrapper around free.

References create_op, delete_op, GNUNET_free, GNUNET_IDENTITY_cancel(), GNUNET_IDENTITY_disconnect(), set_ego, set_op, and sh.

Referenced by run().

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

◆ test_finished()

static void test_finished ( void  )
static

Test if we are finished yet.

Definition at line 176 of file gnunet-identity.c.

177 {
178  if ( (NULL == create_op) &&
179  (NULL == delete_op) &&
180  (NULL == set_op) &&
181  (NULL == set_subsystem) &&
182  (NULL == write_msg) &&
183  (NULL == read_msg) &&
184  (! list) &&
185  (! monitor))
186  {
188  global_ret = 0;
190  }
191 }
#define TIMEOUT_STATUS_CODE
Return value from main on timeout.
static int global_ret
Value to return from main().
static int monitor
Was "monitor" specified?
static int list
Was "list" specified?
static char * read_msg
-R option
static char * set_subsystem
-S option.
static char * write_msg
-W option
void GNUNET_SCHEDULER_shutdown(void)
Request the shutdown of a scheduler.
Definition: scheduler.c:531

References create_op, delete_op, global_ret, GNUNET_SCHEDULER_shutdown(), list, monitor, read_msg, set_op, set_subsystem, TIMEOUT_STATUS_CODE, and write_msg.

Referenced by create_finished(), delete_finished(), print_ego(), run(), and set_done().

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

◆ delete_finished()

static void delete_finished ( void *  cls,
const char *  emsg 
)
static

Deletion operation finished.

Parameters
clspointer to operation handle
emsgNULL on success, otherwise an error message

Definition at line 201 of file gnunet-identity.c.

203 {
204  struct GNUNET_IDENTITY_Operation **op = cls;
205 
206  *op = NULL;
207  if (NULL != emsg)
208  fprintf (stderr, "%s\n", gettext (emsg));
209  test_finished ();
210 }
#define gettext(Msgid)
Definition: gettext.h:45
static struct GNUNET_ARM_Operation * op
Current operation.
Definition: gnunet-arm.c:144
static void test_finished(void)
Test if we are finished yet.
Handle for an operation with the identity service.
Definition: identity_api.c:40
void * cls
Closure for cont or cb.
Definition: identity_api.c:88

References GNUNET_IDENTITY_Operation::cls, gettext, op, and test_finished().

Referenced by run().

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

◆ create_finished()

static void create_finished ( void *  cls,
const struct GNUNET_IDENTITY_PrivateKey pk,
const char *  emsg 
)
static

Creation operation finished.

Parameters
clspointer to operation handle
pkprivate key of the ego, or NULL on error
emsgerror message, NULL on success

Definition at line 221 of file gnunet-identity.c.

224 {
225  struct GNUNET_IDENTITY_Operation **op = cls;
226 
227  *op = NULL;
228  if (NULL == pk)
229  {
230  fprintf (stderr,
231  _ ("Failed to create ego: %s\n"),
232  emsg);
233  global_ret = 1;
234  }
235  else if (verbose)
236  {
238  char *pubs;
239 
242  if (private_keys)
243  {
244  char *privs;
245 
247  fprintf (stdout, "%s - %s\n", pubs, privs);
248  GNUNET_free (privs);
249  }
250  else
251  {
252  fprintf (stdout, "%s\n", pubs);
253  }
254  GNUNET_free (pubs);
255  }
256  test_finished ();
257 }
static unsigned int verbose
Was "verbose" specified?
struct GNUNET_IDENTITY_PrivateKey pk
Private key from command line option, or NULL.
static int private_keys
Was "private" specified?
static struct GNUNET_CRYPTO_EddsaPublicKey pub
Definition: gnunet-scrypt.c:46
enum GNUNET_GenericReturnValue GNUNET_IDENTITY_key_get_public(const struct GNUNET_IDENTITY_PrivateKey *privkey, struct GNUNET_IDENTITY_PublicKey *key)
Retrieves the public key representation of a private key.
Definition: identity_api.c:175
char * GNUNET_IDENTITY_private_key_to_string(const struct GNUNET_IDENTITY_PrivateKey *key)
Creates a (Base32) string representation of the private key.
char * GNUNET_IDENTITY_public_key_to_string(const struct GNUNET_IDENTITY_PublicKey *key)
Creates a (Base32) string representation of the public key.
#define _(String)
GNU gettext support macro.
Definition: platform.h:177
An identity key as per LSD0001.

References _, GNUNET_IDENTITY_Operation::cls, global_ret, GNUNET_free, GNUNET_IDENTITY_key_get_public(), GNUNET_IDENTITY_private_key_to_string(), GNUNET_IDENTITY_public_key_to_string(), op, pk, private_keys, pub, test_finished(), and verbose.

Referenced by run().

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

◆ set_done()

static void set_done ( void *  cls,
const char *  emsg 
)
static

Function called by GNUNET_IDENTITY_set up on completion.

Parameters
clsNULL
emsgerror message (NULL on success)

Definition at line 267 of file gnunet-identity.c.

268 {
269  set_op = NULL;
270  if (NULL != emsg)
271  {
272  fprintf (stderr, _ ("Failed to set default ego: %s\n"), emsg);
273  global_ret = 1;
274  }
275  test_finished ();
276 }

References _, global_ret, set_op, and test_finished().

Referenced by print_ego().

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

◆ write_encrypted_message()

static void write_encrypted_message ( void  )
static

Encrypt a message given with -W, encrypted using public key of an identity given with -k.

Definition at line 284 of file gnunet-identity.c.

285 {
286  struct GNUNET_IDENTITY_PublicKey recipient;
289  {
290  struct GNUNET_CRYPTO_EcdhePublicKey message_key;
291  size_t msg_len = strlen (write_msg);
293  msg_len,
294  &recipient,
295  &message_key,
296  write_msg);
297  if (-1 != res)
298  {
299  char *keystr;
300  char *serialized_msg;
301  keystr = GNUNET_STRINGS_data_to_string_alloc (&message_key,
302  sizeof(struct
305  msg_len);
306  fprintf (stdout,
307  "%s.%s\n",
308  keystr, serialized_msg);
309  GNUNET_free (keystr);
310  GNUNET_free (serialized_msg);
311  }
312  else
313  {
314  fprintf (stderr, "Error during encryption.\n");
315  global_ret = 1;
316  }
317  }
318  else
319  {
320  fprintf (stderr, "Invalid recipient public key.\n");
321  global_ret = 1;
322  }
323 }
static int res
static char * pubkey_msg
-k option
@ GNUNET_SYSERR
Definition: gnunet_common.h:93
enum GNUNET_GenericReturnValue GNUNET_IDENTITY_public_key_from_string(const char *str, struct GNUNET_IDENTITY_PublicKey *key)
Parses a (Base32) string representation of the public key.
ssize_t GNUNET_IDENTITY_encrypt(const void *block, size_t size, const struct GNUNET_IDENTITY_PublicKey *pub, struct GNUNET_CRYPTO_EcdhePublicKey *ecc, void *result)
Encrypt a block with GNUNET_IDENTITY_PublicKey and derives a GNUNET_CRYPTO_EcdhePublicKey which is re...
char * GNUNET_STRINGS_data_to_string_alloc(const void *buf, size_t size)
Return the base32crockford encoding of the given buffer.
Definition: strings.c:764
Public ECC key (always for Curve25519) encoded in a format suitable for network transmission and encr...

References global_ret, GNUNET_free, GNUNET_IDENTITY_encrypt(), GNUNET_IDENTITY_public_key_from_string(), GNUNET_STRINGS_data_to_string_alloc(), GNUNET_SYSERR, pubkey_msg, res, and write_msg.

Referenced by run().

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

◆ read_encrypted_message()

static void read_encrypted_message ( struct GNUNET_IDENTITY_Ego ego)
static

Decrypt a message given with -R, encrypted using public key of ego and ephemeral key given with -k.

Parameters
egoego whose private key is used for decryption

Definition at line 333 of file gnunet-identity.c.

334 {
335  // message contains ECDHE key and ciphertext divided by ".", so split up first
336  char delim[2] = ".";
337  char *key_msg = strtok (read_msg, delim);
338  char *cipher;
339  if (NULL == key_msg)
340  {
341  fprintf (stderr, "Invalid message format.\n");
342  global_ret = 1;
343  return;
344  }
345  cipher = strtok (NULL, delim);
346  if (NULL == cipher)
347  {
348  fprintf (stderr, "Invalid message format, text missing.\n");
349  global_ret = 1;
350  return;
351  }
352 
353  if (NULL != strtok (NULL, delim))
354  {
355  fprintf (stderr,
356  "Invalid message format, expecting only key and cipher components.\n");
357  global_ret = 1;
358  return;
359  }
360 
361  struct GNUNET_CRYPTO_EcdhePublicKey message_key;
362  if (GNUNET_OK == GNUNET_STRINGS_string_to_data (key_msg, strlen (
363  key_msg),
364  &message_key,
365  sizeof(message_key)))
366  {
367  char *deserialized_msg;
368  size_t msg_len;
369  if (GNUNET_OK == GNUNET_STRINGS_string_to_data_alloc (cipher, strlen (
370  cipher),
371  (void **) &
372  deserialized_msg,
373  &msg_len))
374  {
375  ssize_t res = GNUNET_IDENTITY_decrypt (deserialized_msg,
376  msg_len,
378  ego),
379  &message_key,
380  deserialized_msg);
381  if (-1 != res)
382  {
383  fprintf (stdout,
384  "%s\n",
385  deserialized_msg);
386  }
387  else
388  {
389  fprintf (stderr, "Failed to decrypt message.\n");
390  global_ret = 1;
391  }
392  GNUNET_free (deserialized_msg);
393  }
394  else
395  {
396  fprintf (stderr, "Invalid message format.\n");
397  global_ret = 1;
398  }
399  }
400  else
401  {
402  fprintf (stderr, "Invalid message ephemeral key.\n");
403  global_ret = 1;
404  }
405 }
@ GNUNET_OK
Definition: gnunet_common.h:95
const struct GNUNET_IDENTITY_PrivateKey * GNUNET_IDENTITY_ego_get_private_key(const struct GNUNET_IDENTITY_Ego *ego)
Obtain the ECC key associated with a ego.
Definition: identity_api.c:639
ssize_t GNUNET_IDENTITY_decrypt(const void *block, size_t size, const struct GNUNET_IDENTITY_PrivateKey *priv, const struct GNUNET_CRYPTO_EcdhePublicKey *ecc, void *result)
Decrypt a given block with GNUNET_IDENTITY_PrivateKey and a given GNUNET_CRYPTO_EcdhePublicKey using ...
enum GNUNET_GenericReturnValue GNUNET_STRINGS_string_to_data_alloc(const char *enc, size_t enclen, void **out, size_t *out_size)
Convert CrockfordBase32 encoding back to data.
Definition: strings.c:855
enum GNUNET_GenericReturnValue GNUNET_STRINGS_string_to_data(const char *enc, size_t enclen, void *out, size_t out_size)
Convert CrockfordBase32 encoding back to data.
Definition: strings.c:789

References global_ret, GNUNET_free, GNUNET_IDENTITY_decrypt(), GNUNET_IDENTITY_ego_get_private_key(), GNUNET_OK, GNUNET_STRINGS_string_to_data(), GNUNET_STRINGS_string_to_data_alloc(), read_msg, and res.

Referenced by print_ego().

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

◆ print_ego()

static void print_ego ( void *  cls,
struct GNUNET_IDENTITY_Ego ego,
void **  ctx,
const char *  identifier 
)
static

If listing is enabled, prints information about the egos.

This function is initially called for all egos and then again whenever a ego's identifier changes or if it is deleted. At the end of the initial pass over all egos, the function is once called with 'NULL' for 'ego'. That does NOT mean that the callback won't be invoked in the future or that there was an error.

When used with 'GNUNET_IDENTITY_create' or 'GNUNET_IDENTITY_get', this function is only called ONCE, and 'NULL' being passed in 'ego' does indicate an error (for example because name is taken or no default value is known). If 'ego' is non-NULL and if '*ctx' is set in those callbacks, the value WILL be passed to a subsequent call to the identity callback of 'GNUNET_IDENTITY_connect' (if that one was not NULL).

When an identity is renamed, this function is called with the (known) ego but the NEW identifier.

When an identity is deleted, this function is called with the (known) ego and "NULL" for the 'identifier'. In this case, the 'ego' is henceforth invalid (and the 'ctx' should also be cleaned up).

Parameters
clsclosure
egoego handle
ctxcontext for application to store data for this ego (during the lifetime of this process, initially NULL)
identifieridentifier assigned by the user for this ego, NULL if the user just deleted the ego and it must thus no longer be used

Definition at line 441 of file gnunet-identity.c.

445 {
447  char *s;
448  char *privs;
449 
450  if ( (NULL != set_ego) &&
451  (NULL != set_subsystem) &&
452  (NULL != ego) &&
453  (NULL != identifier) &&
454  (0 == strcmp (identifier, set_ego)))
455  {
458  ego,
459  &set_done,
460  NULL);
462  set_subsystem = NULL;
464  set_ego = NULL;
465  }
466  if ( (NULL == ego) &&
467  (NULL != set_ego) &&
468  (NULL != set_subsystem) )
469  {
470  fprintf (stderr,
471  "Could not set ego to `%s' for subsystem `%s', ego not known\n",
472  set_ego,
473  set_subsystem);
475  set_subsystem = NULL;
477  set_ego = NULL;
478  }
479  if ( (NULL == ego) &&
480  (NULL != set_ego) &&
481  (NULL != read_msg) )
482  {
483  fprintf (stderr,
484  "Ego `%s' is not known, cannot decrypt message.\n",
485  set_ego);
487  read_msg = NULL;
489  set_ego = NULL;
490  }
491  if ((NULL == ego) && (! monitor))
492  {
493  list = 0;
494  test_finished ();
495  return;
496  }
497  if (! (list | monitor) && (NULL == read_msg))
498  return;
499  if ( (NULL == ego) ||
500  (NULL == identifier) )
501  return;
502  if ( (NULL != set_ego) &&
503  (0 != strcmp (identifier,
504  set_ego)) )
505  return;
510  if ((NULL != read_msg) && (NULL != set_ego))
511  {
512  // due to the check above, set_ego and the identifier are equal
515  read_msg = NULL;
516  }
517  else if ((monitor) || (NULL != identifier))
518  {
519  if (quiet)
520  {
521  if (private_keys)
522  fprintf (stdout, "%s - %s\n", s, privs);
523  else
524  fprintf (stdout, "%s\n", s);
525  }
526  else
527  {
528  if (private_keys)
529  fprintf (stdout, "%s - %s - %s - %s\n",
530  identifier, s, privs,
531  (ntohl (pk.type) == GNUNET_IDENTITY_TYPE_ECDSA) ?
532  "ECDSA" : "EdDSA");
533  else
534  fprintf (stdout, "%s - %s - %s\n",
535  identifier, s,
536  (ntohl (pk.type) == GNUNET_IDENTITY_TYPE_ECDSA) ?
537  "ECDSA" : "EdDSA");
538 
539  }
540  }
541  GNUNET_free (privs);
542  GNUNET_free (s);
543 }
static int quiet
Was "quiet" specified?
static void read_encrypted_message(struct GNUNET_IDENTITY_Ego *ego)
Decrypt a message given with -R, encrypted using public key of ego and ephemeral key given with -k.
static void set_done(void *cls, const char *emsg)
Function called by GNUNET_IDENTITY_set up on completion.
void GNUNET_IDENTITY_ego_get_public_key(struct GNUNET_IDENTITY_Ego *ego, struct GNUNET_IDENTITY_PublicKey *pk)
Get the identifier (public key) of an ego.
Definition: identity_api.c:652
struct GNUNET_IDENTITY_Operation * GNUNET_IDENTITY_set(struct GNUNET_IDENTITY_Handle *h, const char *service_name, struct GNUNET_IDENTITY_Ego *ego, GNUNET_IDENTITY_Continuation cont, void *cont_cls)
Set the preferred/default identity for a service.
Definition: identity_api.c:720
@ GNUNET_IDENTITY_TYPE_ECDSA
The identity type.
uint32_t type
Type of public key.

References GNUNET_free, GNUNET_IDENTITY_ego_get_private_key(), GNUNET_IDENTITY_ego_get_public_key(), GNUNET_IDENTITY_private_key_to_string(), GNUNET_IDENTITY_public_key_to_string(), GNUNET_IDENTITY_set(), GNUNET_IDENTITY_TYPE_ECDSA, list, monitor, pk, private_keys, quiet, read_encrypted_message(), read_msg, set_done(), set_ego, set_op, set_subsystem, sh, test_finished(), and GNUNET_IDENTITY_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 by the scheduler.

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

Definition at line 555 of file gnunet-identity.c.

559 {
560  if ((NULL != set_subsystem) && (NULL == set_ego))
561  {
562  fprintf (stderr, "Option -s requires option -e to be specified as well.\n");
563  return;
564  }
565 
566  if ((NULL != read_msg) && (NULL == set_ego))
567  {
568  fprintf (stderr,
569  "Option -R requires options -e to be specified as well.\n");
570  return;
571  }
572 
573  if ((NULL != write_msg) && (NULL == pubkey_msg))
574  {
575  fprintf (stderr, "Option -W requires option -k to be specified as well.\n");
576  return;
577  }
579  (monitor | list) ||
580  (NULL != set_ego) ||
581  (NULL != set_subsystem)
582  ? &print_ego
583  : NULL,
584  NULL);
585  if (NULL != write_msg)
586  {
589  write_msg = NULL;
590  }
591  // read message is handled in ego callback (print_ego)
592  if (NULL != delete_ego)
593  delete_op =
595  delete_ego,
597  &delete_op);
598  if (NULL != create_ego)
599  {
600  if (NULL != privkey_ego)
601  {
603  strlen (privkey_ego),
604  &pk,
605  sizeof(struct
607  create_op =
609  create_ego,
610  &pk,
611  0, // Ignored
613  &create_op);
614  }
615  else
616  create_op =
618  create_ego,
619  NULL,
620  (type_eddsa) ?
624  &create_op);
625  }
627  NULL);
628  test_finished ();
629 }
static const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration we are using.
Definition: gnunet-abd.c:36
static void write_encrypted_message(void)
Encrypt a message given with -W, encrypted using public key of an identity given with -k.
static char * privkey_ego
-P option
static void shutdown_task(void *cls)
Task run on shutdown.
static void create_finished(void *cls, const struct GNUNET_IDENTITY_PrivateKey *pk, const char *emsg)
Creation operation finished.
static void print_ego(void *cls, struct GNUNET_IDENTITY_Ego *ego, void **ctx, const char *identifier)
If listing is enabled, prints information about the egos.
static char * delete_ego
-D option
static char * create_ego
-C option
static int type_eddsa
Was "eddsa" specified?
static void delete_finished(void *cls, const char *emsg)
Deletion operation finished.
struct GNUNET_IDENTITY_Operation * GNUNET_IDENTITY_create(struct GNUNET_IDENTITY_Handle *h, const char *name, const struct GNUNET_IDENTITY_PrivateKey *privkey, enum GNUNET_IDENTITY_KeyType ktype, GNUNET_IDENTITY_CreateContinuation cont, void *cont_cls)
Create a new ego with the given name.
Definition: identity_api.c:757
struct GNUNET_IDENTITY_Handle * GNUNET_IDENTITY_connect(const struct GNUNET_CONFIGURATION_Handle *cfg, GNUNET_IDENTITY_Callback cb, void *cb_cls)
Connect to the identity service.
Definition: identity_api.c:610
struct GNUNET_IDENTITY_Operation * GNUNET_IDENTITY_delete(struct GNUNET_IDENTITY_Handle *h, const char *name, GNUNET_IDENTITY_Continuation cb, void *cb_cls)
Delete an existing identity.
Definition: identity_api.c:863
@ GNUNET_IDENTITY_TYPE_EDDSA
EDDSA identity.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_shutdown(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run on shutdown, that is when a CTRL-C signal is received,...
Definition: scheduler.c:1331
A private key for an identity as per LSD0001.

References cfg, create_ego, create_finished(), create_op, delete_ego, delete_finished(), delete_op, GNUNET_free, GNUNET_IDENTITY_connect(), GNUNET_IDENTITY_create(), GNUNET_IDENTITY_delete(), GNUNET_IDENTITY_TYPE_ECDSA, GNUNET_IDENTITY_TYPE_EDDSA, GNUNET_SCHEDULER_add_shutdown(), GNUNET_STRINGS_string_to_data(), list, monitor, pk, print_ego(), privkey_ego, pubkey_msg, read_msg, set_ego, set_subsystem, sh, shutdown_task(), test_finished(), type_eddsa, write_encrypted_message(), and write_msg.

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.

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

Definition at line 640 of file gnunet-identity.c.

641 {
644  "create",
645  "NAME",
646  gettext_noop ("create ego NAME"),
647  &create_ego),
649  "delete",
650  "NAME",
651  gettext_noop ("delete ego NAME "),
652  &delete_ego),
654  "privkey",
655  "PRIVATE_KEY",
656  gettext_noop (
657  "set the private key for the identity to PRIVATE_KEY (use together with -C)"),
658  &privkey_ego),
660  "read",
661  "MESSAGE",
662  gettext_noop (
663  "Read and decrypt message encrypted for the given ego (use together with -e EGO)"),
664  &read_msg),
666  "write",
667  "MESSAGE",
668  gettext_noop (
669  "Encrypt and write message for recipient identity PULBIC_KEY, (use together with -k RECIPIENT_PUBLIC_KEY)"),
670  &write_msg),
672  "eddsa",
673  gettext_noop (
674  "generate an EdDSA identity. (use together with -C) EXPERIMENTAL"),
675  &type_eddsa),
677  "display",
678  gettext_noop ("display all egos"),
679  &list),
681  "quiet",
682  gettext_noop ("reduce output"),
683  &quiet),
685  'e',
686  "ego",
687  "NAME",
688  gettext_noop (
689  "set default identity to NAME for a subsystem SUBSYSTEM (use together with -s), restrict results to NAME (use together with -d) or read and decrypt a message for NAME (use together with -R)"),
690  &set_ego),
692  "key",
693  "PUBLIC_KEY",
694  gettext_noop (
695  "The public key of the recipient (with -W)"),
696  &pubkey_msg),
698  "monitor",
699  gettext_noop ("run in monitor mode egos"),
700  &monitor),
702  "private-keys",
703  gettext_noop ("display private keys as well"),
704  &private_keys),
706  's',
707  "set",
708  "SUBSYSTEM",
709  gettext_noop (
710  "set default identity to EGO for a subsystem SUBSYSTEM (use together with -e)"),
711  &set_subsystem),
714  };
715  int res;
716 
717  if (GNUNET_OK !=
718  GNUNET_STRINGS_get_utf8_args (argc, argv,
719  &argc, &argv))
720  return 4;
721  global_ret = TIMEOUT_STATUS_CODE; /* timeout */
722  res = GNUNET_PROGRAM_run (argc,
723  argv,
724  "gnunet-identity",
725  gettext_noop ("Maintain egos"),
726  options,
727  &run,
728  NULL);
729  GNUNET_free_nz ((void *) argv);
730 
731  if (GNUNET_OK != res)
732  return 3;
733  return global_ret;
734 }
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_OPTION_END
Definition: 002.c:13
struct GNUNET_GETOPT_CommandLineOption options[]
Definition: 002.c:5
#define gettext_noop(String)
Definition: gettext.h:69
static void run(void *cls, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg)
Main function that will be run by the scheduler.
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_option_verbose(unsigned int *level)
Define the '-V' verbosity option.
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_option_flag(char shortName, const char *name, const char *description, int *val)
Allow user to specify a flag (which internally means setting an integer to 1/GNUNET_YES/GNUNET_OK.
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_option_string(char shortName, const char *name, const char *argumentHelp, const char *description, char **str)
Allow user to specify a string.
#define GNUNET_free_nz(ptr)
Wrapper around free.
enum GNUNET_GenericReturnValue GNUNET_PROGRAM_run(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:399
enum GNUNET_GenericReturnValue GNUNET_STRINGS_get_utf8_args(int argc, char *const *argv, int *u8argc, char *const **u8argv)
Returns utf-8 encoded arguments.
Definition: strings.c:1223
Definition of a command line option.

References create_ego, delete_ego, gettext_noop, global_ret, GNUNET_free_nz, GNUNET_GETOPT_OPTION_END, GNUNET_GETOPT_option_flag(), GNUNET_GETOPT_option_string(), GNUNET_GETOPT_option_verbose(), GNUNET_OK, GNUNET_PROGRAM_run(), GNUNET_STRINGS_get_utf8_args(), list, monitor, options, private_keys, privkey_ego, pubkey_msg, quiet, read_msg, res, run(), set_ego, set_subsystem, TIMEOUT_STATUS_CODE, type_eddsa, verbose, and write_msg.

Here is the call graph for this function:

Variable Documentation

◆ sh

struct GNUNET_IDENTITY_Handle* sh
static

Handle to IDENTITY service.

Definition at line 41 of file gnunet-identity.c.

Referenced by print_ego(), run(), and shutdown_task().

◆ list

int list
static

Was "list" specified?

Definition at line 46 of file gnunet-identity.c.

Referenced by main(), print_ego(), run(), and test_finished().

◆ monitor

int monitor
static

Was "monitor" specified?

Definition at line 51 of file gnunet-identity.c.

Referenced by main(), print_ego(), run(), and test_finished().

◆ private_keys

int private_keys
static

Was "private" specified?

Definition at line 56 of file gnunet-identity.c.

Referenced by create_finished(), main(), and print_ego().

◆ verbose

unsigned int verbose
static

Was "verbose" specified?

Definition at line 61 of file gnunet-identity.c.

Referenced by create_finished(), and main().

◆ quiet

int quiet
static

Was "quiet" specified?

Definition at line 66 of file gnunet-identity.c.

Referenced by main(), and print_ego().

◆ type_eddsa

int type_eddsa
static

Was "eddsa" specified?

Definition at line 71 of file gnunet-identity.c.

Referenced by main(), and run().

◆ write_msg

char* write_msg
static

-W option

Definition at line 76 of file gnunet-identity.c.

Referenced by main(), run(), test_finished(), and write_encrypted_message().

◆ read_msg

char* read_msg
static

-R option

Definition at line 81 of file gnunet-identity.c.

Referenced by main(), print_ego(), read_encrypted_message(), run(), and test_finished().

◆ create_ego

char* create_ego
static

-C option

Definition at line 86 of file gnunet-identity.c.

Referenced by main(), and run().

◆ delete_ego

char* delete_ego
static

-D option

Definition at line 91 of file gnunet-identity.c.

Referenced by main(), and run().

◆ privkey_ego

char* privkey_ego
static

-P option

Definition at line 96 of file gnunet-identity.c.

Referenced by main(), and run().

◆ pubkey_msg

char* pubkey_msg
static

-k option

Definition at line 101 of file gnunet-identity.c.

Referenced by main(), run(), and write_encrypted_message().

◆ set_ego

char* set_ego
static

-s option.

Definition at line 106 of file gnunet-identity.c.

Referenced by main(), print_ego(), run(), and shutdown_task().

◆ set_subsystem

char* set_subsystem
static

-S option.

Definition at line 111 of file gnunet-identity.c.

Referenced by main(), print_ego(), run(), and test_finished().

◆ set_op

struct GNUNET_IDENTITY_Operation* set_op
static

Operation handle for set operation.

Definition at line 116 of file gnunet-identity.c.

Referenced by print_ego(), set_done(), shutdown_task(), and test_finished().

◆ create_op

struct GNUNET_IDENTITY_Operation* create_op
static

Handle for create operation.

Definition at line 121 of file gnunet-identity.c.

Referenced by run(), shutdown_task(), and test_finished().

◆ delete_op

struct GNUNET_IDENTITY_Operation* delete_op
static

Handle for delete operation.

Definition at line 126 of file gnunet-identity.c.

Referenced by run(), shutdown_task(), and test_finished().

◆ pk

◆ global_ret

int global_ret
static