mirror of
https://github.com/bitwarden/mobile.git
synced 2024-12-27 17:08:00 +01: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
@ -51,6 +51,11 @@ namespace Bit.Droid.Services
|
|||||||
IKey key = _keystore.GetKey(KeyName, null);
|
IKey key = _keystore.GetKey(KeyName, null);
|
||||||
Cipher cipher = Cipher.GetInstance(Transformation);
|
Cipher cipher = Cipher.GetInstance(Transformation);
|
||||||
|
|
||||||
|
if (key == null || cipher == null)
|
||||||
|
{
|
||||||
|
return Task.FromResult(true);
|
||||||
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
cipher.Init(CipherMode.EncryptMode, key);
|
cipher.Init(CipherMode.EncryptMode, key);
|
||||||
@ -76,15 +81,23 @@ namespace Bit.Droid.Services
|
|||||||
|
|
||||||
private void CreateKey()
|
private void CreateKey()
|
||||||
{
|
{
|
||||||
KeyGenerator keyGen = KeyGenerator.GetInstance(KeyAlgorithm, KeyStoreName);
|
try
|
||||||
KeyGenParameterSpec keyGenSpec =
|
{
|
||||||
new KeyGenParameterSpec.Builder(KeyName, KeyStorePurpose.Encrypt | KeyStorePurpose.Decrypt)
|
var keyGen = KeyGenerator.GetInstance(KeyAlgorithm, KeyStoreName);
|
||||||
.SetBlockModes(BlockMode)
|
var keyGenSpec =
|
||||||
.SetEncryptionPaddings(EncryptionPadding)
|
new KeyGenParameterSpec.Builder(KeyName, KeyStorePurpose.Encrypt | KeyStorePurpose.Decrypt)
|
||||||
.SetUserAuthenticationRequired(true)
|
.SetBlockModes(BlockMode)
|
||||||
.Build();
|
.SetEncryptionPaddings(EncryptionPadding)
|
||||||
keyGen.Init(keyGenSpec);
|
.SetUserAuthenticationRequired(true)
|
||||||
keyGen.GenerateKey();
|
.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 New Issue
Block a user