nx_x509_chain_verify.nx
buildroot/runtime/nx_x509_chain_verify.nx
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
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
| 86 | const NX_MAGIC_8192: i64 = 8192 |
| 101 | const NX_X509_CHAIN_OK: i64 = 1 |
| 102 | const NX_X509_CHAIN_EMPTY: i64 = 2 |
| 103 | const NX_X509_CHAIN_TOO_LONG: i64 = 3 |
| 104 | const NX_X509_CHAIN_DN_MISMATCH: i64 = 4 |
| 105 | const NX_X509_CHAIN_SIG_FAIL: i64 = 5 |
| 106 | const NX_X509_CHAIN_VERDICT_N: i64 = 6 |
| 108 | const NX_X509_CHAIN_MAX_LEN: i64 = 16 |
| 125 | const CV_CACHE_N: i64 = 128 |
functions
| 89 | func _cv_pn(v: i64) -> i64 |
| 110 | func nx_x509_chain_verdict_is_valid(v: i64) -> i64 called by 1: main |
| 132 | func _cv_der_len(buf: *u8) -> i64 |
| 144 | func _cv_key_eq(keys: *u8, off: i64, key: *u8) -> i64 |
| 150 | func _cv_verify_memo(child_buf: *u8, child: *X509Cert, parent_buf: *u8, parent: *X509Cert) -> i64 called by 1: nx_x509_chain_verify calls 5: _cv_der_lennx_x509_verify_under_issuersys_mmapsha256_digest_cv_key_eq |
| 197 | func nx_x509_chain_verify(bufs: **u8, certs: **X509Cert, n: i64) -> i64 |
| 234 | func main() -> i64 |