mirror of
https://github.com/bitwarden/mobile.git
synced 2024-09-10 01:08:23 +02:00
KeyGenParameterSpec options added back. cleanup.
This commit is contained in:
parent
724ae51110
commit
76652f6c6b
@ -11,7 +11,6 @@ using Android.Security.Keystore;
|
||||
using Android.App;
|
||||
using Plugin.Settings.Abstractions;
|
||||
using Java.Util;
|
||||
using Android.Content;
|
||||
using Javax.Crypto.Spec;
|
||||
|
||||
namespace Bit.Android.Services
|
||||
@ -79,12 +78,10 @@ namespace Bit.Android.Services
|
||||
{
|
||||
return App.Utilities.Crypto.AesCbcDecrypt(new App.Models.CipherString(cs), aesKey);
|
||||
}
|
||||
catch(Exception e)
|
||||
catch
|
||||
{
|
||||
Console.WriteLine("Failed to decrypt from secure storage.");
|
||||
_settings.Remove(formattedKey);
|
||||
//throw;
|
||||
SendEmail(e.Message + "\n\n" + e.StackTrace);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@ -110,11 +107,9 @@ namespace Bit.Android.Services
|
||||
var cipherString = App.Utilities.Crypto.AesCbcEncrypt(dataBytes, aesKey);
|
||||
_settings.AddOrUpdateValue(formattedKey, cipherString.EncryptedString);
|
||||
}
|
||||
catch(Exception e)
|
||||
catch
|
||||
{
|
||||
Console.WriteLine("Failed to encrypt to secure storage.");
|
||||
SendEmail(e.Message + "\n\n" + e.StackTrace);
|
||||
//throw;
|
||||
}
|
||||
}
|
||||
|
||||
@ -146,6 +141,10 @@ namespace Bit.Android.Services
|
||||
else
|
||||
{
|
||||
var spec = new KeyGenParameterSpec.Builder(KeyAlias, KeyStorePurpose.Decrypt | KeyStorePurpose.Encrypt)
|
||||
.SetCertificateSubject(subject)
|
||||
.SetCertificateSerialNumber(BigInteger.Ten)
|
||||
.SetKeyValidityStart(start.Time)
|
||||
.SetKeyValidityEnd(end.Time)
|
||||
.SetDigests(KeyProperties.DigestSha1)
|
||||
.SetEncryptionPaddings(KeyProperties.EncryptionPaddingRsaOaep)
|
||||
.Build();
|
||||
@ -187,13 +186,11 @@ namespace Bit.Android.Services
|
||||
var key = RsaDecrypt(encKeyBytes);
|
||||
return new App.Models.SymmetricCryptoKey(key);
|
||||
}
|
||||
catch(Exception e)
|
||||
catch
|
||||
{
|
||||
Console.WriteLine("Cannot get AesKey.");
|
||||
_keyStore.DeleteEntry(KeyAlias);
|
||||
_settings.Remove(AesKey);
|
||||
//throw;
|
||||
SendEmail(e.Message + "\n\n" + e.StackTrace);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@ -240,17 +237,5 @@ namespace Bit.Android.Services
|
||||
_oldKeyStorageService.Delete(key);
|
||||
}
|
||||
}
|
||||
|
||||
private void SendEmail(string text)
|
||||
{
|
||||
var emailIntent = new Intent(Intent.ActionSend);
|
||||
|
||||
emailIntent.SetType("plain/text");
|
||||
emailIntent.PutExtra(Intent.ExtraEmail, new String[] { "hello@bitwarden.com" });
|
||||
emailIntent.PutExtra(Intent.ExtraSubject, "Crash Report");
|
||||
emailIntent.PutExtra(Intent.ExtraText, text);
|
||||
|
||||
Application.Context.StartActivity(Intent.CreateChooser(emailIntent, "Send mail..."));
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user