refactor(IAsymmetricKey): Umwandlung von RsaSecurityKey in SecurityKey zur besseren Abstraktion.

- RSAEncryptionPadding entfernen
 - Pem als Inhalt Content
This commit is contained in:
Developer 02
2025-01-07 16:53:05 +01:00
parent 34e14fd2f5
commit 608d266d1c
5 changed files with 14 additions and 16 deletions

View File

@@ -8,7 +8,7 @@ namespace DigitalData.Core.Security.RSAKey
{
private string? _pem;
public override string Pem
public override string Content
{
#pragma warning disable CS8603 // Possible null reference return.
get => _pem;
@@ -38,7 +38,7 @@ namespace DigitalData.Core.Security.RSAKey
{
_lazyPublicKey = new(() => new RSAPublicKey()
{
Pem = RSA.ExportRSAPublicKeyPem(),
Content = RSA.ExportRSAPublicKeyPem(),
Padding = Padding
});
@@ -70,14 +70,14 @@ namespace DigitalData.Core.Security.RSAKey
throw PemIsNullException;
if (IsEncrypted)
RSA.ImportFromEncryptedPem(Pem, Secrets.PBE_PASSWORD.AsSpan());
RSA.ImportFromEncryptedPem(Content, Secrets.PBE_PASSWORD.AsSpan());
else
RSA.ImportFromPem(Pem);
RSA.ImportFromPem(Content);
}
private InvalidOperationException PemIsNullException => new($"Pem is null or empty. Issuer: {Issuer}, Audience: {Audience}.");
private InvalidOperationException PemIsNullException => new($"Content is null or empty. Issuer: {Issuer}, Audience: {Audience}.");
public SigningCredentials CreateSigningCredentials(string algorithm = SecurityAlgorithms.RsaSha256, string? digest = null)
=> digest is null ? new(RsaSecurityKey, algorithm) : new(RsaSecurityKey, algorithm, digest);
=> digest is null ? new(SecurityKey, algorithm) : new(SecurityKey, algorithm, digest);
}
}