Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,9 @@ class DatabaseSecurityManager(private val context: Context) {
setEncryptionPaddings(KeyProperties.ENCRYPTION_PADDING_NONE)
setKeySize(256)
setUserAuthenticationRequired(false)
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.P) {
setUnlockedDeviceRequired(true)
}
}.build()

keyGenerator.init(keyGenParameterSpec)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ class PrivacyDataFragment : PreferenceFragmentCompat() {
} catch (_: KeyPermanentlyInvalidatedException) {
regenerateKeyAndCreateCryptoObject()
} catch (_: Exception) {
null
regenerateKeyAndCreateCryptoObject()
}

private fun regenerateKeyAndCreateCryptoObject(): BiometricPrompt.CryptoObject? = try {
Expand All @@ -369,8 +369,8 @@ class PrivacyDataFragment : PreferenceFragmentCompat() {
BIOMETRIC_KEY_ALIAS,
KeyProperties.PURPOSE_ENCRYPT
)
.setBlockModes(KeyProperties.BLOCK_MODE_CBC)
.setEncryptionPaddings(KeyProperties.ENCRYPTION_PADDING_PKCS7)
.setBlockModes(KeyProperties.BLOCK_MODE_GCM)
.setEncryptionPaddings(KeyProperties.ENCRYPTION_PADDING_NONE)
.setUserAuthenticationRequired(true)
.setInvalidatedByBiometricEnrollment(true)
.build()
Expand All @@ -388,7 +388,7 @@ class PrivacyDataFragment : PreferenceFragmentCompat() {

companion object {
private const val BIOMETRIC_KEY_ALIAS = "urik_learned_words_biometric_key"
private const val CIPHER_TRANSFORMATION = "AES/CBC/PKCS7Padding"
private const val CIPHER_TRANSFORMATION = "AES/GCM/NoPadding"
private val BIOMETRIC_CHALLENGE = byteArrayOf(0)
}
}