Skip to main content

Module crypto

Module crypto 

Source
Expand description

PDF Standard Security Handler (encryption) — decryption side only.

This module implements enough of the PDF 1.7 / PDF 2.0 Standard Security Handler to decrypt documents produced by:

  • revisions 2 and 3 (V=1 or V=2, RC4 with a 40-bit or 128-bit key),
  • revision 4 with V=4 crypt filters naming /V2 (RC4-128) or /AESV2 (AES-128-CBC) as the stream and string method,
  • revisions 5 and 6 (V=5, AES-256-CBC) via the /AESV3 crypt filter — R=5 uses a plain SHA-256 verifier (the vulnerable Extension Level 3 form) and R=6 uses the ISO 32000-2 iterative Algorithm 2.B hash.

Authentication runs against either the user password or the owner password. The empty user password is accepted as a special case of the general user-password path.

Public-key security handlers are not yet implemented and still fail up front with PdfError::Unsupported. They can be layered on top without changing this module’s public surface.

Structs§

StandardSecurityHandler

Enums§

BytesKind
Which slot the ciphertext belongs to. Drives the crypt-method choice (string vs stream) on V=4 documents and is a no-op on V=1/2.
SecurityRevision