refactor(RSADecryptor): aktualisiert, um im Passwort- und Versions-Tupel-Format zu initieren, um Datenintegrität zu gewährleisten.
- password und PasswordVersion initter entfernt.
This commit is contained in:
parent
103ddf5c2e
commit
6ab1777f7c
@ -2,9 +2,9 @@
|
||||
{
|
||||
public interface IRSADecryptor : IRSACryptographer
|
||||
{
|
||||
string? Password { init; }
|
||||
(string Value, Version Version) VersionedPassword { init; }
|
||||
|
||||
Version? PasswordVersion { get; init; }
|
||||
Version? PasswordVersion { get; }
|
||||
|
||||
bool HasEncryptedPem { get; }
|
||||
|
||||
|
||||
@ -6,13 +6,22 @@ namespace DigitalData.Core.Security
|
||||
{
|
||||
public class RSADecryptor : RSACryptographer, IRSADecryptor, IRSACryptographer
|
||||
{
|
||||
public string? Password { internal get; init; }
|
||||
public (string Value, Version Version) VersionedPassword
|
||||
{
|
||||
init
|
||||
{
|
||||
_password = value.Value;
|
||||
PasswordVersion = value.Version;
|
||||
}
|
||||
}
|
||||
|
||||
public Version? PasswordVersion { get; init; }
|
||||
private string? _password;
|
||||
|
||||
public bool HasEncryptedPem => Password is not null;
|
||||
public Version? PasswordVersion { get; private init; }
|
||||
|
||||
public bool IsEncrypted => Password is not null;
|
||||
public bool HasEncryptedPem => _password is not null;
|
||||
|
||||
public bool IsEncrypted => _password is not null;
|
||||
|
||||
private readonly Lazy<IRSAEncryptor> _lazyEncryptor;
|
||||
|
||||
@ -33,10 +42,10 @@ namespace DigitalData.Core.Security
|
||||
lazyRSA = new(() =>
|
||||
{
|
||||
var rsa = RSA.Create();
|
||||
if (Password is null)
|
||||
if (_password is null)
|
||||
RSA.ImportFromPem(Pem);
|
||||
else
|
||||
RSA.ImportFromEncryptedPem(Pem, Password.AsSpan());
|
||||
RSA.ImportFromEncryptedPem(Pem, _password.AsSpan());
|
||||
|
||||
return rsa;
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user