Skip to content

Commit abf150d

Browse files
Additional constants
1 parent feb72a0 commit abf150d

5 files changed

Lines changed: 85 additions & 10 deletions

File tree

Src/DSInternals.Win32.WebAuthn/Enums/AuthenticatorTransport.cs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System;
22
using System.Runtime.Serialization;
33
using System.Text.Json.Serialization;
4+
using DSInternals.Win32.WebAuthn.Interop;
45
using Windows.Win32;
56

67
namespace DSInternals.Win32.WebAuthn
@@ -23,21 +24,21 @@ public enum AuthenticatorTransport : uint
2324
/// Universal Serial Bus (USB).
2425
/// </summary>
2526
/// <remarks>Corresponds to WEBAUTHN_CTAP_TRANSPORT_USB.</remarks>
26-
[EnumMember(Value = "usb")]
27+
[EnumMember(Value = ApiConstants.CtapTransportUsb)]
2728
USB = PInvoke.WEBAUTHN_CTAP_TRANSPORT_USB,
2829

2930
/// <summary>
3031
/// Near Field Communication (NFC).
3132
/// </summary>
3233
/// <remarks>Corresponds to WEBAUTHN_CTAP_TRANSPORT_NFC.</remarks>
33-
[EnumMember(Value = "nfc")]
34+
[EnumMember(Value = ApiConstants.CtapTransportNfc)]
3435
NFC = PInvoke.WEBAUTHN_CTAP_TRANSPORT_NFC,
3536

3637
/// <summary>
3738
/// Bluetooth Low Energy (BLE).
3839
/// </summary>
3940
/// <remarks>Corresponds to WEBAUTHN_CTAP_TRANSPORT_BLE.</remarks>
40-
[EnumMember(Value = "ble")]
41+
[EnumMember(Value = ApiConstants.CtapTransportBle)]
4142
BLE = PInvoke.WEBAUTHN_CTAP_TRANSPORT_BLE,
4243

4344
/// <summary>
@@ -50,21 +51,21 @@ public enum AuthenticatorTransport : uint
5051
/// Client device-specific transport (platform authenticator).
5152
/// </summary>
5253
/// <remarks>Corresponds to WEBAUTHN_CTAP_TRANSPORT_INTERNAL.</remarks>
53-
[EnumMember(Value = "internal")]
54+
[EnumMember(Value = ApiConstants.CtapTransportInternal)]
5455
Internal = PInvoke.WEBAUTHN_CTAP_TRANSPORT_INTERNAL,
5556

5657
/// <summary>
5758
/// Hybrid Transport (QR Code / caBLE).
5859
/// </summary>
5960
/// <remarks>Corresponds to WEBAUTHN_CTAP_TRANSPORT_HYBRID.</remarks>
60-
[EnumMember(Value = "hybrid")]
61+
[EnumMember(Value = ApiConstants.CtapTransportHybrid)]
6162
Hybrid = PInvoke.WEBAUTHN_CTAP_TRANSPORT_HYBRID,
6263

6364
/// <summary>
6465
/// Smart card transport.
6566
/// </summary>
6667
/// <remarks>Corresponds to WEBAUTHN_CTAP_TRANSPORT_SMART_CARD.</remarks>
67-
[EnumMember(Value = "smart-card")]
68+
[EnumMember(Value = ApiConstants.CtapTransportSmartCard)]
6869
SmartCard = PInvoke.WEBAUTHN_CTAP_TRANSPORT_SMART_CARD
6970
}
7071
}

Src/DSInternals.Win32.WebAuthn/Enums/PublicKeyCredentialHint.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System.Runtime.Serialization;
22
using System.Text.Json.Serialization;
3+
using DSInternals.Win32.WebAuthn.Interop;
34

45
namespace DSInternals.Win32.WebAuthn;
56

@@ -21,18 +22,18 @@ public enum PublicKeyCredentialHint
2122
/// <summary>
2223
/// Indicates that the Relying Party believes that users will satisfy this request with a physical security key.
2324
/// </summary>
24-
[EnumMember(Value = "security-key")]
25+
[EnumMember(Value = ApiConstants.CredentialHintSecurityKey)]
2526
SecurityKey,
2627

2728
/// <summary>
2829
/// Indicates that the Relying Party believes that users will satisfy this request with a platform authenticator built into the client device.
2930
/// </summary>
30-
[EnumMember(Value = "client-device")]
31+
[EnumMember(Value = ApiConstants.CredentialHintClientDevice)]
3132
ClientDevice,
3233

3334
/// <summary>
3435
/// Indicates that the Relying Party believes that users will satisfy this request with a general-purpose authenticator such as smartphone (hybrid transport).
3536
/// </summary>
36-
[EnumMember(Value = "hybrid")]
37+
[EnumMember(Value = ApiConstants.CredentialHintHybrid)]
3738
Hybrid
3839
}

