Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6996801

java.security.InvalidKeyException: Illegal key size or default parameters

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Not an Issue
    • Icon: P3 P3
    • None
    • 6u22
    • security-libs

      FULL PRODUCT VERSION :
      Both JRE v1.6.0_21 and v1.6.0_22

      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows 6.0.6002

      EXTRA RELEVANT SYSTEM CONFIGURATION :
      BC 1.45 for JDK6

      A DESCRIPTION OF THE PROBLEM :
      I have a working code worked from JRE v1.4.2_05 upto JRE v1.0.6_17,
       but throwing an exception from two latest JDK6 versions which are
       1.6.0_21 and 1.6.0_22. The exception is as follows:

      java.security.InvalidKeyException: Illegal key size or default parameters
      at javax.crypto.Cipher.a(DashoA13*..)
      at javax.crypto.Cipher.init(DashoA13*..)
      at javax.crypto.Cipher.init(DashoA13*..)

      And the exception is thrown in the block of code included in the following:

      public byte[] encrypt(byte[] clearText, String algName, String providerName, Key secretkey) {
              Cipher encipher = null;
              byte[] cipherText = null;

              // algName; "AES/ECB/PKCS5Padding"
              // providerName; "BC"
              // Key secretkey; "AES", 256, "BC"
              // clearText; byte[]

              try {
                  encipher = Cipher.getInstance(algName, providerName);
                  encipher.init(Cipher.ENCRYPT_MODE, secretkey); // <== This is the line WHERE the EXCEPTION thrown.
                  cipherText = encipher.doFinal(clearText);
              } catch (Exception __ex) {
               __ex.printStackTrace();
              }
              return cipherText;
          }

      It is not certain that the issue I am experiencing is caused by JDK or BC. Is anyone experiencing this kind of case? Or, is something I am missing? Thank you.

      Best regards,


      Pae
      ###@###.###




      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Write a call to that method by providing three parameters as shown in
      the report. One of the parameter is a symmetric key.


      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      a byte array of crypted text by encrypting the given clear text.

      ACTUAL -
      interrupted which was caused by an exception.


      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      java.security.InvalidKeyException: Illegal key size or default parameters
      at javax.crypto.Cipher.a(DashoA13*..)
      at javax.crypto.Cipher.init(DashoA13*..)
      at javax.crypto.Cipher.init(DashoA13*..)



      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      You can write a simple code to test it by generatin g symmetric key. But if
      you needed one I can provide it. Please let me know.


      Pae
      ###@###.###

      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      Removed both JDK/JRE 1.6.0_21 and JDK/JRE 1.6.0_22 to go back to the
      JDK/JRE 1.6.0_17 which may require the end users to do as well.

      Release Regression From : 6u17
      The above release value was the last known release where this
      bug was not reproducible. Since then there has been a regression.

            Unassigned Unassigned
            ndcosta Nelson Dcosta (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: