Graphics Programs Reference
In-Depth Information
The actual algorithm used for each step depends upon the kind of encryption in use.
The same process is used if the user password is non-blank, using the password entered
by the user instead.
To decrypt using the owner password, a similar process is followed, except that the
permissions need not be applied. If the file is opened with the user password and later,
the owner password is entered, the permissions may be relaxed.
Writing Encrypted Documents
To write a parsed PDF to a file with encryption:
1. The /U and /O entries are calculated based a one-way algorithm combining the
owner and user passwords.
2. The rest of the entries in the encryption dictionary are built, including the permis-
sions, and the encryption dictionary is added to the trailer dictionary.
3. Each string and stream in the file is encrypted using a key calculated from the
encryption dictionary.
4. The PDF object graph is flattened to a file in the usual fashion.
Again, the actual algorithms involved at each stage vary with the encryption method
in use.
Editing Encrypted Documents
If the permissions on a file allow it to be edited with just the user password, we must
be able to write the modified file, still encrypted with the same owner and user pass-
word. However, the algorithms given above would require the owner password to be
known to encrypt the file again for writing.
To solve this problem, the encryption parameters from the original reading of the file
are retained, even though the encryption dictionary itself must be removed once the
file is decrypted. The encryption dictionary (including the /O and /U entries) may there-
fore be reconstructed.
Search WWH ::




Custom Search