Src/DSInternals.Win32.WebAuthn/Interop/ApiConstants.cs

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,5 +81,75 @@ public static class ApiConstants
8181
/// Corresponds to WEBAUTHN_EXTENSIONS_IDENTIFIER_HMAC_SECRET.
8282
/// </remarks>
8383
public const string ExtensionIdentifierHmacSecret = PInvoke.WEBAUTHN_EXTENSIONS_IDENTIFIER_HMAC_SECRET;
84+
85+
/// <remarks>
86+
/// Corresponds to WEBAUTHN_ATTESTATION_TYPE_PACKED.
87+
/// </remarks>
88+
public const string AttestationTypePacked = PInvoke.WEBAUTHN_ATTESTATION_TYPE_PACKED;
89+
90+
/// <remarks>
91+
/// Corresponds to WEBAUTHN_ATTESTATION_TYPE_U2F.
92+
/// </remarks>
93+
public const string AttestationTypeU2F = PInvoke.WEBAUTHN_ATTESTATION_TYPE_U2F;
94+
95+
/// <remarks>
96+
/// Corresponds to WEBAUTHN_ATTESTATION_TYPE_TPM.
97+
/// </remarks>
98+
public const string AttestationTypeTpm = PInvoke.WEBAUTHN_ATTESTATION_TYPE_TPM;
99+
100+
/// <remarks>
101+
/// Corresponds to WEBAUTHN_ATTESTATION_TYPE_NONE.
102+
/// </remarks>
103+
public const string AttestationTypeNone = PInvoke.WEBAUTHN_ATTESTATION_TYPE_NONE;
104+
105+
/// <remarks>
106+
/// Corresponds to WEBAUTHN_ATTESTATION_VER_TPM_2_0.
107+
/// </remarks>
108+
public const string AttestationVersionTpm20 = PInvoke.WEBAUTHN_ATTESTATION_VER_TPM_2_0;
109+
110+
/// <remarks>
111+
/// Corresponds to WEBAUTHN_CTAP_TRANSPORT_USB_STRING.
112+
/// </remarks>
113+
public const string CtapTransportUsb = PInvoke.WEBAUTHN_CTAP_TRANSPORT_USB_STRING;
114+
115+
/// <remarks>
116+
/// Corresponds to WEBAUTHN_CTAP_TRANSPORT_NFC_STRING.
117+
/// </remarks>
118+
public const string CtapTransportNfc = PInvoke.WEBAUTHN_CTAP_TRANSPORT_NFC_STRING;
119+
120+
/// <remarks>
121+
/// Corresponds to WEBAUTHN_CTAP_TRANSPORT_BLE_STRING.
122+
/// </remarks>
123+
public const string CtapTransportBle = PInvoke.WEBAUTHN_CTAP_TRANSPORT_BLE_STRING;
124+
125+
/// <remarks>
126+
/// Corresponds to WEBAUTHN_CTAP_TRANSPORT_INTERNAL_STRING.
127+
/// </remarks>
128+
public const string CtapTransportInternal = PInvoke.WEBAUTHN_CTAP_TRANSPORT_INTERNAL_STRING;
129+
130+
/// <remarks>
131+
/// Corresponds to WEBAUTHN_CTAP_TRANSPORT_HYBRID_STRING.
132+
/// </remarks>
133+
public const string CtapTransportHybrid = PInvoke.WEBAUTHN_CTAP_TRANSPORT_HYBRID_STRING;
134+
135+
/// <remarks>
136+
/// Corresponds to WEBAUTHN_CTAP_TRANSPORT_SMART_CARD_STRING.
137+
/// </remarks>
138+
public const string CtapTransportSmartCard = PInvoke.WEBAUTHN_CTAP_TRANSPORT_SMART_CARD_STRING;
139+
140+
/// <remarks>
141+
/// Corresponds to WEBAUTHN_CREDENTIAL_HINT_SECURITY_KEY.
142+
/// </remarks>
143+
public const string CredentialHintSecurityKey = PInvoke.WEBAUTHN_CREDENTIAL_HINT_SECURITY_KEY;
144+
145+
/// <remarks>
146+
/// Corresponds to WEBAUTHN_CREDENTIAL_HINT_CLIENT_DEVICE.
147+
/// </remarks>
148+
public const string CredentialHintClientDevice = PInvoke.WEBAUTHN_CREDENTIAL_HINT_CLIENT_DEVICE;
149+
150+
/// <remarks>
151+
/// Corresponds to WEBAUTHN_CREDENTIAL_HINT_HYBRID.
152+
/// </remarks>
153+
public const string CredentialHintHybrid = PInvoke.WEBAUTHN_CREDENTIAL_HINT_HYBRID;
84154
}
85155
}

Src/DSInternals.Win32.WebAuthn/NativeMethods.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ WEBAUTHN_CTAP_TRANSPORT_*
3131
WEBAUTHN_CREDENTIAL_EX_CURRENT_VERSION
3232
WEBAUTHN_CREDENTIAL_CURRENT_VERSION
3333
WEBAUTHN_ENTERPRISE_ATTESTATION_*
34+
WEBAUTHN_ATTESTATION_TYPE_*
35+
WEBAUTHN_ATTESTATION_VER_*
36+
WEBAUTHN_CREDENTIAL_HINT_*
3437
WEBAUTHN_RP_ENTITY_INFORMATION_CURRENT_VERSION
3538
WEBAUTHN_GET_CREDENTIALS_OPTIONS_VERSION_*
3639
WEBAUTHN_GET_CREDENTIALS_OPTIONS_CURRENT_VERSION

Src/DSInternals.Win32.WebAuthn/SoftwareAuthenticator.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,7 @@ private static byte[] BuildAttestationObject(byte[] authenticatorData, Algorithm
365365
writer.WriteStartMap(3);
366366

367367
writer.WriteTextString("fmt");
368-
writer.WriteTextString("packed");
368+
writer.WriteTextString(ApiConstants.AttestationTypePacked);
369369

370370
writer.WriteTextString("authData");
371371
writer.WriteByteString(authenticatorData);

0 commit comments

Comments
 (0)