refactor(RSAFactory): Entfernen der Methode ReadRSADecryptorAsync.
This commit is contained in:
parent
50e2581727
commit
38bd23d012
@ -12,7 +12,5 @@ namespace DigitalData.Core.Abstractions.Security
|
|||||||
PbeEncryptionAlgorithm? pbeEncryptionAlgorithm = null,
|
PbeEncryptionAlgorithm? pbeEncryptionAlgorithm = null,
|
||||||
HashAlgorithmName? hashAlgorithmName = null,
|
HashAlgorithmName? hashAlgorithmName = null,
|
||||||
int? iterationCount = null);
|
int? iterationCount = null);
|
||||||
|
|
||||||
Task<IRSADecryptor> ReadRSADecryptorAsync(string path, Version? version = null, CancellationToken cancellationToken = default);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1,4 +1,5 @@
|
|||||||
using DigitalData.Core.Abstractions.Security;
|
using DigitalData.Core.Abstractions.Security;
|
||||||
|
using System.Text.Json.Serialization;
|
||||||
|
|
||||||
namespace DigitalData.Core.Security.Config
|
namespace DigitalData.Core.Security.Config
|
||||||
{
|
{
|
||||||
|
|||||||
@ -22,6 +22,6 @@ namespace DigitalData.Core.Security.Config
|
|||||||
[JsonIgnore]
|
[JsonIgnore]
|
||||||
public PbeParameters PbeParameters => _pbeParameters!;
|
public PbeParameters PbeParameters => _pbeParameters!;
|
||||||
|
|
||||||
public void OnDeserialized() => _pbeParameters = new PbeParameters(PbeEncryptionAlgorithm, PbeHashAlgorithmName, PbeIterationCount);
|
public virtual void OnDeserialized() => _pbeParameters = new PbeParameters(PbeEncryptionAlgorithm, PbeHashAlgorithmName, PbeIterationCount);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -40,26 +40,5 @@ namespace DigitalData.Core.Security.Cryptographer
|
|||||||
|
|
||||||
return new string(pemChars);
|
return new string(pemChars);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<IRSADecryptor> ReadRSADecryptorAsync(string path, Version? version = null, CancellationToken cancellationToken = default)
|
|
||||||
{
|
|
||||||
var pem = await File.ReadAllTextAsync(path, cancellationToken);
|
|
||||||
|
|
||||||
(string Value, Version Version)? versionedPassword = null;
|
|
||||||
|
|
||||||
if (version is not null)
|
|
||||||
{
|
|
||||||
if (version != Secrets.Version)
|
|
||||||
throw new InvalidOperationException($"The provided version {version} does not match the expected version {Secrets.Version}.");
|
|
||||||
|
|
||||||
versionedPassword = (Secrets.PBE_PASSWORD, Secrets.Version);
|
|
||||||
}
|
|
||||||
|
|
||||||
return new RSADecryptor()
|
|
||||||
{
|
|
||||||
Pem = pem,
|
|
||||||
VersionedPassword = versionedPassword
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user