Uploaded image for project: 'PDFBox'
  1. PDFBox
  2. PDFBOX-3756

javax.crypto.BadPaddingException: Given final block not properly padded

    Details

    • Type: Bug
    • Status: Open
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: 2.0.5
    • Fix Version/s: None
    • Component/s: Crypto
    • Labels:
    • Environment:
      java version "1.8.0_112"
      Java(TM) SE Runtime Environment (build 1.8.0_112-b15)
      Java HotSpot(TM) 64-Bit Server VM (build 25.112-b15, mixed mode)

      Description

      I get the following stack trace when running:

      java -jar pdfbox-app-2.0.5.jar PDFDebugger somefile.pdf

      File is properly opened with other viewers, I cannot publish the pdf file due to privacy restrictions.

      java.io.IOException: javax.crypto.BadPaddingException: Given final block not properly padded
      org.apache.pdfbox.pdmodel.encryption.SecurityHandler.encryptDataAESother(SecurityHandler.java:296)
      org.apache.pdfbox.pdmodel.encryption.SecurityHandler.encryptData(SecurityHandler.java:153)
      org.apache.pdfbox.pdmodel.encryption.SecurityHandler.decryptStream(SecurityHandler.java:454)
      org.apache.pdfbox.pdfparser.COSParser.parseFileObject(COSParser.java:790)
      org.apache.pdfbox.pdfparser.COSParser.parseObjectDynamically(COSParser.java:747)
      org.apache.pdfbox.pdfparser.COSParser.parseObjectDynamically(COSParser.java:678)
      org.apache.pdfbox.pdfparser.COSParser.parseDictObjects(COSParser.java:638)
      org.apache.pdfbox.pdfparser.PDFParser.initialParse(PDFParser.java:236)
      org.apache.pdfbox.pdfparser.PDFParser.parse(PDFParser.java:271)
      org.apache.pdfbox.pdmodel.PDDocument.load(PDDocument.java:984)
      org.apache.pdfbox.pdmodel.PDDocument.load(PDDocument.java:922)
      org.apache.pdfbox.debugger.PDFDebugger.parseDocument(PDFDebugger.java:1288)
      org.apache.pdfbox.debugger.PDFDebugger.readPDFFile(PDFDebugger.java:1209)
      org.apache.pdfbox.debugger.PDFDebugger.readPDFFile(PDFDebugger.java:1194)
      org.apache.pdfbox.debugger.PDFDebugger.main(PDFDebugger.java:1185)
      org.apache.pdfbox.tools.PDFBox.main(PDFBox.java:76)
      Caused by: javax.crypto.BadPaddingException: Given final block not properly padded
      com.sun.crypto.provider.CipherCore.doFinal(CipherCore.java:989)
      com.sun.crypto.provider.CipherCore.doFinal(CipherCore.java:845)
      com.sun.crypto.provider.AESCipher.engineDoFinal(AESCipher.java:446)
      javax.crypto.Cipher.doFinal(Cipher.java:2048)
      org.apache.pdfbox.pdmodel.encryption.SecurityHandler.encryptDataAESother(SecurityHandler.java:276)
      org.apache.pdfbox.pdmodel.encryption.SecurityHandler.encryptData(SecurityHandler.java:153)
      org.apache.pdfbox.pdmodel.encryption.SecurityHandler.decryptStream(SecurityHandler.java:454)
      org.apache.pdfbox.pdfparser.COSParser.parseFileObject(COSParser.java:790)
      org.apache.pdfbox.pdfparser.COSParser.parseObjectDynamically(COSParser.java:747)
      org.apache.pdfbox.pdfparser.COSParser.parseObjectDynamically(COSParser.java:678)
      org.apache.pdfbox.pdfparser.COSParser.parseDictObjects(COSParser.java:638)
      org.apache.pdfbox.pdfparser.PDFParser.initialParse(PDFParser.java:236)
      org.apache.pdfbox.pdfparser.PDFParser.parse(PDFParser.java:271)
      org.apache.pdfbox.pdmodel.PDDocument.load(PDDocument.java:984)
      org.apache.pdfbox.pdmodel.PDDocument.load(PDDocument.java:922)
      org.apache.pdfbox.debugger.PDFDebugger.parseDocument(PDFDebugger.java:1288)
      org.apache.pdfbox.debugger.PDFDebugger.readPDFFile(PDFDebugger.java:1209)
      org.apache.pdfbox.debugger.PDFDebugger.readPDFFile(PDFDebugger.java:1194)
      org.apache.pdfbox.debugger.PDFDebugger.main(PDFDebugger.java:1185)
      org.apache.pdfbox.tools.PDFBox.main(PDFBox.java:76)

        Attachments

        1. pdfdebugger.png
          59 kB
          Esteban Nicolas Ruiz

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              eruiz0 Esteban Nicolas Ruiz
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated: