diff options
author | Kenny Root <kroot@google.com> | 2014-02-12 13:20:41 -0800 |
---|---|---|
committer | Kenny Root <kroot@android.com> | 2014-02-13 01:02:25 +0000 |
commit | 16ec6489f8339c55fb65db423c4a997a9f91d089 (patch) | |
tree | ccaf9f831f637643ad1ca2d69680448481d7a361 /luni | |
parent | da4b7effaad7a9cdc2bcb9b25b63b338308ae2d6 (diff) | |
download | libcore-16ec6489f8339c55fb65db423c4a997a9f91d089.zip libcore-16ec6489f8339c55fb65db423c4a997a9f91d089.tar.gz libcore-16ec6489f8339c55fb65db423c4a997a9f91d089.tar.bz2 |
Late binding: support NullCipher
NullCipher is a special case that needs to never reset its spiImpl
Bug: 12971024
Change-Id: I0e1e4a6525808959e068810c3a8c239baacf8a95
Diffstat (limited to 'luni')
-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; |