std1.0.0-beta-7 SafeC docs

Module crypto::x509

#include <std/crypto/x509.h> source

X.509 Certificate Parsing (DER format, read-only) Parses the minimum fields needed for TLS: subject, issuer, validity, public key, SAN. Freestanding-safe; no dynamic allocation.

Structs

X509Validity
X509NameDistinguished Name (simplified: CN + O + C as strings).
X509SanSubject Alternative Name (DNS names only).
X509CertParsed certificate (all fields, no dynamic allocation).
X509Span
X509Parsed

Functions

x509_parseParses a DER certificate. 0 on success, X509_ERR_* otherwise.
x509_verify_signed_by1 if the signature on cert (der/c) verifies with issuer's public key (issuer_der/issuer); 0 otherwise (bad signature, unsupported algorithm, SHA-1, or an RSA key under 1024 bits).
x509_issued_by1 if cert's issuer name is byte-for-byte issuer's subject name.
x509_match_host1 if 'host' (a DNS name, or an IPv4/IPv6 literal) matches the certificate: DNS names against dNSName SANs (case-insensitive, a '*' leftmost label matching exactly one label, never in IP literals or a public-suffix-like two-label pattern), IP literals against iPAddress SANs; the subject CN is consulted only when the certificate has no DNS or IP SAN at all.

Macros

X509_MAX_NAME_LEN
X509_MAX_SAN
X509_MAX_SAN_LEN
X509_KEY_LENmax RSA/EC public key bytes
X509_KEY_UNKNOWN
X509_KEY_RSA
X509_KEY_EC_P256
X509_KEY_EC_P384
X509_KEY_ED25519recognized, not verifiable here
X509_SIG_UNKNOWN
X509_SIG_RSA_PKCS1
X509_SIG_RSA_PSS
X509_SIG_ECDSA
X509_SIG_ED25519
X509_KU_DIGITAL_SIGNATUREKeyUsage bits (as X509Parsed::key_usage holds them).
X509_KU_KEY_ENCIPHERMENT
X509_KU_KEY_AGREEMENT
X509_KU_KEY_CERT_SIGN
X509_ERR_MALFORMEDError codes of x509_parse (negative).
X509_ERR_UNSUPPORTED