code wiki / (root) / nx_x509_validate.nx

nx_x509_validate.nx

buildroot/runtime/nx_x509_validate.nx

4418 B104 linesdepth 9pulls 14 transitivereach 539 importersview sourcekind librarytopic x509
docsdependenciesstructsconstsfunctions

about

nx_x509_validate.nx -- X.509 certificate validation (Gap I.2.A). Phase 0b §I.2 of the Nishi TLS 1.3 stack per docs/NISHI_TLS13_GAP_AUDIT.md. Composes the shipped ed25519_verify_full (T11) with the X509Cert parse offsets (nx_x509, extended in T6) into the cert-validation primitives that the TLS client's accept-any stub will eventually call. What it does today: - x509_verify_signature_ed25519(buf, cert, signer_pubkey32): read cert.tbs + cert.sig from buf, verify the signature under signer_pubkey32 using shipped ed25519_verify_full. Returns NX_X509_VAL_OK (1) on valid, NX_X509_VAL_BAD_SIG (0) on invalid. Negative on malformed (e.g. sig wrong length). - Sealed verdict + validity gate. What it doesn't do yet (sub-pieces I.2.B + I.2.C, ~1 session each): - validity period check (UTCTime / GeneralizedTime parse + compare against caller-supplied now_unix_secs). Needs: * fn x509_validity_get(cert, buf, out_notBefore, out_notAfter) * ASN.1 time-string parser (Year Month Day Hour Min Sec Z) * compose against nx_time / unix-epoch math - SAN extension walk (parse cert.extensions_off/len for OID 2.5.29.17 SubjectAltName, walk GeneralName SEQUENCE, extract dNSName entries, match against SNI hostname). - ECDSA-P256 signature verify (for real-world server certs; covers ~80% of Web PKI). - RSA-PSS signature verify (for the remaining ~15%). - Full RFC 5280 chain walk + trust-anchor matching (Gap I.3). KAT verified: - Self-signed Ed25519 cert (RFC 8032 §7.1 TEST 1 keypair; fake tbs blob; sign with ed25519_sign_full at test time; wrap into a synthetic X509Cert offset structure) validates. - Same cert with one tbs byte flipped: validation FAILS. - Same cert with a different signer_pubkey: validation FAILS. - Same cert with sig byte flipped: validation FAILS. Composes with:

dependencies 3 imports · 4 importers

nx_syscalls.nx nx_x509.nx nx_ed25519_signature.nx nx_x509_validate.nx nx_mtls_identity.nx nx_x509_leaf_emit.nx nx_x509_validate_test.nx nx_x509_verify_under_issuer.nx

imports: nx_syscalls.nxnx_x509.nxnx_ed25519_signature.nx

imported by: nx_mtls_identity.nxnx_x509_leaf_emit.nxnx_x509_validate_test.nxnx_x509_verify_under_issuer.nx

structs

none

consts

58const NX_X509_VAL_OK: i64 = 1
59const NX_X509_VAL_BAD_SIG: i64 = 2
60const NX_X509_VAL_BAD_SIG_LEN: i64 = 3
61const NX_X509_VAL_BAD_PUB_LEN: i64 = 4
62const NX_X509_VAL_BAD_TBS: i64 = 5
63const NX_X509_VAL_VERDICT_N: i64 = 6

functions

86func x509_verify_signature_ed25519(
100func nx_x509_val_verdict_is_valid(v: i64) -> i64
called by 1: main