Skip to content

Commit a2d2242

Browse files
committed
Fixed Android 8.0 inability to retrive secretKey from the keystore
1 parent d41e4ae commit a2d2242

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

android/src/main/java/br/com/classapp/RNSensitiveInfo/RNSensitiveInfoModule.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ private void initKeyStore() {
261261
try {
262262
if (!mKeyStore.containsAlias(KEY_ALIAS)) {
263263
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
264-
KeyGenerator keyGenerator = KeyGenerator.getInstance(KeyProperties.KEY_ALGORITHM_RSA, ANDROID_KEYSTORE_PROVIDER);
264+
KeyGenerator keyGenerator = KeyGenerator.getInstance(KeyProperties.KEY_ALGORITHM_AES, ANDROID_KEYSTORE_PROVIDER);
265265
keyGenerator.init(
266266
new KeyGenParameterSpec.Builder(KEY_ALIAS,
267267
KeyProperties.PURPOSE_ENCRYPT | KeyProperties.PURPOSE_DECRYPT)
@@ -544,8 +544,8 @@ public void onAuthenticationSucceeded(FingerprintManager.AuthenticationResult re
544544

545545
public String encrypt(String input) throws Exception {
546546
byte[] bytes = input.getBytes();
547-
548547
Cipher c;
548+
549549
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
550550
Key secretKey = ((KeyStore.SecretKeyEntry) mKeyStore.getEntry(KEY_ALIAS, null)).getSecretKey();
551551
c = Cipher.getInstance(AES_GCM);

0 commit comments

Comments
 (0)