code wiki / (root) / nx_x509_leaf_check.nx

nx_x509_leaf_check.nx

buildroot/runtime/nx_x509_leaf_check.nx

5058 B113 linesdepth 5pulls 7 transitivereach 515 importersview sourcekind tooltopic x509
docsdependenciesstructsconstsfunctions

about

nx_x509_leaf_check.nx -- single-cert "leaf" orchestrator. Composes the three shipped X.509 primitives: - x509_parse (nx_x509.nx) - x509_validity_check (nx_x509_validity.nx) - x509_san_match_hostname (nx_x509_san.nx) into one call that callers (nx_https_client + future chain walker) use to validate a single leaf cert against a hostname + clock. What this DOES verify (today, this commit): - DER parses cleanly per RFC 5280 §4.1 - now_epoch_secs is within [notBefore, notAfter] - hostname matches a SAN dNSName entry (RFC 6125 §6.4) What this DOES NOT verify (separate primitives, queued): - signature_algorithm OID is one of the supported set (caller-driven via cert.sig_alg_off/_len + per-alg verifier) - signature value matches the cert's tbs under a trust-anchor pubkey (chain walk + ECDSA-P256 verify queued) - revocation status (OCSP / CRL -- separate primitives) - extension-criticality checks (every extension marked critical must be understood by the validator -- iterator queued) - certificatePolicies, basicConstraints, keyUsage, extendedKeyUsage (queued) The leaf-check verdict therefore answers "is this cert well-formed AND within its validity period AND covering the hostname I asked for" -- it does NOT answer "should I trust this cert". A chain walker that establishes trust calls nx_x509_leaf_check for every cert in the path PLUS its own signature verify. This split keeps single-responsibility (Cardinal 9) clean. license_tier: INDEPENDENT_REDERIVE genealogy_id: international-research-sources/ietf/rfc_5280 lineage_id: nishi_x509_leaf_check_q10

dependencies 4 imports · 2 importers

nx_syscalls.nx nx_x509.nx nx_x509_validity.nx nx_x509_san.nx nx_x509_leaf_check.nx nx_https_cert_pipeline.nx nx_x509_leaf_check_test.nx

imports: nx_syscalls.nxnx_x509.nxnx_x509_validity.nxnx_x509_san.nx

imported by: nx_https_cert_pipeline.nxnx_x509_leaf_check_test.nx

structs

none

consts

53const NX_X509_LEAF_OK: i64 = 1
54const NX_X509_LEAF_PARSE_FAIL: i64 = 2 // x509_parse returned negative
55const NX_X509_LEAF_NOT_YET_VALID: i64 = 3 // now < notBefore
56const NX_X509_LEAF_EXPIRED: i64 = 4 // now > notAfter
57const NX_X509_LEAF_VALIDITY_BAD: i64 = 5 // bad validity TLV
58const NX_X509_LEAF_NO_SAN: i64 = 6 // cert has no SAN at all
59const NX_X509_LEAF_HOSTNAME_MISMATCH: i64 = 7 // SAN present, no match
60const NX_X509_LEAF_BAD_FORMAT: i64 = 8 // SAN extension malformed
61const NX_X509_LEAF_BAD_PATTERN: i64 = 9 // SAN entry has illegal wildcard
62const NX_X509_LEAF_VERDICT_N: i64 = 10

functions

64func nx_x509_leaf_verdict_is_valid(v: i64) -> i64
called by 1: main
84func x509_leaf_check(buf: *u8, buf_len: i64,
111func main() -> i64