ln.identities/SecureAttribute.cs

37 lines
907 B
C#

using System;
namespace ln.identities
{
public abstract class SecureAttribute
{
static public Random Random { get; } = new Random();
public Guid UniqueID { get; private set; }
public String Label { get; set; }
public byte[] Challenge { get; private set; }
protected SecureAttribute()
{
UniqueID = Guid.NewGuid();
}
protected SecureAttribute(String label)
:this()
{
Label = label;
}
public abstract String GetAuthenticationParameters();
public abstract bool Authenticate(byte[] challenge, byte[] prove);
public virtual byte[] CreateChallenge()
{
Challenge = new byte[32];
Random.NextBytes(Challenge);
return Challenge;
}
public string GetAttributeTypeName() => this.GetType().Name;
}
}