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

Cipher getParameters() throws RuntimeException: Cannot find SunJCE provider

    Details

    • Subcomponent:
    • Resolved In Build:
      b87
    • CPU:
      x86
    • OS:
      linux
    • Verification:
      Verified

      Backports

        Description

        When we remove the SunJCE provider first, then create the Cipher object via a stand-alone SunJCE provider "new com.sun.crypto.provider.SunJCE()", then the method getParameters() will fail and throw the RuntimeException: Cannot find SunJCE provider. This is not acceptable. Should make this work with stand-alone provider as well.

        The underlying cause is, inside the getParameters() method, it uses "getInstance(xxxx, SunJCE)" even when there is no static installed SunJCE in the system.

        example:
                    /*
                      * Bob encrypts, using DES in CBC mode
                      */
                     ...........
                     ///// remove the static installed SunJCE provider
                     Security.removeProvider("SunJCE");

                     ///// create the Cipher object via a stand-alone SunJCE provider
                     bobCipher = Cipher.getInstance("DES/CBC/PKCS5Padding", new com.sun.crypto.provider.SunJCE());
                     bobCipher.init(Cipher.ENCRYPT_MODE, bobDesKey);

                     cleartext = "This is just an example".getBytes();
                     ciphertext = bobCipher.doFinal(cleartext);

                     // Retrieve the parameter that was used, and transfer it to Alice in encoded format
                     byte[] encodedParams = bobCipher.getParameters().getEncoded(); ////// This line causes the RuntimeException

                     /*
                      * Alice decrypts, using DES in CBC mode
                      */
                     // Instantiate AlgorithmParameters object from parameter encoding
                     // obtained from Bob
                     AlgorithmParameters params = AlgorithmParameters.getInstance("DES", new com.sun.crypto.provider.SunJCE());
                     params.init(encodedParams);
                     .............

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  ascarpino Anthony Scarpino
                  Reporter:
                  yulixu Vivian Xu (Inactive)
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  5 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved:
                    Imported:
                    Indexed: