summaryrefslogtreecommitdiffstats
path: root/luni/src/main
diff options
context:
space:
mode:
authorKenny Root <kroot@google.com>2014-02-06 19:07:52 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2014-02-06 19:07:53 +0000
commit19a25cc3cc407aa4a8bb770d4034cde2846fe50f (patch)
tree80670ac2fa24a82a639265fb095deef23eeb3425 /luni/src/main
parentb5e85ee90a28188c97ea34a8843cdf50ebe8809d (diff)
parentbeff0f1375b635c692d48190aa69a06986b5111f (diff)
downloadlibcore-19a25cc3cc407aa4a8bb770d4034cde2846fe50f.zip
libcore-19a25cc3cc407aa4a8bb770d4034cde2846fe50f.tar.gz
libcore-19a25cc3cc407aa4a8bb770d4034cde2846fe50f.tar.bz2
Merge "Late binding: reinitializing causes selection"
Diffstat (limited to 'luni/src/main')
-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);
}