IdentityShroud/IdentityShroud.Core/Security/Keys/IKeyProvider.cs

35 lines
861 B
C#
Raw Normal View History

using IdentityShroud.Core.Messages;
namespace IdentityShroud.Core.Security.Keys;
public class KeyPolicy
{
public KeyType KeyType { get; protected init; }
public int KeySize { get; protected init; }
}
public record KeyData(byte[] PrivateKey, Dictionary<string, string>? PublicKeyParameters = null)
{
/// <summary>
/// The data to be kept private, also used for symmetric keys
/// </summary>
public byte[] PrivateKey { get; set; } = PrivateKey;
public Dictionary<string, string>? PublicKeyParameters { get; set; } = PublicKeyParameters;
}
public interface IKeyProvider
{
/// <summary>
/// Returns true when this key uses public key cryptography
/// </summary>
bool IsPublic { get; }
KeyData CreateKey(KeyPolicy policy);
void SetJwkParameters(Dictionary<string, string> parameters, JsonWebKey jwk);
}