Expand description
§pdf_signer
Pure-Rust, self-contained library to digitally sign (PAdES) and
verify PDF documents with a PKCS#12 (.p12/.pfx) keystore. It replaces
the bundled BatchPDFSignPortable.jar (Java/PDFBox) used by the R package
signer, removing the Java runtime dependency and the binary blob.
§What it does
sign_pdf_file/sign_pdf_bytes: append a signature field (optionally with a visible appearance) and anETSI.CAdES.detachedCMS signature as an incremental update, so any prior signature stays valid. Targets PAdES B-B through B-LTA (RFC 3161 signature & document timestamps,/DSS).verify_pdf_file/verify_pdf_bytes: re-extract the signed byte range, validate the CMS signature cryptographically, check that the document was not modified after the last signature (SignatureReport::document_intact), report signer info, and optionally validate the signer and TSA chains against aTrustStore.
§Notes
- Keys: RSA (PKCS#1 v1.5), ECDSA (P-256/P-384), Ed25519.
- 100% pure Rust (RustCrypto) — no OpenSSL, no Java, no system C libraries.
An optional
httpsfeature (ureq/rustls) enables TLS TSA/CRL/OCSP. - Incremental updates support both classic xref tables and xref streams.
- Encrypted PDFs and documents certified with DocMDP
P=1are refused. - The
testkitfeature exposes fixture builders for tests and demos.
Structs§
- Appearance
- A visible signature appearance, rendered as the widget’s
/AP /Nstream. - Sign
Options - Options controlling the signature dictionary metadata.
- Signature
Report - Report over all signatures and document timestamps found, in file order.
- Trust
Store - A set of trusted root certificates (e.g. the ICP-Brasil AC Raiz set), plus optional validation parameters.
- Verified
Signature - Outcome of verifying a single signature or document timestamp.
Enums§
- Error
- Errors that can occur while signing or verifying a PDF.
- Pades
Level - PAdES conformance level to produce.
Functions§
- sign_
pdf_ bytes - Sign an in-memory PDF with an in-memory PKCS#12 keystore.
- sign_
pdf_ file - Sign
inputPDF, writing the signed PDF tooutput. - verify_
certificate_ chain - Validate a certificate path directly (decoupled from PDF signing): does
leaf_derchain to a trusted root inroots, usingpool_dersas candidate intermediates andcrl_dersfor revocation, at timeat? Exposed mainly for conformance testing (e.g. NIST PKITS), so no purpose-specific leaf key-usage check is applied. - verify_
pdf_ bytes - Verify all signatures of an in-memory PDF (one per
/ByteRange). - verify_
pdf_ bytes_ with_ roots - Verify an in-memory PDF, validating signer chains against
roots. - verify_
pdf_ file - Verify the signatures of a PDF file.
- verify_
pdf_ file_ with_ roots - Verify a PDF file, additionally validating each signer certificate chain
against
roots(e.g. the ICP-Brasil roots).
Type Aliases§
- Result
- Convenience result type for the crate.