Learning Beyond the page

Encryption and signatures

1.4 §3.5, §8.71.7 §7.6, §12.8

Encryption

The trailer's /Encrypt dictionary turns encryption on. Strings and streams are encrypted; the structure (dictionaries, names, numbers) stays in the clear. Each object gets its own key, derived from the file key plus its object and generation numbers.

trailer
<< /Size 42 /Root 1 0 R /ID [<…> <…>]
   /Encrypt << /Filter /Standard /V 2 /R 3 /Length 128
              /O <…32 bytes…> /U <…32 bytes…> /P -3904 >> >>
/V/RAlgorithmVersion
12RC4, 40-bit1.1+
23RC4, 40–128-bit (/Length)1.4
44Crypt filters: RC4 (/V2) or AES-128 (/AESV2, 1.6)1.5 / 1.6, the ISO 32000-1 maximum
55, 6AES-256 (/AESV3)Adobe extensions to 1.7; R6 standardized in 2.0

User password opens the document. Owner password unlocks full rights. /P is a bit field of permissions (print, modify, copy, annotate, fill forms, extract for accessibility, assemble, high-quality print). These are advisory: anyone who can open the file can decrypt it, and honoring /P is up to the reader.

The trailer /ID (two byte strings) feeds the key derivation, which is why it must exist in encrypted files. 1.4 §9.3, 1.7 §14.4

Read: 1.4 §3.51.7 §7.6

Digital signatures

A signature is a form field (/FT /Sig) whose value is a signature dictionary. /ByteRange lists the signed spans, which is the whole file except the hex /Contents hole holding the PKCS#7/CMS blob.

<< /Type /Sig /Filter /Adobe.PPKLite /SubFilter /adbe.pkcs7.detached
   /ByteRange [0 840 960 240]      % sign bytes 0–839 and 960–1199
   /Contents <3082…000000>         % fills bytes 840–959, zero-padded
   /M (D:20081103120000Z) >>
  • Later changes must be incremental updates, or they invalidate the signature.
  • SubFilters in 1.7: adbe.pkcs7.detached, adbe.pkcs7.sha1, adbe.x509.rsa_sha1.
  • Signatures date from 1.3. Certification signatures (DocMDP, 1.5) and field locking (FieldMDP) control which later changes are allowed; usage-rights signatures (1.5) move to the /UR3 entry in 1.6.

Read: 1.4 §8.6 signature fields1.7 §12.8 Modern signatures and PAdES: ISO 32000-2ISO/TS 32002

Q1. In an encrypted PDF, what is encrypted?
Everything after the headerStrings and streams; dictionaries, names and numbers stay in the clearOnly the page content streamsOnly the document information dictionary
Check
Q2. An encrypted file's /P forbids printing. What stops someone who can open it from printing it?
Only the reader choosing to honor /PThe encryption itselfThe owner password, which is needed to decrypt the contentA digital signature over /P
Check
Q3. What does a signature's /ByteRange cover?
The page content streamsThe objects changed since the last saveThe signature field's widget annotationThe whole file except the hole holding the signature value in /Contents
Check
Reset3 questions

Section references such as 1.4 §3.4 1.7 §7.5 are to the Adobe PDF Reference, third edition (PDF 1.4) and ISO 32000-1:2008 (PDF 1.7). Where to get them: PDF specifications.