nx_tls13_kdf.nx
buildroot/runtime/nx_tls13_kdf.nx
about
nx_tls13_kdf.nx -- TLS 1.3 HKDF-Expand-Label + Derive-Secret
(RFC 8446 §7.1).
Phase 0b §C of the Nishi TLS 1.3 stack per
docs/NISHI_TLS13_GAP_AUDIT.md. The thin TLS-specific wrapper
over plain HKDF-Expand that prepends the "tls13 " literal label
and length-prefixes the label + context per the spec's HkdfLabel
struct. Every traffic key, handshake secret, application secret,
and Finished MAC key in TLS 1.3 derives from this.
HkdfLabel layout (RFC 8446 §7.1):
struct {
uint16 length; // big-endian
opaque label<7..255>; // = "tls13 " || Label
// 1-byte length prefix
opaque context<0..255>; // 1-byte length prefix
} HkdfLabel;
Then: HKDF-Expand-Label(Secret, Label, Context, Length) =
HKDF-Expand(Secret, HkdfLabel, Length).
Derive-Secret is convenience: Context = Transcript-Hash(Messages),
Length = hash output (32 for SHA-256, 48 for SHA-384).
What it does today:
- build HkdfLabel struct into a caller buffer
- HKDF-Expand-Label one-shot
- Derive-Secret one-shot (composes ExpandLabel + Transcript-Hash
as caller-supplied buffer)
What it doesn't do yet:
- SHA-384 variant (composes against existing nx_hkdf_sha384;
queued sub-phase)
- Multi-block transcript-hash streaming (caller computes
transcript hash via nx_sha256 incremental API)
KAT verified:
- HkdfLabel byte-exact construction for ("derived", empty hash, 32)
- RFC 8448 §3 early_secret = HMAC-SHA256(0^32, 0^32)
= 33ad0a1c607ec03b09e6cd9893680ce210adf300aa1f2660e1b22e10f170f92a
dependencies 2 imports · 16 importers
diagram shows first 10 each side; +0 more imports, +6 more importers in the complete lists below.
imports: nx_syscalls.nxnx_hkdf.nx
imported by: _tlskdf_minrepro.nxnx_edge_serve_static_test.nxnx_tls13_client_session_recv_sh.nxnx_tls13_handshake.nxnx_tls13_kdf_test.nxnx_tls13_mtls_finished.nxnx_tls13_schedule.nxnx_tls13_schedule_test.nxnx_tls13_server_full_handshake_test.nxnx_tls13_server_session_app_data_test.nxnx_tls13_server_session_derive_hs.nxnx_tls13_server_session_derive_traffic.nxnx_tls13_server_session_emit_sf.nxnx_tls13_server_session_recv_cf.nxnx_tls13_server_session_recv_cf_test.nxnx_tls13_server_session_run_mtls.nx
structs
| none |
consts
| 64 | const TLS13_LABEL_PREFIX_LEN: i64 = 6 |
| 68 | const TLS13_LABEL_MAX: i64 = 249 |
| 72 | const NX_TLS13_KDF_VERDICT_OK: i64 = 1 |
| 73 | const NX_TLS13_KDF_VERDICT_LABEL_TOO_LONG: i64 = 2 |
| 74 | const NX_TLS13_KDF_VERDICT_CONTEXT_TOO_LONG: i64 = 3 |
| 75 | const NX_TLS13_KDF_VERDICT_HKDF_FAIL: i64 = 4 |
| 76 | const NX_TLS13_KDF_VERDICT_N: i64 = 5 |
functions
| 81 | func tls13_build_hkdf_label( |
| 129 | func tls13_hkdf_expand_label( |
| 154 | func tls13_derive_secret( |
| 168 | func nx_tls13_kdf_verdict_is_valid(v: i64) -> i64 called by 1: main |