Skip to main content

Crate pkix_path

Crate pkix_path 

Source
Expand description

RFC 5280 X.509 certificate path validation — pure Rust, no_std.

Implements certificate path building and validation per RFC 5280 §6.

§Architecture

Cryptographic signature verification is pluggable via SignatureVerifier. The default feature set wires in RustCrypto backends for RSA (PKCS#1 v1.5 and RSASSA-PSS with SHA-256/384/512; rsa feature) and ECDSA on P-256 (p256 feature). The optional p384, p521 and ed25519 features add ECDSA on P-384 and P-521 and Ed25519; rustcrypto enables all of them. DefaultVerifier dispatches over whatever is enabled, taking the ECDSA curve from the issuer’s key. For FIPS-validated crypto, implement SignatureVerifier against wolfcrypt-rustcrypto and disable the rustcrypto feature.

Revocation checking is handled by pkix-revocation. This crate never touches the network — use pkix_chain::verify_chain for the combined API.

§Limitations

The following are not currently implemented:

  • UTCTime before 1970. The supported range is 1970-2049, where RFC 5280 §4.1.2.5.1 allows 1950-2049. A certificate whose notBefore or notAfter falls in the missing twenty years is refused, and refused at the DER layer — the error reads “malformed ASN.1 DER value for UTCTime” and comes back before validation runs.

    This is a deliberate scope decision, not an accident. The floor is the Unix epoch because der 0.8 puts it there (“due to common operations working on UNIX_EPOCH, UtcTimes are only supported for the years 1970-2049”), and lifting it would mean forking the DER layer every consumer of this crate depends on. No conforming CA issues certificates dated before 1970, so the trade is a fork of a foundational dependency against twenty years of dates nobody uses.

    It is fail-closed: such a certificate is refused, never misread. OpenSSL does read them, so expect a genuine disagreement rather than a difference of strictness — NIST PKITS §4.2.3 “Valid pre2000 UTC notBefore Date Test3” is exactly this shape, and is the one PKITS vector this crate does not evaluate.

  • Legacy SHA-1 — shipped, but behind rsa-sha1 and ecdsa-sha1, which are deliberately outside default and outside the rustcrypto umbrella: that umbrella means “algorithms we recommend” and these are not. Verification only; nothing here signs with SHA-1. RSA moduli outside 1024–8192 bits are refused by the bundled RSA backend.

  • DSA — not implemented. The recorded stance is verify-only and opt-in, following FIPS 186-5, which retains DSA “only for the purposes of verifying existing signatures”; a chain issued under DSA before it was retired either verifies or it does not, and saying which is more useful than refusing to look. When it lands it will sit outside default and outside rustcrypto, as the SHA-1 features do. Until then such a certificate is refused as an unsupported algorithm, never misread. NIST PKITS 4.1.4 and 4.1.5 are the two vectors this affects, and RFC 3279 §2.3.2 domain-parameter inheritance is the awkward half of 4.1.5.

  • RFC 4518 full Unicode NFKC DN normalization — ASCII case-folding plus insignificant-whitespace collapsing is applied. BMPString AVA values are transcoded UCS-2-BE → UTF-8 and then compared via the same ASCII-only normalization pipeline, so two AVAs that share Unicode code points but differ only in DER string-type (e.g. BMPString “Foo Co” vs UTF8String “Foo Co”) compare equal. Full RFC 4518 prep (NFKC, non-ASCII Unicode case fold, prohibit/bidi steps) is future work tracked under PKIX-l63j; until it lands, two BMPString values that contain the same Unicode code points but differ in canonical decomposition (e.g. precomposed U+00E9 ‘é’ vs decomposed U+0065 U+0301 ‘e’+ combining acute) compare unequal. UniversalString AVA values are rejected by the der crate at parse time (tag 0x1C is not in der::Tag in 0.7) and never reach the path validator. TeletexString AVAs use raw DER byte comparison by policy — pkix-path deliberately does not transcode T.61 to Unicode; see any_to_str_bytes rustdoc for the rationale.

  • Path building — converting an unordered bag of certificates into a validated chain is handled by pkix-path-builder. This crate validates a caller-ordered &[Certificate] only.

  • AIA fetching — chains with missing intermediates are not reassembled from AuthorityInfoAccess URIs here. Callers supply a complete chain, or go through pkix-chain, which follows caIssuers URIs via pkix-aia / pkix-aia-http (PKIX-zkjb).

Modules§

serde_derserde
Helper module for format-adaptive serde serialization of DER-encodable types. Public so downstream crates (pkix-chain, pkix-revocation, pkix-truststore) can reuse the same wire form on their own result types without redefining the helpers. Helper functions for serde-serializing DER-encodable types in a format-adaptive wire form.

Structs§

DefaultVerifiered25519 or p256 or p384 or p521 or rsa
A SignatureVerifier covering every RustCrypto backend enabled at build time.
DerError
Opaque wrapper around an underlying ASN.1 / DER error.
EcdsaP256Sha1Verifierecdsa-sha1
Verifies ECDSA P-256 signatures over SHA-1. Legacy interop only.
EcdsaP256Verifierp256
ECDSA verifier for P-256 (secp256r1) issuer keys.
EcdsaP384Verifierp384
ECDSA verifier for P-384 (secp384r1) issuer keys.
EcdsaP521Verifierp521
ECDSA verifier for P-521 (secp521r1) issuer keys.
Ed25519Verifiered25519
Ed25519 signature verifier (RFC 8410, RFC 8032 §5.1.7).
NameConstraints
Re-exported for use with TrustAnchor::name_constraints. NameConstraints extension as defined in RFC 5280 Section 4.2.1.10.
PolicyTreeNode
A node of the final policy graph, exposed for post-validation qualifier extraction on ValidatedPath::valid_policy_tree.
RsaPkcs1v15Sha1Verifierrsa-sha1
Verifies RSA PKCS#1 v1.5 signatures over SHA-1. Legacy interop only.
RsaPkcs1v15Sha256Verifierrsa
RSA with PKCS#1 v1.5 padding and SHA-256 signature verifier.
RsaPkcs1v15Sha384Verifierrsa
RSA with PKCS#1 v1.5 padding and SHA-384 signature verifier.
RsaPkcs1v15Sha512Verifierrsa
RSA with PKCS#1 v1.5 padding and SHA-512 signature verifier.
RsaPssVerifierrsa
RSASSA-PSS signature verifier (RFC 4055 §3.1).
TrustAnchor
A trust anchor used to terminate path validation.
ValidatedPath
The result of a successful certificate path validation.
ValidationPolicy
Policy parameters controlling path validation.
VerificationError
Error returned by SignatureVerifier::verify_signature.

Enums§

DnAttrRule
Compositional rule for asserting required Subject DN attributes on a leaf cert.
Error
Errors returned by path validation.
VerificationErrorKind
Why a SignatureVerifier did not accept a signature.

Constants§

MAX_AVAS_PER_RDN
Maximum number of attribute-value assertions in one RDN that names_match will compare.

Traits§

Profile
A PKI regime profile that bundles identity, citation, and a validation policy.
SignatureVerifier
Pluggable signature verification backend.

Functions§

cert_is_ca
Returns Ok(true) if cert is a CA certificate per its BasicConstraints extension (RFC 5280 §4.2.1.9), Ok(false) if the extension is absent or cA = FALSE, and Err(DerError) if the extension is present but cannot be DER-decoded.
names_match
Compare two distinguished names per RFC 4518 string prep rules.
tbs_certificate_der
Returns the DER encoding of cert’s TBSCertificate: the bytes its issuer signed.
validate_path
Validate a certificate chain from subject to a trust anchor.
validate_path_with_profile
Validate a certificate chain using a Profile to produce the policy.

Type Aliases§

AlgorithmIdentifierRef
AlgorithmIdentifier reference which has AnyRef parameters.
Result
Result alias for this crate.
SubjectPublicKeyInfoRef
SubjectPublicKeyInfo with AnyRef algorithm parameters, and BitStringRef params.