code wiki / (root) / nx_tls13_server_clientauth.nx

nx_tls13_server_clientauth.nx

buildroot/runtime/nx_tls13_server_clientauth.nx

9167 B174 linesdepth 11pulls 17 transitivereach 2 importersview sourcekind tooltopic tls13
docsdependenciesstructsconstsfunctions

about

nx_tls13_server_clientauth.nx -- TLS 1.3 server-side CLIENT authentication: verify a presented client certificate's CertificateVerify over the handshake transcript (RFC 8446 §4.4.3). mTLS rung R3 of the NO-COOKIE session carrier. This is the cryptographic heart: it proves that whoever opened the TLS connection HOLDS THE PRIVATE KEY of the presented client identity cert -- so the browser authenticates itself at the TLS layer on EVERY connection (top-level navs, refresh, new tab) with zero cookie, zero header, zero auth-carrier JS. R7 wires this into the live terminator's record loop (send CertificateRequest after EncryptedExtensions, then receive+decrypt the client's Certificate + CertificateVerify before its Finished). R6 turns the verified identity pubkey/Subject into HR entitlements. The signed content mirrors the server's build_cv_context (nx_tls13_server_session_emit_cv) but with the CLIENT context label (RFC 8446 §4.4.3): 64*0x20 || "TLS 1.3, client CertificateVerify" || 0x00 || hash. Ed25519 signs/verifies the 130-byte content directly. Composes nx_x509 (parse) + nx_ed25519_signature. license_tier: ORIGINAL expect_exit: 0

dependencies 4 imports · 2 importers

nx_syscalls.nx nx_x509.nx nx_ed25519_signature.nx nx_x509_leaf_emit.nx nx_tls13_server_clientauth.nx nx_mtls_loopback_probe.nx nx_tls13_mtls_loopback_test.nx

imports: nx_syscalls.nxnx_x509.nxnx_ed25519_signature.nxnx_x509_leaf_emit.nx

imported by: nx_mtls_loopback_probe.nxnx_tls13_mtls_loopback_test.nx

call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown

main ca_w sys_write sys_mmap ca_mint ed25519_pub_from_priv sys_mmap ↻ ed25519_sha512 sys_mmap ↻ sha512_init sha512_update sha512_blk_set_byte blk_get_i64 blk_set_i64 sha512_compress sys_mmap ↻ blk_get_i64 ↻ sha512_gamma0 sha512_gamma1 sha512_sigma1 sha512_ch sha512_k sha512_sigma0 sha512_maj sha512_final sha512_blk_set_byte ↻ sha512_compress ↻ ge_p3_alloc sys_mmap ↻ fe_alloc nx_scratch nx_scratch_init nx_scratch_oom sys_mmap ↻ fe_zero ed25519_basepoint_p3 sys_mmap ↻ ge_p3_decompress sys_mmap ↻ fe_from_bytes

structs

none

consts

19const NX_MAGIC_4096: i64 = 4096
21const NX_CA_OK: i64 = 0
22const NX_CA_BAD_CERT: i64 = 1
23const NX_CA_BAD_SIG: i64 = 2
24const NX_CA_UNSUPPORTED_SCHEME: i64 = 3
25const NX_CA_CV_CONTEXT_LEN: i64 = 130
26const NX_CA_SS_ED25519: i64 = 0x0807 // SignatureScheme ed25519

functions

29func tls13_build_client_cv_content(transcript_hash_32: *u8, out_130: *u8) -> i64
45func tls13_verify_client_auth_ed25519(
74func ca_w(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(1, s, n); return 0 }
called by 2: ca_rowmain calls 1: sys_write
75func ca_len(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n }
called by 1: main
76func ca_row(name: *u8, ok: i64) -> i64 { if ok == 1 { ca_w(" PASS " as *u8) } else { ca_w(" FAIL " as *u8) } ca_w(name); ca_w("\n" as *u8); return ok }
called by 1: main calls 1: ca_w
79func ca_mint(seed: *u8, pub: *u8, cn: *u8, cn_n: i64, cert: *u8, cap: i64, clen: *i64) -> i64
88func main() -> i64