1*2ccfa855SEd Maste.\" Copyright (c) 2018-2022 Yubico AB. All rights reserved. 20afa8e06SEd Maste.\" 3*2ccfa855SEd Maste.\" Redistribution and use in source and binary forms, with or without 4*2ccfa855SEd Maste.\" modification, are permitted provided that the following conditions are 5*2ccfa855SEd Maste.\" met: 6*2ccfa855SEd Maste.\" 7*2ccfa855SEd Maste.\" 1. Redistributions of source code must retain the above copyright 8*2ccfa855SEd Maste.\" notice, this list of conditions and the following disclaimer. 9*2ccfa855SEd Maste.\" 2. Redistributions in binary form must reproduce the above copyright 10*2ccfa855SEd Maste.\" notice, this list of conditions and the following disclaimer in 11*2ccfa855SEd Maste.\" the documentation and/or other materials provided with the 12*2ccfa855SEd Maste.\" distribution. 13*2ccfa855SEd Maste.\" 14*2ccfa855SEd Maste.\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 15*2ccfa855SEd Maste.\" "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 16*2ccfa855SEd Maste.\" LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 17*2ccfa855SEd Maste.\" A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 18*2ccfa855SEd Maste.\" HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 19*2ccfa855SEd Maste.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 20*2ccfa855SEd Maste.\" LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21*2ccfa855SEd Maste.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22*2ccfa855SEd Maste.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23*2ccfa855SEd Maste.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 24*2ccfa855SEd Maste.\" OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25*2ccfa855SEd Maste.\" 26*2ccfa855SEd Maste.\" SPDX-License-Identifier: BSD-2-Clause 27*2ccfa855SEd Maste.\" 28*2ccfa855SEd Maste.Dd $Mdocdate: July 15 2022 $ 290afa8e06SEd Maste.Dt FIDO_CRED_SET_AUTHDATA 3 300afa8e06SEd Maste.Os 310afa8e06SEd Maste.Sh NAME 320afa8e06SEd Maste.Nm fido_cred_set_authdata , 330afa8e06SEd Maste.Nm fido_cred_set_authdata_raw , 34f540a430SEd Maste.Nm fido_cred_set_attstmt , 350afa8e06SEd Maste.Nm fido_cred_set_x509 , 360afa8e06SEd Maste.Nm fido_cred_set_sig , 370afa8e06SEd Maste.Nm fido_cred_set_id , 380afa8e06SEd Maste.Nm fido_cred_set_clientdata , 390afa8e06SEd Maste.Nm fido_cred_set_clientdata_hash , 400afa8e06SEd Maste.Nm fido_cred_set_rp , 410afa8e06SEd Maste.Nm fido_cred_set_user , 420afa8e06SEd Maste.Nm fido_cred_set_extensions , 430afa8e06SEd Maste.Nm fido_cred_set_blob , 44f540a430SEd Maste.Nm fido_cred_set_pin_minlen , 450afa8e06SEd Maste.Nm fido_cred_set_prot , 460afa8e06SEd Maste.Nm fido_cred_set_rk , 470afa8e06SEd Maste.Nm fido_cred_set_uv , 480afa8e06SEd Maste.Nm fido_cred_set_fmt , 490afa8e06SEd Maste.Nm fido_cred_set_type 500afa8e06SEd Maste.Nd set parameters of a FIDO2 credential 510afa8e06SEd Maste.Sh SYNOPSIS 520afa8e06SEd Maste.In fido.h 530afa8e06SEd Maste.Bd -literal 540afa8e06SEd Mastetypedef enum { 550afa8e06SEd Maste FIDO_OPT_OMIT = 0, /* use authenticator's default */ 560afa8e06SEd Maste FIDO_OPT_FALSE, /* explicitly set option to false */ 570afa8e06SEd Maste FIDO_OPT_TRUE, /* explicitly set option to true */ 580afa8e06SEd Maste} fido_opt_t; 590afa8e06SEd Maste.Ed 600afa8e06SEd Maste.Ft int 610afa8e06SEd Maste.Fn fido_cred_set_authdata "fido_cred_t *cred" "const unsigned char *ptr" "size_t len" 620afa8e06SEd Maste.Ft int 630afa8e06SEd Maste.Fn fido_cred_set_authdata_raw "fido_cred_t *cred" "const unsigned char *ptr" "size_t len" 640afa8e06SEd Maste.Ft int 65f540a430SEd Maste.Fn fido_cred_set_attstmt "fido_cred_t *cred" "const unsigned char *ptr" "size_t len" 66f540a430SEd Maste.Ft int 670afa8e06SEd Maste.Fn fido_cred_set_x509 "fido_cred_t *cred" "const unsigned char *ptr" "size_t len" 680afa8e06SEd Maste.Ft int 690afa8e06SEd Maste.Fn fido_cred_set_sig "fido_cred_t *cred" "const unsigned char *ptr" "size_t len" 700afa8e06SEd Maste.Ft int 710afa8e06SEd Maste.Fn fido_cred_set_id "fido_cred_t *cred" "const unsigned char *ptr" "size_t len" 720afa8e06SEd Maste.Ft int 730afa8e06SEd Maste.Fn fido_cred_set_clientdata "fido_cred_t *cred" "const unsigned char *ptr" "size_t len" 740afa8e06SEd Maste.Ft int 750afa8e06SEd Maste.Fn fido_cred_set_clientdata_hash "fido_cred_t *cred" "const unsigned char *ptr" "size_t len" 760afa8e06SEd Maste.Ft int 770afa8e06SEd Maste.Fn fido_cred_set_rp "fido_cred_t *cred" "const char *id" "const char *name" 780afa8e06SEd Maste.Ft int 790afa8e06SEd Maste.Fn fido_cred_set_user "fido_cred_t *cred" "const unsigned char *user_id" "size_t user_id_len" "const char *name" "const char *display_name" "const char *icon" 800afa8e06SEd Maste.Ft int 810afa8e06SEd Maste.Fn fido_cred_set_extensions "fido_cred_t *cred" "int flags" 820afa8e06SEd Maste.Ft int 830afa8e06SEd Maste.Fn fido_cred_set_blob "fido_cred_t *cred" "const unsigned char *ptr" "size_t len" 840afa8e06SEd Maste.Ft int 85f540a430SEd Maste.Fn fido_cred_set_pin_minlen "fido_cred_t *cred" "size_t len" 86f540a430SEd Maste.Ft int 870afa8e06SEd Maste.Fn fido_cred_set_prot "fido_cred_t *cred" "int prot" 880afa8e06SEd Maste.Ft int 890afa8e06SEd Maste.Fn fido_cred_set_rk "fido_cred_t *cred" "fido_opt_t rk" 900afa8e06SEd Maste.Ft int 910afa8e06SEd Maste.Fn fido_cred_set_uv "fido_cred_t *cred" "fido_opt_t uv" 920afa8e06SEd Maste.Ft int 930afa8e06SEd Maste.Fn fido_cred_set_fmt "fido_cred_t *cred" "const char *ptr" 940afa8e06SEd Maste.Ft int 950afa8e06SEd Maste.Fn fido_cred_set_type "fido_cred_t *cred" "int cose_alg" 960afa8e06SEd Maste.Sh DESCRIPTION 970afa8e06SEd MasteThe 980afa8e06SEd Maste.Nm 990afa8e06SEd Masteset of functions define the various parameters of a FIDO2 1000afa8e06SEd Mastecredential, allowing a 1010afa8e06SEd Maste.Fa fido_cred_t 1020afa8e06SEd Mastetype to be prepared for a subsequent call to 1030afa8e06SEd Maste.Xr fido_dev_make_cred 3 1040afa8e06SEd Masteor 1050afa8e06SEd Maste.Xr fido_cred_verify 3 . 1060afa8e06SEd MasteFor the complete specification of a FIDO2 credential and the format 1070afa8e06SEd Masteof its constituent parts, please refer to the Web Authentication 1080afa8e06SEd Maste(webauthn) standard. 1090afa8e06SEd Maste.Pp 1100afa8e06SEd MasteThe 1110afa8e06SEd Maste.Fn fido_cred_set_authdata , 112f540a430SEd Maste.Fn fido_cred_set_attstmt , 1130afa8e06SEd Maste.Fn fido_cred_set_x509 , 1140afa8e06SEd Maste.Fn fido_cred_set_sig , 1150afa8e06SEd Maste.Fn fido_cred_set_id , 1160afa8e06SEd Masteand 1170afa8e06SEd Maste.Fn fido_cred_set_clientdata_hash 118f540a430SEd Mastefunctions set the authenticator data, attestation statement, 119f540a430SEd Masteattestation certificate, attestation signature, id, and client 120f540a430SEd Mastedata hash parts of 1210afa8e06SEd Maste.Fa cred 1220afa8e06SEd Masteto 1230afa8e06SEd Maste.Fa ptr , 1240afa8e06SEd Mastewhere 1250afa8e06SEd Maste.Fa ptr 1260afa8e06SEd Mastepoints to 1270afa8e06SEd Maste.Fa len 1280afa8e06SEd Mastebytes. 1290afa8e06SEd MasteA copy of 1300afa8e06SEd Maste.Fa ptr 1310afa8e06SEd Masteis made, and no references to the passed pointer are kept. 132f540a430SEd Maste.Pp 1330afa8e06SEd MasteThe authenticator data passed to 1340afa8e06SEd Maste.Fn fido_cred_set_authdata 1350afa8e06SEd Mastemust be a CBOR-encoded byte string, as obtained from 1360afa8e06SEd Maste.Fn fido_cred_authdata_ptr . 1370afa8e06SEd MasteAlternatively, a raw binary blob may be passed to 1380afa8e06SEd Maste.Fn fido_cred_set_authdata_raw . 1390afa8e06SEd MasteAn application calling 1400afa8e06SEd Maste.Fn fido_cred_set_authdata 1410afa8e06SEd Mastedoes not need to call 1420afa8e06SEd Maste.Fn fido_cred_set_id . 1430afa8e06SEd MasteThe latter is meant to be used in contexts where the 1440afa8e06SEd Mastecredential's authenticator data is not available. 1450afa8e06SEd Maste.Pp 146f540a430SEd MasteThe attestation statement passed to 147f540a430SEd Maste.Fn fido_cred_set_attstmt 148f540a430SEd Mastemust be a CBOR-encoded map, as obtained from 149f540a430SEd Maste.Fn fido_cred_attstmt_ptr . 150f540a430SEd MasteAn application calling 151f540a430SEd Maste.Fn fido_cred_set_attstmt 152f540a430SEd Mastedoes not need to call 153f540a430SEd Maste.Fn fido_cred_set_x509 154f540a430SEd Masteor 155f540a430SEd Maste.Fn fido_cred_set_sig . 156f540a430SEd MasteThe latter two are meant to be used in contexts where the 157f540a430SEd Mastecredential's complete attestation statement is not available or 158f540a430SEd Masterequired. 159f540a430SEd Maste.Pp 1600afa8e06SEd MasteThe 1610afa8e06SEd Maste.Fn fido_cred_set_clientdata 1620afa8e06SEd Mastefunction allows an application to set the client data hash of 1630afa8e06SEd Maste.Fa cred 1640afa8e06SEd Masteby specifying the credential's unhashed client data. 1650afa8e06SEd MasteThis is required by Windows Hello, which calculates the client data 1660afa8e06SEd Mastehash internally. 1670afa8e06SEd MasteFor compatibility with Windows Hello, applications should use 1680afa8e06SEd Maste.Fn fido_cred_set_clientdata 1690afa8e06SEd Masteinstead of 1700afa8e06SEd Maste.Fn fido_cred_set_clientdata_hash . 1710afa8e06SEd Maste.Pp 1720afa8e06SEd MasteThe 1730afa8e06SEd Maste.Fn fido_cred_set_rp 1740afa8e06SEd Mastefunction sets the relying party 1750afa8e06SEd Maste.Fa id 1760afa8e06SEd Masteand 1770afa8e06SEd Maste.Fa name 1780afa8e06SEd Masteparameters of 1790afa8e06SEd Maste.Fa cred , 1800afa8e06SEd Mastewhere 1810afa8e06SEd Maste.Fa id 1820afa8e06SEd Masteand 1830afa8e06SEd Maste.Fa name 1840afa8e06SEd Masteare NUL-terminated UTF-8 strings. 1850afa8e06SEd MasteThe contents of 1860afa8e06SEd Maste.Fa id 1870afa8e06SEd Masteand 1880afa8e06SEd Maste.Fa name 1890afa8e06SEd Masteare copied, and no references to the passed pointers are kept. 1900afa8e06SEd Maste.Pp 1910afa8e06SEd MasteThe 1920afa8e06SEd Maste.Fn fido_cred_set_user 1930afa8e06SEd Mastefunction sets the user attributes of 1940afa8e06SEd Maste.Fa cred , 1950afa8e06SEd Mastewhere 1960afa8e06SEd Maste.Fa user_id 1970afa8e06SEd Mastepoints to 1980afa8e06SEd Maste.Fa user_id_len 1990afa8e06SEd Mastebytes and 2000afa8e06SEd Maste.Fa name , 2010afa8e06SEd Maste.Fa display_name , 2020afa8e06SEd Masteand 2030afa8e06SEd Maste.Fa icon 2040afa8e06SEd Masteare NUL-terminated UTF-8 strings. 2050afa8e06SEd MasteThe contents of 2060afa8e06SEd Maste.Fa user_id , 2070afa8e06SEd Maste.Fa name , 2080afa8e06SEd Maste.Fa display_name , 2090afa8e06SEd Masteand 2100afa8e06SEd Maste.Fa icon 2110afa8e06SEd Masteare copied, and no references to the passed pointers are kept. 2120afa8e06SEd MastePreviously set user attributes are flushed. 2130afa8e06SEd MasteThe 2140afa8e06SEd Maste.Fa user_id , 2150afa8e06SEd Maste.Fa name , 2160afa8e06SEd Maste.Fa display_name , 2170afa8e06SEd Masteand 2180afa8e06SEd Maste.Fa icon 2190afa8e06SEd Masteparameters may be NULL. 2200afa8e06SEd Maste.Pp 2210afa8e06SEd MasteThe 2220afa8e06SEd Maste.Fn fido_cred_set_extensions 2230afa8e06SEd Mastefunction sets the extensions of 2240afa8e06SEd Maste.Fa cred 2250afa8e06SEd Masteto the bitmask 2260afa8e06SEd Maste.Fa flags . 2270afa8e06SEd MasteAt the moment, only the 2280afa8e06SEd Maste.Dv FIDO_EXT_CRED_BLOB , 2290afa8e06SEd Maste.Dv FIDO_EXT_CRED_PROTECT , 2300afa8e06SEd Maste.Dv FIDO_EXT_HMAC_SECRET , 231f540a430SEd Maste.Dv FIDO_EXT_MINPINLEN , 2320afa8e06SEd Masteand 2330afa8e06SEd Maste.Dv FIDO_EXT_LARGEBLOB_KEY 2340afa8e06SEd Masteextensions are supported. 2350afa8e06SEd MasteIf 2360afa8e06SEd Maste.Fa flags 2370afa8e06SEd Masteis zero, the extensions of 2380afa8e06SEd Maste.Fa cred 2390afa8e06SEd Masteare cleared. 2400afa8e06SEd Maste.Pp 2410afa8e06SEd MasteThe 2420afa8e06SEd Maste.Fn fido_cred_set_blob 2430afa8e06SEd Mastefunction sets the 2440afa8e06SEd Maste.Dq credBlob 2450afa8e06SEd Masteto be stored with 2460afa8e06SEd Maste.Fa cred 2470afa8e06SEd Masteto the data pointed to by 2480afa8e06SEd Maste.Fa ptr , 2490afa8e06SEd Mastewhich must be 2500afa8e06SEd Maste.Fa len 2510afa8e06SEd Mastebytes long. 2520afa8e06SEd Maste.Pp 2530afa8e06SEd MasteThe 254f540a430SEd Maste.Fn fido_cred_set_pin_minlen 2553e696dfbSEd Mastefunction enables the CTAP 2.1 256f540a430SEd Maste.Dv FIDO_EXT_MINPINLEN 257f540a430SEd Masteextension on 258f540a430SEd Maste.Fa cred 259f540a430SEd Masteand sets the expected minimum PIN length of 260f540a430SEd Maste.Fa cred 261f540a430SEd Masteto 262f540a430SEd Maste.Fa len , 263f540a430SEd Mastewhere 264f540a430SEd Maste.Fa len 265f540a430SEd Masteis greater than zero. 266f540a430SEd MasteIf 267f540a430SEd Maste.Fa len 268f540a430SEd Masteis zero, the 269f540a430SEd Maste.Dv FIDO_EXT_MINPINLEN 270f540a430SEd Masteextension is disabled on 271f540a430SEd Maste.Fa cred . 272f540a430SEd Maste.Pp 273f540a430SEd MasteThe 2740afa8e06SEd Maste.Fn fido_cred_set_prot 2753e696dfbSEd Mastefunction enables the CTAP 2.1 276f540a430SEd Maste.Dv FIDO_EXT_CRED_PROTECT 277f540a430SEd Masteextension on 278f540a430SEd Maste.Fa cred 279f540a430SEd Masteand sets the protection of 2800afa8e06SEd Maste.Fa cred 2810afa8e06SEd Masteto the scalar 2820afa8e06SEd Maste.Fa prot . 2830afa8e06SEd MasteAt the moment, only the 2840afa8e06SEd Maste.Dv FIDO_CRED_PROT_UV_OPTIONAL , 2850afa8e06SEd Maste.Dv FIDO_CRED_PROT_UV_OPTIONAL_WITH_ID , 2860afa8e06SEd Masteand 2870afa8e06SEd Maste.Dv FIDO_CRED_PROT_UV_REQUIRED 2880afa8e06SEd Masteprotections are supported. 2890afa8e06SEd MasteIf 2900afa8e06SEd Maste.Fa prot 2910afa8e06SEd Masteis zero, the protection of 2920afa8e06SEd Maste.Fa cred 2930afa8e06SEd Masteis cleared. 2940afa8e06SEd Maste.Pp 2950afa8e06SEd MasteThe 2960afa8e06SEd Maste.Fn fido_cred_set_rk 2970afa8e06SEd Masteand 2980afa8e06SEd Maste.Fn fido_cred_set_uv 2990afa8e06SEd Mastefunctions set the 3000afa8e06SEd Maste.Em rk 3010afa8e06SEd Maste.Pq resident/discoverable key 3020afa8e06SEd Masteand 3030afa8e06SEd Maste.Em uv 3040afa8e06SEd Maste.Pq user verification 3050afa8e06SEd Masteattributes of 3060afa8e06SEd Maste.Fa cred . 3070afa8e06SEd MasteBoth are 3080afa8e06SEd Maste.Dv FIDO_OPT_OMIT 3090afa8e06SEd Masteby default, allowing the authenticator to use its default settings. 3100afa8e06SEd Maste.Pp 3110afa8e06SEd MasteThe 3120afa8e06SEd Maste.Fn fido_cred_set_fmt 313*2ccfa855SEd Mastefunction sets the attestation statement format identifier of 3140afa8e06SEd Maste.Fa cred 3150afa8e06SEd Masteto 3160afa8e06SEd Maste.Fa fmt , 3170afa8e06SEd Mastewhere 3180afa8e06SEd Maste.Fa fmt 3190afa8e06SEd Mastemust be 3200afa8e06SEd Maste.Vt "packed" 3210afa8e06SEd Maste.Pq the format used in FIDO2 , 3220afa8e06SEd Maste.Vt "fido-u2f" 323*2ccfa855SEd Maste.Pq the format used in U2F , 324*2ccfa855SEd Maste.Vt "tpm" 325*2ccfa855SEd Maste.Pq the format used by TPM-based authenticators , 3260afa8e06SEd Masteor 3270afa8e06SEd Maste.Vt "none" . 3280afa8e06SEd MasteA copy of 3290afa8e06SEd Maste.Fa fmt 3300afa8e06SEd Masteis made, and no references to the passed pointer are kept. 331*2ccfa855SEd MasteNote that not all authenticators support FIDO2 and therefore may only 3320afa8e06SEd Mastebe able to generate 333*2ccfa855SEd Maste.Vt fido-u2f 334*2ccfa855SEd Masteattestation statements. 3350afa8e06SEd Maste.Pp 3360afa8e06SEd MasteThe 3370afa8e06SEd Maste.Fn fido_cred_set_type 3380afa8e06SEd Mastefunction sets the type of 3390afa8e06SEd Maste.Fa cred to 3400afa8e06SEd Maste.Fa cose_alg , 3410afa8e06SEd Mastewhere 3420afa8e06SEd Maste.Fa cose_alg 3430afa8e06SEd Masteis 3440afa8e06SEd Maste.Dv COSE_ES256 , 345*2ccfa855SEd Maste.Dv COSE_ES384 , 3460afa8e06SEd Maste.Dv COSE_RS256 , 3470afa8e06SEd Masteor 3480afa8e06SEd Maste.Dv COSE_EDDSA . 3490afa8e06SEd MasteThe type of a credential may only be set once. 350*2ccfa855SEd MasteNote that not all authenticators support COSE_RS256, COSE_ES384, or 351*2ccfa855SEd MasteCOSE_EDDSA. 3520afa8e06SEd Maste.Pp 3530afa8e06SEd MasteUse of the 3540afa8e06SEd Maste.Nm 3550afa8e06SEd Masteset of functions may happen in two distinct situations: 3563e696dfbSEd Mastewhen generating a new credential on a FIDO2 device, prior to 3570afa8e06SEd Maste.Xr fido_dev_make_cred 3 3583e696dfbSEd Maste(i.e, in the context of a FIDO2 client), or when validating 3590afa8e06SEd Mastea generated credential using 3600afa8e06SEd Maste.Xr fido_cred_verify 3 3613e696dfbSEd Maste(i.e, in the context of a FIDO2 server). 3620afa8e06SEd Maste.Pp 3630afa8e06SEd MasteFor a complete description of the generation of a FIDO2 credential 3640afa8e06SEd Masteand its verification, please refer to the FIDO2 specification. 3650afa8e06SEd MasteA concrete utilisation example of the 3660afa8e06SEd Maste.Nm 3670afa8e06SEd Masteset of functions can be found in the 3680afa8e06SEd Maste.Pa cred.c 3690afa8e06SEd Masteexample shipped with 3700afa8e06SEd Maste.Em libfido2 . 3710afa8e06SEd Maste.Sh RETURN VALUES 3720afa8e06SEd MasteThe error codes returned by the 3730afa8e06SEd Maste.Nm 3740afa8e06SEd Masteset of functions are defined in 3750afa8e06SEd Maste.In fido/err.h . 3760afa8e06SEd MasteOn success, 3770afa8e06SEd Maste.Dv FIDO_OK 3780afa8e06SEd Masteis returned. 3790afa8e06SEd Maste.Sh SEE ALSO 3800afa8e06SEd Maste.Xr fido_cred_exclude 3 , 3810afa8e06SEd Maste.Xr fido_cred_verify 3 , 3820afa8e06SEd Maste.Xr fido_dev_make_cred 3 383