michaelrsweet / pdfio

PDFio is a simple C library for reading and writing PDF files.
https://www.msweet.org/pdfio
Apache License 2.0
199 stars 44 forks source link

Unable to read files password-protected by Adobe Protect PDF online tool #62

Closed lorenzobergama6 closed 3 months ago

lorenzobergama6 commented 9 months ago

Apparently PDFio cannot open PDF files that were password-protected via this online tool by Adobe. The encryption label is PDFIO_ENCRYPTION_AES_128. In fact, the files are properly decrypted but afterwards the following error messages appear:

Corrupt stream data.
Unable to decompress stream data for object 4: Data error.
Unable to find pages object.

The same unprotected files are read correctly.

I have tried this by adding a test in the test routine of the provided Visual Studio solution on Windows 11. Thank you.

P.S. The following does not have to do with this issue, but it is just a brief comment. The encryption labeled by PDFIO_ENCRYPTION_AES_256 corresponds to V6 R6. However from the PDF 2.0 specifications I understand that it should be associated with V5 R6; also I have a protected 2.0 PDF which has indeed V=5 and R=6.

michaelrsweet commented 9 months ago

Can you attach the before and after PDF files that show this? I've been separately tracking what might be the same issue (#42), but haven't figured out the proper fix yet.

lorenzobergama6 commented 9 months ago

Here they are: test.pdf test-protected.pdf Password is "password" (without quotes).

michaelrsweet commented 3 months ago

What's interesting is that the last 16 bytes of the user password value are nul (0)... This is technically allowed (you are supposed to pad with 16 bytes of arbitrary data) but might be significant...

michaelrsweet commented 3 months ago

[master 7d22477] Fix opening of certain encrypted PDF files (Issue #62)