GNUnet 0.22.2
crypto_ecc_gnsrecord.c File Reference

public key cryptography (ECC) for GNS records (LSD0001) More...

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

Go to the source code of this file.

Macros

#define CURVE   "Ed25519"
 

Functions

static void derive_h (const void *pub, size_t pubsize, const char *label, const char *context, struct GNUNET_HashCode *hc)
 Derive the 'h' value for key derivation, where 'h = H(l,P)'. More...
 
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_eddsa_sign_derived (const struct GNUNET_CRYPTO_EddsaPrivateKey *pkey, const char *label, const char *context, const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose, struct GNUNET_CRYPTO_EddsaSignature *sig)
 This is a signature function for EdDSA which takes a private key and derives it using the label and context before signing. More...
 
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_ecdsa_sign_derived (const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv, const char *label, const char *context, const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose, struct GNUNET_CRYPTO_EcdsaSignature *sig)
 This is a signature function for ECDSA which takes a private key, derives/blinds it and signs the message. More...
 
struct GNUNET_CRYPTO_EcdsaPrivateKeyGNUNET_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. More...
 
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. More...
 
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. More...
 
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. More...
 
void GNUNET_CRYPTO_eddsa_key_get_public_from_scalar (const struct GNUNET_CRYPTO_EddsaPrivateScalar *priv, struct GNUNET_CRYPTO_EddsaPublicKey *pkey)
 Extract the public key of the given private scalar. More...
 

Detailed Description

public key cryptography (ECC) for GNS records (LSD0001)

Author
Christian Grothoff
Florian Dold
Martin Schanzenbach

Definition in file crypto_ecc_gnsrecord.c.

Macro Definition Documentation

◆ CURVE

#define CURVE   "Ed25519"

Definition at line 34 of file crypto_ecc_gnsrecord.c.

Function Documentation

◆ derive_h()

static void derive_h ( const void *  pub,
size_t  pubsize,
const char *  label,
const char *  context,
struct GNUNET_HashCode hc 
)
static

Derive the 'h' value for key derivation, where 'h = H(l,P)'.

Parameters
pubpublic key for deriviation
pubsizethe size of the public key
labellabel for deriviation
contextadditional context to use for HKDF of 'h'; typically the name of the subsystem/application
hcwhere to write the result

NOTE: While (H)KDF calls this value a salt it is not necessary for it to be a random value. It is more common to use a NULL value here (https://www.rfc-editor.org/rfc/rfc8446#section-7.1) But it is safe either way (See RFC 5869)

Definition at line 48 of file crypto_ecc_gnsrecord.c.

53{
60 static const char *const salt = "key-derivation";
61
63 sizeof(*hc),
64 salt,
65 strlen (salt),
66 pub,
67 pubsize,
68 label,
69 strlen (label),
70 context,
71 strlen (context),
72 NULL,
73 0);
74}
static pa_context * context
Pulseaudio context.
static struct GNUNET_CRYPTO_EddsaPublicKey pub
Definition: gnunet-scrypt.c:47
static struct GNUNET_CRYPTO_PowSalt salt
Salt for PoW calculations.
Definition: gnunet-scrypt.c:34
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_kdf(void *result, size_t out_len, const void *xts, size_t xts_len, const void *skm, size_t skm_len,...)
Derive key.
Definition: crypto_kdf.c:62

References context, GNUNET_CRYPTO_kdf(), pub, and salt.

Referenced by GNUNET_CRYPTO_ecdsa_private_key_derive(), GNUNET_CRYPTO_ecdsa_public_key_derive(), GNUNET_CRYPTO_eddsa_private_key_derive(), and GNUNET_CRYPTO_eddsa_public_key_derive().

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