Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
1.8.13
-
Java 1.8. Pdfbox 1.8.13 Windows and Linux
-
Important
Description
Using the attached pdf, When running the pdf through org.apache.pdfbox.pdmodel.encryption.SecurityHandler I get
BadPaddingException.
The exception occurs when it is processing
nextObj = COSObject
I see: nextCOSBase = COSDictionary{(COSName
{Length}:COSInt
{3504}) (COSName
{Subtype}:COSName
{XML}) (COSName
{Type}:COSName
{Metadata}) }
The problem is that SecurityHandler.proceedDecryption() runs decryptObject(nextObj);
and then decrypt(base, objNum, genNum) and then decryptStream()
However for this object decryptStream doesn't actually decrypt anything because the type is xml.
So when decryptStream calls encryptData() encryptData() throws the bad packet exception.
output.write(decryptCipher.doFinal()); throws the exception because the data buffer is all zeros. It has nothing in it. I recommend that encryption be skipped if the data buffer has all zeros.