diff options
-rw-r--r-- | luni/src/main/java/javax/crypto/Cipher.java | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/luni/src/main/java/javax/crypto/Cipher.java b/luni/src/main/java/javax/crypto/Cipher.java index 9bca45e..2e3b341 100644 --- a/luni/src/main/java/javax/crypto/Cipher.java +++ b/luni/src/main/java/javax/crypto/Cipher.java @@ -139,6 +139,11 @@ public class Cipher { private CipherSpi spiImpl; /** + * The SPI implementation. + */ + private final CipherSpi specifiedSpi; + + /** * The transformation. */ private final String transformation; @@ -176,7 +181,7 @@ public class Cipher { throw new NullPointerException("provider == null"); } this.specifiedProvider = provider; - this.spiImpl = cipherSpi; + this.specifiedSpi = cipherSpi; this.transformation = transformation; this.transformParts = null; } @@ -185,6 +190,7 @@ public class Cipher { this.transformation = transformation; this.transformParts = transformParts; this.specifiedProvider = provider; + this.specifiedSpi = null; } @@ -336,6 +342,10 @@ public class Cipher { * Makes sure a CipherSpi that matches this type is selected. */ private CipherSpi getSpi(Key key) { + if (specifiedSpi != null) { + return specifiedSpi; + } + synchronized (initLock) { if (spiImpl != null && key == null) { return spiImpl; |