Expand description
X.509 certificate parsing, minimal issuance helpers, PEM/DER bridging, and chain validation for NoxTLS.
The crate re-exports a flat API from the crate root: Certificate parsing, RSA/EC/X25519/X448 key
material helpers, optional strict chain validation, and small DER writers used by tests and tooling.
Structs§
- Certificate
- Captures parsed certificate fields needed for PKI and TLS flows.
- DerNode
- Represents a parsed DER TLV node body with its ASN.1 tag.
- Pkcs8
Private KeyInfo DerParts - Holds PKCS#8
PrivateKeyInfofields for algorithm dispatch and key extraction. - RsaPrivate
KeyDer Parts - Holds core PKCS#1 RSA private-key fields needed by current consumers.
- RsaPublic
KeyDer Parts - Holds PKCS#1 RSA public-key modulus/exponent fields.
- Spki
Public KeyInfo DerParts - Holds SPKI fields for algorithm dispatch and key extraction.
- Validation
Options - Controls optional policy and revocation-related path validation requirements.
- Validation
Report - Summarizes key properties of a validated certificate chain.
Enums§
- Validation
Error - Describes why certificate path validation failed.
Functions§
- certificate_
chain_ pem_ to_ der_ blocks - Parses all PEM
CERTIFICATEblocks into DER bytes. - certificate_
der_ to_ pem - Converts certificate DER bytes into PEM
CERTIFICATEarmor. - certificate_
matches_ hostname - Matches
hostnameagainst certificate DNS identities. - certificate_
pem_ to_ der - Parses one PEM
CERTIFICATEblock into DER bytes. - der_
to_ file - Writes raw DER bytes to a file path.
- der_
to_ pem - Converts DER bytes into PEM armor with caller-provided label.
- der_
to_ pem_ file - Encodes DER as PEM and writes it to a file path.
- ec_
private_ key_ der_ to_ pem_ sec1 - Converts SEC1 EC private-key DER bytes into PEM armor.
- ec_
private_ key_ pem_ to_ der_ sec1 - Parses one PEM SEC1 EC private-key block into DER bytes.
- ed25519_
private_ key_ from_ pem_ file_ pkcs8 - Reads one PKCS#8
PRIVATE KEYPEM file and parses it asEd25519PrivateKey. - ed25519_
private_ key_ from_ pem_ pkcs8 - Builds
Ed25519PrivateKeyfrom PEM PKCS#8PRIVATE KEYtext. - ed25519_
private_ key_ from_ pkcs8_ der - Builds
Ed25519PrivateKeyfrom PKCS#8 DER bytes for RFC 8410 Ed25519 keys. - ed25519_
private_ key_ to_ pem_ file_ pkcs8 - Encodes
Ed25519PrivateKeyas PKCS#8 PEM and writes it to a file. - ed25519_
private_ key_ to_ pem_ pkcs8 - Serializes
Ed25519PrivateKeyinto PEM PKCS#8PRIVATE KEY. - ed25519_
private_ key_ to_ pkcs8_ der - Serializes
Ed25519PrivateKeyinto PKCS#8 DER (id-Ed25519). - ed25519_
public_ key_ from_ pem_ spki - Builds
Ed25519PublicKeyfrom PEM SPKIPUBLIC KEYtext. - ed25519_
public_ key_ from_ spki_ der - Builds
Ed25519PublicKeyfrom DER SPKI bytes for RFC 8410 Ed25519 keys. - ed25519_
public_ key_ to_ pem_ spki - Serializes
Ed25519PublicKeyinto PEM SPKIPUBLIC KEY. - ed25519_
public_ key_ to_ spki_ der - Serializes
Ed25519PublicKeyinto SPKI DER (RFC 8410id-Ed25519). - mldsa_
public_ key_ from_ spki_ der - Builds
MlDsaPublicKeyfrom DER SPKI bytes for experimental ML-DSA keys. - p256_
private_ key_ from_ pem_ file_ pkcs8 - Reads one PKCS#8
PRIVATE KEYPEM file and parses it asP256PrivateKey. - p256_
private_ key_ from_ pem_ pkcs8 - Builds
P256PrivateKeyfrom PEM PKCS#8PRIVATE KEYtext. - p256_
private_ key_ from_ pem_ sec1 - Builds
P256PrivateKeyfrom PEM SEC1EC PRIVATE KEYtext. - p256_
private_ key_ from_ pkcs8_ der - Builds
P256PrivateKeyfrom PKCS#8 DER bytes forid-ecPublicKey+prime256v1. - p256_
private_ key_ from_ sec1_ der - Builds
P256PrivateKeyfrom SEC1 ECPrivateKey DER bytes. - p256_
private_ key_ to_ pem_ file_ pkcs8 - Encodes
P256PrivateKeyas PKCS#8 PEM and writes it to a file. - p256_
private_ key_ to_ pem_ pkcs8 - Serializes
P256PrivateKeyinto PEM PKCS#8PRIVATE KEY. - p256_
private_ key_ to_ pkcs8_ der - Serializes
P256PrivateKeyinto PKCS#8 DER (id-ecPublicKey+prime256v1). - p256_
public_ key_ from_ pem_ spki - Builds
P256PublicKeyfrom PEM SPKIPUBLIC KEYtext. - p256_
public_ key_ from_ spki_ der - Builds
P256PublicKeyfrom DER SPKI bytes forid-ecPublicKey+prime256v1. - p256_
public_ key_ to_ pem_ spki - Serializes
P256PublicKeyinto PEM SPKIPUBLIC KEY. - p256_
public_ key_ to_ spki_ der - Serializes
P256PublicKeyinto SPKI DER (id-ecPublicKey+prime256v1). - parse_
certificate - Parses a top-level DER certificate sequence and extracts core fields.
- parse_
der_ length - Parses DER length octets and returns
(content_length, length_octet_count). - parse_
der_ node - Parses one DER node from input and returns the node plus remaining bytes.
- parse_
ecdsa_ signature_ der - Parses DER-encoded ECDSA signature
SEQUENCE { INTEGER r; INTEGER s }into 32-byte scalars. - parse_
pkcs1_ rsa_ private_ key_ der - Parses PKCS#1 RSAPrivateKey DER and returns key field parts.
- parse_
pkcs1_ rsa_ public_ key_ der - Parses PKCS#1 RSAPublicKey DER and returns modulus/exponent fields.
- parse_
pkcs8_ private_ key_ info_ der - Parses PKCS#8 PrivateKeyInfo DER and extracts algorithm OID and key octets.
- parse_
spki_ public_ key_ info_ der - Parses SubjectPublicKeyInfo DER and extracts algorithm OID and key bit-string bytes.
- pem_
file_ to_ der - Reads one PEM block from file and decodes DER payload for
label. - pem_
file_ to_ der_ blocks - Reads all matching PEM blocks from file and decodes DER payloads for
label. - pem_
to_ der - Parses PEM armor into DER bytes and verifies expected label markers.
- pem_
to_ der_ blocks - Parses all PEM blocks matching
labelinto DER payload bytes. - private_
key_ der_ to_ pem_ pkcs8 - Converts PKCS#8 private-key DER bytes into PEM armor.
- private_
key_ pem_ to_ der_ pkcs8 - Parses one PEM PKCS#8 private-key block into DER bytes.
- public_
key_ der_ to_ pem_ spki - Converts SubjectPublicKeyInfo DER bytes into PEM armor.
- public_
key_ pem_ to_ der_ spki - Parses one PEM SPKI public-key block into DER bytes.
- rsa_
private_ key_ der_ to_ pem_ pkcs1 - Converts PKCS#1 RSA private-key DER bytes into PEM armor.
- rsa_
private_ key_ from_ pem_ pkcs1 - Builds
RsaPrivateKeyfrom PEM PKCS#1RSA PRIVATE KEYtext. - rsa_
private_ key_ from_ pem_ pkcs8 - Builds
RsaPrivateKeyfrom PEM PKCS#8PRIVATE KEYtext. - rsa_
private_ key_ from_ pkcs1_ der - Builds
RsaPrivateKeyfrom PKCS#1 DER bytes. - rsa_
private_ key_ from_ pkcs8_ der - Builds
RsaPrivateKeyfrom PKCS#8 DER bytes for RSA keys. - rsa_
private_ key_ pem_ to_ der_ pkcs1 - Parses one PEM PKCS#1 RSA private-key block into DER bytes.
- rsa_
public_ key_ der_ to_ pem_ pkcs1 - Converts PKCS#1 RSA public-key DER bytes into PEM armor.
- rsa_
public_ key_ from_ pem_ pkcs1 - Builds
RsaPublicKeyfrom PEM PKCS#1RSA PUBLIC KEYtext. - rsa_
public_ key_ from_ pem_ spki - Builds
RsaPublicKeyfrom PEM SPKIPUBLIC KEYtext. - rsa_
public_ key_ from_ pkcs1_ der - Builds
RsaPublicKeyfrom PKCS#1 DER bytes. - rsa_
public_ key_ from_ spki_ der - Builds
RsaPublicKeyfrom DER SPKI bytes for RSA keys. - rsa_
public_ key_ pem_ to_ der_ pkcs1 - Parses one PEM PKCS#1 RSA public-key block into DER bytes.
- rsa_
public_ key_ to_ pem_ pkcs1 - Serializes
RsaPublicKeyinto PEM PKCS#1RSA PUBLIC KEY. - rsa_
public_ key_ to_ pem_ spki - Serializes
RsaPublicKeyinto PEM SPKIPUBLIC KEY. - rsa_
public_ key_ to_ spki_ der - Serializes
RsaPublicKeyinto SPKI DER usingrsaEncryptionOID. - validate_
certificate_ chain - Validates certificate chain with signature enforcement at each hop.
- validate_
certificate_ chain_ constraints_ only - Validates certificate path constraints without enforcing signature checks.
- validate_
certificate_ chain_ strict - Validates certificate chain with explicit strict-signature naming for callers.
- validate_
certificate_ chain_ with_ options - Validates certificate chain with caller-provided policy/revocation options.
- verify_
certificate_ signature - Verifies one certificate signature using issuer public key material.
- write_
csr_ p256_ sha256 - Writes a PKCS#10 CSR using ECDSA P-256 SHA-256.
- write_
csr_ rsa_ sha256 - Writes a PKCS#10 CSR using RSA PKCS#1 v1.5 SHA-256.
- write_
der_ bit_ string - Writes DER BIT STRING encoding with zero unused bits.
- write_
der_ integer - Writes DER INTEGER encoding for a positive integer value.
- write_
der_ oid - Writes DER OBJECT IDENTIFIER encoding from content octets.
- write_
der_ sequence - Writes DER SEQUENCE around already-encoded child elements.
- write_
minimal_ certificate_ der - Writes a minimal certificate-like DER structure for fixture generation workflows.
- write_
self_ signed_ certificate_ p256_ sha256 - Writes a self-signed X.509 v3 certificate using ECDSA P-256 SHA-256.
- write_
self_ signed_ certificate_ rsa_ sha256 - Writes a self-signed X.509 v3 certificate using RSA PKCS#1 v1.5 SHA-256.
- x448_
private_ key_ from_ pem_ file_ pkcs8 - Reads one PKCS#8
PRIVATE KEYPEM file and parses it asX448PrivateKey. - x448_
private_ key_ from_ pem_ pkcs8 - Builds
X448PrivateKeyfrom PEM PKCS#8PRIVATE KEYtext. - x448_
private_ key_ from_ pkcs8_ der - Builds
X448PrivateKeyfrom PKCS#8 DER bytes for RFC 8410 X448 keys. - x448_
private_ key_ to_ pem_ file_ pkcs8 - Encodes
X448PrivateKeyas PKCS#8 PEM and writes it to a file. - x448_
private_ key_ to_ pem_ pkcs8 - Serializes
X448PrivateKeyinto PEM PKCS#8PRIVATE KEY. - x448_
private_ key_ to_ pkcs8_ der - Serializes
X448PrivateKeyinto PKCS#8 DER (id-X448). - x448_
public_ key_ from_ pem_ spki - Builds
X448PublicKeyfrom PEM SPKIPUBLIC KEYtext. - x448_
public_ key_ from_ spki_ der - Builds
X448PublicKeyfrom DER SPKI bytes for RFC 8410 X448 keys. - x448_
public_ key_ to_ pem_ spki - Serializes
X448PublicKeyinto PEM SPKIPUBLIC KEY. - x448_
public_ key_ to_ spki_ der - Serializes
X448PublicKeyinto SPKI DER (RFC 8410). - x25519_
private_ key_ from_ pem_ file_ pkcs8 - Reads one PKCS#8
PRIVATE KEYPEM file and parses it asX25519PrivateKey. - x25519_
private_ key_ from_ pem_ pkcs8 - Builds
X25519PrivateKeyfrom PEM PKCS#8PRIVATE KEYtext. - x25519_
private_ key_ from_ pkcs8_ der - Builds
X25519PrivateKeyfrom PKCS#8 DER bytes for RFC 8410 X25519 keys. - x25519_
private_ key_ to_ pem_ file_ pkcs8 - Encodes
X25519PrivateKeyas PKCS#8 PEM and writes it to a file. - x25519_
private_ key_ to_ pem_ pkcs8 - Serializes
X25519PrivateKeyinto PEM PKCS#8PRIVATE KEY. - x25519_
private_ key_ to_ pkcs8_ der - Serializes
X25519PrivateKeyinto PKCS#8 DER (id-X25519). - x25519_
public_ key_ from_ pem_ spki - Builds
X25519PublicKeyfrom PEM SPKIPUBLIC KEYtext. - x25519_
public_ key_ from_ spki_ der - Builds
X25519PublicKeyfrom DER SPKI bytes for RFC 8410 X25519 keys. - x25519_
public_ key_ to_ pem_ spki - Serializes
X25519PublicKeyinto PEM SPKIPUBLIC KEY. - x25519_
public_ key_ to_ spki_ der - Serializes
X25519PublicKeyinto SPKI DER (RFC 8410).