Skip Menu |

This queue is for tickets about the CAM-PDF CPAN distribution.

Report information
The Basics
Id: 28763
Status: open
Priority: 0/
Queue: CAM-PDF

People
Owner: Nobody in particular
Requestors: pmark [...] CartesianInc.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: Encrypted PDFs without an ID
Date: Thu, 9 Aug 2007 10:19:02 -0400
To: <bug-CAM-PDF [...] rt.cpan.org>
From: "Peter Mark" <pmark [...] CartesianInc.com>
Thank you for your excellent package. Unfortunately, we have found that the package is unable to open encrypted PDFs without an ID. Although most PDFs do have an ID, the specification says that it is optional. And, it does not appear to make it required for encrypted documents. The EPO (ep.espacenet.com) distributes encrypted v1.2 PDFs without an ID. These files are read by both Adobe and Apple PDF software without complaint. The following simple change to CAM::PDF::Decrypt.pm appears to allow decryption of these documents: diff -r1.1 Decrypt.pm 127,129c127,130 < { < $CAM::PDF::errstr = "This PDF lacks an ID. The document cannot be decrypted.\n"; < return; --- Show quoted text
> { > $doc->{ID} = qq{};
Please consider it for a future release of the package. Thanks again for the excellent package. Best regards, Peter Mark Cartesian Products, Inc.
From: Thomas Equeter
On Thu Aug 09 10:21:23 2007, pmark@CartesianInc.com wrote: Show quoted text
> Unfortunately, we have found that the package is unable to open encrypted > PDFs without an ID. Although most PDFs do have an ID, the
specification says Show quoted text
> that it is optional. And, it does not appear to make it required for > encrypted documents.
According to the specification, the ID is indeed only "Optional, but strongly recommended" (page 98, PDF reference 1.7). However, it is used to compute the encryption key - see algorithm 3.2 page 125, "Pass the first element of [...] the value of the ID entry in the document's trailer dictionary to the MD5 hash function." In the absence of further details in the specification, an empty (byte-)string is probably a reasonable default indeed. For the record, from page 847 the ID entry is "an array of two byte strings. The first byte string is a permanent identifier based on the contents of the file at the time it was originally created and does not change when the file is incrementally updated. The second byte string is a changing identifier based on the file's contents at the time it was last updated." I hope this helps resolving the issue.