Pass Span instead of Memory
This commit is contained in:
parent
650fe99990
commit
ccc00d8e80
10 changed files with 45 additions and 38 deletions
|
|
@ -1,21 +0,0 @@
|
|||
using IdentityShroud.Core.Contracts;
|
||||
using IdentityShroud.Core.Security;
|
||||
|
||||
namespace IdentityShroud.TestUtils.Substitutes;
|
||||
|
||||
public static class EncryptionServiceSubstitute
|
||||
{
|
||||
public static KekId KeyId { get; } = KekId.NewId();
|
||||
|
||||
public static IDekEncryptionService CreatePassthrough()
|
||||
{
|
||||
var encryptionService = Substitute.For<IDekEncryptionService>();
|
||||
encryptionService
|
||||
.Encrypt(Arg.Any<ReadOnlyMemory<byte>>())
|
||||
.Returns(x => new EncryptedDek(KeyId, x.ArgAt<ReadOnlyMemory<byte>>(0).ToArray()));
|
||||
encryptionService
|
||||
.Decrypt(Arg.Any<EncryptedDek>())
|
||||
.Returns(x => x.ArgAt<EncryptedDek>(0).Value);
|
||||
return encryptionService;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
using IdentityShroud.Core.Contracts;
|
||||
using IdentityShroud.Core.Security;
|
||||
|
||||
namespace IdentityShroud.TestUtils.Substitutes;
|
||||
|
||||
public class NullDataEncryptionService : IDataEncryptionService
|
||||
{
|
||||
public DekId KeyId { get; } = DekId.NewId();
|
||||
public EncryptedValue Encrypt(ReadOnlySpan<byte> plain)
|
||||
{
|
||||
return new(KeyId, plain.ToArray());
|
||||
}
|
||||
|
||||
public byte[] Decrypt(EncryptedValue input)
|
||||
{
|
||||
return input.Value;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
using IdentityShroud.Core.Contracts;
|
||||
using IdentityShroud.Core.Security;
|
||||
|
||||
namespace IdentityShroud.TestUtils.Substitutes;
|
||||
|
||||
public class NullDekEncryptionService : IDekEncryptionService
|
||||
{
|
||||
public KekId KeyId { get; } = KekId.NewId();
|
||||
public EncryptedDek Encrypt(ReadOnlySpan<byte> plain)
|
||||
{
|
||||
return new(KeyId, plain.ToArray());
|
||||
}
|
||||
|
||||
public byte[] Decrypt(EncryptedDek input)
|
||||
{
|
||||
return input.Value;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue