Expand description
The standard security handler, revisions 2–6 (§7.6).
What is read, and which algorithms carry it:
/V | /R | Cipher | Key derivation | Password check |
|---|---|---|---|---|
| 1 | 2 | RC4, 40 bit | Algorithm 2 (MD5) | Algorithm 4 |
| 2 | 3 | RC4, 40–128 bit | Algorithm 2, 50 rounds | Algorithm 5 |
| 4 | 4 | RC4 (/V2) or AES-128 (/AESV2) | as /R 3 | Algorithm 5 |
| 5 | 6 | AES-256 (/AESV3) | Algorithm 2.B | Algorithm 2.A |
Two structures differ between the generations and are worth stating:
- Revisions 2–4 derive a per-object key from the file key, the object number and its generation (Algorithm 1), which is why a string or stream from those revisions cannot be decrypted without knowing which object it came from. Revisions 5 and 6 use the file key directly.
- Revision 6 verification is Algorithm 2.B — a 64-round minimum key stretch
over SHA-256/384/512 and AES-128-CBC — implemented in
hash_r6, while revisions 2–4 use MD5, implemented here rather than pulled in as a dependency: it is 100 lines, needs nostd, and its only use is key derivation for files that predate PDF 2.0.
/R 5 is refused: it is the deprecated draft of revision 6 and no file in
the corpus uses it.
Structs§
- Encryption
- The standard security handler for one document.
Constants§
- KEY_
LENGTH - Length of the file key, and of the AES key, for
/V 5.
Functions§
- hash_r6
- Algorithm 2.B: the revision 6 password hash.