mirror of
https://github.com/bitwarden/android.git
synced 2024-12-24 18:08:26 +03:00
RSA/ECB/OAEPWithSHA-1AndMGF1Padding
This commit is contained in:
parent
1503124108
commit
724ae51110
1 changed files with 2 additions and 6 deletions
|
@ -32,7 +32,7 @@ namespace Bit.Android.Services
|
||||||
public KeyStoreBackedStorageService(ISettings settings)
|
public KeyStoreBackedStorageService(ISettings settings)
|
||||||
{
|
{
|
||||||
_oldAndroid = Build.VERSION.SdkInt < BuildVersionCodes.M;
|
_oldAndroid = Build.VERSION.SdkInt < BuildVersionCodes.M;
|
||||||
_rsaMode = _oldAndroid ? "RSA/ECB/PKCS1Padding" : "RSA/ECB/OAEPPadding";
|
_rsaMode = _oldAndroid ? "RSA/ECB/PKCS1Padding" : "RSA/ECB/OAEPWithSHA-1AndMGF1Padding";
|
||||||
|
|
||||||
_oldKeyStorageService = new KeyStoreStorageService(new char[] { });
|
_oldKeyStorageService = new KeyStoreStorageService(new char[] { });
|
||||||
_settings = settings;
|
_settings = settings;
|
||||||
|
@ -146,10 +146,6 @@ namespace Bit.Android.Services
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var spec = new KeyGenParameterSpec.Builder(KeyAlias, KeyStorePurpose.Decrypt | KeyStorePurpose.Encrypt)
|
var spec = new KeyGenParameterSpec.Builder(KeyAlias, KeyStorePurpose.Decrypt | KeyStorePurpose.Encrypt)
|
||||||
.SetCertificateSubject(subject)
|
|
||||||
.SetCertificateSerialNumber(BigInteger.Ten)
|
|
||||||
.SetKeyValidityStart(start.Time)
|
|
||||||
.SetKeyValidityEnd(end.Time)
|
|
||||||
.SetDigests(KeyProperties.DigestSha1)
|
.SetDigests(KeyProperties.DigestSha1)
|
||||||
.SetEncryptionPaddings(KeyProperties.EncryptionPaddingRsaOaep)
|
.SetEncryptionPaddings(KeyProperties.EncryptionPaddingRsaOaep)
|
||||||
.Build();
|
.Build();
|
||||||
|
@ -216,7 +212,7 @@ namespace Bit.Android.Services
|
||||||
private byte[] RsaDecrypt(byte[] encData)
|
private byte[] RsaDecrypt(byte[] encData)
|
||||||
{
|
{
|
||||||
using(var entry = GetRsaKeyEntry())
|
using(var entry = GetRsaKeyEntry())
|
||||||
using(var cipher = Cipher.GetInstance(_rsaMode, "AndroidKeyStoreBCWorkaround"))
|
using(var cipher = Cipher.GetInstance(_rsaMode))
|
||||||
{
|
{
|
||||||
cipher.Init(CipherMode.DecryptMode, entry.PrivateKey, OAEPParameterSpec.Default);
|
cipher.Init(CipherMode.DecryptMode, entry.PrivateKey, OAEPParameterSpec.Default);
|
||||||
var plainText = cipher.DoFinal(encData);
|
var plainText = cipher.DoFinal(encData);
|
||||||
|
|
Loading…
Reference in a new issue