Merge "Switch from getSpi to getCurrentSpi."

This commit is contained in:
Alex Klyubin
2015-05-18 19:08:32 +00:00
committed by Gerrit Code Review

View File

@@ -110,6 +110,7 @@ public class AndroidKeyStoreProvider extends Provider {
*
* @throws IllegalArgumentException if the provided primitive is not supported or is not backed
* by AndroidKeyStore provider.
* @throws IllegalStateException if the provided primitive is not initialized.
*/
public static Long getKeyStoreOperationHandle(Object cryptoPrimitive) {
if (cryptoPrimitive == null) {
@@ -117,15 +118,17 @@ public class AndroidKeyStoreProvider extends Provider {
}
Object spi;
if (cryptoPrimitive instanceof Mac) {
spi = ((Mac) cryptoPrimitive).getSpi();
spi = ((Mac) cryptoPrimitive).getCurrentSpi();
} else if (cryptoPrimitive instanceof Cipher) {
spi = ((Cipher) cryptoPrimitive).getSpi();
spi = ((Cipher) cryptoPrimitive).getCurrentSpi();
} else {
throw new IllegalArgumentException("Unsupported crypto primitive: " + cryptoPrimitive);
}
if (!(spi instanceof KeyStoreCryptoOperation)) {
if (spi == null) {
throw new IllegalStateException("Crypto primitive not initialized");
} else if (!(spi instanceof KeyStoreCryptoOperation)) {
throw new IllegalArgumentException(
"Crypto primitive not backed by AndroidKeyStore: " + cryptoPrimitive
"Crypto primitive not backed by AndroidKeyStore provider: " + cryptoPrimitive
+ ", spi: " + spi);
}
return ((KeyStoreCryptoOperation) spi).getOperationHandle();