[jira] [Comment Edited] (PDFBOX-2469) javax.crypto.BadPaddingException in PDFBox 1.8.8-SNAPSHOT

2014-11-24 Thread Thomas Chojecki (JIRA)

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

Thomas Chojecki edited comment on PDFBOX-2469 at 11/24/14 9:18 AM:
---

Ups, I simply forgot to write it to the OutputStream. My fault.

I checked it twice now and I don't know why, but the NonSeq parser log 
the exception that the stream can not be decrypted, but don't fail to finish 
parsing. The legacy parser fails hard and stop parsing the rest of the document.

All I want to say is, that the NonSeq parser run into the same error but handle 
it better. Failing the whole decryption because one object can't be handled 
isn't good. 

There are also cases where the NonSeq parser isn't working, So not every user 
can just switch to it. Maybe you remember the "signature" discussion ;-) This 
is one TODO I try to fix, but at the moment I haven't time to do it. 


was (Author: tchojecki):
Ups, I simply forgot to write it to the OutputStream. My fault.

The case with the exception is, that the NonSeq parser already ignore it 
silently and just log it. So both parser would act the same, if the new 
exception block will be also logged and ignored. All I want to say is, that the 
NonSeq parser run into the same error but handle it better. Failing the whole 
decryption because one object can't be handled isn't good. 

There are also cases where the NonSeq parser isn't working, So not every user 
can just switch to it. Maybe you remember the "signature" discussion ;-) This 
is one TODO I try to fix, but at the moment I haven't time to do it. 

> 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: FormI-9-English.pdf, PDFBOX-2469-regression.patch, 
> 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)


[jira] [Comment Edited] (PDFBOX-2469) javax.crypto.BadPaddingException in PDFBox 1.8.8-SNAPSHOT

2014-11-17 Thread JIRA

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

Andreas Lehmkühler edited comment on PDFBOX-2469 at 11/17/14 10:25 AM:
---

I read a lot about the BadPaddingException and learned the the usage of the 
CipherInputStream should be avoided. I've replaced at least one piece of code 
to avoid the particular stream and now the BadPaddingException is gone. There 
is still one part left which doesn't seem to be critical but maybe it's a good 
idea to change that part as well


was (Author: lehmi):
I read a lot about the BadPaddingException and learned the the usage of the 
CipherInputStream should be avoided. I've replaced at least one peice of code 
to avoid the particular stream and now the BadPaddingException is gone. There 
is still one part left which doesn't seem to be critical but maybe it's a good 
idea to change that part as well

> 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)


[jira] [Comment Edited] (PDFBOX-2469) javax.crypto.BadPaddingException in PDFBox 1.8.8-SNAPSHOT

2014-11-05 Thread Tilman Hausherr (JIRA)

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

Tilman Hausherr edited comment on PDFBOX-2469 at 11/6/14 7:16 AM:
--

I have opened the new issue PDFBOX-2484 on that one, as it involves AES256 only.


was (Author: tilman):
I'm opening a new issue on that one, as it involves AES256 only.

> 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)


[jira] [Comment Edited] (PDFBOX-2469) javax.crypto.BadPaddingException in PDFBox 1.8.8-SNAPSHOT

2014-11-05 Thread JIRA

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

Andreas Lehmkühler edited comment on PDFBOX-2469 at 11/5/14 6:58 PM:
-

My patch works for the non sequential parser only


was (Author: lehmi):
My patch seems to work for the non sequential parser only

> 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)


[jira] [Comment Edited] (PDFBOX-2469) javax.crypto.BadPaddingException in PDFBox 1.8.8-SNAPSHOT

2014-10-31 Thread Tim Allison (JIRA)

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

Tim Allison edited comment on PDFBOX-2469 at 10/31/14 11:49 AM:


I'm actually now getting the same exception back through pdfbox app 1.6. PDFBox 
used to be able to handle this file...  Must be a change in java updates?

With:
java version "1.7.0_40"
Java(TM) SE Runtime Environment (build 1.7.0_40-b43)
Java HotSpot(TM) 64-Bit Server VM (build 24.0-b56, mixed mode)

The exception is this:

{noformat}
WARNING: PDF file 'testPDF_acroForm.pdf' does not allow extracting content.
ExtractText failed with the following exception:
java.io.IOException: You do not have permission to extract text
at org.apache.pdfbox.ExtractText.startExtraction(ExtractText.java:223)
at org.apache.pdfbox.ExtractText.main(ExtractText.java:85)
at org.apache.pdfbox.PDFBox.main(PDFBox.java:58)

{noformat}


was (Author: talli...@mitre.org):
I'm actually now getting the same exception back through pdfbox app 1.6. PDFBox 
used to be able to handle this file...  Must be a change in java updates?

> 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
>Reporter: Tim Allison
>Priority: Minor
> 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)