From 9aafc9e467ec656b23e65bb39fab5d00eb2c99d8 Mon Sep 17 00:00:00 2001 From: Developer 02 Date: Tue, 7 Jan 2025 11:33:53 +0100 Subject: [PATCH] refactor(IRSAEncryptor): umbenannt in IAsymmetricPublicKey --- .../Security/IAsymCryptHandler.cs | 2 +- .../Security/IAsymmetricPrivateKey.cs | 2 +- .../{IRSAEncryptor.cs => IAsymmetricPublicKey.cs} | 2 +- DigitalData.Core.Security/AsymCryptHandler.cs | 8 ++++---- DigitalData.Core.Security/Cryptographer/RSAEncryptor.cs | 2 +- DigitalData.Core.Security/Cryptographer/RSAPrivateKey.cs | 6 +++--- 6 files changed, 11 insertions(+), 11 deletions(-) rename DigitalData.Core.Abstractions/Security/{IRSAEncryptor.cs => IAsymmetricPublicKey.cs} (80%) diff --git a/DigitalData.Core.Abstractions/Security/IAsymCryptHandler.cs b/DigitalData.Core.Abstractions/Security/IAsymCryptHandler.cs index 20bf192..277acce 100644 --- a/DigitalData.Core.Abstractions/Security/IAsymCryptHandler.cs +++ b/DigitalData.Core.Abstractions/Security/IAsymCryptHandler.cs @@ -6,6 +6,6 @@ IAsymmetricPrivateKey VaultPrivateKey { get; } - IEnumerable Encryptors { get; } + IEnumerable PublicKeys { get; } } } \ No newline at end of file diff --git a/DigitalData.Core.Abstractions/Security/IAsymmetricPrivateKey.cs b/DigitalData.Core.Abstractions/Security/IAsymmetricPrivateKey.cs index 27364f8..22b3eed 100644 --- a/DigitalData.Core.Abstractions/Security/IAsymmetricPrivateKey.cs +++ b/DigitalData.Core.Abstractions/Security/IAsymmetricPrivateKey.cs @@ -6,7 +6,7 @@ namespace DigitalData.Core.Abstractions.Security { public bool IsEncrypted { get; init; } - IRSAEncryptor Encryptor { get; } + IAsymmetricPublicKey PublicKey { get; } byte[] Decrypt(byte[] data); diff --git a/DigitalData.Core.Abstractions/Security/IRSAEncryptor.cs b/DigitalData.Core.Abstractions/Security/IAsymmetricPublicKey.cs similarity index 80% rename from DigitalData.Core.Abstractions/Security/IRSAEncryptor.cs rename to DigitalData.Core.Abstractions/Security/IAsymmetricPublicKey.cs index 3970570..96aeda3 100644 --- a/DigitalData.Core.Abstractions/Security/IRSAEncryptor.cs +++ b/DigitalData.Core.Abstractions/Security/IAsymmetricPublicKey.cs @@ -1,6 +1,6 @@ namespace DigitalData.Core.Abstractions.Security { - public interface IRSAEncryptor : IAsymmetricKey + public interface IAsymmetricPublicKey : IAsymmetricKey { public byte[] Encrypt(byte[] data); diff --git a/DigitalData.Core.Security/AsymCryptHandler.cs b/DigitalData.Core.Security/AsymCryptHandler.cs index 95445a8..1698ebb 100644 --- a/DigitalData.Core.Security/AsymCryptHandler.cs +++ b/DigitalData.Core.Security/AsymCryptHandler.cs @@ -15,9 +15,9 @@ namespace DigitalData.Core.Security /// public IAsymmetricPrivateKey VaultPrivateKey { get; } - private readonly Lazy> _lazyEncryptors; + private readonly Lazy> _lazyPublicKeys; - public IEnumerable Encryptors => _lazyEncryptors.Value; + public IEnumerable PublicKeys => _lazyPublicKeys.Value; public IEnumerable TokenDescriptions { get; init; } = new List(); @@ -34,9 +34,9 @@ namespace DigitalData.Core.Security 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)); } } } \ No newline at end of file diff --git a/DigitalData.Core.Security/Cryptographer/RSAEncryptor.cs b/DigitalData.Core.Security/Cryptographer/RSAEncryptor.cs index b2fab17..0512ac4 100644 --- a/DigitalData.Core.Security/Cryptographer/RSAEncryptor.cs +++ b/DigitalData.Core.Security/Cryptographer/RSAEncryptor.cs @@ -2,7 +2,7 @@ namespace DigitalData.Core.Security.Cryptographer { - public class RSAEncryptor : RSAKeyBase, IRSAEncryptor, IAsymmetricKey + public class RSAEncryptor : RSAKeyBase, IAsymmetricPublicKey, IAsymmetricKey { public override string Pem { diff --git a/DigitalData.Core.Security/Cryptographer/RSAPrivateKey.cs b/DigitalData.Core.Security/Cryptographer/RSAPrivateKey.cs index 66da411..2891d86 100644 --- a/DigitalData.Core.Security/Cryptographer/RSAPrivateKey.cs +++ b/DigitalData.Core.Security/Cryptographer/RSAPrivateKey.cs @@ -24,13 +24,13 @@ namespace DigitalData.Core.Security.Cryptographer public bool IsEncrypted { get; init; } - private readonly Lazy _lazyEncryptor; + private readonly Lazy _lazyPublicKey; - public IRSAEncryptor Encryptor => _lazyEncryptor.Value; + public IAsymmetricPublicKey PublicKey => _lazyPublicKey.Value; public RSAPrivateKey() { - _lazyEncryptor = new(() => new RSAEncryptor() + _lazyPublicKey = new(() => new RSAEncryptor() { Pem = RSA.ExportRSAPublicKeyPem(), Padding = Padding