Skip to content

Modernize encryption and signature support; post-quantum signatures, SHA-3 digests.#1549

Open
andreasrosdalw wants to merge 4 commits intoLibrePDF:masterfrom
andreasrosdalw:encryption2
Open

Modernize encryption and signature support; post-quantum signatures, SHA-3 digests.#1549
andreasrosdalw wants to merge 4 commits intoLibrePDF:masterfrom
andreasrosdalw:encryption2

Conversation

@andreasrosdalw
Copy link
Copy Markdown
Contributor

@andreasrosdalw andreasrosdalw commented May 5, 2026

Description of the new Feature/Bugfix

Encryption & signature modernization

  • PdfEncryption: document IDs are now generated from SecureRandom (16 bytes) instead of an MD5 hash of time/memory/sequence, removing the last non-spec-mandated MD5 use in the encryption module.
  • TSAClientBouncyCastle: default TSA imprint digest changed from SHA-1 to SHA-256, and the RFC 3161 nonce is now a 64-bit SecureRandom value instead of System.currentTimeMillis().
  • PdfSignatureAppearance: DocMDP DigestMethod changed from MD5 to SHA256 (PDF 2.0 / ISO 32000-2 disallows MD5).
  • PdfPKCS7: added support for SHA3-256 and SHA3-512 (FIPS 202) as signature digest algorithms, both for creation and verification.
  • PdfPKCS7: wrapped ASN1InputStream usages in try-with-resources and removed stale "duplicate key" TODO comments that referred to entries in a different map.
  • Add initial support for ML-DSA (NIST FIPS 204) post-quantum signatures in PdfPKCS7 via the Bouncy Castle provider (parameter sets ML-DSA-44, ML-DSA-65, ML-DSA-87).

No public API changes, no new tests.

I spent some "research" and innovation time to try improving and modernizing encryption and signature support using AI copilot.

Your real name

Andreas Røsdal

Encryption & signature modernization

- PdfEncryption: document IDs are now generated from SecureRandom (16
  bytes) instead of an MD5 hash of time/memory/sequence, removing the
  last non-spec-mandated MD5 use in the encryption module.
- TSAClientBouncyCastle: default TSA imprint digest changed from SHA-1
  to SHA-256, and the RFC 3161 nonce is now a 64-bit SecureRandom value
  instead of System.currentTimeMillis().
- PdfSignatureAppearance: DocMDP DigestMethod changed from MD5 to
  SHA256 (PDF 2.0 / ISO 32000-2 disallows MD5).
- PdfPKCS7: added support for SHA3-256 and SHA3-512 (FIPS 202) as
  signature digest algorithms, both for creation and verification.
- PdfPKCS7: wrapped ASN1InputStream usages in try-with-resources and
  removed stale "duplicate key" TODO comments that referred to entries
  in a different map.

No public API changes, no new tests.
@codacy-production
Copy link
Copy Markdown

codacy-production Bot commented May 5, 2026

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 0 duplication

Metric Results
Duplication 0

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

…PKCS7 via the Bouncy Castle provider (parameter sets ML-DSA-44, ML-DSA-65, ML-DSA-87). Signing, external-signature, and verification paths recognise the ML-DSA OIDs and JCE algorithm names.
@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented May 5, 2026

@andreasrosdalw andreasrosdalw changed the title Modernize encryption and signature support; add SHA-3 digests Modernize encryption and signature support; post-quantum signatures, SHA-3 digests. May 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant