Reworked encryption to use less heap allocated buffers for secrets.
Also some work on plugin system.
This commit is contained in:
parent
8782ef39c6
commit
054754f553
42 changed files with 1452 additions and 242 deletions
|
|
@ -25,8 +25,13 @@ public class DekEncryptionServiceTests
|
|||
|
||||
// act
|
||||
DekEncryptionService sut = new(secretProvider);
|
||||
|
||||
EncryptedDek cipher = sut.Encrypt(input.ToArray());
|
||||
byte[] result = sut.Decrypt(cipher);
|
||||
int decryptedSize = sut.GetDecryptedSize(cipher);
|
||||
Assert.Equal(input.Length, decryptedSize);
|
||||
|
||||
var result = new byte[decryptedSize];
|
||||
sut.Decrypt(cipher, result);
|
||||
|
||||
// verify
|
||||
Assert.Equal(input, result);
|
||||
|
|
@ -56,8 +61,10 @@ public class DekEncryptionServiceTests
|
|||
|
||||
// act
|
||||
DekEncryptionService sut = new(secretProvider);
|
||||
int decryptedSize = sut.GetDecryptedSize(secret);
|
||||
var result = new byte[decryptedSize];
|
||||
Assert.Throws<InvalidOperationException>(
|
||||
() => sut.Decrypt(secret),
|
||||
() => sut.Decrypt(secret, result),
|
||||
ex => ex.Message.Contains("Decryption failed") ? null : "Expected Decryption failed in message");
|
||||
}
|
||||
|
||||
|
|
@ -89,7 +96,8 @@ public class DekEncryptionServiceTests
|
|||
|
||||
// act
|
||||
DekEncryptionService sut = new(secretProvider);
|
||||
byte[] result = sut.Decrypt(secret);
|
||||
byte[] result = new byte[sut.GetDecryptedSize(secret)];
|
||||
sut.Decrypt(secret, result);
|
||||
|
||||
// verify
|
||||
Assert.Equal("Hello, World!"u8, result);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue