refactor(IRSAEncryptor): umbenannt in IAsymmetricPublicKey

This commit is contained in:
Developer 02 2025-01-07 11:33:53 +01:00
parent 4ce738957d
commit 9aafc9e467
6 changed files with 11 additions and 11 deletions

View File

@ -6,6 +6,6 @@
IAsymmetricPrivateKey VaultPrivateKey { get; } IAsymmetricPrivateKey VaultPrivateKey { get; }
IEnumerable<IRSAEncryptor> Encryptors { get; } IEnumerable<IAsymmetricPublicKey> PublicKeys { get; }
} }
} }

View File

@ -6,7 +6,7 @@ namespace DigitalData.Core.Abstractions.Security
{ {
public bool IsEncrypted { get; init; } public bool IsEncrypted { get; init; }
IRSAEncryptor Encryptor { get; } IAsymmetricPublicKey PublicKey { get; }
byte[] Decrypt(byte[] data); byte[] Decrypt(byte[] data);

View File

@ -1,6 +1,6 @@
namespace DigitalData.Core.Abstractions.Security namespace DigitalData.Core.Abstractions.Security
{ {
public interface IRSAEncryptor : IAsymmetricKey public interface IAsymmetricPublicKey : IAsymmetricKey
{ {
public byte[] Encrypt(byte[] data); public byte[] Encrypt(byte[] data);

View File

@ -15,9 +15,9 @@ namespace DigitalData.Core.Security
/// </summary> /// </summary>
public IAsymmetricPrivateKey VaultPrivateKey { get; } public IAsymmetricPrivateKey VaultPrivateKey { get; }
private readonly Lazy<IEnumerable<IRSAEncryptor>> _lazyEncryptors; private readonly Lazy<IEnumerable<IAsymmetricPublicKey>> _lazyPublicKeys;
public IEnumerable<IRSAEncryptor> Encryptors => _lazyEncryptors.Value; public IEnumerable<IAsymmetricPublicKey> PublicKeys => _lazyPublicKeys.Value;
public IEnumerable<TokenDescription> TokenDescriptions { get; init; } = new List<TokenDescription>(); public IEnumerable<TokenDescription> TokenDescriptions { get; init; } = new List<TokenDescription>();
@ -34,9 +34,9 @@ namespace DigitalData.Core.Security
PrivateKeys = _params.PrivateKeys; PrivateKeys = _params.PrivateKeys;
VaultPrivateKey = _params.Vault ?? PrivateKeys.First(); VaultPrivateKey = _params.VaultPrivateKey ?? PrivateKeys.First();
_lazyEncryptors = new(PrivateKeys.Select(decryptor => decryptor.Encryptor)); _lazyPublicKeys = new(PrivateKeys.Select(decryptor => decryptor.PublicKey));
} }
} }
} }

View File

@ -2,7 +2,7 @@
namespace DigitalData.Core.Security.Cryptographer namespace DigitalData.Core.Security.Cryptographer
{ {
public class RSAEncryptor : RSAKeyBase, IRSAEncryptor, IAsymmetricKey public class RSAEncryptor : RSAKeyBase, IAsymmetricPublicKey, IAsymmetricKey
{ {
public override string Pem public override string Pem
{ {

View File

@ -24,13 +24,13 @@ namespace DigitalData.Core.Security.Cryptographer
public bool IsEncrypted { get; init; } public bool IsEncrypted { get; init; }
private readonly Lazy<IRSAEncryptor> _lazyEncryptor; private readonly Lazy<IAsymmetricPublicKey> _lazyPublicKey;
public IRSAEncryptor Encryptor => _lazyEncryptor.Value; public IAsymmetricPublicKey PublicKey => _lazyPublicKey.Value;
public RSAPrivateKey() public RSAPrivateKey()
{ {
_lazyEncryptor = new(() => new RSAEncryptor() _lazyPublicKey = new(() => new RSAEncryptor()
{ {
Pem = RSA.ExportRSAPublicKeyPem(), Pem = RSA.ExportRSAPublicKeyPem(),
Padding = Padding Padding = Padding