[
https://issues.apache.org/jira/browse/PDFBOX-2456?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14190859#comment-14190859
]
Tilman Hausherr commented on PDFBOX-2456:
-----------------------------------------
[[email protected]] I'm wondering what the purpose of the other test is. From
having a quick look, what you're doing is to compare the size of the inner
file, encrypting, decrypting - correct? However, AFAIK a file attachment is
also just a stream. What I means is that comparing a file that has images isn't
much different than comparing the attachment in a PDF.
I tested the code that isn't committed. It fails at 256bit:
{code}
java.io.IOException: javax.crypto.IllegalBlockSizeException: Input length must
be multiple of 16 when decrypting with padded cipher
at com.sun.crypto.provider.CipherCore.doFinal(CipherCore.java:750)
at com.sun.crypto.provider.CipherCore.doFinal(CipherCore.java:676)
at com.sun.crypto.provider.AESCipher.engineDoFinal(AESCipher.java:313)
at javax.crypto.Cipher.doFinal(Cipher.java:1970)
at
javax.crypto.CipherInputStream.getMoreData(CipherInputStream.java:112)
at javax.crypto.CipherInputStream.read(CipherInputStream.java:233)
at javax.crypto.CipherInputStream.read(CipherInputStream.java:209)
at org.apache.pdfbox.io.IOUtils.copy(IOUtils.java:68)
at
org.apache.pdfbox.pdmodel.encryption.SecurityHandler.encryptData(SecurityHandler.java:258)
at
org.apache.pdfbox.pdmodel.encryption.SecurityHandler.decryptString(SecurityHandler.java:486)
at
org.apache.pdfbox.pdfwriter.COSWriter.visitFromString(COSWriter.java:1265)
at org.apache.pdfbox.cos.COSString.accept(COSString.java:446)
at
org.apache.pdfbox.pdfwriter.COSWriter.visitFromDictionary(COSWriter.java:1071)
at org.apache.pdfbox.cos.COSDictionary.accept(COSDictionary.java:1329)
at
org.apache.pdfbox.pdfwriter.COSWriter.doWriteObject(COSWriter.java:541)
at org.apache.pdfbox.pdfwriter.COSWriter.doWriteBody(COSWriter.java:449)
at
org.apache.pdfbox.pdfwriter.COSWriter.visitFromDocument(COSWriter.java:1106)
at org.apache.pdfbox.cos.COSDocument.accept(COSDocument.java:513)
at org.apache.pdfbox.pdfwriter.COSWriter.write(COSWriter.java:1379)
at org.apache.pdfbox.pdmodel.PDDocument.save(PDDocument.java:1137)
at org.apache.pdfbox.pdmodel.PDDocument.save(PDDocument.java:1117)
at
org.apache.pdfbox.encryption.TestSymmetricKeyEncryption.encrypt(TestSymmetricKeyEncryption.java:280)
at
org.apache.pdfbox.encryption.TestSymmetricKeyEncryption.testSymmEncrForKeySizeInner(TestSymmetricKeyEncryption.java:380)
at
org.apache.pdfbox.encryption.TestSymmetricKeyEncryption.testProtectionInnerAttachment(TestSymmetricKeyEncryption.java:372)
{code}
Why not run the encryption / decryption test on a longer file, i.e. with
several pages, and a bit of text and images?
> 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
> Fix For: 2.0.0
>
> Attachments: TestSymmetricKeyEncryption.java,
> 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)