GNUnet  0.10.x
Macros | Functions
crypto_ecc_setup.c File Reference

helper function for easy EdDSA key setup More...

#include "platform.h"
#include <gcrypt.h>
#include "gnunet_util_lib.h"
Include dependency graph for crypto_ecc_setup.c:

Go to the source code of this file.

Macros

#define LOG(kind, ...)   GNUNET_log_from(kind, "util-crypto-ecc", __VA_ARGS__)
 
#define LOG_STRERROR(kind, syscall)   GNUNET_log_from_strerror(kind, "util-crypto-ecc", syscall)
 
#define LOG_STRERROR_FILE(kind, syscall, filename)   GNUNET_log_from_strerror_file(kind, "util-crypto-ecc", syscall, filename)
 
#define LOG_GCRY(level, cmd, rc)
 Log an error message at log-level 'level' that indicates a failure of the command 'cmd' with the message given by gcry_strerror(rc). More...
 

Functions

static void short_wait ()
 Wait for a short time (we're trying to lock a file or want to give another process a shot at finishing a disk write, etc.). More...
 
struct GNUNET_CRYPTO_EddsaPrivateKeyGNUNET_CRYPTO_eddsa_key_create_from_file (const char *filename)
 Create a new private key by reading it from a file. More...
 
struct GNUNET_CRYPTO_EcdsaPrivateKeyGNUNET_CRYPTO_ecdsa_key_create_from_file (const char *filename)
 Create a new private key by reading it from a file. More...
 
struct GNUNET_CRYPTO_EddsaPrivateKeyGNUNET_CRYPTO_eddsa_key_create_from_configuration (const struct GNUNET_CONFIGURATION_Handle *cfg)
 Create a new private key by reading our peer's key from the file specified in the configuration. More...
 
int GNUNET_CRYPTO_get_peer_identity (const struct GNUNET_CONFIGURATION_Handle *cfg, struct GNUNET_PeerIdentity *dst)
 Retrieve the identity of the host's peer. More...
 
void GNUNET_CRYPTO_eddsa_setup_key (const char *cfg_name)
 Setup a key file for a peer given the name of the configuration file (!). More...
 

Detailed Description

helper function for easy EdDSA key setup

Author
Christian Grothoff

Definition in file crypto_ecc_setup.c.

Macro Definition Documentation

◆ LOG

#define LOG (   kind,
  ... 
)    GNUNET_log_from(kind, "util-crypto-ecc", __VA_ARGS__)

◆ LOG_STRERROR

#define LOG_STRERROR (   kind,
  syscall 
)    GNUNET_log_from_strerror(kind, "util-crypto-ecc", syscall)

Definition at line 32 of file crypto_ecc_setup.c.

◆ LOG_STRERROR_FILE

#define LOG_STRERROR_FILE (   kind,
  syscall,
  filename 
)    GNUNET_log_from_strerror_file(kind, "util-crypto-ecc", syscall, filename)

◆ LOG_GCRY

#define LOG_GCRY (   level,
  cmd,
  rc 
)
Value:
do \
{ \
LOG(level, \
_("`%s' failed at %s:%d with error: %s\n"), \
cmd, \
__FILE__, \
__LINE__, \
gcry_strerror(rc)); \
} while (0)
#define _(String)
GNU gettext support macro.
Definition: platform.h:181

Log an error message at log-level 'level' that indicates a failure of the command 'cmd' with the message given by gcry_strerror(rc).

Definition at line 43 of file crypto_ecc_setup.c.

Function Documentation

◆ short_wait()

static void short_wait ( )
static

Wait for a short time (we're trying to lock a file or want to give another process a shot at finishing a disk write, etc.).

Sleeps for 100ms (as that should be long enough for virtually all modern systems to context switch and allow another process to do some 'real' work).

Definition at line 63 of file crypto_ecc_setup.c.

References GNUNET_NETWORK_socket_select(), GNUNET_TIME_relative_multiply(), and GNUNET_TIME_UNIT_MILLISECONDS.

Referenced by GNUNET_CRYPTO_ecdsa_key_create_from_file(), and GNUNET_CRYPTO_eddsa_key_create_from_file().

64 {
66 
68  (void)GNUNET_NETWORK_socket_select(NULL, NULL, NULL, timeout);
69 }
static struct GNUNET_TIME_Relative timeout
User defined timestamp for completing operations.
Definition: gnunet-arm.c:114
struct GNUNET_TIME_Relative GNUNET_TIME_relative_multiply(struct GNUNET_TIME_Relative rel, unsigned long long factor)
Multiply relative time by a given factor.
Definition: time.c:440
#define GNUNET_TIME_UNIT_MILLISECONDS
One millisecond.
int GNUNET_NETWORK_socket_select(struct GNUNET_NETWORK_FDSet *rfds, struct GNUNET_NETWORK_FDSet *wfds, struct GNUNET_NETWORK_FDSet *efds, struct GNUNET_TIME_Relative timeout)
Check if sockets meet certain conditions.
Definition: network.c:1328
Time for relative time used by GNUnet, in microseconds.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_CRYPTO_eddsa_setup_key()

void GNUNET_CRYPTO_eddsa_setup_key ( const char *  cfg_name)

Setup a key file for a peer given the name of the configuration file (!).

This function is used so that at a later point code can be certain that reading a key is fast (for example in time-dependent testcases).

Parameters
cfg_namename of the configuration file to use

Definition at line 487 of file crypto_ecc_setup.c.

References cfg, GNUNET_CONFIGURATION_create(), GNUNET_CONFIGURATION_destroy(), GNUNET_CONFIGURATION_load(), GNUNET_CRYPTO_eddsa_key_create_from_configuration(), and GNUNET_free.

488 {
490  struct GNUNET_CRYPTO_EddsaPrivateKey *priv;
491 
493  (void)GNUNET_CONFIGURATION_load(cfg, cfg_name);
495  if (NULL != priv)
496  GNUNET_free(priv);
498 }
struct GNUNET_CONFIGURATION_Handle * GNUNET_CONFIGURATION_create(void)
Create a new configuration object.
int GNUNET_CONFIGURATION_load(struct GNUNET_CONFIGURATION_Handle *cfg, const char *filename)
Load configuration.
void GNUNET_CONFIGURATION_destroy(struct GNUNET_CONFIGURATION_Handle *cfg)
Destroy configuration object.
static struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
Definition: gnunet-arm.c:104
Private ECC key encoded for transmission.
configuration data
Definition: configuration.c:83
struct GNUNET_CRYPTO_EddsaPrivateKey * GNUNET_CRYPTO_eddsa_key_create_from_configuration(const struct GNUNET_CONFIGURATION_Handle *cfg)
Create a new private key by reading our peer&#39;s key from the file specified in the configuration...
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function: