diff --git a/DigitalData.Core.Abstractions/Security/IRSADecryptor.cs b/DigitalData.Core.Abstractions/Security/IRSADecryptor.cs index 2600394..91a906b 100644 --- a/DigitalData.Core.Abstractions/Security/IRSADecryptor.cs +++ b/DigitalData.Core.Abstractions/Security/IRSADecryptor.cs @@ -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; } diff --git a/DigitalData.Core.Security/RSADecryptor.cs b/DigitalData.Core.Security/RSADecryptor.cs index 244ef17..4c23da2 100644 --- a/DigitalData.Core.Security/RSADecryptor.cs +++ b/DigitalData.Core.Security/RSADecryptor.cs @@ -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 _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; });