Browse Source

[EC-178] Fix RSA encrypt for newSymmetricKey, add null check (#17)

* Throw error if encKey is null

* Fix variable name
pull/19/head
Thomas Rittson 4 years ago committed by GitHub
parent
commit
7b0bbfc3aa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 8
      src/KeyConnector/Services/CryptoService.cs

8
src/KeyConnector/Services/CryptoService.cs

@ -108,7 +108,13 @@ namespace Bit.KeyConnector.Services @@ -108,7 +108,13 @@ namespace Bit.KeyConnector.Services
else
{
var newSymmetricKey = await _cryptoFunctionService.GetRandomBytesAsync(32);
var decodedEncKey = await RsaEncryptAsync(_symmetricKey);
var decodedEncKey = await RsaEncryptAsync(newSymmetricKey);
if (decodedEncKey == null)
{
throw new Exception("RSA encryption failed. Your RSA key may not be configured properly.");
}
encKey = Convert.ToBase64String(decodedEncKey);
await _applicationDataRepository.UpdateSymmetricKeyAsync(encKey);

Loading…
Cancel
Save