webauthn.h 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709
  1. // Copyright (c) Microsoft Corporation. All rights reserved.
  2. // Licensed under the MIT License.
  3. #ifndef __WEBAUTHN_H_
  4. #define __WEBAUTHN_H_
  5. #pragma once
  6. #include <winapifamily.h>
  7. #pragma region Desktop Family or OneCore Family
  8. #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP | WINAPI_PARTITION_SYSTEM)
  9. #ifdef __cplusplus
  10. extern "C" {
  11. #endif
  12. #ifndef WINAPI
  13. #define WINAPI __stdcall
  14. #endif
  15. #ifndef INITGUID
  16. #define INITGUID
  17. #include <guiddef.h>
  18. #undef INITGUID
  19. #else
  20. #include <guiddef.h>
  21. #endif
  22. //+------------------------------------------------------------------------------------------
  23. // API Version Information.
  24. // Caller should check for WebAuthNGetApiVersionNumber to check the presence of relevant APIs
  25. // and features for their usage.
  26. //-------------------------------------------------------------------------------------------
  27. #define WEBAUTHN_API_VERSION_1 1
  28. // WEBAUTHN_API_VERSION_1 : Baseline Version
  29. // Data Structures and their sub versions:
  30. // - WEBAUTHN_RP_ENTITY_INFORMATION : 1
  31. // - WEBAUTHN_USER_ENTITY_INFORMATION : 1
  32. // - WEBAUTHN_CLIENT_DATA : 1
  33. // - WEBAUTHN_COSE_CREDENTIAL_PARAMETER : 1
  34. // - WEBAUTHN_COSE_CREDENTIAL_PARAMETERS : Not Applicable
  35. // - WEBAUTHN_CREDENTIAL : 1
  36. // - WEBAUTHN_CREDENTIALS : Not Applicable
  37. // - WEBAUTHN_CREDENTIAL_EX : 1
  38. // - WEBAUTHN_CREDENTIAL_LIST : Not Applicable
  39. // - WEBAUTHN_EXTENSION : Not Applicable
  40. // - WEBAUTHN_EXTENSIONS : Not Applicable
  41. // - WEBAUTHN_AUTHENTICATOR_MAKE_CREDENTIAL_OPTIONS : 3
  42. // - WEBAUTHN_AUTHENTICATOR_GET_ASSERTION_OPTIONS : 4
  43. // - WEBAUTHN_COMMON_ATTESTATION : 1
  44. // - WEBAUTHN_CREDENTIAL_ATTESTATION : 3
  45. // - WEBAUTHN_ASSERTION : 1
  46. // Extensions:
  47. // - WEBAUTHN_EXTENSIONS_IDENTIFIER_HMAC_SECRET
  48. // APIs:
  49. // - WebAuthNGetApiVersionNumber
  50. // - WebAuthNIsUserVerifyingPlatformAuthenticatorAvailable
  51. // - WebAuthNAuthenticatorMakeCredential
  52. // - WebAuthNAuthenticatorGetAssertion
  53. // - WebAuthNFreeCredentialAttestation
  54. // - WebAuthNFreeAssertion
  55. // - WebAuthNGetCancellationId
  56. // - WebAuthNCancelCurrentOperation
  57. // - WebAuthNGetErrorName
  58. // - WebAuthNGetW3CExceptionDOMError
  59. #define WEBAUTHN_API_VERSION_2 2
  60. // WEBAUTHN_API_VERSION_2 : Delta From WEBAUTHN_API_VERSION_1
  61. // Added Extensions:
  62. // - WEBAUTHN_EXTENSIONS_IDENTIFIER_CRED_PROTECT
  63. //
  64. #define WEBAUTHN_API_CURRENT_VERSION WEBAUTHN_API_VERSION_2
  65. //+------------------------------------------------------------------------------------------
  66. // Information about an RP Entity
  67. //-------------------------------------------------------------------------------------------
  68. #define WEBAUTHN_RP_ENTITY_INFORMATION_CURRENT_VERSION 1
  69. typedef struct _WEBAUTHN_RP_ENTITY_INFORMATION {
  70. // Version of this structure, to allow for modifications in the future.
  71. // This field is required and should be set to CURRENT_VERSION above.
  72. DWORD dwVersion;
  73. // Identifier for the RP. This field is required.
  74. PCWSTR pwszId;
  75. // Contains the friendly name of the Relying Party, such as "Acme Corporation", "Widgets Inc" or "Awesome Site".
  76. // This field is required.
  77. PCWSTR pwszName;
  78. // Optional URL pointing to RP's logo.
  79. PCWSTR pwszIcon;
  80. } WEBAUTHN_RP_ENTITY_INFORMATION, *PWEBAUTHN_RP_ENTITY_INFORMATION;
  81. typedef const WEBAUTHN_RP_ENTITY_INFORMATION *PCWEBAUTHN_RP_ENTITY_INFORMATION;
  82. //+------------------------------------------------------------------------------------------
  83. // Information about an User Entity
  84. //-------------------------------------------------------------------------------------------
  85. #define WEBAUTHN_MAX_USER_ID_LENGTH 64
  86. #define WEBAUTHN_USER_ENTITY_INFORMATION_CURRENT_VERSION 1
  87. typedef struct _WEBAUTHN_USER_ENTITY_INFORMATION {
  88. // Version of this structure, to allow for modifications in the future.
  89. // This field is required and should be set to CURRENT_VERSION above.
  90. DWORD dwVersion;
  91. // Identifier for the User. This field is required.
  92. DWORD cbId;
  93. _Field_size_bytes_(cbId)
  94. PBYTE pbId;
  95. // Contains a detailed name for this account, such as "john.p.smith@example.com".
  96. PCWSTR pwszName;
  97. // Optional URL that can be used to retrieve an image containing the user's current avatar,
  98. // or a data URI that contains the image data.
  99. PCWSTR pwszIcon;
  100. // For User: Contains the friendly name associated with the user account by the Relying Party, such as "John P. Smith".
  101. PCWSTR pwszDisplayName;
  102. } WEBAUTHN_USER_ENTITY_INFORMATION, *PWEBAUTHN_USER_ENTITY_INFORMATION;
  103. typedef const WEBAUTHN_USER_ENTITY_INFORMATION *PCWEBAUTHN_USER_ENTITY_INFORMATION;
  104. //+------------------------------------------------------------------------------------------
  105. // Information about client data.
  106. //-------------------------------------------------------------------------------------------
  107. #define WEBAUTHN_HASH_ALGORITHM_SHA_256 L"SHA-256"
  108. #define WEBAUTHN_HASH_ALGORITHM_SHA_384 L"SHA-384"
  109. #define WEBAUTHN_HASH_ALGORITHM_SHA_512 L"SHA-512"
  110. #define WEBAUTHN_CLIENT_DATA_CURRENT_VERSION 1
  111. typedef struct _WEBAUTHN_CLIENT_DATA {
  112. // Version of this structure, to allow for modifications in the future.
  113. // This field is required and should be set to CURRENT_VERSION above.
  114. DWORD dwVersion;
  115. // Size of the pbClientDataJSON field.
  116. DWORD cbClientDataJSON;
  117. // UTF-8 encoded JSON serialization of the client data.
  118. _Field_size_bytes_(cbClientDataJSON)
  119. PBYTE pbClientDataJSON;
  120. // Hash algorithm ID used to hash the pbClientDataJSON field.
  121. LPCWSTR pwszHashAlgId;
  122. } WEBAUTHN_CLIENT_DATA, *PWEBAUTHN_CLIENT_DATA;
  123. typedef const WEBAUTHN_CLIENT_DATA *PCWEBAUTHN_CLIENT_DATA;
  124. //+------------------------------------------------------------------------------------------
  125. // Information about credential parameters.
  126. //-------------------------------------------------------------------------------------------
  127. #define WEBAUTHN_CREDENTIAL_TYPE_PUBLIC_KEY L"public-key"
  128. #define WEBAUTHN_COSE_ALGORITHM_ECDSA_P256_WITH_SHA256 -7
  129. #define WEBAUTHN_COSE_ALGORITHM_ECDSA_P384_WITH_SHA384 -35
  130. #define WEBAUTHN_COSE_ALGORITHM_ECDSA_P521_WITH_SHA512 -36
  131. #define WEBAUTHN_COSE_ALGORITHM_RSASSA_PKCS1_V1_5_WITH_SHA256 -257
  132. #define WEBAUTHN_COSE_ALGORITHM_RSASSA_PKCS1_V1_5_WITH_SHA384 -258
  133. #define WEBAUTHN_COSE_ALGORITHM_RSASSA_PKCS1_V1_5_WITH_SHA512 -259
  134. #define WEBAUTHN_COSE_ALGORITHM_RSA_PSS_WITH_SHA256 -37
  135. #define WEBAUTHN_COSE_ALGORITHM_RSA_PSS_WITH_SHA384 -38
  136. #define WEBAUTHN_COSE_ALGORITHM_RSA_PSS_WITH_SHA512 -39
  137. #define WEBAUTHN_COSE_CREDENTIAL_PARAMETER_CURRENT_VERSION 1
  138. typedef struct _WEBAUTHN_COSE_CREDENTIAL_PARAMETER {
  139. // Version of this structure, to allow for modifications in the future.
  140. DWORD dwVersion;
  141. // Well-known credential type specifying a credential to create.
  142. LPCWSTR pwszCredentialType;
  143. // Well-known COSE algorithm specifying the algorithm to use for the credential.
  144. LONG lAlg;
  145. } WEBAUTHN_COSE_CREDENTIAL_PARAMETER, *PWEBAUTHN_COSE_CREDENTIAL_PARAMETER;
  146. typedef const WEBAUTHN_COSE_CREDENTIAL_PARAMETER *PCWEBAUTHN_COSE_CREDENTIAL_PARAMETER;
  147. typedef struct _WEBAUTHN_COSE_CREDENTIAL_PARAMETERS {
  148. DWORD cCredentialParameters;
  149. _Field_size_(cCredentialParameters)
  150. PWEBAUTHN_COSE_CREDENTIAL_PARAMETER pCredentialParameters;
  151. } WEBAUTHN_COSE_CREDENTIAL_PARAMETERS, *PWEBAUTHN_COSE_CREDENTIAL_PARAMETERS;
  152. typedef const WEBAUTHN_COSE_CREDENTIAL_PARAMETERS *PCWEBAUTHN_COSE_CREDENTIAL_PARAMETERS;
  153. //+------------------------------------------------------------------------------------------
  154. // Information about credential.
  155. //-------------------------------------------------------------------------------------------
  156. #define WEBAUTHN_CREDENTIAL_CURRENT_VERSION 1
  157. typedef struct _WEBAUTHN_CREDENTIAL {
  158. // Version of this structure, to allow for modifications in the future.
  159. DWORD dwVersion;
  160. // Size of pbID.
  161. DWORD cbId;
  162. // Unique ID for this particular credential.
  163. _Field_size_bytes_(cbId)
  164. PBYTE pbId;
  165. // Well-known credential type specifying what this particular credential is.
  166. LPCWSTR pwszCredentialType;
  167. } WEBAUTHN_CREDENTIAL, *PWEBAUTHN_CREDENTIAL;
  168. typedef const WEBAUTHN_CREDENTIAL *PCWEBAUTHN_CREDENTIAL;
  169. typedef struct _WEBAUTHN_CREDENTIALS {
  170. DWORD cCredentials;
  171. _Field_size_(cCredentials)
  172. PWEBAUTHN_CREDENTIAL pCredentials;
  173. } WEBAUTHN_CREDENTIALS, *PWEBAUTHN_CREDENTIALS;
  174. typedef const WEBAUTHN_CREDENTIALS *PCWEBAUTHN_CREDENTIALS;
  175. //+------------------------------------------------------------------------------------------
  176. // Information about credential with extra information, such as, dwTransports
  177. //-------------------------------------------------------------------------------------------
  178. #define WEBAUTHN_CTAP_TRANSPORT_USB 0x00000001
  179. #define WEBAUTHN_CTAP_TRANSPORT_NFC 0x00000002
  180. #define WEBAUTHN_CTAP_TRANSPORT_BLE 0x00000004
  181. #define WEBAUTHN_CTAP_TRANSPORT_TEST 0x00000008
  182. #define WEBAUTHN_CTAP_TRANSPORT_INTERNAL 0x00000010
  183. #define WEBAUTHN_CTAP_TRANSPORT_FLAGS_MASK 0x0000001F
  184. #define WEBAUTHN_CREDENTIAL_EX_CURRENT_VERSION 1
  185. typedef struct _WEBAUTHN_CREDENTIAL_EX {
  186. // Version of this structure, to allow for modifications in the future.
  187. DWORD dwVersion;
  188. // Size of pbID.
  189. DWORD cbId;
  190. // Unique ID for this particular credential.
  191. _Field_size_bytes_(cbId)
  192. PBYTE pbId;
  193. // Well-known credential type specifying what this particular credential is.
  194. LPCWSTR pwszCredentialType;
  195. // Transports. 0 implies no transport restrictions.
  196. DWORD dwTransports;
  197. } WEBAUTHN_CREDENTIAL_EX, *PWEBAUTHN_CREDENTIAL_EX;
  198. typedef const WEBAUTHN_CREDENTIAL_EX *PCWEBAUTHN_CREDENTIAL_EX;
  199. //+------------------------------------------------------------------------------------------
  200. // Information about credential list with extra information
  201. //-------------------------------------------------------------------------------------------
  202. typedef struct _WEBAUTHN_CREDENTIAL_LIST {
  203. DWORD cCredentials;
  204. _Field_size_(cCredentials)
  205. PWEBAUTHN_CREDENTIAL_EX *ppCredentials;
  206. } WEBAUTHN_CREDENTIAL_LIST, *PWEBAUTHN_CREDENTIAL_LIST;
  207. typedef const WEBAUTHN_CREDENTIAL_LIST *PCWEBAUTHN_CREDENTIAL_LIST;
  208. //+------------------------------------------------------------------------------------------
  209. // Hmac-Secret extension
  210. //-------------------------------------------------------------------------------------------
  211. #define WEBAUTHN_EXTENSIONS_IDENTIFIER_HMAC_SECRET L"hmac-secret"
  212. // Below type definitions is for WEBAUTHN_EXTENSIONS_IDENTIFIER_HMAC_SECRET
  213. // MakeCredential Input Type: BOOL.
  214. // - pvExtension must point to a BOOL with the value TRUE.
  215. // - cbExtension must contain the sizeof(BOOL).
  216. // MakeCredential Output Type: BOOL.
  217. // - pvExtension will point to a BOOL with the value TRUE if credential
  218. // was successfully created with HMAC_SECRET.
  219. // - cbExtension will contain the sizeof(BOOL).
  220. // GetAssertion Input Type: Not Supported
  221. // GetAssertion Output Type: Not Supported
  222. //+------------------------------------------------------------------------------------------
  223. // credProtect extension
  224. //-------------------------------------------------------------------------------------------
  225. #define WEBAUTHN_USER_VERIFICATION_ANY 0
  226. #define WEBAUTHN_USER_VERIFICATION_OPTIONAL 1
  227. #define WEBAUTHN_USER_VERIFICATION_OPTIONAL_WITH_CREDENTIAL_ID_LIST 2
  228. #define WEBAUTHN_USER_VERIFICATION_REQUIRED 3
  229. typedef struct _WEBAUTHN_CRED_PROTECT_EXTENSION_IN {
  230. // One of the above WEBAUTHN_USER_VERIFICATION_* values
  231. DWORD dwCredProtect;
  232. // Set the following to TRUE to require authenticator support for the
  233. // credProtect extension
  234. BOOL bRequireCredProtect;
  235. } WEBAUTHN_CRED_PROTECT_EXTENSION_IN, *PWEBAUTHN_CRED_PROTECT_EXTENSION_IN;
  236. typedef const WEBAUTHN_CRED_PROTECT_EXTENSION_IN*
  237. PCWEBAUTHN_CRED_PROTECT_EXTENSION_IN;
  238. #define WEBAUTHN_EXTENSIONS_IDENTIFIER_CRED_PROTECT L"credProtect"
  239. // Below type definitions is for WEBAUTHN_EXTENSIONS_IDENTIFIER_CRED_PROTECT
  240. // MakeCredential Input Type: WEBAUTHN_CRED_PROTECT_EXTENSION_IN.
  241. // - pvExtension must point to a WEBAUTHN_CRED_PROTECT_EXTENSION_IN struct
  242. // - cbExtension will contain the
  243. // sizeof(WEBAUTHN_CRED_PROTECT_EXTENSION_IN).
  244. // MakeCredential Output Type: DWORD.
  245. // - pvExtension will point to a DWORD with one of the above
  246. // WEBAUTHN_USER_VERIFICATION_* values
  247. // if credential was successfully created with CRED_PROTECT.
  248. // - cbExtension will contain the sizeof(DWORD).
  249. // GetAssertion Input Type: Not Supported
  250. // GetAssertion Output Type: Not Supported
  251. //+------------------------------------------------------------------------------------------
  252. // Information about Extensions.
  253. //-------------------------------------------------------------------------------------------
  254. typedef struct _WEBAUTHN_EXTENSION {
  255. LPCWSTR pwszExtensionIdentifier;
  256. DWORD cbExtension;
  257. PVOID pvExtension;
  258. } WEBAUTHN_EXTENSION, *PWEBAUTHN_EXTENSION;
  259. typedef const WEBAUTHN_EXTENSION *PCWEBAUTHN_EXTENSION;
  260. typedef struct _WEBAUTHN_EXTENSIONS {
  261. DWORD cExtensions;
  262. _Field_size_(cExtensions)
  263. PWEBAUTHN_EXTENSION pExtensions;
  264. } WEBAUTHN_EXTENSIONS, *PWEBAUTHN_EXTENSIONS;
  265. typedef const WEBAUTHN_EXTENSIONS *PCWEBAUTHN_EXTENSIONS;
  266. //+------------------------------------------------------------------------------------------
  267. // Options.
  268. //-------------------------------------------------------------------------------------------
  269. #define WEBAUTHN_AUTHENTICATOR_ATTACHMENT_ANY 0
  270. #define WEBAUTHN_AUTHENTICATOR_ATTACHMENT_PLATFORM 1
  271. #define WEBAUTHN_AUTHENTICATOR_ATTACHMENT_CROSS_PLATFORM 2
  272. #define WEBAUTHN_AUTHENTICATOR_ATTACHMENT_CROSS_PLATFORM_U2F_V2 3
  273. #define WEBAUTHN_USER_VERIFICATION_REQUIREMENT_ANY 0
  274. #define WEBAUTHN_USER_VERIFICATION_REQUIREMENT_REQUIRED 1
  275. #define WEBAUTHN_USER_VERIFICATION_REQUIREMENT_PREFERRED 2
  276. #define WEBAUTHN_USER_VERIFICATION_REQUIREMENT_DISCOURAGED 3
  277. #define WEBAUTHN_ATTESTATION_CONVEYANCE_PREFERENCE_ANY 0
  278. #define WEBAUTHN_ATTESTATION_CONVEYANCE_PREFERENCE_NONE 1
  279. #define WEBAUTHN_ATTESTATION_CONVEYANCE_PREFERENCE_INDIRECT 2
  280. #define WEBAUTHN_ATTESTATION_CONVEYANCE_PREFERENCE_DIRECT 3
  281. #define WEBAUTHN_AUTHENTICATOR_MAKE_CREDENTIAL_OPTIONS_VERSION_1 1
  282. #define WEBAUTHN_AUTHENTICATOR_MAKE_CREDENTIAL_OPTIONS_VERSION_2 2
  283. #define WEBAUTHN_AUTHENTICATOR_MAKE_CREDENTIAL_OPTIONS_VERSION_3 3
  284. #define WEBAUTHN_AUTHENTICATOR_MAKE_CREDENTIAL_OPTIONS_CURRENT_VERSION WEBAUTHN_AUTHENTICATOR_MAKE_CREDENTIAL_OPTIONS_VERSION_3
  285. typedef struct _WEBAUTHN_AUTHENTICATOR_MAKE_CREDENTIAL_OPTIONS {
  286. // Version of this structure, to allow for modifications in the future.
  287. DWORD dwVersion;
  288. // Time that the operation is expected to complete within.
  289. // This is used as guidance, and can be overridden by the platform.
  290. DWORD dwTimeoutMilliseconds;
  291. // Credentials used for exclusion.
  292. WEBAUTHN_CREDENTIALS CredentialList;
  293. // Optional extensions to parse when performing the operation.
  294. WEBAUTHN_EXTENSIONS Extensions;
  295. // Optional. Platform vs Cross-Platform Authenticators.
  296. DWORD dwAuthenticatorAttachment;
  297. // Optional. Require key to be resident or not. Defaulting to FALSE;
  298. BOOL bRequireResidentKey;
  299. // User Verification Requirement.
  300. DWORD dwUserVerificationRequirement;
  301. // Attestation Conveyance Preference.
  302. DWORD dwAttestationConveyancePreference;
  303. // Reserved for future Use
  304. DWORD dwFlags;
  305. //
  306. // The following fields have been added in WEBAUTHN_AUTHENTICATOR_MAKE_CREDENTIAL_OPTIONS_VERSION_2
  307. //
  308. // Cancellation Id - Optional - See WebAuthNGetCancellationId
  309. GUID *pCancellationId;
  310. //
  311. // The following fields have been added in WEBAUTHN_AUTHENTICATOR_MAKE_CREDENTIAL_OPTIONS_VERSION_3
  312. //
  313. // Exclude Credential List. If present, "CredentialList" will be ignored.
  314. PWEBAUTHN_CREDENTIAL_LIST pExcludeCredentialList;
  315. } WEBAUTHN_AUTHENTICATOR_MAKE_CREDENTIAL_OPTIONS, *PWEBAUTHN_AUTHENTICATOR_MAKE_CREDENTIAL_OPTIONS;
  316. typedef const WEBAUTHN_AUTHENTICATOR_MAKE_CREDENTIAL_OPTIONS *PCWEBAUTHN_AUTHENTICATOR_MAKE_CREDENTIAL_OPTIONS;
  317. #define WEBAUTHN_AUTHENTICATOR_GET_ASSERTION_OPTIONS_VERSION_1 1
  318. #define WEBAUTHN_AUTHENTICATOR_GET_ASSERTION_OPTIONS_VERSION_2 2
  319. #define WEBAUTHN_AUTHENTICATOR_GET_ASSERTION_OPTIONS_VERSION_3 3
  320. #define WEBAUTHN_AUTHENTICATOR_GET_ASSERTION_OPTIONS_VERSION_4 4
  321. #define WEBAUTHN_AUTHENTICATOR_GET_ASSERTION_OPTIONS_CURRENT_VERSION WEBAUTHN_AUTHENTICATOR_GET_ASSERTION_OPTIONS_VERSION_4
  322. typedef struct _WEBAUTHN_AUTHENTICATOR_GET_ASSERTION_OPTIONS {
  323. // Version of this structure, to allow for modifications in the future.
  324. DWORD dwVersion;
  325. // Time that the operation is expected to complete within.
  326. // This is used as guidance, and can be overridden by the platform.
  327. DWORD dwTimeoutMilliseconds;
  328. // Allowed Credentials List.
  329. WEBAUTHN_CREDENTIALS CredentialList;
  330. // Optional extensions to parse when performing the operation.
  331. WEBAUTHN_EXTENSIONS Extensions;
  332. // Optional. Platform vs Cross-Platform Authenticators.
  333. DWORD dwAuthenticatorAttachment;
  334. // User Verification Requirement.
  335. DWORD dwUserVerificationRequirement;
  336. // Reserved for future Use
  337. DWORD dwFlags;
  338. //
  339. // The following fields have been added in WEBAUTHN_AUTHENTICATOR_GET_ASSERTION_OPTIONS_VERSION_2
  340. //
  341. // Optional identifier for the U2F AppId. Converted to UTF8 before being hashed. Not lower cased.
  342. PCWSTR pwszU2fAppId;
  343. // If the following is non-NULL, then, set to TRUE if the above pwszU2fAppid was used instead of
  344. // PCWSTR pwszRpId;
  345. BOOL *pbU2fAppId;
  346. //
  347. // The following fields have been added in WEBAUTHN_AUTHENTICATOR_GET_ASSERTION_OPTIONS_VERSION_3
  348. //
  349. // Cancellation Id - Optional - See WebAuthNGetCancellationId
  350. GUID *pCancellationId;
  351. //
  352. // The following fields have been added in WEBAUTHN_AUTHENTICATOR_GET_ASSERTION_OPTIONS_VERSION_4
  353. //
  354. // Allow Credential List. If present, "CredentialList" will be ignored.
  355. PWEBAUTHN_CREDENTIAL_LIST pAllowCredentialList;
  356. } WEBAUTHN_AUTHENTICATOR_GET_ASSERTION_OPTIONS, *PWEBAUTHN_AUTHENTICATOR_GET_ASSERTION_OPTIONS;
  357. typedef const WEBAUTHN_AUTHENTICATOR_GET_ASSERTION_OPTIONS *PCWEBAUTHN_AUTHENTICATOR_GET_ASSERTION_OPTIONS;
  358. //+------------------------------------------------------------------------------------------
  359. // Attestation Info.
  360. //
  361. //-------------------------------------------------------------------------------------------
  362. #define WEBAUTHN_ATTESTATION_DECODE_NONE 0
  363. #define WEBAUTHN_ATTESTATION_DECODE_COMMON 1
  364. // WEBAUTHN_ATTESTATION_DECODE_COMMON supports format types
  365. // L"packed"
  366. // L"fido-u2f"
  367. #define WEBAUTHN_ATTESTATION_VER_TPM_2_0 L"2.0"
  368. typedef struct _WEBAUTHN_X5C {
  369. // Length of X.509 encoded certificate
  370. DWORD cbData;
  371. // X.509 encoded certificate bytes
  372. _Field_size_bytes_(cbData)
  373. PBYTE pbData;
  374. } WEBAUTHN_X5C, *PWEBAUTHN_X5C;
  375. // Supports either Self or Full Basic Attestation
  376. // Note, new fields will be added to the following data structure to
  377. // support additional attestation format types, such as, TPM.
  378. // When fields are added, the dwVersion will be incremented.
  379. //
  380. // Therefore, your code must make the following check:
  381. // "if (dwVersion >= WEBAUTHN_COMMON_ATTESTATION_CURRENT_VERSION)"
  382. #define WEBAUTHN_COMMON_ATTESTATION_CURRENT_VERSION 1
  383. typedef struct _WEBAUTHN_COMMON_ATTESTATION {
  384. // Version of this structure, to allow for modifications in the future.
  385. DWORD dwVersion;
  386. // Hash and Padding Algorithm
  387. //
  388. // The following won't be set for "fido-u2f" which assumes "ES256".
  389. PCWSTR pwszAlg;
  390. LONG lAlg; // COSE algorithm
  391. // Signature that was generated for this attestation.
  392. DWORD cbSignature;
  393. _Field_size_bytes_(cbSignature)
  394. PBYTE pbSignature;
  395. // Following is set for Full Basic Attestation. If not, set then, this is Self Attestation.
  396. // Array of X.509 DER encoded certificates. The first certificate is the signer, leaf certificate.
  397. DWORD cX5c;
  398. _Field_size_(cX5c)
  399. PWEBAUTHN_X5C pX5c;
  400. // Following are also set for tpm
  401. PCWSTR pwszVer; // L"2.0"
  402. DWORD cbCertInfo;
  403. _Field_size_bytes_(cbCertInfo)
  404. PBYTE pbCertInfo;
  405. DWORD cbPubArea;
  406. _Field_size_bytes_(cbPubArea)
  407. PBYTE pbPubArea;
  408. } WEBAUTHN_COMMON_ATTESTATION, *PWEBAUTHN_COMMON_ATTESTATION;
  409. typedef const WEBAUTHN_COMMON_ATTESTATION *PCWEBAUTHN_COMMON_ATTESTATION;
  410. #define WEBAUTHN_ATTESTATION_TYPE_PACKED L"packed"
  411. #define WEBAUTHN_ATTESTATION_TYPE_U2F L"fido-u2f"
  412. #define WEBAUTHN_ATTESTATION_TYPE_TPM L"tpm"
  413. #define WEBAUTHN_ATTESTATION_TYPE_NONE L"none"
  414. #define WEBAUTHN_CREDENTIAL_ATTESTATION_VERSION_1 1
  415. #define WEBAUTHN_CREDENTIAL_ATTESTATION_VERSION_2 2
  416. #define WEBAUTHN_CREDENTIAL_ATTESTATION_VERSION_3 3
  417. #define WEBAUTHN_CREDENTIAL_ATTESTATION_CURRENT_VERSION WEBAUTHN_CREDENTIAL_ATTESTATION_VERSION_3
  418. typedef struct _WEBAUTHN_CREDENTIAL_ATTESTATION {
  419. // Version of this structure, to allow for modifications in the future.
  420. DWORD dwVersion;
  421. // Attestation format type
  422. PCWSTR pwszFormatType;
  423. // Size of cbAuthenticatorData.
  424. DWORD cbAuthenticatorData;
  425. // Authenticator data that was created for this credential.
  426. _Field_size_bytes_(cbAuthenticatorData)
  427. PBYTE pbAuthenticatorData;
  428. // Size of CBOR encoded attestation information
  429. //0 => encoded as CBOR null value.
  430. DWORD cbAttestation;
  431. //Encoded CBOR attestation information
  432. _Field_size_bytes_(cbAttestation)
  433. PBYTE pbAttestation;
  434. DWORD dwAttestationDecodeType;
  435. // Following depends on the dwAttestationDecodeType
  436. // WEBAUTHN_ATTESTATION_DECODE_NONE
  437. // NULL - not able to decode the CBOR attestation information
  438. // WEBAUTHN_ATTESTATION_DECODE_COMMON
  439. // PWEBAUTHN_COMMON_ATTESTATION;
  440. PVOID pvAttestationDecode;
  441. // The CBOR encoded Attestation Object to be returned to the RP.
  442. DWORD cbAttestationObject;
  443. _Field_size_bytes_(cbAttestationObject)
  444. PBYTE pbAttestationObject;
  445. // The CredentialId bytes extracted from the Authenticator Data.
  446. // Used by Edge to return to the RP.
  447. DWORD cbCredentialId;
  448. _Field_size_bytes_(cbCredentialId)
  449. PBYTE pbCredentialId;
  450. //
  451. // Following fields have been added in WEBAUTHN_CREDENTIAL_ATTESTATION_VERSION_2
  452. //
  453. WEBAUTHN_EXTENSIONS Extensions;
  454. //
  455. // Following fields have been added in WEBAUTHN_CREDENTIAL_ATTESTATION_VERSION_3
  456. //
  457. // One of the WEBAUTHN_CTAP_TRANSPORT_* bits will be set corresponding to
  458. // the transport that was used.
  459. DWORD dwUsedTransport;
  460. } WEBAUTHN_CREDENTIAL_ATTESTATION, *PWEBAUTHN_CREDENTIAL_ATTESTATION;
  461. typedef const WEBAUTHN_CREDENTIAL_ATTESTATION *PCWEBAUTHN_CREDENTIAL_ATTESTATION;
  462. //+------------------------------------------------------------------------------------------
  463. // authenticatorGetAssertion output.
  464. //-------------------------------------------------------------------------------------------
  465. #define WEBAUTHN_ASSERTION_CURRENT_VERSION 1
  466. typedef struct _WEBAUTHN_ASSERTION {
  467. // Version of this structure, to allow for modifications in the future.
  468. DWORD dwVersion;
  469. // Size of cbAuthenticatorData.
  470. DWORD cbAuthenticatorData;
  471. // Authenticator data that was created for this assertion.
  472. _Field_size_bytes_(cbAuthenticatorData)
  473. PBYTE pbAuthenticatorData;
  474. // Size of pbSignature.
  475. DWORD cbSignature;
  476. // Signature that was generated for this assertion.
  477. _Field_size_bytes_(cbSignature)
  478. PBYTE pbSignature;
  479. // Credential that was used for this assertion.
  480. WEBAUTHN_CREDENTIAL Credential;
  481. // Size of User Id
  482. DWORD cbUserId;
  483. // UserId
  484. _Field_size_bytes_(cbUserId)
  485. PBYTE pbUserId;
  486. } WEBAUTHN_ASSERTION, *PWEBAUTHN_ASSERTION;
  487. typedef const WEBAUTHN_ASSERTION *PCWEBAUTHN_ASSERTION;
  488. //+------------------------------------------------------------------------------------------
  489. // APIs.
  490. //-------------------------------------------------------------------------------------------
  491. DWORD
  492. WINAPI
  493. WebAuthNGetApiVersionNumber();
  494. HRESULT
  495. WINAPI
  496. WebAuthNIsUserVerifyingPlatformAuthenticatorAvailable(
  497. _Out_ BOOL *pbIsUserVerifyingPlatformAuthenticatorAvailable);
  498. HRESULT
  499. WINAPI
  500. WebAuthNAuthenticatorMakeCredential(
  501. _In_ HWND hWnd,
  502. _In_ PCWEBAUTHN_RP_ENTITY_INFORMATION pRpInformation,
  503. _In_ PCWEBAUTHN_USER_ENTITY_INFORMATION pUserInformation,
  504. _In_ PCWEBAUTHN_COSE_CREDENTIAL_PARAMETERS pPubKeyCredParams,
  505. _In_ PCWEBAUTHN_CLIENT_DATA pWebAuthNClientData,
  506. _In_opt_ PCWEBAUTHN_AUTHENTICATOR_MAKE_CREDENTIAL_OPTIONS pWebAuthNMakeCredentialOptions,
  507. _Outptr_result_maybenull_ PWEBAUTHN_CREDENTIAL_ATTESTATION *ppWebAuthNCredentialAttestation);
  508. HRESULT
  509. WINAPI
  510. WebAuthNAuthenticatorGetAssertion(
  511. _In_ HWND hWnd,
  512. _In_ LPCWSTR pwszRpId,
  513. _In_ PCWEBAUTHN_CLIENT_DATA pWebAuthNClientData,
  514. _In_opt_ PCWEBAUTHN_AUTHENTICATOR_GET_ASSERTION_OPTIONS pWebAuthNGetAssertionOptions,
  515. _Outptr_result_maybenull_ PWEBAUTHN_ASSERTION *ppWebAuthNAssertion);
  516. void
  517. WINAPI
  518. WebAuthNFreeCredentialAttestation(
  519. _In_opt_ PWEBAUTHN_CREDENTIAL_ATTESTATION pWebAuthNCredentialAttestation);
  520. void
  521. WINAPI
  522. WebAuthNFreeAssertion(
  523. _In_ PWEBAUTHN_ASSERTION pWebAuthNAssertion);
  524. HRESULT
  525. WINAPI
  526. WebAuthNGetCancellationId(
  527. _Out_ GUID* pCancellationId);
  528. HRESULT
  529. WINAPI
  530. WebAuthNCancelCurrentOperation(
  531. _In_ const GUID* pCancellationId);
  532. //
  533. // Returns the following Error Names:
  534. // L"Success" - S_OK
  535. // L"InvalidStateError" - NTE_EXISTS
  536. // L"ConstraintError" - HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED),
  537. // NTE_NOT_SUPPORTED,
  538. // NTE_TOKEN_KEYSET_STORAGE_FULL
  539. // L"NotSupportedError" - NTE_INVALID_PARAMETER
  540. // L"NotAllowedError" - NTE_DEVICE_NOT_FOUND,
  541. // NTE_NOT_FOUND,
  542. // HRESULT_FROM_WIN32(ERROR_CANCELLED),
  543. // NTE_USER_CANCELLED,
  544. // HRESULT_FROM_WIN32(ERROR_TIMEOUT)
  545. // L"UnknownError" - All other hr values
  546. //
  547. PCWSTR
  548. WINAPI
  549. WebAuthNGetErrorName(
  550. _In_ HRESULT hr);
  551. HRESULT
  552. WINAPI
  553. WebAuthNGetW3CExceptionDOMError(
  554. _In_ HRESULT hr);
  555. #ifdef __cplusplus
  556. } // Balance extern "C" above
  557. #endif
  558. #endif // WINAPI_FAMILY_PARTITION
  559. #pragma endregion
  560. #endif // __WEBAUTHN_H_