pdfcraft/crates
Thorsten Hirsch 56f85f76df
M9: more signature validation algorithms (SHA-3, RIPEMD-160, Ed25519, P-521, brainpool, PSS, rsa_sha1) (#386)
* M9: more signature validation algorithms

Validation now reads what real signers write, and says when it is weak:

- Digests SHA-224, SHA-512/224, SHA-512/256, SHA3-224/256/384/512 and
  RIPEMD-160, beside SHA-1 and SHA-2.
- RSA PKCS#1 v1.5 for every digest, in `rsa_pad`: the one expected encoding
  is built and compared byte for byte, with or without the DigestInfo's NULL
  (RFC 8017 App. B.1). A signature over the bare digest, which doesn't say
  which hash it uses, is refused. The signature value must be below the
  modulus (RFC 8017 §5.2.2); s and s + n both verified before.
- RSA-PSS with the hash, MGF1 hash and salt length the signature declares.
- ECDSA as DER, non-minimal DER or raw r||s on P-256, P-384, P-521 and
  brainpoolP256r1/P384r1/P512r1 (BSI "plain" ECDSA OIDs too); brainpoolP512r1
  is hand-written on crypto-bigint because no RustCrypto crate has it.
- Ed25519 (RFC 8419), and the legacy adbe.x509.rsa_sha1 format.
- An algorithm PdfCraft can't check is Unknown, never Invalid.
- SHA-1 and RIPEMD-160 signatures validate, but the signature's details say
  the algorithm is weak (wording pinned by tests).
- Encoding irregularities that were tolerated are listed in the details
  (`verify_noting`; `verify` keeps its signature).

Found while testing, each with a regression test that failed before the fix:
a brainpoolP512r1 public key with a coordinate >= p panicked inside
crypto-bigint's `sub_mod` (the certificate comes from the PDF); it is refused
now, and the point at infinity is an invalid signature, not an error.

Vectors were made with OpenSSL (tests/data/README.md has the commands).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

* Update comment to clarify MAC digest restrictions

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

* M9: a legacy x509.rsa_sha1 signature whose key the verifier rejects is Invalid; only unsupported keys are "can't check yet"

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Brandon Thomas <echelon@gmail.com>
2026-10-09 18:44:38 -04:00
..
a11y Add image signatures with placement preview and resize controls (#335) 2026-10-08 16:36:26 -04:00
annot Refs #169: no form bar for push-button-only documents; Screen is not a comment (#615) 2026-10-09 17:49:54 -04:00
automation Refs #103: ship the OCR models in the desktop release packages (#630) 2026-10-09 18:42:23 -04:00
compare Rename PrintCraft to PdfCraft (#174) 2026-10-07 16:03:57 -04:00
content Fix #155: edit text across content stream pieces (#628) 2026-10-09 17:57:02 -04:00
cos Refs #142: decode outline titles with BOMs and raw UTF-8 consistently (#614) 2026-10-09 16:52:07 -04:00
create M10.2: Create PDF from multiple files, edited as pages in the Organize grid (#361) 2026-10-08 17:42:13 -04:00
crypt Rename PrintCraft to PdfCraft (#174) 2026-10-07 16:03:57 -04:00
edit Export to Word/HTML/RTF: read text and images drawn by form XObjects (fixes #314) (#406) 2026-10-09 18:22:07 -04:00
engine Export to Word/HTML/RTF: read text and images drawn by form XObjects (fixes #314) (#406) 2026-10-09 18:22:07 -04:00
export Fix #526: keep text colour in Word, HTML and RTF export (#547) 2026-10-09 10:49:21 -04:00
filters Rename PrintCraft to PdfCraft (#174) 2026-10-07 16:03:57 -04:00
fonts Issue #125: page text the standard fonts can't draw is refused, not written as ? (#510) 2026-10-09 13:20:47 -04:00
forms Fix main CI: drop four duplicate copies of the forms redraw tests (#605) 2026-10-09 15:42:10 -04:00
geom Rename PrintCraft to PdfCraft (#174) 2026-10-07 16:03:57 -04:00
js XFA: run FormCalc scripts (#301) 2026-10-08 13:06:33 -04:00
measure M5: draw all ten PDF line-ending styles (#520) 2026-10-09 13:15:44 -04:00
model Phone photos follow EXIF orientation; image signatures stay upright on rotated pages (#434) (#485) 2026-10-09 09:14:55 -04:00
ocr Refs #103: ship the OCR models in the desktop release packages (#630) 2026-10-09 18:42:23 -04:00
optimize M11: Optimize PDF and Reduce File Size run in the background with a progress bar (#370) 2026-10-08 18:46:34 -04:00
organize M2: bound page-label traversal and output (#480) 2026-10-09 14:12:16 -04:00
platform Platform: one save-staging helper for automation and the desktop app (#356) 2026-10-08 17:07:00 -04:00
preflight Rename PrintCraft to PdfCraft (#174) 2026-10-07 16:03:57 -04:00
print M10: Print ▸ Properties… opens the printer driver's own settings (#482) 2026-10-09 14:27:02 -04:00
redact Fix #155: edit text across content stream pieces (#628) 2026-10-09 17:57:02 -04:00
render Refs #169: no form bar for push-button-only documents; Screen is not a comment (#615) 2026-10-09 17:49:54 -04:00
sign M9: more signature validation algorithms (SHA-3, RIPEMD-160, Ed25519, P-521, brainpool, PSS, rsa_sha1) (#386) 2026-10-09 18:44:38 -04:00
ui-egui Refs #103: ship the OCR models in the desktop release packages (#630) 2026-10-09 18:42:23 -04:00
xfa XFA: choice lists, signature, password, image and barcode fields; PNG and GIF pictures (#414) 2026-10-09 14:46:07 -04:00
xfdf M6.2: check boxes with non-UTF-8 state names show their mark when clicked (#536) 2026-10-09 12:58:38 -04:00