Signature Algorithms
RSA PKCS#1 v1.5, RSA-PSS, and ECDSA P-256/384/521 over SHA-256/384/512 — variants, digests, and per-backend support
A Signer reports one SignatureAlgorithm, and mudrit-pdfsign reads it back to build the CMS
with the matching digestAlgorithm and signatureAlgorithm. Mudrit supports three schemes —
RSA PKCS#1 v1.5, RSA-PSS, and ECDSA — each over SHA-256, SHA-384, or SHA-512.
The SignatureAlgorithm variants
Prop
Type
The digest is bound to the variant: each Sha256 / Sha384 / Sha512 suffix drives both the
messageDigest signed attribute and the RFC-3161 timestamp imprint. RSA PKCS#1 v1.5 is deterministic;
PSS and ECDSA are not — which is fine, because the PDF layer signs the content once and embeds
that single signature (the timestamp is taken over the bytes actually produced).
How the CMS is labelled
mudrit-pdfsign maps each variant onto the CMS signatureAlgorithm:
| Variant | CMS signatureAlgorithm | Notes |
|---|---|---|
RsaPkcs1Sha256 (default) / …384 / …512 | rsaEncryption | What every Indian DSC uses |
RsaPssSha256 / …384 / …512 | id-RSASSA-PSS (+ params) | Same RSA key, PSS padding |
EcdsaP256Sha256 / EcdsaP384Sha384 / EcdsaP521Sha512 | ecdsa-with-SHA* | DER r,s; P-256/384/521 on every backend |
Choosing the algorithm
For a PFX, the scheme is auto-detected from the key: an RSA key defaults to PKCS#1 SHA-256,
an EC key to ECDSA with the curve's hash. To switch an RSA key to PSS — or pick a different digest —
call .with_algorithm(...).
let pss = PfxSigner::from_file("rsa.pfx", "pw")?.with_algorithm(SignatureAlgorithm::RsaPssSha256)?;
let ec = PfxSigner::from_file("ecdsa-p256.pfx", "pw")?; // ECDSA P-256 detected automaticallyBackend support
Which schemes a backend can actually produce depends on what the key material and the device support.
| Scheme | PFX | PKCS#11 token | Windows store |
|---|---|---|---|
| RSA PKCS#1 v1.5 | ✅ | ✅ always | ✅ always |
| RSA-PSS | ✅ | if the device supports it | if the device supports it |
| ECDSA P-256/384/521 | ✅ | if the device supports the curve | if the device supports the curve |
PfxSigner covers all three schemes, including ECDSA and PSS, in pure Rust. On a PKCS#11 token
or the Windows store, RSA PKCS#1 v1.5 is always available; RSA-PSS and ECDSA are available when
the device can do them.
Sign-time self-verify — fail loud, never Adobe-invalid
For the hardware backends, the device signs the hash and returns raw bytes, which the SDK
re-verifies against the leaf certificate before use. A token that returns an unexpected format,
the wrong curve, a curve it cannot really do, or that silently downgrades a PSS request to PKCS#1 is
rejected with a clear error — rather than emitting a file that a validator would flag as invalid. For
ECDSA the token returns raw r‖s, which the SDK DER-encodes and then self-verifies.
The PFX P-521 path and the token P-256/384/521 + RSA-PSS paths are validated against SoftHSM2;
coverage on a physical EC token depends on the device. A key that reports a scheme this backend
can't produce surfaces as Error::UnsupportedKey.