summaryrefslogtreecommitdiffstats
path: root/luni/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'luni/src/main/java')
-rw-r--r--luni/src/main/java/java/security/Signature.java9
-rw-r--r--luni/src/main/java/javax/crypto/Cipher.java14
2 files changed, 16 insertions, 7 deletions
diff --git a/luni/src/main/java/java/security/Signature.java b/luni/src/main/java/java/security/Signature.java
index 8c056c0..e70898b 100644
--- a/luni/src/main/java/java/security/Signature.java
+++ b/luni/src/main/java/java/security/Signature.java
@@ -637,11 +637,14 @@ public abstract class Signature extends SignatureSpi {
*/
private final Object initLock = new Object();
+ // The provider specified when creating this instance.
+ private final Provider specifiedProvider;
+
private SignatureSpi spiImpl;
public SignatureImpl(String algorithm, Provider provider) {
super(algorithm);
- super.provider = provider;
+ this.specifiedProvider = provider;
}
private SignatureImpl(String algorithm, Provider provider, SignatureSpi spi) {
@@ -715,11 +718,11 @@ public abstract class Signature extends SignatureSpi {
*/
private SignatureSpi getSpi(Key key) {
synchronized (initLock) {
- if (spiImpl != null) {
+ if (spiImpl != null && key == null) {
return spiImpl;
}
- final Engine.SpiAndProvider sap = tryAlgorithm(key, provider, algorithm);
+ final Engine.SpiAndProvider sap = tryAlgorithm(key, specifiedProvider, algorithm);
if (sap == null) {
throw new ProviderException("No provider for " + getAlgorithm());
}
diff --git a/luni/src/main/java/javax/crypto/Cipher.java b/luni/src/main/java/javax/crypto/Cipher.java
index 2c1feeb..9bca45e 100644
--- a/luni/src/main/java/javax/crypto/Cipher.java
+++ b/luni/src/main/java/javax/crypto/Cipher.java
@@ -129,6 +129,11 @@ public class Cipher {
private Provider provider;
/**
+ * The provider specified when instance created.
+ */
+ private final Provider specifiedProvider;
+
+ /**
* The SPI implementation.
*/
private CipherSpi spiImpl;
@@ -170,7 +175,7 @@ public class Cipher {
if (!(cipherSpi instanceof NullCipherSpi) && provider == null) {
throw new NullPointerException("provider == null");
}
- this.provider = provider;
+ this.specifiedProvider = provider;
this.spiImpl = cipherSpi;
this.transformation = transformation;
this.transformParts = null;
@@ -179,7 +184,7 @@ public class Cipher {
private Cipher(String transformation, String[] transformParts, Provider provider) {
this.transformation = transformation;
this.transformParts = transformParts;
- this.provider = provider;
+ this.specifiedProvider = provider;
}
@@ -332,11 +337,12 @@ public class Cipher {
*/
private CipherSpi getSpi(Key key) {
synchronized (initLock) {
- if (spiImpl != null) {
+ if (spiImpl != null && key == null) {
return spiImpl;
}
- final Engine.SpiAndProvider sap = tryCombinations(key, provider, transformParts);
+ final Engine.SpiAndProvider sap = tryCombinations(key, specifiedProvider,
+ transformParts);
if (sap == null) {
throw new ProviderException("No provider for " + transformation);
}