[
https://issues.apache.org/jira/browse/PDFBOX-2469?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14198728#comment-14198728
]
Tilman Hausherr commented on PDFBOX-2469:
-----------------------------------------
Some observations:
- the decrypt that fails is obj 661, which is just after the %%EOF
- it is /Metadata
- the stream length is 4336
- regardless of the buffer size, decrypt always fails after having read 4304
bytes
- when using a big buffer, blocks are being read, the first has size 496, then
512, then a block of 224 bytes
- saving the decrypted stuff does not show anything meaningful, despite that
the stream is not compressed.
- there is metadata in obj 61. That one is readable.
- other objects with exception: 1036 (Xref), 995 (Sig), 998 (Xref), 972
("/AuthEvent/DocOpen/CFM/AESV2")
"Though this be madness, yet there is method in it" - are we possibly
decrypting stuff that shouldn't be decrypted, or that must be decrypted with
another method / password, or that should be ignored?
- when running with a JRE 1.6.0_45 I get identical content for object 661 than
with JRE7 with swallowing the exception.
- when swallowing the exception, I am able to get the meta data
doc.getDocumentCatalog().getMetadata().createInputStream(), i.e. that object
661 isn't used for that.
> javax.crypto.BadPaddingException in PDFBox 1.8.8-SNAPSHOT
> ---------------------------------------------------------
>
> Key: PDFBOX-2469
> URL: https://issues.apache.org/jira/browse/PDFBOX-2469
> Project: PDFBox
> Issue Type: Bug
> Components: PDModel
> Affects Versions: 1.8.7, 2.0.0
> Reporter: Tim Allison
> Assignee: Andreas Lehmkühler
> Priority: Minor
> Labels: AES128
> Fix For: 1.8.8, 2.0.0
>
> Attachments: testPDF_acroForm.pdf
>
>
> [~gagravarr] noticed that one of our old test files fails a Tika test now
> with PDFBox 1.8.7 and Java 1.6.
> I just tested the pure PDFBox app built with PDFBox 1.8.8-SNAPSHOT, and I'm
> getting the same exception with Java 1.6 and Java 1.7.
> Stacktrace:
> {noformat}
> ExtractText failed with the following exception:
> java.io.IOException: javax.crypto.BadPaddingException: Given final block not
> properly padded
> at
> javax.crypto.CipherInputStream.getMoreData(CipherInputStream.java:118)
> at javax.crypto.CipherInputStream.read(CipherInputStream.java:236)
> at javax.crypto.CipherInputStream.read(CipherInputStream.java:212)
> at
> org.apache.pdfbox.pdmodel.encryption.SecurityHandler.encryptData(SecurityHandler.java:316)
> at
> org.apache.pdfbox.pdmodel.encryption.SecurityHandler.decryptStream(SecurityHandler.java:421)
> at
> org.apache.pdfbox.pdmodel.encryption.SecurityHandler.decrypt(SecurityHandler.java:390)
> at
> org.apache.pdfbox.pdmodel.encryption.SecurityHandler.decryptObject(SecurityHandler.java:365)
> at
> org.apache.pdfbox.pdmodel.encryption.SecurityHandler.proceedDecryption(SecurityHandler.java:196)
> at
> org.apache.pdfbox.pdmodel.encryption.StandardSecurityHandler.decryptDocument(StandardSecurityHandler.java:158)
> at
> org.apache.pdfbox.pdmodel.PDDocument.openProtection(PDDocument.java:1598)
> at org.apache.pdfbox.ExtractText.startExtraction(ExtractText.java:216)
> at org.apache.pdfbox.ExtractText.main(ExtractText.java:85)
> at org.apache.pdfbox.PDFBox.main(PDFBox.java:58)
> Caused by: javax.crypto.BadPaddingException: Given final block not properly
> padded
> at com.sun.crypto.provider.CipherCore.doFinal(CipherCore.java:811)
> at com.sun.crypto.provider.CipherCore.doFinal(CipherCore.java:676)
> at com.sun.crypto.provider.AESCipher.engineDoFinal(AESCipher.java:423)
> at javax.crypto.Cipher.doFinal(Cipher.java:1708)
> at
> javax.crypto.CipherInputStream.getMoreData(CipherInputStream.java:112)
> ... 12 more
> {noformat}
> java version "1.7.0_71"
> OpenJDK Runtime Environment (rhel-2.5.3.1.el6-x86_64 u71-b14)
> OpenJDK 64-Bit Server VM (build 24.65-b04, mixed mode)
> and
> java version "1.6.0_33"
> OpenJDK Runtime Environment (IcedTea6 1.13.5) (rhel-1.13.5.0.el6_6-x86_64)
> OpenJDK 64-Bit Server VM (build 23.25-b01, mixed mode)
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)