35 lines
1.3 KiB
C#
35 lines
1.3 KiB
C#
using DigitalData.Core.Abstractions.Security;
|
|
using DigitalData.Core.Security.Config;
|
|
using DigitalData.Core.Security.Cryptographer;
|
|
using Microsoft.Extensions.Logging;
|
|
using Microsoft.Extensions.Options;
|
|
using System.Collections;
|
|
|
|
namespace DigitalData.Core.Security
|
|
{
|
|
public class AsymCryptService<TAsymCryptParams> : RSAFactory<TAsymCryptParams>, IAsymCryptService<TAsymCryptParams>, IRSAFactory<TAsymCryptParams>, IEnumerable<IRSADecryptor>
|
|
where TAsymCryptParams : AsymCryptParams
|
|
{
|
|
public IEnumerable<IRSADecryptor> Decryptors => _params.Decryptors;
|
|
|
|
public AsymCryptService(IOptions<TAsymCryptParams> options, ILogger<AsymCryptService<TAsymCryptParams>>? logger = null) : base(options)
|
|
{
|
|
logger?.LogInformation("Core.Secrets version: {Version}, Created on: {CreationDate}.", Secrets.Version, Secrets.CreationDate.ToString("dd.MM.yyyy"));
|
|
}
|
|
|
|
public IEnumerator<IRSADecryptor> GetEnumerator() => Decryptors.GetEnumerator();
|
|
|
|
IEnumerator IEnumerable.GetEnumerator() => Decryptors.GetEnumerator();
|
|
|
|
public IEnumerable<IRSAEncryptor> Encryptors
|
|
{
|
|
get
|
|
{
|
|
foreach (var decryptor in Decryptors)
|
|
{
|
|
yield return decryptor.Encryptor;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} |