code wiki / (root) / nx_x509_chain_verify.nx

nx_x509_chain_verify.nx

buildroot/runtime/nx_x509_chain_verify.nx

10716 B236 linesdepth 13pulls 66 transitivereach 516 importersview sourcekind tooltopic x509
docsdependenciesstructsconstsfunctions

about

nx_x509_chain_verify.nx -- walk an X.509 cert chain leaf-to-root. Phase 0b §I.4 piece 7 of the chain-walker arc. THE primitive that turns the substrate's single-cert verify (verify_under_issuer, commit 927d9d47) into a real Web PKI chain validator. Composes: nx_x509_verify_under_issuer.nx -- per-cert sig verify nx_x509_dn_match.nx -- DN byte-equality nx_x509_leaf_check.nx (caller) -- separate; caller invokes first for leaf cert's validity + SAN. Chain model: caller prepares an array of parsed X509Cert pointers + their backing buffers, in order from leaf to root: certs[0] = leaf cert (server identity) certs[1] = first intermediate (signed leaf) certs[..] = more intermediates certs[n-1] = trust anchor (root CA, treated as self-signed for the chain-walker purpose -- caller has separately confirmed it lives in the trusted root set) For each adjacent (child, parent) pair (i, i+1): 1. DN linkage: child.issuer must byte-equal parent.subject 2. Sig verify: child's outer sig verifies under parent's pubkey The final cert (trust anchor) is NOT verified against anything further -- the caller's responsibility to ensure it's actually in the trusted root set. RFC 5280 §6.1 calls this the "trust anchor input" to path validation. Public API: nx_x509_chain_verify(bufs, certs, n) -> verdict bufs[i] = *u8 to cert[i]'s DER buffer certs[i] = *X509Cert parsed from bufs[i] n = number of certs in the chain (>=1) nx_x509_chain_verdict_is_valid(v) -> 0|1 Sealed verdict enum:

dependencies 7 imports · 3 importers

nx_syscalls.nx nx_x509.nx nx_x509_dn_match.nx nx_x509_verify_under_issuer.nx nx_x509_sig_alg.nx nx_u384.nx nx_sha256.nx nx_x509_chain_verify.nx nx_https_cert_pipeline.nx nx_x509_chain_cache_gate.nx nx_x509_chain_verify_test.nx

imports: nx_syscalls.nxnx_x509.nxnx_x509_dn_match.nxnx_x509_verify_under_issuer.nxnx_x509_sig_alg.nxnx_u384.nxnx_sha256.nx

imported by: nx_https_cert_pipeline.nxnx_x509_chain_cache_gate.nxnx_x509_chain_verify_test.nx

structs

none

consts

86const NX_MAGIC_8192: i64 = 8192
101const NX_X509_CHAIN_OK: i64 = 1
102const NX_X509_CHAIN_EMPTY: i64 = 2
103const NX_X509_CHAIN_TOO_LONG: i64 = 3
104const NX_X509_CHAIN_DN_MISMATCH: i64 = 4
105const NX_X509_CHAIN_SIG_FAIL: i64 = 5
106const NX_X509_CHAIN_VERDICT_N: i64 = 6
108const NX_X509_CHAIN_MAX_LEN: i64 = 16
125const CV_CACHE_N: i64 = 128

functions

89func _cv_pn(v: i64) -> i64
110func nx_x509_chain_verdict_is_valid(v: i64) -> i64
called by 1: main
132func _cv_der_len(buf: *u8) -> i64
called by 2: main_cv_verify_memo
144func _cv_key_eq(keys: *u8, off: i64, key: *u8) -> i64
called by 2: main_cv_verify_memo
150func _cv_verify_memo(child_buf: *u8, child: *X509Cert, parent_buf: *u8, parent: *X509Cert) -> i64
197func nx_x509_chain_verify(bufs: **u8, certs: **X509Cert, n: i64) -> i64
234func main() -> i64