[ 
https://issues.apache.org/jira/browse/PDFBOX-5639?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17744354#comment-17744354
 ] 

Michael Klink commented on PDFBOX-5639:
---------------------------------------

R=5 was an Adobe first shot at AES256 which they defined in an Adobe extension 
to ISO 32000-1 and which in ISO 32000-2 has been deprecated. Before this 
example here I've only seen R=5 being used in Adobe PDFs.

Interestingly, this scanner has copied an Adobe error, too: It fills the *O* 
and *U* value (which are specified to be 48 bytes long) with zeros to 128 
bytes. In case of R=6 PDFBox repairs such values and cuts off any bytes in 
excess of the specified ones (see the {{computeHash2A}} method) but it doesn't 
do so for R=5. Maybe it suffices to cut down the *O* and *U* values to 48 bytes 
here, too...

> Password protected PDF opens in GUI apps but PDFbox says invalid password
> -------------------------------------------------------------------------
>
>                 Key: PDFBOX-5639
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-5639
>             Project: PDFBox
>          Issue Type: Bug
>          Components: Crypto
>    Affects Versions: 2.0.29, 3.0.0 PDFBox
>         Environment: Java 17 on both Linux and Windows
>            Reporter: Steve Davies
>            Priority: Major
>         Attachments: incorrect_password.pdf
>
>
> I am using PDFbox to test whether a password is correct for a protected PDF 
> before handling it with a different process. This is working for the vast 
> majority of files I receive but from one particular source PDFbox reports an 
> invalid password when the files can be opened without complaint in GUI 
> applications (Adobe Reader et. al.).
> These files are created by scanning to PDF on Xerox MFDs and using the MFD's 
> menus to add a password to the document. As luck would have it I have access 
> to the same MFDs in my location and my files created using the same method 
> are correctly read by PDFbox.
> The issue can be seen using the command line utilities and the same is seen 
> on v2.0.29 and v3.0.0-beta1 (I am using the 2.0 series in the application):
> {code:java}
> ❯ java -jar pdfbox-app-2.0.29.jar Decrypt -password JUL2023rfi 
> invalid_password.pdf
> Exception in thread "main" 
> org.apache.pdfbox.pdmodel.encryption.InvalidPasswordException: Cannot decrypt 
> PDF, the password is incorrect
>         at 
> org.apache.pdfbox.pdmodel.encryption.StandardSecurityHandler.prepareForDecryption(StandardSecurityHandler.java:284)
>         at 
> org.apache.pdfbox.pdfparser.COSParser.prepareDecryption(COSParser.java:2992)
>         at 
> org.apache.pdfbox.pdfparser.COSParser.retrieveTrailer(COSParser.java:285)
>         at 
> org.apache.pdfbox.pdfparser.PDFParser.initialParse(PDFParser.java:173)
>         at org.apache.pdfbox.pdfparser.PDFParser.parse(PDFParser.java:226)
>         at org.apache.pdfbox.pdmodel.PDDocument.load(PDDocument.java:1110)
>         at org.apache.pdfbox.pdmodel.PDDocument.load(PDDocument.java:1093)
>         at org.apache.pdfbox.pdmodel.PDDocument.load(PDDocument.java:1070)
>         at org.apache.pdfbox.tools.Decrypt.decrypt(Decrypt.java:143)
>         at org.apache.pdfbox.tools.Decrypt.main(Decrypt.java:65)
>         at org.apache.pdfbox.tools.PDFBox.main(PDFBox.java:52){code}
> {code:java}
> ❯ java -jar pdfbox-app-3.0.0-beta1.jar Decrypt -password JUL2023rfi -i 
> invalid_password.pdf
> Error decrypting document [InvalidPasswordException]: Cannot decrypt PDF, the 
> password is incorrect{code}
> A sample file is attached, the password is JUL2023rfi



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@pdfbox.apache.org
For additional commands, e-mail: dev-h...@pdfbox.apache.org

Reply via email to