refactor(RSADecryptor): RSADecryptor, Version und Passwort entfernen und hinzufügen
This commit is contained in:
parent
0c6c84852d
commit
dbfee49dee
@ -2,11 +2,7 @@
|
||||
{
|
||||
public interface IRSADecryptor : IRSACryptographer
|
||||
{
|
||||
(string Value, Version Version)? VersionedPassword { init; }
|
||||
|
||||
Version? PasswordVersion { get; }
|
||||
|
||||
bool HasEncryptedPem { get; }
|
||||
public bool Encrypt { get; init; }
|
||||
|
||||
IRSAEncryptor Encryptor { get; }
|
||||
|
||||
|
||||
@ -6,22 +6,7 @@ namespace DigitalData.Core.Security.Cryptographer
|
||||
{
|
||||
public class RSADecryptor : RSACryptographer, IRSADecryptor, IRSACryptographer
|
||||
{
|
||||
public (string Value, Version Version)? VersionedPassword
|
||||
{
|
||||
init
|
||||
{
|
||||
_password = value?.Value;
|
||||
PasswordVersion = value?.Version;
|
||||
}
|
||||
}
|
||||
|
||||
private string? _password;
|
||||
|
||||
public Version? PasswordVersion { get; private init; } = null;
|
||||
|
||||
public bool HasEncryptedPem => _password is not null;
|
||||
|
||||
public bool IsEncrypted => _password is not null;
|
||||
public bool Encrypt { get; init; }
|
||||
|
||||
private readonly Lazy<IRSAEncryptor> _lazyEncryptor;
|
||||
|
||||
@ -43,10 +28,10 @@ namespace DigitalData.Core.Security.Cryptographer
|
||||
public override void Init()
|
||||
{
|
||||
base.Init();
|
||||
if (_password is null)
|
||||
RSA.ImportFromPem(Pem);
|
||||
if (Encrypt)
|
||||
RSA.ImportFromEncryptedPem(Pem, Secrets.PBE_PASSWORD.AsSpan());
|
||||
else
|
||||
RSA.ImportFromEncryptedPem(Pem, _password.AsSpan());
|
||||
RSA.ImportFromPem(Pem);
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user