[
https://issues.apache.org/jira/browse/PDFBOX-2456?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14194978#comment-14194978
]
Stephen Hendrix commented on PDFBOX-2456:
-----------------------------------------
>From what I can tell, the BadPaddingException is thrown for AES256 when
>attempting to decrypt the encryption dictionary values (U, UE, O, OE) which
>are set during encryption in
>StandardSecurityHandler.prepareDocumentForEncryption. Those values are not
>encrypted with the same key as the rest of the document, so decryption fails.
>I got around this by excluding those keys from decryption in
>SecurityHandler.decryptDictionary as follows:
{code}
if (!(entry.getKey().equals(COSName.UE) || entry.getKey().equals(COSName.OE) ||
entry.getKey().equals(COSName.O) || entry.getKey().equals(COSName.U))) {
decrypt(value, objNum, genNum);
}
{code}
With that change, the 256 bit test in TestSymmetricKeyEncryption passes with no
BadPaddingException (using java version "1.7.0_71"). I don't know enough about
the codebase or PDF though to know whether that fix has other side effects.
In previous versions of the JDK, the BadPaddingException was silently swallowed
(see my bug reference above).
> create TestSymmetricKeyEncryption.java
> --------------------------------------
>
> Key: PDFBOX-2456
> URL: https://issues.apache.org/jira/browse/PDFBOX-2456
> Project: PDFBox
> Issue Type: Improvement
> Components: Utilities
> Affects Versions: 2.0.0
> Environment: java7 debian7
> Reporter: Ralf Hauser
> Labels: AES256
> Fix For: 2.0.0
>
> Attachments: TestSymmetricKeyEncryption.java,
> enc128bit_20141025_115145.pdf, enc256bit_20141025_105451.pdf,
> preEnc_20141025_105451.pdf, preEnc_20141025_115145.pdf
>
>
> similarly to org.apache.pdfbox.encryption.TestPublicKeyEncryption, also test
> password based encryption
> 1) 128bit
> 2) 256bit AES PDFBOX-1594
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)