mirror of
https://github.com/MichaelGrafnetter/DSInternals
synced 2025-04-26 12:58:26 +00:00
79 lines
2.3 KiB
C#
79 lines
2.3 KiB
C#
using System;
|
|
using System.Security.Cryptography.X509Certificates;
|
|
using Newtonsoft.Json;
|
|
|
|
namespace DSInternals.Common.Data
|
|
{
|
|
[JsonObject(MemberSerialization = MemberSerialization.OptIn)]
|
|
public class KeyMaterialFido
|
|
{
|
|
/// <summary>
|
|
/// Version is an integer that specifies the version of the structure.
|
|
/// </summary>
|
|
[JsonProperty("version")]
|
|
public int Version
|
|
{
|
|
get;
|
|
private set;
|
|
}
|
|
|
|
/// <summary>
|
|
/// AuthData is a WebAuthn authenticator data structure.
|
|
/// <see>https://www.w3.org/TR/webauthn/#sec-authenticator-data</see>
|
|
/// </summary>
|
|
[JsonProperty("authData")]
|
|
public string AuthenticatorDataRaw
|
|
{
|
|
get;
|
|
private set;
|
|
}
|
|
|
|
/// <summary>
|
|
/// X5c is an array of attestation certificates associated with the authenticator.
|
|
/// </summary>
|
|
[JsonProperty("x5c")]
|
|
public string[] AttestationCertificatesRaw
|
|
{
|
|
get;
|
|
private set;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Display name is a user provided string which can help the user differentiate between multiple registered authenticators.
|
|
/// </summary>
|
|
[JsonProperty("displayName")]
|
|
public string DisplayName
|
|
{
|
|
get;
|
|
private set;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Attestation certificates can be helpful for establishing a chain of trust.
|
|
/// </summary>
|
|
public X509Certificate2Collection AttestationCertificates
|
|
{
|
|
get
|
|
{
|
|
X509Certificate2Collection certs = new X509Certificate2Collection();
|
|
foreach (string s in this.AttestationCertificatesRaw)
|
|
{
|
|
certs.Add(new X509Certificate2(Convert.FromBase64String(s)));
|
|
}
|
|
return certs;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Authenticator data contains information about the registered authenticator device.
|
|
/// </summary>
|
|
public Fido.AuthenticatorData AuthenticatorData
|
|
{
|
|
get
|
|
{
|
|
return new Fido.AuthenticatorData(Convert.FromBase64String(this.AuthenticatorDataRaw));
|
|
}
|
|
}
|
|
}
|
|
}
|