31#include "sodium/crypto_scalarmult.h"
32#include "sodium/crypto_scalarmult_curve25519.h"
33#include "sodium/utils.h"
52 const void *
salt,
size_t salt_len,
53 const void *label,
size_t label_len,
54 const void *
ikm,
size_t ikm_len,
55 const uint8_t *suite_id,
size_t suite_id_len,
58 size_t labeled_ikm_len = strlen (ctx_str) + suite_id_len
59 + label_len + ikm_len;
60 uint8_t labeled_ikm[labeled_ikm_len];
61 uint8_t *tmp = labeled_ikm;
64 memcpy (tmp, ctx_str, strlen (ctx_str));
65 tmp += strlen (ctx_str);
66 memcpy (tmp, suite_id, suite_id_len);
68 memcpy (tmp, label, label_len);
70 memcpy (tmp,
ikm, ikm_len);
74 labeled_ikm, labeled_ikm_len);
96 const char *label,
size_t label_len,
97 const void *
info,
size_t info_len,
98 const uint8_t *suite_id,
size_t suite_id_len,
102 uint8_t labeled_info[2 + strlen (ctx_str) + suite_id_len + label_len
104 uint8_t *tmp = labeled_info;
105 uint16_t out_len_nbo = htons (out_len);
109 memcpy (tmp, &out_len_nbo, 2);
111 memcpy (tmp, ctx_str, strlen (ctx_str));
112 tmp += strlen (ctx_str);
113 memcpy (tmp, suite_id, suite_id_len);
115 memcpy (tmp, label, label_len);
117 memcpy (tmp,
info, info_len);
123 sizeof labeled_info));
130 const char *extract_ctx,
131 const char *expand_ctx,
132 const void*extract_lbl,
size_t
134 const void*expand_lbl,
size_t
136 const uint8_t *kem_context,
137 size_t kem_context_len,
138 const uint8_t *suite_id,
size_t
147 extract_lbl, extract_lbl_len,
149 suite_id, suite_id_len,
153 expand_lbl, expand_lbl_len,
154 kem_context, kem_context_len,
155 suite_id, suite_id_len,
156 shared_secret,
sizeof *shared_secret);
178 uint8_t kem_context[
sizeof *c +
sizeof pkR->
ecdhe_key];
187 "HPKE KEM encaps: Validation error\n");
193 memcpy (kem_context, c,
sizeof *c);
194 memcpy (kem_context +
sizeof *c,
202 "eae_prk", strlen (
"eae_prk"),
203 "shared_secret", strlen (
"shared_secret"),
204 kem_context,
sizeof kem_context,
205 suite_id, suite_id_len,
227 pkR,
enc, skE, shared_secret);
253 if (0 != crypto_sign_ed25519_pk_to_curve25519 (pkR.
ecdhe_key.
q_y,
268 uint8_t kem_context[
sizeof *c + crypto_scalarmult_curve25519_BYTES];
269 uint8_t pkR[crypto_scalarmult_BYTES];
280 crypto_scalarmult_curve25519_base (pkR,
283 memcpy (kem_context, c,
sizeof *c);
284 memcpy (kem_context +
sizeof *c, pkR,
sizeof pkR);
290 "eae_prk", strlen (
"eae_prk"),
291 "shared_secret", strlen (
"shared_secret"),
292 kem_context,
sizeof kem_context,
309 if (0 != crypto_sign_ed25519_sk_to_curve25519 (skR.
ecdhe_key.
d,
319 uint8_t random_tweak,
353 uint8_t random_tweak;
364 &skE, shared_secret);
377 uint8_t kem_context[
sizeof *
r + crypto_scalarmult_curve25519_BYTES];
378 uint8_t pkR[crypto_scalarmult_BYTES];
393 crypto_scalarmult_curve25519_base (pkR,
395 memcpy (kem_context,
r,
sizeof *
r);
396 memcpy (kem_context +
sizeof *
r, pkR,
sizeof pkR);
402 "eae_prk", strlen (
"eae_prk"),
403 "shared_secret", strlen (
"shared_secret"),
404 kem_context,
sizeof kem_context,
413 const uint8_t *psk,
size_t psk_len,
414 const uint8_t *psk_id,
size_t psk_id_len)
419 got_psk = (0 != psk_len);
420 got_psk_id = (0 != psk_id_len);
422 if (got_psk != got_psk_id)
425 "Inconsistent PSK inputs\n");
434 "PSK input provided when not needed\n");
442 "Missing required PSK input\n");
453 const uint8_t *
info,
size_t info_len,
454 const uint8_t *psk,
size_t psk_len,
455 const uint8_t *psk_id,
size_t psk_id_len,
461 uint8_t key_schedule_context[1 +
sizeof info_hash * 2];
462 uint8_t suite_id[4 + 3 * 2];
463 uint16_t kem_id = htons (32);
464 uint16_t kdf_id = htons (1);
465 uint16_t aead_id = htons (3);
469 memcpy (suite_id,
"HPKE", 4);
470 memcpy (suite_id + 4, &kem_id, 2);
471 memcpy (suite_id + 6, &kdf_id, 2);
472 memcpy (suite_id + 8, &aead_id, 2);
478 "psk_id_hash", strlen (
"psk_id_hash"),
480 suite_id,
sizeof suite_id, &psk_id_hash))
483 "info_hash", strlen (
"info_hash"),
485 suite_id,
sizeof suite_id, &info_hash))
487 memcpy (key_schedule_context, &
mode, 1);
488 memcpy (key_schedule_context + 1, &psk_id_hash,
sizeof psk_id_hash);
489 memcpy (key_schedule_context + 1 +
sizeof psk_id_hash,
490 &info_hash,
sizeof info_hash);
492 shared_secret,
sizeof *shared_secret,
493 "secret", strlen (
"secret"),
495 suite_id,
sizeof suite_id, &secret))
501 "key", strlen (
"key"),
502 &key_schedule_context,
503 sizeof key_schedule_context,
504 suite_id,
sizeof suite_id,
505 ctx->key,
sizeof ctx->key))
511 "base_nonce", strlen (
"base_nonce"),
512 &key_schedule_context,
513 sizeof key_schedule_context,
514 suite_id,
sizeof suite_id,
515 ctx->base_nonce,
sizeof ctx->base_nonce))
521 "exp", strlen (
"exp"),
522 &key_schedule_context,
523 sizeof key_schedule_context,
524 suite_id,
sizeof suite_id,
525 &
ctx->exporter_secret,
526 sizeof ctx->exporter_secret))
541 const uint8_t *
info,
size_t info_len,
542 const uint8_t *psk,
size_t psk_len,
543 const uint8_t *psk_id,
size_t psk_id_len,
563 uint8_t random_tweak;
596 const uint8_t *
info,
size_t info_len,
623 const uint8_t *
info,
size_t info_len,
624 const uint8_t *psk,
size_t psk_len,
625 const uint8_t *psk_id,
size_t psk_id_len,
668 const uint8_t *
info,
size_t info_len,
676 NULL, 0, NULL, 0,
ctx);
683 if (
ctx->seq >= UINT64_MAX)
703 memset (&nonce[i],
ctx->base_nonce[i], 1);
705 nonce[i] =
ctx->base_nonce[i] ^ ((uint8_t*) &
ctx->seq)[j++];
712 const uint8_t*aad,
size_t aad_len,
713 const uint8_t *pt,
size_t pt_len,
714 uint8_t *ct,
unsigned long long *ct_len_p)
720 "HPKE: Wrong role; called as receiver (%d)!\n",
725 crypto_aead_chacha20poly1305_ietf_encrypt (ct, ct_len_p,
734 "HPKE: Seq increment failed!\n");
743 const uint8_t*aad,
size_t aad_len,
744 const uint8_t *ct,
size_t ct_len,
745 uint8_t *pt,
unsigned long long *pt_len)
751 "HPKE: Wrong role; called as sender (%d)!\n",
756 if (0 != crypto_aead_chacha20poly1305_ietf_decrypt (pt, pt_len,
769 "HPKE: Seq increment failed!\n");
779 const uint8_t *
info,
size_t info_len,
780 const uint8_t*aad,
size_t aad_len,
781 const uint8_t *pt,
size_t pt_len,
782 uint8_t *ct,
unsigned long long *ct_len_p)
789 ct_off = (uint8_t*) &
enc[1];
795 "HPKE: Sender setup failed!\n");
809 const uint8_t *
info,
size_t info_len,
810 const uint8_t*aad,
size_t aad_len,
811 const uint8_t *ct,
size_t ct_len,
812 uint8_t *pt,
unsigned long long *pt_len_p)
819 ct_off = (uint8_t*) &
enc[1];
825 "HPKE: Receiver setup failed!\n");
831 ct_len -
sizeof *
enc,
846 if (0 != crypto_sign_ed25519_pk_to_curve25519 (x25519->
ecdhe_key.
q_y,
852 if (0 != crypto_sign_ed25519_pk_to_curve25519 (x25519->
ecdhe_key.
q_y,
871 switch (ntohl (sk->
type))
880 if (0 != crypto_sign_ed25519_sk_to_curve25519 (x25519->
ecdhe_key.
d,
897 switch (ntohl (
key->type))
900 return sizeof (
key->type) +
sizeof (
key->ecdhe_key);
916 if (len <
sizeof (
key->type))
927 buffer + sizeof (
key->type),
928 length - sizeof (
key->type));
947 - sizeof (
key->type));
955 switch (ntohl (
key->type))
1033 switch (ntohl (
key->type))
1036 return sizeof (
key->type) +
sizeof (
key->ecdhe_key);
1040 "Got key type %u\n", ntohl (
key->type));
1056 if (len <
sizeof (
key->type))
1060 sizeof (
key->type));
1067 buffer + sizeof (
key->type),
1068 length - sizeof (
key->type));
1088 - sizeof (
key->type));
1101 switch (ntohl (privkey->
type))
static void compute_nonce(struct GNUNET_CRYPTO_HpkeContext *ctx, uint8_t *nonce)
static enum GNUNET_GenericReturnValue key_schedule(enum GNUNET_CRYPTO_HpkeRole role, enum GNUNET_CRYPTO_HpkeMode mode, const struct GNUNET_ShortHashCode *shared_secret, const uint8_t *info, size_t info_len, const uint8_t *psk, size_t psk_len, const uint8_t *psk_id, size_t psk_id_len, struct GNUNET_CRYPTO_HpkeContext *ctx)
static enum GNUNET_GenericReturnValue increment_seq(struct GNUNET_CRYPTO_HpkeContext *ctx)
static enum GNUNET_GenericReturnValue labeled_extract(const char *ctx_str, const void *salt, size_t salt_len, const void *label, size_t label_len, const void *ikm, size_t ikm_len, const uint8_t *suite_id, size_t suite_id_len, struct GNUNET_ShortHashCode *prk)
A RFC9180 inspired labeled extract.
static enum GNUNET_GenericReturnValue verify_psk_inputs(enum GNUNET_CRYPTO_HpkeMode mode, const uint8_t *psk, size_t psk_len, const uint8_t *psk_id, size_t psk_id_len)
static uint8_t GNUNET_CRYPTO_HPKE_KEM_SUITE_ID[]
static enum GNUNET_GenericReturnValue GNUNET_CRYPTO_hpke_labeled_extract_and_expand(const void *dh, size_t dh_len, const char *extract_ctx, const char *expand_ctx, const void *extract_lbl, size_t extract_lbl_len, const void *expand_lbl, size_t expand_lbl_len, const uint8_t *kem_context, size_t kem_context_len, const uint8_t *suite_id, size_t suite_id_len, struct GNUNET_ShortHashCode *shared_secret)
static enum GNUNET_GenericReturnValue labeled_expand(const char *ctx_str, const struct GNUNET_ShortHashCode *prk, const char *label, size_t label_len, const void *info, size_t info_len, const uint8_t *suite_id, size_t suite_id_len, void *out_buf, uint16_t out_len)
A RFC9180 inspired labeled extract.
static enum GNUNET_GenericReturnValue kem_encaps_norand(uint8_t *suite_id, size_t suite_id_len, const struct GNUNET_CRYPTO_HpkePublicKey *pkR, const struct GNUNET_CRYPTO_HpkeEncapsulation *c, const struct GNUNET_CRYPTO_HpkePrivateKey *skE, struct GNUNET_ShortHashCode *shared_secret)
static uint8_t GNUNET_CRYPTO_HPKE_KEM_ELLIGATOR_SUITE_ID[]
struct GNUNET_HashCode key
The key used in the DHT.
static struct GNUNET_FS_Handle * ctx
static OpusEncoder * enc
OPUS encoder.
struct GNUNET_CRYPTO_BlindablePrivateKey pk
Private key from command line option, or NULL.
static uint32_t type
Type string converted to DNS type value.
static struct GNUNET_CRYPTO_EddsaPublicKey pub
static struct GNUNET_CRYPTO_PowSalt salt
Salt for PoW calculations.
static unsigned char ikm[256/8]
The initial key material for the peer.
commonly used definitions; globals in this file are exempt from the rule that the module name ("commo...
static enum @49 mode
Should we do a PUT (mode = 0) or GET (mode = 1);.
void GNUNET_CRYPTO_ecdhe_key_create(struct GNUNET_CRYPTO_EcdhePrivateKey *pk)
Create a new private key.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_eddsa_kem_decaps(const struct GNUNET_CRYPTO_EddsaPrivateKey *priv, const struct GNUNET_CRYPTO_HpkeEncapsulation *c, struct GNUNET_ShortHashCode *shared_secret)
Decapsulate a key for a private EdDSA key.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_x25519_ecdh(const struct GNUNET_CRYPTO_EcdhePrivateKey *sk, const struct GNUNET_CRYPTO_EcdhePublicKey *pk, struct GNUNET_CRYPTO_EcdhePublicKey *dh)
Derive key material from a ECDH public key and a private X25519 key.
void GNUNET_CRYPTO_ecdhe_elligator_key_create(struct GNUNET_CRYPTO_ElligatorEcdhePrivateKey *sk)
Generates a private key for Curve25519.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_hpke_elligator_kem_encaps(const struct GNUNET_CRYPTO_HpkePublicKey *pkR, struct GNUNET_CRYPTO_HpkeEncapsulation *c, struct GNUNET_ShortHashCode *shared_secret)
Carries out ecdh encapsulation with given public key and the private key from a freshly created ephem...
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_hpke_kem_decaps(const struct GNUNET_CRYPTO_HpkePrivateKey *skR, const struct GNUNET_CRYPTO_HpkeEncapsulation *c, struct GNUNET_ShortHashCode *shared_secret)
Decapsulate a key for a private X25519 key.
void GNUNET_CRYPTO_random_block(enum GNUNET_CRYPTO_Quality mode, void *buffer, size_t length)
Fill block with a random values.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_hpke_kem_encaps_norand(const struct GNUNET_CRYPTO_HpkePublicKey *pkR, struct GNUNET_CRYPTO_HpkeEncapsulation *enc, const struct GNUNET_CRYPTO_HpkePrivateKey *skE, struct GNUNET_ShortHashCode *shared_secret)
Deterministic variant of GNUNET_CRYPTO_hpke_kem_encaps.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_hpke_elligator_kem_decaps(const struct GNUNET_CRYPTO_HpkePrivateKey *skR, const struct GNUNET_CRYPTO_HpkeEncapsulation *c, struct GNUNET_ShortHashCode *shared_secret)
Carries out ecdh decapsulation with own private key and the representative of the received public key...
void GNUNET_CRYPTO_ecdhe_elligator_decoding(struct GNUNET_CRYPTO_EcdhePublicKey *point, bool *high_y, const struct GNUNET_CRYPTO_ElligatorRepresentative *representative)
Clears the most significant bit and second most significant bit of the serialized representaive befor...
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_ecdhe_elligator_key_get_public_norand(uint8_t random_tweak, const struct GNUNET_CRYPTO_ElligatorEcdhePrivateKey *sk, struct GNUNET_CRYPTO_EcdhePublicKey *pub, struct GNUNET_CRYPTO_ElligatorRepresentative *repr)
Generates a valid public key for elligator's inverse map by adding a lower order point to a prime ord...
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_hpke_kem_encaps(const struct GNUNET_CRYPTO_HpkePublicKey *pub, struct GNUNET_CRYPTO_HpkeEncapsulation *c, struct GNUNET_ShortHashCode *shared_secret)
Encapsulate key material for a X25519 public key.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_ecdh_x25519(const struct GNUNET_CRYPTO_EcdhePrivateKey *priv, const struct GNUNET_CRYPTO_EcdhePublicKey *pub, struct GNUNET_CRYPTO_EcdhePublicKey *dh)
Derive key material from a EdDSA public key and a private ECDH key.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_eddsa_kem_encaps(const struct GNUNET_CRYPTO_EddsaPublicKey *pub, struct GNUNET_CRYPTO_HpkeEncapsulation *c, struct GNUNET_ShortHashCode *shared_secret)
Encapsulate key material for a EdDSA public key.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_hpke_elligator_kem_encaps_norand(uint8_t random_tweak, const struct GNUNET_CRYPTO_HpkePublicKey *pkR, struct GNUNET_CRYPTO_HpkeEncapsulation *c, const struct GNUNET_CRYPTO_ElligatorEcdhePrivateKey *skE, struct GNUNET_ShortHashCode *shared_secret)
Carries out ecdh encapsulation with given public key and the private key from a freshly created ephem...
void GNUNET_CRYPTO_ecdhe_key_clear(struct GNUNET_CRYPTO_EcdhePrivateKey *pk)
Clear memory that was used to store a private key.
void GNUNET_CRYPTO_ecdhe_key_get_public(const struct GNUNET_CRYPTO_EcdhePrivateKey *priv, struct GNUNET_CRYPTO_EcdhePublicKey *pub)
Extract the public key for the given private key.
@ GNUNET_CRYPTO_QUALITY_NONCE
Randomness for IVs etc.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_hkdf_extract(struct GNUNET_ShortHashCode *prk, const void *salt, size_t salt_len, const void *ikm, size_t ikm_len)
HKDF-Extract using SHA256.
#define GNUNET_CRYPTO_hkdf_expand(result, out_len, prk,...)
HKDF-Expand using SHA256.
GNUNET_CRYPTO_HpkeKem
HPKE KEM identifier TODO: Elligator KEM was requested at IANA; Number is currently a placeholder.
ssize_t GNUNET_CRYPTO_write_hpke_pk_to_buffer(const struct GNUNET_CRYPTO_HpkePublicKey *key, void *buffer, size_t len)
Writes a GNUNET_CRYPTO_HpkePublicKey to a compact buffer.
#define GNUNET_log(kind,...)
ssize_t GNUNET_CRYPTO_hpke_sk_get_length(const struct GNUNET_CRYPTO_HpkePrivateKey *key)
Get the compacted length of a GNUNET_CRYPTO_HpkePrivateKey.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_read_hpke_pk_from_buffer(const void *buffer, size_t len, struct GNUNET_CRYPTO_HpkePublicKey *key, size_t *read)
Reads a GNUNET_CRYPTO_HpkePublicKey from a compact buffer.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_hpke_seal(struct GNUNET_CRYPTO_HpkeContext *ctx, const uint8_t *aad, size_t aad_len, const uint8_t *pt, size_t pt_len, uint8_t *ct, unsigned long long *ct_len_p)
RFC9180 HPKE encryption.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_hpke_sender_setup(const struct GNUNET_CRYPTO_HpkePublicKey *pkR, const uint8_t *info, size_t info_len, struct GNUNET_CRYPTO_HpkeEncapsulation *enc, struct GNUNET_CRYPTO_HpkeContext *ctx)
RFC9180 HPKE encryption.
ssize_t GNUNET_CRYPTO_hpke_pk_get_length(const struct GNUNET_CRYPTO_HpkePublicKey *key)
Get the compacted length of a GNUNET_CRYPTO_HpkePublicKey.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_hpke_seal_oneshot(const struct GNUNET_CRYPTO_HpkePublicKey *pkR, const uint8_t *info, size_t info_len, const uint8_t *aad, size_t aad_len, const uint8_t *pt, size_t pt_len, uint8_t *ct, unsigned long long *ct_len_p)
RFC9180 HPKE encryption.
uint64_t GNUNET_ntohll(uint64_t n)
Convert unsigned 64-bit integer to host byte order.
ssize_t GNUNET_CRYPTO_write_hpke_sk_to_buffer(const struct GNUNET_CRYPTO_HpkePrivateKey *key, void *buffer, size_t len)
Writes a GNUNET_CRYPTO_HpkePrivateKey to a compact buffer.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_hpke_sk_create(enum GNUNET_CRYPTO_HpkeKeyType type, struct GNUNET_CRYPTO_HpkePrivateKey *pk)
Create a new GNUNET_CRYPTO_HpkePrivateKey of specific type.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_hpke_sk_to_x25519(const struct GNUNET_CRYPTO_BlindablePrivateKey *sk, struct GNUNET_CRYPTO_HpkePrivateKey *x25519)
Convert a GNUnet identity key to a key sutiable for HPKE (X25519)
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_hpke_open_oneshot(const struct GNUNET_CRYPTO_HpkePrivateKey *skR, const uint8_t *info, size_t info_len, const uint8_t *aad, size_t aad_len, const uint8_t *ct, size_t ct_len, uint8_t *pt, unsigned long long *pt_len_p)
RFC9180 HPKE encryption.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_hpke_open(struct GNUNET_CRYPTO_HpkeContext *ctx, const uint8_t *aad, size_t aad_len, const uint8_t *ct, size_t ct_len, uint8_t *pt, unsigned long long *pt_len)
RFC9180 HPKE encryption.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_hpke_sender_setup2(enum GNUNET_CRYPTO_HpkeKem kem, enum GNUNET_CRYPTO_HpkeMode mode, struct GNUNET_CRYPTO_HpkePrivateKey *skE, struct GNUNET_CRYPTO_HpkePrivateKey *skS, const struct GNUNET_CRYPTO_HpkePublicKey *pkR, const uint8_t *info, size_t info_len, const uint8_t *psk, size_t psk_len, const uint8_t *psk_id, size_t psk_id_len, struct GNUNET_CRYPTO_HpkeEncapsulation *enc, struct GNUNET_CRYPTO_HpkeContext *ctx)
RFC9180 HPKE encryption.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_hpke_receiver_setup2(enum GNUNET_CRYPTO_HpkeKem kem, enum GNUNET_CRYPTO_HpkeMode mode, const struct GNUNET_CRYPTO_HpkeEncapsulation *enc, const struct GNUNET_CRYPTO_HpkePrivateKey *skR, const struct GNUNET_CRYPTO_HpkePublicKey *pkS, const uint8_t *info, size_t info_len, const uint8_t *psk, size_t psk_len, const uint8_t *psk_id, size_t psk_id_len, struct GNUNET_CRYPTO_HpkeContext *ctx)
RFC9180 HPKE encryption.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_hpke_sk_get_public(const struct GNUNET_CRYPTO_HpkePrivateKey *privkey, struct GNUNET_CRYPTO_HpkePublicKey *key)
Retrieves the GNUNET_CRYPTO_HpkePublicKey representation of a GNUNET_CRYPTO_HpkePrivateKey.
uint64_t GNUNET_htonll(uint64_t n)
Convert unsigned 64-bit integer to network byte order.
#define GNUNET_CRYPTO_HPKE_NONCE_LEN
void GNUNET_CRYPTO_hpke_sk_clear(struct GNUNET_CRYPTO_HpkePrivateKey *key)
Clear memory that was used to store a GNUNET_CRYPTO_HpkePrivateKey.
#define GNUNET_CRYPTO_kdf_arg(d, s)
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_hpke_receiver_setup(const struct GNUNET_CRYPTO_HpkeEncapsulation *enc, const struct GNUNET_CRYPTO_HpkePrivateKey *skR, const uint8_t *info, size_t info_len, struct GNUNET_CRYPTO_HpkeContext *ctx)
RFC9180 HPKE encryption.
GNUNET_CRYPTO_HpkeMode
HPKE RFC 9180.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_hpke_sk_create2(enum GNUNET_CRYPTO_HpkeKeyType type, const char *ikm, size_t ikm_len, struct GNUNET_CRYPTO_HpkePrivateKey *sk)
Create a new GNUNET_CRYPTO_HpkePrivateKey of specific type.
GNUNET_GenericReturnValue
Named constants for return values.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_hpke_pk_to_x25519(const struct GNUNET_CRYPTO_BlindablePublicKey *pk, struct GNUNET_CRYPTO_HpkePublicKey *x25519)
Convert a GNUnet identity key to a key sutiable for HPKE (X25519)
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_read_hpke_sk_from_buffer(const void *buffer, size_t len, struct GNUNET_CRYPTO_HpkePrivateKey *key, size_t *read)
Reads a GNUNET_CRYPTO_HpkePrivateKey from a compact buffer.
GNUNET_CRYPTO_HpkeKeyType
Key type for the hpke public key union.
GNUNET_CRYPTO_HpkeRole
Role of the HPKE participant.
@ GNUNET_CRYPTO_HPKE_KEM_DH_X25519_HKDF256
@ GNUNET_CRYPTO_HPKE_KEM_DH_X25519ELLIGATOR_HKDF256
@ GNUNET_PUBLIC_KEY_TYPE_EDDSA
EDDSA identity.
@ GNUNET_PUBLIC_KEY_TYPE_ECDSA
The identity type.
@ GNUNET_CRYPTO_HPKE_MODE_PSK
@ GNUNET_CRYPTO_HPKE_MODE_AUTH_PSK
@ GNUNET_CRYPTO_HPKE_MODE_BASE
@ GNUNET_CRYPTO_HPKE_MODE_AUTH
@ GNUNET_CRYPTO_HPKE_KEY_TYPE_X25519
Type for X25519 hybrid public key encryption.
@ GNUNET_CRYPTO_HPKE_ROLE_R
@ GNUNET_CRYPTO_HPKE_ROLE_S
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur.
@ GNUNET_ERROR_TYPE_ERROR
A private key for an identity as per LSD0001.
struct GNUNET_CRYPTO_EcdsaPrivateKey ecdsa_key
An ECDSA identity key.
uint32_t type
Type of public key.
struct GNUNET_CRYPTO_EddsaPrivateKey eddsa_key
AN EdDSA identtiy key.
An identity key as per LSD0001.
unsigned char d[256/8]
d is a value mod n, where n has at most 256 bits.
Public ECC key (always for Curve25519) encoded in a format suitable for network transmission and encr...
unsigned char q_y[256/8]
Q consists of an x- and a y-value, each mod p (256 bits), given here in affine coordinates and Ed2551...
unsigned char d[256/8]
d is a value mod n, where n has at most 256 bits.
Private ECC key encoded for transmission.
unsigned char d[256/8]
d is a value mod n, where n has at most 256 bits.
Public ECC key (always for curve Ed25519) encoded in a format suitable for network transmission and E...
unsigned char q_y[256/8]
Point Q consists of a y-value mod p (256 bits); the x-value is always positive.
Special private ECC key generated by GNUNET_CRYPTO_ecdhe_elligator_key_create.
Elligator representative (always for Curve25519)
uint8_t r[256/8]
Represents an element of Curve25519 finite field.
HPKE DHKEM encapsulation (X25519) See RFC 9180.
A public key used for decryption.
uint32_t type
Type of key.
struct GNUNET_CRYPTO_EcdhePrivateKey ecdhe_key
An ECDHE/X25519 key.
A public key used for encryption.
uint32_t type
Type of key.
struct GNUNET_CRYPTO_EcdhePublicKey ecdhe_key
An ECDHE/X25519 key.