GNUnet  0.17.6
Data Structures | Functions
gnsrecord_crypto.h File Reference

API for GNS record-related crypto. More...

#include "platform.h"
#include "gnunet_util_lib.h"
#include "gnunet_constants.h"
#include "gnunet_signatures.h"
#include "gnunet_arm_service.h"
#include "gnunet_gnsrecord_lib.h"
#include "gnunet_dnsparser_lib.h"
#include "gnunet_tun_lib.h"
Include dependency graph for gnsrecord_crypto.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  GNRBlockPS
 Information we have in an encrypted block with record data (i.e. More...
 

Functions

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. More...
 
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. More...
 

Detailed Description

API for GNS record-related crypto.

Author
Martin Schanzenbach
Matthias Wachs
Christian Grothoff

Definition in file gnsrecord_crypto.h.

Function Documentation

◆ GNR_derive_block_aes_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.

Parameters
ivinitialization vector to initialize
skeysession key to initialize
labellabel to use for KDF
pubpublic key to use for KDF

4 byte nonce

Expiration time 64 bit.

Set counter part to 1

Definition at line 127 of file gnsrecord_crypto.c.

132 {
133  static const char ctx_key[] = "gns-aes-ctx-key";
134  static const char ctx_iv[] = "gns-aes-ctx-iv";
135 
137  ctx_key, strlen (ctx_key),
138  pub, sizeof(struct GNUNET_CRYPTO_EcdsaPublicKey),
139  label, strlen (label),
140  NULL, 0);
141  memset (ctr, 0, GNUNET_CRYPTO_AES_KEY_LENGTH / 2);
143  GNUNET_CRYPTO_kdf (ctr, 4,
144  ctx_iv, strlen (ctx_iv),
145  pub, sizeof(struct GNUNET_CRYPTO_EcdsaPublicKey),
146  label, strlen (label),
147  NULL, 0);
149  memcpy (ctr + 4, &exp, sizeof (exp));
151  ctr[15] |= 0x01;
152 }
struct GNUNET_HashCode key
The key used in the DHT.
static struct GNUNET_CRYPTO_EddsaPublicKey pub
Definition: gnunet-scrypt.c:46
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:69
#define GNUNET_CRYPTO_AES_KEY_LENGTH
length of the sessionkey in bytes (256 BIT sessionkey)
Public ECC key (always for Curve25519) encoded in a format suitable for network transmission and ECDS...

References GNUNET_CRYPTO_AES_KEY_LENGTH, GNUNET_CRYPTO_kdf(), key, and pub.

Referenced by run_pkey().

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

◆ GNR_derive_block_xsalsa_key()

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.

Parameters
nonceinitialization vector to initialize
skeysession key to initialize
labellabel to use for KDF
pubpublic key to use for KDF

16 byte nonce

Expiration time 64 bit.

Definition at line 156 of file gnsrecord_crypto.c.

161 {
162  static const char ctx_key[] = "gns-xsalsa-ctx-key";
163  static const char ctx_iv[] = "gns-xsalsa-ctx-iv";
164 
165  GNUNET_CRYPTO_kdf (key, crypto_secretbox_KEYBYTES,
166  ctx_key, strlen (ctx_key),
167  pub, sizeof(struct GNUNET_CRYPTO_EddsaPublicKey),
168  label, strlen (label),
169  NULL, 0);
170  memset (nonce, 0, crypto_secretbox_NONCEBYTES);
172  GNUNET_CRYPTO_kdf (nonce, (crypto_secretbox_NONCEBYTES - sizeof (exp)),
173  ctx_iv, strlen (ctx_iv),
174  pub, sizeof(struct GNUNET_CRYPTO_EddsaPublicKey),
175  label, strlen (label),
176  NULL, 0);
178  memcpy (nonce + (crypto_secretbox_NONCEBYTES - sizeof (exp)),
179  &exp, sizeof (exp));
180 }
Public ECC key (always for curve Ed25519) encoded in a format suitable for network transmission and E...

References GNUNET_CRYPTO_kdf(), key, and pub.

Referenced by run_edkey().

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