mirror of
https://github.com/bitwarden/mobile
synced 2025-12-21 02:33:36 +00:00
catch when key is null
This commit is contained in:
@@ -5,6 +5,7 @@ using Bit.App.Abstractions;
|
|||||||
using Bit.App.Models;
|
using Bit.App.Models;
|
||||||
using PCLCrypto;
|
using PCLCrypto;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using Xamarin.Forms;
|
||||||
|
|
||||||
namespace Bit.App.Services
|
namespace Bit.App.Services
|
||||||
{
|
{
|
||||||
@@ -129,18 +130,19 @@ namespace Bit.App.Services
|
|||||||
|
|
||||||
public string Decrypt(CipherString encyptedValue)
|
public string Decrypt(CipherString encyptedValue)
|
||||||
{
|
{
|
||||||
if(Key == null)
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException(nameof(Key));
|
|
||||||
}
|
|
||||||
|
|
||||||
if(encyptedValue == null)
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException(nameof(encyptedValue));
|
|
||||||
}
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
if(Key == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(Key));
|
||||||
|
}
|
||||||
|
|
||||||
|
if(encyptedValue == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(encyptedValue));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
var provider = WinRTCrypto.SymmetricKeyAlgorithmProvider.OpenAlgorithm(SymmetricAlgorithm.AesCbcPkcs7);
|
var provider = WinRTCrypto.SymmetricKeyAlgorithmProvider.OpenAlgorithm(SymmetricAlgorithm.AesCbcPkcs7);
|
||||||
var cryptoKey = provider.CreateSymmetricKey(Key);
|
var cryptoKey = provider.CreateSymmetricKey(Key);
|
||||||
var decryptedBytes = WinRTCrypto.CryptographicEngine.Decrypt(cryptoKey, encyptedValue.CipherTextBytes,
|
var decryptedBytes = WinRTCrypto.CryptographicEngine.Decrypt(cryptoKey, encyptedValue.CipherTextBytes,
|
||||||
|
|||||||
Reference in New Issue
Block a user