feat(RSAFactory): Optionale Verschlüsselungseingabe in CreatePrivateKeyPem Methode hinzugefügt.

- Falsch als Standard eingestellt.
This commit is contained in:
Developer 02 2024-12-16 10:01:09 +01:00
parent 7da93c6719
commit eced1a5afc
2 changed files with 6 additions and 5 deletions

View File

@ -4,16 +4,16 @@ namespace DigitalData.Core.Abstractions.Security
{
public interface IRSAFactory
{
string CreatePrivateKeyPem(int? keySizeInBits = null);
string CreatePrivateKeyPem(int? keySizeInBits = null, bool encrypt = false);
public string CreateEncryptedPrivateKeyPem(
string CreateEncryptedPrivateKeyPem(
PbeEncryptionAlgorithm? pbeEncryptionAlgorithm = null,
HashAlgorithmName? hashAlgorithmName = null,
int? iterationCount = null,
int? keySizeInBits = null,
string? password = null);
public string CreateEncryptedPrivateKeyPem(
string CreateEncryptedPrivateKeyPem(
PbeParameters pbeParameters,
int? keySizeInBits = null,
string? password = null);

View File

@ -11,8 +11,9 @@ namespace DigitalData.Core.Security.Cryptographer
public RSAFactory(IOptions<TRSAFactoryParams> options) => _params = options.Value;
public string CreatePrivateKeyPem(int? keySizeInBits = null)
=> RSA.Create(keySizeInBits ?? _params.KeySizeInBits).ExportRSAPrivateKeyPem();
public string CreatePrivateKeyPem(int? keySizeInBits = null, bool encrypt = false) => encrypt
? CreateEncryptedPrivateKeyPem(keySizeInBits: keySizeInBits)
: RSA.Create(keySizeInBits ?? _params.KeySizeInBits).ExportRSAPrivateKeyPem();
public string CreateEncryptedPrivateKeyPem(
PbeEncryptionAlgorithm? pbeEncryptionAlgorithm = null,