pdftract/crates/pdftract-cli/src
jedarden a62913f25d feat(pdftract-1z0qt): implement encryption detection + RC4/AES-128/AES-256 decryption
Implement decrypt feature with RC4, AES-128, and AES-256 decryption support
for encrypted PDFs per PDF 1.7/2.0 spec.

Core components:
- detection.rs: Parse /Encrypt dictionary, validate encryption metadata
- rc4.rs: V=1 R=2 (40-bit) and V=2 R=3 (40-128 bit) key derivation
- aes_128.rs: V=4 R=4 AES-128 CBC with PKCS#7 padding
- aes_256.rs: V=5 R=5/6 AES-256 with SHA-256/384/512 key derivation
- decryptor.rs: Unified API for password validation and stream/string decryption

Integration:
- extract_pdf: Detect encryption and validate passwords after xref loading
- CLI: Exit code 3 for encryption errors (wrong password, unsupported)
- Password sources: --password-stdin, PDFTRACT_PASSWORD, --password VALUE (opt-in)

Password validation: Empty string first, then user-provided. Wrong
password emits ENCRYPTION_UNSUPPORTED diagnostic and exits with code 3.

Tests: Unit tests for RC4, AES-128, AES-256 key derivation and
validation. All pass with `cargo test --features decrypt`.

Refs: Plan Phase 1.4 line 1114, EC-04/EC-05/EC-06, PDF spec 7.6

Co-Authored-By: Claude Code <noreply@anthropic.com>
2026-05-28 03:22:36 -04:00
..
doctor feat(pdftract-3s2i): implement Phase 5.5.2 validation filter 2026-05-24 04:57:17 -04:00
grep fix(pdftract-63ka2): AES-128 test buffer allocation for PKCS#7 padding 2026-05-28 01:30:33 -04:00
inspect fix(pdftract-63ka2): AES-128 test buffer allocation for PKCS#7 padding 2026-05-28 01:30:33 -04:00
mcp fix(pdftract-63ka2): AES-128 test buffer allocation for PKCS#7 padding 2026-05-28 01:30:33 -04:00
middleware feat(pdftract-1t5sj): implement book_chapter profile with fixtures and tests 2026-05-27 22:30:09 -04:00
cache_cmd.rs feat(pdftract-3s2i): implement Phase 5.5.2 validation filter 2026-05-24 04:57:17 -04:00
classify.rs fix: resolve compilation errors across codebase 2026-05-25 08:38:04 -04:00
codegen.rs feat(pdftract-3s2i): implement Phase 5.5.2 validation filter 2026-05-24 04:57:17 -04:00
lib.rs fix(pdftract-63ka2): AES-128 test buffer allocation for PKCS#7 padding 2026-05-28 01:30:33 -04:00
main.rs feat(pdftract-1z0qt): implement encryption detection + RC4/AES-128/AES-256 decryption 2026-05-28 03:22:36 -04:00
output.rs fix(pdftract-63ka2): AES-128 test buffer allocation for PKCS#7 padding 2026-05-28 01:30:33 -04:00
password.rs feat(pdftract-3s2i): implement Phase 5.5.2 validation filter 2026-05-24 04:57:17 -04:00
serve.rs fix(pdftract-63ka2): AES-128 test buffer allocation for PKCS#7 padding 2026-05-28 01:30:33 -04:00
serve.rs.bak feat(pdftract-1t5sj): implement book_chapter profile with fixtures and tests 2026-05-27 22:30:09 -04:00
verify_receipt.rs feat(pdftract-3s2i): implement Phase 5.5.2 validation filter 2026-05-24 04:57:17 -04:00