code wiki / (root) / x509.nx

x509.nx

buildroot/runtime/x509.nx

9424 B229 linesdepth 4pulls 4 transitivereach 0 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.

dependencies 2 imports · 0 importers

syscalls.nx asn1.nx x509.nx

imports: syscalls.nxasn1.nx

imported by: nobody (leaf or entry point)

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

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

structs

45struct X509Cert {

consts

none

functions

59func x509_read_tlv(buf: *u8, c: *Asn1Cursor,
called by 1: x509_parse calls 1: asn1_expect_tag
75func x509_read_alg_id(buf: *u8, c: *Asn1Cursor,
called by 1: x509_parse calls 1: asn1_expect_tag
94func x509_parse(buf: *u8, buf_len: i64, cert: *X509Cert) -> i64 {
218func main() -> i64 {
calls 1: x509_parse