From 55db8234200c2f91667acce1445597d7c9adce27 Mon Sep 17 00:00:00 2001 From: Corewala Date: Tue, 17 May 2022 13:25:49 -0400 Subject: [PATCH] Removed unnecessary values in BiometricManager --- .../buran/io/keymanager/BuranBiometricManager.kt | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/corewala/buran/io/keymanager/BuranBiometricManager.kt b/app/src/main/java/corewala/buran/io/keymanager/BuranBiometricManager.kt index 414f523..0b8e0b5 100644 --- a/app/src/main/java/corewala/buran/io/keymanager/BuranBiometricManager.kt +++ b/app/src/main/java/corewala/buran/io/keymanager/BuranBiometricManager.kt @@ -1,5 +1,6 @@ package corewala.buran.io.keymanager +import android.app.Activity import android.content.Context import android.os.Build import android.security.keystore.KeyGenParameterSpec @@ -8,6 +9,7 @@ import androidx.annotation.RequiresApi import androidx.biometric.BiometricPrompt import androidx.core.content.ContextCompat import androidx.fragment.app.Fragment +import androidx.fragment.app.FragmentActivity import corewala.buran.Buran import corewala.buran.R import java.nio.charset.Charset @@ -25,10 +27,6 @@ class BuranBiometricManager { private lateinit var biometricPrompt: BiometricPrompt private lateinit var promptInfo: BiometricPrompt.PromptInfo - private val ENCRYPTION_BLOCK_MODE = KeyProperties.BLOCK_MODE_GCM - private val ENCRYPTION_PADDING = KeyProperties.ENCRYPTION_PADDING_NONE - private val ENCRYPTION_ALGORITHM = KeyProperties.KEY_ALGORITHM_AES - fun createBiometricPrompt(context: Context, fragment: Fragment, callback: BiometricPrompt.AuthenticationCallback){ val executor = ContextCompat.getMainExecutor(context) biometricPrompt = BiometricPrompt(fragment, executor, callback) @@ -76,7 +74,7 @@ class BuranBiometricManager { } private fun getCipher(): Cipher { - val transformation = "$ENCRYPTION_ALGORITHM/$ENCRYPTION_BLOCK_MODE/$ENCRYPTION_PADDING" + val transformation = "${KeyProperties.KEY_ALGORITHM_AES}/${KeyProperties.BLOCK_MODE_GCM}/${KeyProperties.ENCRYPTION_PADDING_NONE}" return Cipher.getInstance(transformation) } @@ -90,8 +88,8 @@ class BuranBiometricManager { keyName, KeyProperties.PURPOSE_ENCRYPT or KeyProperties.PURPOSE_DECRYPT ).apply { - setBlockModes(ENCRYPTION_BLOCK_MODE) - setEncryptionPaddings(ENCRYPTION_PADDING) + setBlockModes(KeyProperties.BLOCK_MODE_GCM) + setEncryptionPaddings(KeyProperties.ENCRYPTION_PADDING_NONE) setKeySize(256) setUserAuthenticationRequired(true) }.build()