code wiki / (root) / nx_tls13_server_recv_client_cv.nx

nx_tls13_server_recv_client_cv.nx

buildroot/runtime/nx_tls13_server_recv_client_cv.nx

11680 B212 linesdepth 11pulls 45 transitivereach 3 importersview sourcekind tooltopic tls13
docsdependenciesstructsconstsfunctions

about

nx_tls13_server_recv_client_cv.nx -- R7 rung 7c: receive + verify the client's CertificateVerify. After recv_client_cert (7b) folded the client Certificate into the transcript, this rung: snapshots the transcript (= Transcript-Hash through the client Certificate, per RFC 8446 ยง4.4.3), AEAD-decrypts the client CertificateVerify record, parses out the SignatureScheme + signature, rebuilds the 130-byte signed content (64*0x20 || "TLS 1.3, client CertificateVerify" || 0x00 || transcript-hash), and VERIFIES it against the client cert's public key -- dispatching Ed25519 (0x0807) -> ed25519_verify_full and ECDSA-P256 (0x0403) -> nx_x509_verify_ecdsa_p256. This is the same crypto proven in R3 (6/6) + R5c (5/5), re-composed here over the verify PRIMITIVES (not the R3/R5c files) so this rung shares only the TLS-record + x509-verify closures (no cert-MINTER imports -> no build-closure clash). NEVER-LOCKOUT: returns a distinct verdict for "no/!valid client auth" so the run loop can fall back to the header path rather than failing the handshake. license_tier: ORIGINAL expect_exit: 0

dependencies 10 imports · 1 importers

nx_syscalls.nx nx_tls13.nx nx_tls13_record.nx nx_tls13_transcript.nx nx_tls13_server_session.nx nx_tls13_auth.nx nx_ed25519_signature.nx nx_x509.nx nx_x509_verify_ecdsa.nx nx_u256.nx nx_tls13_server_recv_client_cv nx_tls13_server_session_run_mtls.n

imports: nx_syscalls.nxnx_tls13.nxnx_tls13_record.nxnx_tls13_transcript.nxnx_tls13_server_session.nxnx_tls13_auth.nxnx_ed25519_signature.nxnx_x509.nxnx_x509_verify_ecdsa.nxnx_u256.nx

imported by: nx_tls13_server_session_run_mtls.nx

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

main rcv_w sys_write sys_mmap rcv_build_cv rcv_u24 rcv_seal sys_mmap ↻ nx_tls13_record_encrypt_v2 sys_mmap ↻ tls13_record_write_header tls13_record_build_nonce tls13_record_aead_seal nx_chacha20_poly1305_encry sys_mmap ↻ aead_derive_otk sys_mmap ↻ chacha20_block chacha20_encrypt sys_mmap ↻ _chacha20_set_consts_key load_u32_le chacha20_perm_core aead_build_mac_data aead_put_u64_le poly1305_mac sys_mmap ↻ poly1305_clamp p_load_u32_le p_store_u32_le nx_aes128_gcm_seal sys_mmap ↻ aes128_expand_key _aes_sbox _aes_rcon aes128_encrypt_block nx_ghash_reflect16 gh_byterev_bits nx_ghash_mul_rev gh_clmul_core

structs

none

consts

25const NX_RCV_OK: i64 = 0
26const NX_RCV_BAD_STATE: i64 = 1
27const NX_RCV_DECRYPT_FAIL: i64 = 2 // AEAD/record error
28const NX_RCV_PARSE_FAIL: i64 = 3 // not a well-formed CertificateVerify
29const NX_RCV_BAD_CERT: i64 = 4 // client cert unparseable / wrong key shape
30const NX_RCV_VERIFY_FAIL: i64 = 5 // signature did not verify (reject -- no access)
31const NX_RCV_UNSUPPORTED: i64 = 6 // scheme not Ed25519 / ECDSA-P256
32const NX_RCV_CV_CONTENT_LEN: i64 = 130
33const NX_RCV_SS_ED25519: i64 = 0x0807
34const NX_RCV_SS_ECDSA: i64 = 0x0403
35const NX_RCV_REC_HEADER: i64 = 5
36const NX_RCV_REC_TAG: i64 = 16

functions

38func rcv_cv_content(th32: *u8, out130: *u8) -> i64
52func nx_tls13_server_recv_client_cv(
121func rcv_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: rcv_rowmain calls 1: sys_write
122func rcv_row(name: *u8, ok: i64) -> i64 { if ok == 1 { rcv_w(" PASS " as *u8) } else { rcv_w(" FAIL " as *u8) } rcv_w(name); rcv_w("\n" as *u8); return ok }
called by 1: main calls 1: rcv_w
123func rcv_u24(b: *u8, o: i64, v: i64) -> i64 { b[o] = ((v >> 16) & 0xff) as u8; b[o+1] = ((v >> 8) & 0xff) as u8; b[o+2] = (v & 0xff) as u8; return o + 3 }
called by 1: rcv_build_cv
126func rcv_build_cv(scheme: i64, sig: *u8, sig_len: i64, msg: *u8) -> i64
called by 1: main calls 1: rcv_u24
138func rcv_seal(msg: *u8, msg_len: i64, key: *u8, iv: *u8, rec: *u8) -> i64
149func rcv_mksession(key: *u8, iv: *u8) -> *Tls13ServerSession
160func main() -> i64