-
Bug
-
Resolution: Fixed
-
P4
-
7, 7u15, 8
-
b87
-
x86
-
linux
-
Verified
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8200020 | openjdk7u | Vincent Ryan | P4 | Resolved | Fixed | master |
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);
.............
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);
.............
- backported by
-
JDK-8200020 Cipher getParameters() throws RuntimeException: Cannot find SunJCE provider
-
- Resolved
-