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

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

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 1.8.10, 1.8.11, 2.0.0
    • Fix Version/s: 1.8.11, 2.0.0
    • Component/s: Crypto, Preflight
    • Labels:
    • Environment:
      java version "1.8.0_25"
      Java(TM) SE Runtime Environment (build 1.8.0_25-b17)
      Java HotSpot(TM) 64-Bit Server VM (build 25.25-b02, mixed mode)

      Description

      I get the following stack trace when trying to parse certain pdfs:

      org.apache.pdfbox.preflight.exception.SyntaxValidationException
              at org.apache.pdfbox.preflight.parser.PreflightParser.parse(PreflightParser.java:203)
              at org.apache.pdfbox.preflight.parser.PreflightParser.parse(PreflightParser.java:180)
              at org.apache.pdfbox.preflight.parser.PreflightParser.parse(PreflightParser.java:168)
              at PDFBoxTest.main(hello.java:11)
      Caused by: org.apache.pdfbox.exceptions.WrappedIOException
              at org.apache.pdfbox.pdmodel.encryption.SecurityHandler.encryptData(SecurityHandler.java:376)
              at org.apache.pdfbox.pdmodel.encryption.SecurityHandler.decryptString(SecurityHandler.java:578)
              at org.apache.pdfbox.pdfparser.NonSequentialPDFParser.decryptString(NonSequentialPDFParser.java:1571)
              at org.apache.pdfbox.pdfparser.NonSequentialPDFParser.decryptDictionary(NonSequentialPDFParser.java:1535)
              at org.apache.pdfbox.pdfparser.NonSequentialPDFParser.decrypt(NonSequentialPDFParser.java:1596)
              at org.apache.pdfbox.preflight.parser.PreflightParser.parseObjectDynamically(PreflightParser.java:797)
              at org.apache.pdfbox.pdfparser.NonSequentialPDFParser.parseObjectDynamically(NonSequentialPDFParser.java:1343)
              at org.apache.pdfbox.preflight.parser.PreflightParser.initialParse(PreflightParser.java:273)
              at org.apache.pdfbox.pdfparser.NonSequentialPDFParser.parse(NonSequentialPDFParser.java:886)
              at org.apache.pdfbox.preflight.parser.PreflightParser.parse(PreflightParser.java:198)
              ... 3 more
      Caused by: javax.crypto.BadPaddingException: Given final block not properly padded
              at com.sun.crypto.provider.CipherCore.doFinal(CipherCore.java:966)
              at com.sun.crypto.provider.CipherCore.doFinal(CipherCore.java:824)
              at com.sun.crypto.provider.AESCipher.engineDoFinal(AESCipher.java:436)
              at javax.crypto.Cipher.doFinal(Cipher.java:2004)
              at org.apache.pdfbox.pdmodel.encryption.SecurityHandler.encryptData(SecurityHandler.java:352)
              ... 12 more
      

      The parsing code looks something like:

      FileDataSource fd = new FileDataSource("i-129.pdf");
      PreflightParser parser = new PreflightParser(fd);
      parser.parse();
      

        Attachments

        1. i-129.pdf
          1.79 MB
          Daniel Woelfel

          Activity

            People

            • Assignee:
              tilman Tilman Hausherr
              Reporter:
              dwwoelfel Daniel Woelfel
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: