Support rotation of master key.
The EncryptionService now loads a set of keys and uses the active one to encrypt and selects key based on keyid during decryption. Introduced EncryptedValue to hold keyId and encrypted data. (There are no intermeddiate keys yet)
This commit is contained in:
parent
4201d0240d
commit
644b005f2a
19 changed files with 259 additions and 72 deletions
|
|
@ -8,11 +8,11 @@ public static class EncryptionServiceSubstitute
|
|||
{
|
||||
var encryptionService = Substitute.For<IEncryptionService>();
|
||||
encryptionService
|
||||
.Encrypt(Arg.Any<byte[]>())
|
||||
.Returns(x => x.ArgAt<byte[]>(0));
|
||||
.Encrypt(Arg.Any<ReadOnlyMemory<byte>>())
|
||||
.Returns(x => new EncryptedValue("kid", x.ArgAt<ReadOnlyMemory<byte>>(0).ToArray()));
|
||||
encryptionService
|
||||
.Decrypt(Arg.Any<ReadOnlyMemory<byte>>())
|
||||
.Returns(x => x.ArgAt<ReadOnlyMemory<byte>>(0).ToArray());
|
||||
.Decrypt(Arg.Any<EncryptedValue>())
|
||||
.Returns(x => x.ArgAt<EncryptedValue>(0).Value);
|
||||
return encryptionService;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue