mirror of
https://github.com/bitwarden/android.git
synced 2024-12-24 01:48:25 +03:00
fix issue with biometric validation (#1081)
* fix issue with biometric validation * null check key & cipher
This commit is contained in:
parent
d33e38012a
commit
0388738e02
1 changed files with 22 additions and 9 deletions
|
@ -51,6 +51,11 @@ namespace Bit.Droid.Services
|
|||
IKey key = _keystore.GetKey(KeyName, null);
|
||||
Cipher cipher = Cipher.GetInstance(Transformation);
|
||||
|
||||
if (key == null || cipher == null)
|
||||
{
|
||||
return Task.FromResult(true);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
cipher.Init(CipherMode.EncryptMode, key);
|
||||
|
@ -76,15 +81,23 @@ namespace Bit.Droid.Services
|
|||
|
||||
private void CreateKey()
|
||||
{
|
||||
KeyGenerator keyGen = KeyGenerator.GetInstance(KeyAlgorithm, KeyStoreName);
|
||||
KeyGenParameterSpec keyGenSpec =
|
||||
new KeyGenParameterSpec.Builder(KeyName, KeyStorePurpose.Encrypt | KeyStorePurpose.Decrypt)
|
||||
.SetBlockModes(BlockMode)
|
||||
.SetEncryptionPaddings(EncryptionPadding)
|
||||
.SetUserAuthenticationRequired(true)
|
||||
.Build();
|
||||
keyGen.Init(keyGenSpec);
|
||||
keyGen.GenerateKey();
|
||||
try
|
||||
{
|
||||
var keyGen = KeyGenerator.GetInstance(KeyAlgorithm, KeyStoreName);
|
||||
var keyGenSpec =
|
||||
new KeyGenParameterSpec.Builder(KeyName, KeyStorePurpose.Encrypt | KeyStorePurpose.Decrypt)
|
||||
.SetBlockModes(BlockMode)
|
||||
.SetEncryptionPaddings(EncryptionPadding)
|
||||
.SetUserAuthenticationRequired(true)
|
||||
.Build();
|
||||
keyGen.Init(keyGenSpec);
|
||||
keyGen.GenerateKey();
|
||||
}
|
||||
catch
|
||||
{
|
||||
// Catch silently to allow biometrics to function on devices that are in a state where key generation
|
||||
// is not functioning
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue