Openpdf: "Unknown encryption type R = 6" support AES256

Created on 28 May 2020  路  11Comments  路  Source: LibrePDF/OpenPDF

It seems that the first AES256 encrypted pdf's are out in the wild

https://stackoverflow.com/questions/50822874/unknown-encryption-type-opening-pdf-file

I guess they should be supported

enhancement help wanted

Most helpful comment

pwProtectedAES256_openPDFiss375.pdf

Here comes a test file

All 11 comments

Pull requests welcome

I tried this once but failed and didn't have the time to investigate further. Seems not so easy...

pwProtectedAES256_openPDFiss375.pdf

Here comes a test file

Created with
SettingsPwProtectedAES256_openPDFiss375

Damn also had a document with this error now :-(
Seems more and more docs are in the wild using this standard

Here is an another example of the 256-bit AES encrypted file:
https://pratiyogitaabhiyan.in/wp-content/uploads/2020/09/Indian-National-Movement-Phase-III-1935-1947-NotesMCQ-PDF-pratiyogitaabhiyan.in_.pdf

Qpdf output:

>qpdf --show-encryption Indian-National-Movement_1.pdf
WARNING: Indian-National-Movement_1.pdf: file is damaged
WARNING: Indian-National-Movement_1.pdf (offset 1116099): xref not found
WARNING: Indian-National-Movement_1.pdf: Attempting to reconstruct cross-reference table
R = 5
P = -1852
User password =
Supplied password is user password
extract for accessibility: not allowed
extract for any purpose: not allowed
print low resolution: allowed
print high resolution: allowed
modify document assembly: not allowed
modify forms: not allowed
modify annotations: not allowed
modify other: not allowed
modify anything: not allowed
stream encryption method: AESv3
string encryption method: AESv3
file encryption method: AESv3
qpdf: operation succeeded with warnings

To fix the problem of opening files with 256-bit AES encryption this part from "itext7-dotnet" repository should be brought into this repository somewhere here:

https://github.com/LibrePDF/OpenPDF/blob/116b38cdbe30385161444976a2c418446fdaf0a5/openpdf/src/main/java/com/lowagie/text/pdf/PdfReader.java#L728-L737

Pull requests welcome!

To fix the problem of opening files with 256-bit AES encryption this part from "itext7-dotnet" repository should be brought into this repository somewhere here:

Beware not to really copy from there to here. While being inspired by it certainly is ok, a more or less verbatim copy of too much code might cause license issues.

@mkl-public I get you point.

Actually I saved the link with AES256 implementation in iText because it is always nice to have a working code and you can always take a look into the alternative implementation, if you got stuck.

BTW here is the same part on Java, which is more useful for us, as long as OpenPDF is written on Java.

From the other side the encryption algorithm should be more or less the same, as long as we need to get the same result.

From the third side it looks like we still can copy the code from iText to OpenPDF:

So this mean, that if you copy code from AGPL, into the LGPL project, the copied code still is AGPL. And OpenPDF would become AGPL too, which is not the intend of OpenPDF. It should remain LGPL, so it can still be used in closed source projects.

https://www.gnu.org/licenses/gpl-faq.en.html#UnreleasedModsAGPL

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mattymurphy picture mattymurphy  路  3Comments

marbetschar picture marbetschar  路  5Comments

Lonzak picture Lonzak  路  5Comments

kdekooter picture kdekooter  路  5Comments

michaelhugi picture michaelhugi  路  6Comments