refactor(IRSADecryptor): Umbenennung in IAsymmetricPrivateKey

This commit is contained in:
Developer 02
2025-01-07 11:16:12 +01:00
parent 4f96d271f3
commit 5e1bf16b6d
10 changed files with 19 additions and 20 deletions

View File

@@ -4,7 +4,7 @@ using System.Security.Cryptography;
namespace DigitalData.Core.Security.Cryptographer
{
public class RSADecryptor : RSACryptographer, IRSADecryptor, IAsymmetricKey
public class RSADecryptor : RSAKeyBase, IAsymmetricPrivateKey, IAsymmetricKey
{
private string? _pem;

View File

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

View File

@@ -56,7 +56,7 @@ namespace DigitalData.Core.Security.Cryptographer
return new string(pemChars);
}
public IRSADecryptor CreateDecryptor(string pem, string? issuer = null, string? audience = null, bool encrypt = false, RSAEncryptionPadding? padding = null) => new RSADecryptor()
public IAsymmetricPrivateKey CreatePrivateKey(string pem, string? issuer = null, string? audience = null, bool encrypt = false, RSAEncryptionPadding? padding = null) => new RSADecryptor()
{
Pem = pem,
Issuer = issuer ?? string.Empty,

View File

@@ -5,8 +5,7 @@ using System.Security.Cryptography;
namespace DigitalData.Core.Security.Cryptographer
{
//TODO: Abstract RSA for future updates (using ECC, El Gamal or Lattice-based Cryptography)
public class RSACryptographer : IAsymmetricKey
public class RSAKeyBase : IAsymmetricKey
{
public virtual string Pem { get; init; }
@@ -30,7 +29,7 @@ namespace DigitalData.Core.Security.Cryptographer
public RsaSecurityKey RsaSecurityKey => _lazyRsaSecurityKey.Value;
#pragma warning disable CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable.
internal RSACryptographer()
internal RSAKeyBase()
{
_lazyRsaSecurityKey = new(() => new RsaSecurityKey(RSA));
}