31 lines
840 B
C#
31 lines
840 B
C#
using DigitalData.Core.Abstractions.Security;
|
|
using System.Security.Cryptography;
|
|
|
|
namespace DigitalData.Core.Security
|
|
{
|
|
public class RSACryptographer : IRSACryptographer
|
|
{
|
|
public required virtual string Pem { get; init; }
|
|
|
|
public RSAEncryptionPadding Padding { get; init; } = RSAEncryptionPadding.OaepSHA256;
|
|
|
|
protected virtual RSA RSA { get; } = RSA.Create();
|
|
|
|
private DateOnly? _expiration;
|
|
|
|
public DateOnly? Expiration
|
|
{
|
|
get => _expiration;
|
|
init
|
|
{
|
|
|
|
if (value <= DateOnly.FromDateTime(DateTime.Now))
|
|
throw new InvalidOperationException("The expiration date has already passed.");
|
|
|
|
_expiration = value;
|
|
}
|
|
}
|
|
|
|
internal RSACryptographer() { }
|
|
}
|
|
} |