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
|
public interface IRSADecryptor : IRSACryptographer
|
||||||
{
|
{
|
||||||
(string Value, Version Version)? VersionedPassword { init; }
|
public bool Encrypt { get; init; }
|
||||||
|
|
||||||
Version? PasswordVersion { get; }
|
|
||||||
|
|
||||||
bool HasEncryptedPem { get; }
|
|
||||||
|
|
||||||
IRSAEncryptor Encryptor { get; }
|
IRSAEncryptor Encryptor { get; }
|
||||||
|
|
||||||
|
|||||||
@ -6,22 +6,7 @@ namespace DigitalData.Core.Security.Cryptographer
|
|||||||
{
|
{
|
||||||
public class RSADecryptor : RSACryptographer, IRSADecryptor, IRSACryptographer
|
public class RSADecryptor : RSACryptographer, IRSADecryptor, IRSACryptographer
|
||||||
{
|
{
|
||||||
public (string Value, Version Version)? VersionedPassword
|
public bool Encrypt { get; init; }
|
||||||
{
|
|
||||||
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;
|
|
||||||
|
|
||||||
private readonly Lazy<IRSAEncryptor> _lazyEncryptor;
|
private readonly Lazy<IRSAEncryptor> _lazyEncryptor;
|
||||||
|
|
||||||
@ -43,10 +28,10 @@ namespace DigitalData.Core.Security.Cryptographer
|
|||||||
public override void Init()
|
public override void Init()
|
||||||
{
|
{
|
||||||
base.Init();
|
base.Init();
|
||||||
if (_password is null)
|
if (Encrypt)
|
||||||
RSA.ImportFromPem(Pem);
|
RSA.ImportFromEncryptedPem(Pem, Secrets.PBE_PASSWORD.AsSpan());
|
||||||
else
|
else
|
||||||
RSA.ImportFromEncryptedPem(Pem, _password.AsSpan());
|
RSA.ImportFromPem(Pem);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user