wired
libc-free QUIC/HTTP3 SDK in C for x86_64-linux
Loading...
Searching...
No Matches
hkdf.h File Reference

RFC 5869 HKDF over HMAC-SHA-256, plus the TLS 1.3 / QUIC HKDF-Expand-Label construction (RFC 8446 7.1, RFC 9001 5.1). More...

Go to the source code of this file.

Data Structures

struct  quic_hkdf_label
 HkdfLabel inputs (RFC 8446 7.1): the label (without the "tls13 " prefix) and the context (may be empty: {0, 0}). More...

Macros

#define QUIC_HKDF_PRK   QUIC_SHA256_DIGEST
 pseudorandom key length
#define QUIC_HKDF_PRK_384   QUIC_SHA384_DIGEST
 pseudorandom key length for the SHA-384 instantiation

Functions

void quic_hkdf_extract (quic_span salt, quic_span ikm, u8 prk[QUIC_HKDF_PRK])
 prk = HKDF-Extract(salt, ikm).
int quic_hkdf_expand (const u8 prk[QUIC_HKDF_PRK], quic_span info, quic_mspan okm)
 okm = HKDF-Expand(prk, info, okm.n).
int quic_hkdf_expand_label (const u8 prk[QUIC_HKDF_PRK], const quic_hkdf_label *l, quic_mspan okm)
 okm = HKDF-Expand-Label(prk, label, context, okm.n) with the "tls13 " prefix.
void quic_hkdf_extract_384 (quic_span salt, quic_span ikm, u8 prk[QUIC_HKDF_PRK_384])
 prk = HKDF-Extract(salt, ikm) instantiated with HMAC-SHA-384 (RFC 5869 2.2, TLS_AES_256_GCM_SHA384).
int quic_hkdf_expand_384 (const u8 prk[QUIC_HKDF_PRK_384], quic_span info, quic_mspan okm)
 okm = HKDF-Expand(prk, info, okm.n) instantiated with HMAC-SHA-384 (RFC 5869 2.3).
int quic_hkdf_expand_label_384 (const u8 prk[QUIC_HKDF_PRK_384], const quic_hkdf_label *l, quic_mspan okm)
 okm = HKDF-Expand-Label(prk, label, context, okm.n) with the "tls13 " prefix, instantiated with HMAC-SHA-384 (RFC 8446 7.1, RFC 9001 5.1).

Detailed Description

RFC 5869 HKDF over HMAC-SHA-256, plus the TLS 1.3 / QUIC HKDF-Expand-Label construction (RFC 8446 7.1, RFC 9001 5.1).

Function Documentation

◆ quic_hkdf_expand()

int quic_hkdf_expand ( const u8 prk[QUIC_HKDF_PRK],
quic_span info,
quic_mspan okm )

okm = HKDF-Expand(prk, info, okm.n).

okm.n must be <= 255*32.

Parameters
prk32-byte pseudorandom key from quic_hkdf_extract()
infocontext/application-specific info (may be empty)
okmreceives exactly okm.n bytes of output keying material
Returns
1 on success, 0 if the length is out of range.

◆ quic_hkdf_expand_384()

int quic_hkdf_expand_384 ( const u8 prk[QUIC_HKDF_PRK_384],
quic_span info,
quic_mspan okm )

okm = HKDF-Expand(prk, info, okm.n) instantiated with HMAC-SHA-384 (RFC 5869 2.3).

okm.n must be <= 255*48.

Parameters
prk48-byte pseudorandom key from quic_hkdf_extract_384()
infocontext/application-specific info (may be empty)
okmreceives exactly okm.n bytes of output keying material
Returns
1 on success, 0 if the length is out of range.

◆ quic_hkdf_expand_label()

int quic_hkdf_expand_label ( const u8 prk[QUIC_HKDF_PRK],
const quic_hkdf_label * l,
quic_mspan okm )

okm = HKDF-Expand-Label(prk, label, context, okm.n) with the "tls13 " prefix.

Parameters
prk32-byte pseudorandom key
llabel and context inputs (see quic_hkdf_label)
okmreceives exactly okm.n bytes of output keying material
Returns
1 on success, 0 if the label/context/length do not fit.

◆ quic_hkdf_expand_label_384()

int quic_hkdf_expand_label_384 ( const u8 prk[QUIC_HKDF_PRK_384],
const quic_hkdf_label * l,
quic_mspan okm )

okm = HKDF-Expand-Label(prk, label, context, okm.n) with the "tls13 " prefix, instantiated with HMAC-SHA-384 (RFC 8446 7.1, RFC 9001 5.1).

Parameters
prk48-byte pseudorandom key
llabel and context inputs (see quic_hkdf_label)
okmreceives exactly okm.n bytes of output keying material
Returns
1 on success, 0 if the label/context/length do not fit.

◆ quic_hkdf_extract()

void quic_hkdf_extract ( quic_span salt,
quic_span ikm,
u8 prk[QUIC_HKDF_PRK] )

prk = HKDF-Extract(salt, ikm).

Parameters
saltoptional salt (may be empty)
ikminput keying material
prkreceives the 32-byte pseudorandom key

◆ quic_hkdf_extract_384()

void quic_hkdf_extract_384 ( quic_span salt,
quic_span ikm,
u8 prk[QUIC_HKDF_PRK_384] )

prk = HKDF-Extract(salt, ikm) instantiated with HMAC-SHA-384 (RFC 5869 2.2, TLS_AES_256_GCM_SHA384).

Parameters
saltoptional salt (may be empty)
ikminput keying material
prkreceives the 48-byte pseudorandom key