refactor(RSAFactory): params-Abhängigkeit durch Ersetzen von params.Defaults entfernt

This commit is contained in:
Developer 02
2025-03-14 09:37:24 +01:00
parent 6a12ad77ec
commit 8498dc0456
3 changed files with 91 additions and 82 deletions

View File

@@ -6,13 +6,13 @@ namespace DigitalData.Core.Security.Config
{
public class RSAFactoryParams
{
public int KeySizeInBits { get; init; } = 2048;
public int KeySizeInBits { get; init; } = Default.KeySizeInBits;
public string PbePassword { internal get; init; } = Secrets.PBE_PASSWORD;
public string PbePassword { internal get; init; } = Default.PbePassword;
public PbeEncryptionAlgorithm PbeEncryptionAlgorithm { get; init; } = PbeEncryptionAlgorithm.Aes256Cbc;
public PbeEncryptionAlgorithm PbeEncryptionAlgorithm { get; init; } = Default.PbeEncryptionAlgorithm;
public HashAlgorithmName PbeHashAlgorithm { get; init; } = HashAlgorithmName.SHA256;
public HashAlgorithmName PbeHashAlgorithm { get; init; } = Default.PbeHashAlgorithm;
// TODO: add as json converter to IConfigurIConfiguration.Config
public string PbeHashAlgorithmName
@@ -23,9 +23,9 @@ namespace DigitalData.Core.Security.Config
: new(value);
}
public int PbeIterationCount { get; init; } = 100_000;
public int PbeIterationCount { get; init; } = Default.PbeIterationCount;
public string EncryptedPrivateKeyPemLabel { get; init; } = "ENCRYPTED PRIVATE KEY";
public string EncryptedPrivateKeyPemLabel { get; init; } = Default.EncryptedPrivateKeyPemLabel;
private readonly Lazy<PbeParameters> _lazyPbeParameters;
@@ -36,5 +36,22 @@ namespace DigitalData.Core.Security.Config
{
_lazyPbeParameters = new(() => new PbeParameters(PbeEncryptionAlgorithm, PbeHashAlgorithm, PbeIterationCount));
}
public static class Default
{
public static readonly int KeySizeInBits = 2048;
public static readonly string PbePassword = Secrets.PBE_PASSWORD;
public static readonly PbeEncryptionAlgorithm PbeEncryptionAlgorithm = PbeEncryptionAlgorithm.Aes256Cbc;
public static readonly HashAlgorithmName PbeHashAlgorithm = HashAlgorithmName.SHA256;
public static readonly int PbeIterationCount = 100_000;
public static readonly string EncryptedPrivateKeyPemLabel = "ENCRYPTED PRIVATE KEY";
public static readonly PbeParameters PbeParameters = new(PbeEncryptionAlgorithm, PbeHashAlgorithm, PbeIterationCount);
}
}
}