code wiki / (root) / nx_x509.nx

nx_x509.nx

buildroot/runtime/nx_x509.nx

11374 B279 linesdepth 3pulls 3 transitivereach 577 importersview sourcekind tooltopic x509
docsdependenciesstructsconstsfunctions

about

x509.nx -- minimal X.509 v3 certificate parser (RFC 5280). Reader-only subset that extracts the fields needed for TLS 1.3 certificate chain verification: - tbsCertificate bytes + length (to hash for signature verify) - serialNumber (for revocation / pinning) - subjectPublicKeyInfo (the public key we trust) - signatureAlgorithm OID (tells us which verify to use) - signatureValue BIT STRING (the actual signature bytes) ASN.1 structure (abbreviated from RFC 5280 ยง4.1): Certificate ::= SEQUENCE { tbsCertificate TBSCertificate, signatureAlgorithm AlgorithmIdentifier, signatureValue BIT STRING } TBSCertificate ::= SEQUENCE { version [0] EXPLICIT Version DEFAULT v1, serialNumber CertificateSerialNumber, signature AlgorithmIdentifier, issuer Name, validity Validity, subject Name, subjectPublicKeyInfo SubjectPublicKeyInfo, ... optional extensions } Invariants: X1 Returns pointers into the caller's DER buffer; nothing copied. Caller owns the buffer's lifetime. X2 All bounds-checks delegated to asn1.nx (A1 invariant). Malformed certs fail with a negative return code, never silent truncation. X3 Version field is optional (DEFAULT v1); we detect the [0] EXPLICIT wrapper and skip over it if present. X4 Extensions (v3 only) are parsed enough to find Subject Alternative Name -- the rest is skipped. Extension OID matching is caller-driven via x509_next_extension. license_tier: INDEPENDENT_REDERIVE

dependencies 2 imports · 55 importers

nx_syscalls.nx nx_asn1.nx nx_x509.nx _h2_multistream_curl_daemon.nx _h2_serve_curl_daemon.nx _h2_serve_loopback_gate.nx nx_cert_debug.nx nx_cert_monitor.nx nx_chain_full_real_test.nx nx_chain_pair_leaf_real_test.nx nx_chain_pair_real_diag_test.nx nx_cms_tls_gate.nx nx_ecdsa_p384_real_bisect_test.nx

diagram shows first 10 each side; +0 more imports, +45 more importers in the complete lists below.

imports: nx_syscalls.nxnx_asn1.nx

imported by: _h2_multistream_curl_daemon.nx_h2_serve_curl_daemon.nx_h2_serve_loopback_gate.nxnx_cert_debug.nxnx_cert_monitor.nxnx_chain_full_real_test.nxnx_chain_pair_leaf_real_test.nxnx_chain_pair_real_diag_test.nxnx_cms_tls_gate.nxnx_ecdsa_p384_real_bisect_test.nxnx_h2_test_leaf.nxnx_https_cert_pipeline.nxnx_https_cert_pipeline_test.nxnx_https_get_happy_test.nxnx_https_pipeline_e2e_test.nxnx_mtls_authz.nxnx_mtls_identity.nxnx_pem_loader.nxnx_porkbun_ping_probe.nxnx_tls12_client.nxnx_tls12_client_session.nxnx_tls12_mutant.nxnx_tls13_client_validate_certificate_test.nxnx_tls13_client_verify_cv.nxnx_tls13_clientauth_ecdsa.nxnx_tls13_recv_hs_probe_test.nxnx_tls13_server_clientauth.nxnx_tls13_server_recv_client_cv.nxnx_trust_store_load_from_certdata_e2e_test.nxnx_x509_chain_verify.nxnx_x509_chain_verify_test.nxnx_x509_leaf_check.nxnx_x509_leaf_check_test.nxnx_x509_leaf_emit.nxnx_x509_parse_globalsign_test.nxnx_x509_pubkey_ec.nxnx_x509_pubkey_ec_test.nxnx_x509_pubkey_ed.nxnx_x509_pubkey_ed_kat.nxnx_x509_pubkey_rsa.nxnx_x509_pubkey_rsa_4096.nxnx_x509_san.nxnx_x509_san_test.nxnx_x509_trust_root_kat.nxnx_x509_trust_store.nxnx_x509_trust_store_load.nxnx_x509_trust_store_load_test.nxnx_x509_trust_store_test.nxnx_x509_validate.nxnx_x509_validate_test.nxnx_x509_validity.nxnx_x509_validity_test.nxnx_x509_verify_rsa_gate.nxnx_x509_verify_under_issuer.nxnx_x509_verify_under_issuer_test.nx

call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown

main sys_mmap x509_parse sys_mmap ↻ asn1_cursor_init asn1_expect_tag sys_mmap ↻ asn1_read_tlv_header asn1_read_tag asn1_read_length asn1_read_length ↻ x509_read_tlv sys_mmap ↻ asn1_expect_tag ↻ x509_read_alg_id sys_mmap ↻ asn1_expect_tag ↻

structs

55struct X509Cert

consts

none

functions

81func x509_read_tlv(buf: *u8, c: *Asn1Cursor,
called by 1: x509_parse calls 2: sys_mmapasn1_expect_tag
97func x509_read_alg_id(buf: *u8, c: *Asn1Cursor,
called by 1: x509_parse calls 2: sys_mmapasn1_expect_tag
116func x509_parse(buf: *u8, buf_len: i64, cert: *X509Cert) -> i64
268func main() -> i64