29 lines
1.0 KiB
C#
29 lines
1.0 KiB
C#
using DigitalData.Core.Abstractions.Security;
|
|
using Microsoft.IdentityModel.Tokens;
|
|
using System.Reflection;
|
|
using System.Security.Cryptography;
|
|
|
|
namespace DigitalData.Core.Security.RSAKey
|
|
{
|
|
public class RSAKeyBase : IAsymmetricKey
|
|
{
|
|
public virtual string Content { get; init; }
|
|
|
|
protected virtual RSA RSA { get; } = RSA.Create();
|
|
|
|
public string Issuer { get; init; } = string.Empty;
|
|
|
|
public string Audience { get; init; } = string.Empty;
|
|
|
|
private readonly Lazy<RsaSecurityKey> _lazyRsaSecurityKey;
|
|
|
|
public SecurityKey SecurityKey => _lazyRsaSecurityKey.Value;
|
|
|
|
#pragma warning disable CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable.
|
|
internal RSAKeyBase()
|
|
{
|
|
_lazyRsaSecurityKey = new(() => new RsaSecurityKey(RSA));
|
|
}
|
|
#pragma warning restore CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable.
|
|
}
|
|
} |