pub enum PermsCheck {
NotApplicable,
Match,
Mismatch {
perms_p: u32,
dict_p: u32,
perms_encrypt_metadata: Option<bool>,
dict_encrypt_metadata: bool,
},
MarkerMissing,
}Expand description
The verdict of Algorithm 3.13 — the only integrity check in PDF encryption (negative result N7).
§Why this is reported and never acted on (T27)
/Perms is a 16-byte block holding an encrypted copy of /P and of
/EncryptMetadata. At /V 1–4 those values sit in the file as editable
plaintext with no protection at all; /Perms is the one place PDF binds
them to the encryption key. That makes it the only thing in clause 7.6 that
can detect tampering — and the supplement still states its verdict as
should match, with no clause anywhere saying what to do when it
does not.
pdfcer therefore reports the disagreement and prefers neither value:
- It does not refuse the document. The spec’s modality is
should, and every other reader opens the file; refusing would make pdfcer reject documents nothing else objects to, on the strength of a check the standard declines to require. - It does not silently substitute the decrypted
/Pfor the dictionary’s. That is exactly the shape rule 4 forbids: a value pdfcer inferred to be more trustworthy, becoming what the operator is shown, with no disclosure.Permissionskeeps reporting the dictionary/P— the value the file declares and the value every other viewer displays — and the disagreement is surfaced beside it throughDocumentEncryption::perms. - It does not treat a mismatch as damage.
Self::MarkerMissingis the case that means “the decryption itself is suspect”, and it is kept distinct for that reason.
Variants§
NotApplicable
There is no /Perms entry to check. /R ≤ 4 has none — the entry was
introduced by ExtensionLevel 3 — so this is the ordinary answer for
every RC4 and AES-128 document, and is not a negative result.
Match
Decrypted cleanly, the adb marker is present, and both recovered
values agree with the plaintext dictionary.
Mismatch
Decrypted cleanly and the adb marker is present, but a recovered
value disagrees with the dictionary.
The most likely innocent cause is a producer that edited /P without
re-encrypting /Perms; the most likely non-innocent one is someone
widening the permissions of a document they could not decrypt.
Nothing in the file distinguishes those, which is precisely why
pdfcer reports rather than decides.
Fields
perms_p: u32Bytes 0–3 of the decrypted block, little-endian: the permission flags as the encrypting producer recorded them.
MarkerMissing
Decrypted, but bytes 9–11 are not the literal adb.
A different fact from Self::Mismatch: the marker is a fixed
constant, so its absence means the decryption is wrong — a truncated
or corrupted /Perms, or a file encryption key that is not the one
this document was encrypted with. Since authentication has already
succeeded by the time this runs, in practice it points at a damaged
/Perms rather than at a wrong password.