code wiki / (root) / nx_tls13_server.nx

nx_tls13_server.nx

buildroot/runtime/nx_tls13_server.nx

10570 B268 linesdepth 9pulls 16 transitivereach 6 importersview sourcekind librarytopic tls13
docsdependenciesstructsconstsfunctions

about

nx_tls13_server.nx -- TLS 1.3 server-side handshake (sovereign loopback). Phase 0b sovereign-loopback brick per docs/NISHI_TLS13_GAP_AUDIT.md. Mirrors nx_tls13_client.nx so the substrate can be proven end-to-end without depending on any external TLS server (Cloudflare, openssl s_server, etc). The loopback test in nx_tls13_loopback_test.nx wires this module against nx_tls13_client.nx and verifies both sides reach CONNECTED with byte-identical handshake keys. Per user (2026-05-16): "i dont want anything but sovereign". External-server interop is a SEPARATE optional check, never the substrate's correctness proof. What it does today: - parse ClientHello: extract random / session_id / extensions offsets so caller can walk to find key_share + supported_groups - emit minimal ServerHello with TLS 1.3 supported_versions + X25519 key_share + chosen cipher (ChaCha20-Poly1305-SHA256) - server state machine: WAIT_CH -> WAIT_CF -> CONNECTED (caller drives WAIT_CH by calling parse + emit; this module's dispatcher handles WAIT_CF when the client_Finished arrives) - sealed verdict + validity gate What it doesn't do yet: - signature over CertificateVerify (currently the loopback test uses a placeholder; Gap I when wired will sign with ed25519 over the transcript) - HelloRetryRequest emission (the server here ALWAYS accepts the client's first key_share if X25519; if the client offered a group we don't support, today we just fail; queued: emit HRR with our preferred group) - ALPN negotiation (CH offers a list; server picks one; queued) - PSK acceptance / 0-RTT (Gap M) KAT verified: - end-to-end via nx_tls13_loopback_test.nx: client + server both using shipped substrate reach CONNECTED, derive identical handshake_secret + traffic secrets, verify each other's MACs

dependencies 6 imports · 6 importers

nx_syscalls.nx nx_tls13.nx nx_tls13_hello.nx nx_tls13_finished.nx nx_tls13_transcript.nx nx_tls13_schedule.nx nx_tls13_server.nx nx_https_get_happy_test.nx nx_https_loopback_test.nx nx_tls13_full_tcp_test.nx nx_tls13_handshake_io.nx nx_tls13_handshake_tcp_test.nx nx_tls13_loopback_test.nx

imports: nx_syscalls.nxnx_tls13.nxnx_tls13_hello.nxnx_tls13_finished.nxnx_tls13_transcript.nxnx_tls13_schedule.nx

imported by: nx_https_get_happy_test.nxnx_https_loopback_test.nxnx_tls13_full_tcp_test.nxnx_tls13_handshake_io.nxnx_tls13_handshake_tcp_test.nxnx_tls13_loopback_test.nx

structs

none

consts

66const NX_TLS13_SSTATE_WAIT_CH: i64 = 1
67const NX_TLS13_SSTATE_WAIT_CF: i64 = 2
68const NX_TLS13_SSTATE_CONNECTED: i64 = 3
69const NX_TLS13_SSTATE_N: i64 = 4
71const NX_TLS13_SERVER_VERDICT_OK: i64 = 1
72const NX_TLS13_SERVER_VERDICT_BAD_MSG_TYPE: i64 = 2
73const NX_TLS13_SERVER_VERDICT_BAD_CH: i64 = 3
74const NX_TLS13_SERVER_VERDICT_BAD_FORMAT: i64 = 4
75const NX_TLS13_SERVER_VERDICT_CF_BAD_MAC: i64 = 5
76const NX_TLS13_SERVER_VERDICT_BUF_OVERFLOW: i64 = 6
77const NX_TLS13_SERVER_VERDICT_N: i64 = 7
79const NX_TLS13_SERVER_HASH_LEN: i64 = 32

functions

89func tls13_server_parse_client_hello(
142func tls13_server_emit_server_hello(
227func tls13_server_dispatch_client_finished(
258func nx_tls13_server_verdict_is_valid(v: i64) -> i64
called by 1: main
264func nx_tls13_sstate_is_valid(s: i64) -> i64
called by 1: main