Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Supporting attestation formats #530

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions Src/Fido2.Models/AssertionOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,12 @@ public class AssertionOptions
[JsonPropertyName("hints")]
public IReadOnlyList<PublicKeyCredentialHint> Hints { get; set; } = Array.Empty<PublicKeyCredentialHint>();

/// <summary>
/// This member is intended for use by Relying Parties that wish to select a preference regarding the attestation statement format used, if such an attestation is requested.
/// </summary>
[JsonPropertyName("attestationFormats")]
public IReadOnlyList<AttestationStatementFormatIdentifier> AttestationFormats { get; set; } = [];

/// <summary>
/// This OPTIONAL member contains additional parameters requesting additional processing by the client and authenticator.
/// For example, if transaction confirmation is sought from the user, then the prompt string might be included as an extension.
Expand Down
9 changes: 9 additions & 0 deletions Src/Fido2.Models/CredentialCreateOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,15 @@ public sealed class CredentialCreateOptions
[JsonPropertyName("attestation")]
public AttestationConveyancePreference Attestation { get; set; } = AttestationConveyancePreference.None;

/// <summary>
/// This member is intended for use by Relying Parties that wish to select a preference regarding the attestation statement format used, if such an attestation is requested.
/// </summary>
/// <remarks>
/// This parameter is advisory and the authenticator MAY use an attestation statement not enumerated in this parameter.
/// </remarks>
[JsonPropertyName("attestationFormats")]
public IReadOnlyList<AttestationStatementFormatIdentifier> AttestationFormats { get; set; } = [];

/// <summary>
/// This member is intended for use by Relying Parties that wish to select the appropriate authenticators to participate in the create() operation.
/// </summary>
Expand Down
55 changes: 55 additions & 0 deletions Src/Fido2.Models/Objects/AttestationStatementFormatIdentifier.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
using System.Runtime.Serialization;
using System.Text.Json.Serialization;

namespace Fido2NetLib.Objects;

/// <summary>
/// The attestation statement format identifier in WebAuthn specifies the format of the attestation statement that is used to attest to the authenticity of a credential created by a WebAuthn authenticator.
/// https://www.iana.org/assignments/webauthn/webauthn.xhtml
/// </summary>
[JsonConverter(typeof(FidoEnumConverter<AttestationStatementFormatIdentifier>))]
public enum AttestationStatementFormatIdentifier
{
/// <summary>
/// The "packed" attestation statement format is a WebAuthn-optimized format for attestation. It uses a very compact but still extensible encoding method. This format is implementable by authenticators with limited resources (e.g., secure elements).
/// </summary>
[EnumMember(Value = "packed")]
Packed,

/// <summary>
/// The "TPM" attestation statement format returns an attestation statement in the same format as the packed attestation statement format, although the rawData and signature fields are computed differently.
/// </summary>
[EnumMember(Value = "tpm")]
Tpm,

/// <summary>
/// Platform authenticators on versions "N", and later, may provide this proprietary "hardware attestation" statement.
/// </summary>
[EnumMember(Value = "android-key")]
AndroidKey,

/// <summary>
/// Android-based platform authenticators MAY produce an attestation statement based on the Android SafetyNet API.
/// </summary>
[EnumMember(Value = "android-safetynet")]
AndroidSafetyNet,

/// <summary>
/// Used with FIDO U2F authenticators.
/// </summary>
[EnumMember(Value = "fido-u2f")]
FidoU2f,

/// <summary>
/// Used with Apple devices' platform authenticators.
/// </summary>
[EnumMember(Value = "apple")]
Apple,

/// <summary>
/// Used to replace any authenticator-provided attestation statement when a WebAuthn Relying Party indicates it does not wish to receive attestation information.
/// </summary>
[EnumMember(Value = "none")]
None
}

Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ public sealed class AuthenticationExtensionsDevicePublicKeyInputs
public string Attestation { get; set; } = "none";

[JsonPropertyName("attestationFormats")]
public string[] AttestationFormats { get; set; } = Array.Empty<string>();
public IReadOnlyList<AttestationStatementFormatIdentifier> AttestationFormats { get; set; } = Array.Empty<AttestationStatementFormatIdentifier>();
jonashendrickx marked this conversation as resolved.
Show resolved Hide resolved
}
Loading