using System.Security.Cryptography.X509Certificates;
using Newtonsoft.Json;
namespace DSInternals.Common.Data
{
public class KeyMaterialFido
{
///
/// Version is an integer that specifies the version of the structure.
///
[JsonProperty("version")]
public int Version { get; set; }
///
/// AuthData is a WebAuthn authenticator data structure.
/// https://www.w3.org/TR/webauthn/#sec-authenticator-data
///
[JsonProperty("authData")]
public string AuthData { get; set; }
///
/// X5c is an array of attestation certificates associated with the authenticator.
///
[JsonProperty("x5c")]
public string[] X5c { get; set; }
///
/// Display name is a user provided string which can help the user differentiate between multiple registered authenticators.
///
[JsonProperty("displayName")]
public string DisplayName { get; set; }
// Attestation certificates can be helpful for establishing a chain of trust.
public X509Certificate2Collection AttestationCertificates
{
get
{
X509Certificate2Collection certs = new X509Certificate2Collection();
foreach (string s in X5c)
{
certs.Add(new X509Certificate2(System.Convert.FromBase64String(s)));
}
return certs;
}
}
// Authenticator data contains information about the registered authenticator device.
public Fido.AuthenticatorData AuthenticatorData
{
get
{
return new Fido.AuthenticatorData(System.Convert.FromBase64String(AuthData));
}
}
}
}