code wiki / (root) / nx_tls13_client_session.nx

nx_tls13_client_session.nx

buildroot/runtime/nx_tls13_client_session.nx

12336 B273 linesdepth 10pulls 23 transitivereach 523 importersview sourcekind tooltopic tls13
docsdependenciesstructsconstsfunctions

about

nx_tls13_client_session.nx -- TLS 1.3 client session state + emit-ClientHello primitive (step 3c.1 of the nx_https_client wiring arc). The Tls13ClientSession struct is the container that the remaining handshake-orchestrator steps (3c.2 recv ServerHello + derive handshake keys; 3c.3 recv encrypted handshake messages via dispatcher_with_validation; 3c.4 emit client Finished; 3c.5 derive application traffic keys) populate field by field as the handshake progresses. At session creation: - client_random[0..32] filled with caller-supplied entropy - x25519 ephemeral keypair generated from caller-supplied seed - transcript hash state initialised - state = CSTATE_INIT (before any message) After emit-CH (this commit): - ClientHello bytes written to caller buffer + transcript updated - state = CSTATE_CH_SENT After 3c.2 (queued): state = WAIT_EE (handshake keys derived) After 3c.3 (queued): state cycles WAIT_EE -> WAIT_CERT -> WAIT_CV -> WAIT_SF -> WAIT_CLIENT_FIN After 3c.4 (queued): state = WAIT_APP_KEYS After 3c.5 (queued): state = CONNECTED (application data flow OK) Public API (this commit): struct Tls13ClientSession { /* see below */ } nx_tls13_client_session_new(client_random, x25519_priv) -> *Tls13ClientSession nx_tls13_client_session_emit_ch(session, sni, sni_len, out_buf, out_cap) -> bytes-written or negative-verdict nx_tls13_client_session_verdict_is_valid(v) -> 0|1 Sealed verdict enum: NX_TLS13_CSESSION_OK positive return = bytes written NX_TLS13_CSESSION_BAD_STATE called emit_ch outside INIT state NX_TLS13_CSESSION_BUF_OVERFLOW output buffer too small NX_TLS13_CSESSION_INTERNAL hello-emit returned negative

dependencies 7 imports · 40 importers

nx_syscalls.nx nx_x25519.nx nx_x25519_ephemeral.nx nx_tls13.nx nx_tls13_hello.nx nx_tls13_transcript.nx nx_p256_ecdh.nx nx_tls13_client_session.nx _dlr_probe.nx nx_ch_census_oracle.nx nx_ch_census_race_stage.nx nx_ch_census_race_stage2.nx nx_chrome_fetch_probe.nx nx_dev_api_build_probe.nx nx_edge_probe.nx nx_golive_dns_gate.nx nx_h2_client_over_tls.nx nx_https_get.nx

diagram shows first 10 each side; +0 more imports, +30 more importers in the complete lists below.

imports: nx_syscalls.nxnx_x25519.nxnx_x25519_ephemeral.nxnx_tls13.nxnx_tls13_hello.nxnx_tls13_transcript.nxnx_p256_ecdh.nx

imported by: _dlr_probe.nxnx_ch_census_oracle.nxnx_ch_census_race_stage.nxnx_ch_census_race_stage2.nxnx_chrome_fetch_probe.nxnx_dev_api_build_probe.nxnx_edge_probe.nxnx_golive_dns_gate.nxnx_h2_client_over_tls.nxnx_https_get.nxnx_https_get_complete.nxnx_https_get_complete_test.nxnx_https_get_spoof.nxnx_https_get_stream.nxnx_https_ka_probe.nxnx_https_post_complete.nxnx_kaprobe.nxnx_lib_fetch_cookie.nxnx_login_e2e_probe.nxnx_mcp_call.nxnx_mgmt_client.nxnx_porkbun_ping_probe.nxnx_research_ka.nxnx_sites_sni_cert_gate.nxnx_sovgit_push.nxnx_tls13_chrome_session.nxnx_tls13_client_h2run.nxnx_tls13_client_session_derive_app.nxnx_tls13_client_session_derive_app_test.nxnx_tls13_client_session_emit_finished.nxnx_tls13_client_session_emit_finished_test.nxnx_tls13_client_session_recv_hs.nxnx_tls13_client_session_recv_hs_test.nxnx_tls13_client_session_recv_sh.nxnx_tls13_client_session_recv_sh_test.nxnx_tls13_client_session_run.nxnx_tls13_client_session_test.nxnx_tls13_p256_loopback_test.nxnx_tls13_sh_probe_test.nxnx_video_get.nx

structs

89struct Tls13ClientSession

consts

69const NX_MAGIC_8192: i64 = 8192
73const NX_TLS13_CSESSION_STATE_INIT: i64 = 0
74const NX_TLS13_CSESSION_STATE_CH_SENT: i64 = 1
75const NX_TLS13_CSESSION_STATE_WAIT_EE: i64 = 2
76const NX_TLS13_CSESSION_STATE_WAIT_CERT: i64 = 3
77const NX_TLS13_CSESSION_STATE_WAIT_CV: i64 = 4
78const NX_TLS13_CSESSION_STATE_WAIT_SF: i64 = 5
79const NX_TLS13_CSESSION_STATE_WAIT_CLIENT_FIN: i64 = 6
80const NX_TLS13_CSESSION_STATE_WAIT_APP_KEYS: i64 = 7
81const NX_TLS13_CSESSION_STATE_CONNECTED: i64 = 8
83const NX_TLS13_CSESSION_OK: i64 = 1
84const NX_TLS13_CSESSION_BAD_STATE: i64 = 2
85const NX_TLS13_CSESSION_BUF_OVERFLOW: i64 = 3
86const NX_TLS13_CSESSION_INTERNAL: i64 = 4
87const NX_TLS13_CSESSION_VERDICT_N: i64 = 5
150const NX_TLS13_CSESSION_BYTES: i64 = 512 // struct + leaf-cert capture fields; page-backed, ample headroom
151const NX_TLS13_HS_REASM_BYTES: i64 = 65536 // handshake-reassembly accumulator: holds a Certificate flight fragmented across records (RFC 8446 ยง5.1) + also the DoS bound on a claimed message length

functions

153func nx_tls13_client_session_verdict_is_valid(v: i64) -> i64
called by 1: main
163func nx_tls13_client_session_new(
244func nx_tls13_client_session_emit_ch(
271func main() -> i64