From 82d3b34bd41d0d5d67fbdf6d2658b620c45d77ec Mon Sep 17 00:00:00 2001 From: TonyTandAndroid Date: Sun, 20 Jan 2019 11:37:54 -0500 Subject: [PATCH] remove entryInstanceOf check to fix https://github.com/iamMehedi/Secured-Preference-Store/issues/39 --- .../online/securedpreferencestore/EncryptionManager.java | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/securedpreferencestore/src/main/java/devliving/online/securedpreferencestore/EncryptionManager.java b/securedpreferencestore/src/main/java/devliving/online/securedpreferencestore/EncryptionManager.java index 0d48b5b..a744498 100644 --- a/securedpreferencestore/src/main/java/devliving/online/securedpreferencestore/EncryptionManager.java +++ b/securedpreferencestore/src/main/java/devliving/online/securedpreferencestore/EncryptionManager.java @@ -8,14 +8,12 @@ import android.security.keystore.KeyGenParameterSpec; import android.security.keystore.KeyProperties; import android.support.annotation.Nullable; -import android.support.annotation.RequiresApi; import android.util.Base64; import java.io.BufferedInputStream; import java.io.BufferedOutputStream; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; -import java.io.FileInputStream; import java.io.IOException; import java.io.UnsupportedEncodingException; import java.math.BigInteger; @@ -687,10 +685,7 @@ byte[] decryptAESCompat(EncryptedData encryptedData) throws UnsupportedEncodingE void loadKey(SharedPreferences prefStore) throws KeyStoreException, UnrecoverableEntryException, NoSuchAlgorithmException, NoSuchPaddingException, NoSuchProviderException, InvalidKeyException, IOException { if (!isCompatMode) { - if (mStore.containsAlias(AES_KEY_ALIAS) && mStore.entryInstanceOf(AES_KEY_ALIAS, KeyStore.SecretKeyEntry.class)) { - KeyStore.SecretKeyEntry entry = (KeyStore.SecretKeyEntry) mStore.getEntry(AES_KEY_ALIAS, null); - aesKey = entry.getSecretKey(); - } + aesKey = (SecretKey) mStore.getKey(AES_KEY_ALIAS, null); } else { aesKey = getFallbackAESKey(prefStore); macKey = getMacKey(prefStore);