nx_x509_leaf_check.nx
buildroot/runtime/nx_x509_leaf_check.nx
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
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
| 53 | const NX_X509_LEAF_OK: i64 = 1 |
| 54 | const NX_X509_LEAF_PARSE_FAIL: i64 = 2 // x509_parse returned negative |
| 55 | const NX_X509_LEAF_NOT_YET_VALID: i64 = 3 // now < notBefore |
| 56 | const NX_X509_LEAF_EXPIRED: i64 = 4 // now > notAfter |
| 57 | const NX_X509_LEAF_VALIDITY_BAD: i64 = 5 // bad validity TLV |
| 58 | const NX_X509_LEAF_NO_SAN: i64 = 6 // cert has no SAN at all |
| 59 | const NX_X509_LEAF_HOSTNAME_MISMATCH: i64 = 7 // SAN present, no match |
| 60 | const NX_X509_LEAF_BAD_FORMAT: i64 = 8 // SAN extension malformed |
| 61 | const NX_X509_LEAF_BAD_PATTERN: i64 = 9 // SAN entry has illegal wildcard |
| 62 | const NX_X509_LEAF_VERDICT_N: i64 = 10 |
functions
| 64 | func nx_x509_leaf_verdict_is_valid(v: i64) -> i64 called by 1: main |
| 84 | func x509_leaf_check(buf: *u8, buf_len: i64, called by 2: _pipeline_verify_nmain calls 4: sys_mmapx509_parsex509_validity_checkx509_san_match_hostname |
| 111 | func main() -> i64 |