1.\" Copyright (c) 2018 Yubico AB. All rights reserved. 2.\" Use of this source code is governed by a BSD-style 3.\" license that can be found in the LICENSE file. 4.\" 5.Dd $Mdocdate: February 7 2020 $ 6.Dt FIDO_DEV_OPEN 3 7.Os 8.Sh NAME 9.Nm fido_dev_open , 10.Nm fido_dev_close , 11.Nm fido_dev_cancel , 12.Nm fido_dev_new , 13.Nm fido_dev_free , 14.Nm fido_dev_force_fido2 , 15.Nm fido_dev_force_u2f , 16.Nm fido_dev_is_fido2 , 17.Nm fido_dev_protocol , 18.Nm fido_dev_build , 19.Nm fido_dev_flags , 20.Nm fido_dev_major , 21.Nm fido_dev_minor 22.Nd FIDO 2 device open/close and related functions 23.Sh SYNOPSIS 24.In fido.h 25.Ft int 26.Fn fido_dev_open "fido_dev_t *dev" "const char *path" 27.Ft int 28.Fn fido_dev_close "fido_dev_t *dev" 29.Ft int 30.Fn fido_dev_cancel "fido_dev_t *dev" 31.Ft fido_dev_t * 32.Fn fido_dev_new "void" 33.Ft void 34.Fn fido_dev_free "fido_dev_t **dev_p" 35.Ft void 36.Fn fido_dev_force_fido2 "fido_dev_t *dev" 37.Ft void 38.Fn fido_dev_force_u2f "fido_dev_t *dev" 39.Ft bool 40.Fn fido_dev_is_fido2 "const fido_dev_t *dev" 41.Ft uint8_t 42.Fn fido_dev_protocol "const fido_dev_t *dev" 43.Ft uint8_t 44.Fn fido_dev_build "const fido_dev_t *dev" 45.Ft uint8_t 46.Fn fido_dev_flags "const fido_dev_t *dev" 47.Ft uint8_t 48.Fn fido_dev_major "const fido_dev_t *dev" 49.Ft uint8_t 50.Fn fido_dev_minor "const fido_dev_t *dev" 51.Sh DESCRIPTION 52The 53.Fn fido_dev_open 54function opens the device pointed to by 55.Fa path , 56where 57.Fa dev 58is a freshly allocated or otherwise closed 59.Vt fido_dev_t . 60.Pp 61The 62.Fn fido_dev_close 63function closes the device represented by 64.Fa dev . 65If 66.Fa dev 67is already closed, 68.Fn fido_dev_close 69is a NOP. 70.Pp 71The 72.Fn fido_dev_cancel 73function cancels any pending requests on 74.Fa dev . 75.Pp 76The 77.Fn fido_dev_new 78function returns a pointer to a newly allocated, empty 79.Vt fido_dev_t . 80If memory cannot be allocated, NULL is returned. 81.Pp 82The 83.Fn fido_dev_free 84function releases the memory backing 85.Fa *dev_p , 86where 87.Fa *dev_p 88must have been previously allocated by 89.Fn fido_dev_new . 90On return, 91.Fa *dev_p 92is set to NULL. 93Either 94.Fa dev_p 95or 96.Fa *dev_p 97may be NULL, in which case 98.Fn fido_dev_free 99is a NOP. 100.Pp 101The 102.Fn fido_dev_force_fido2 103function can be used to force CTAP2 communication with 104.Fa dev . 105.Pp 106The 107.Fn fido_dev_force_u2f 108function can be used to force CTAP1 (U2F) communication with 109.Fa dev . 110.Pp 111The 112.Fn fido_dev_is_fido2 113function returns 114.Dv true 115if 116.Fa dev 117is a FIDO 2 device. 118.Pp 119The 120.Fn fido_dev_protocol 121function returns the CTAPHID protocol version identifier of 122.Fa dev . 123.Pp 124The 125.Fn fido_dev_build 126function returns the CTAPHID build version number of 127.Fa dev . 128.Pp 129The 130.Fn fido_dev_flags 131function returns the CTAPHID capabilities flags of 132.Fa dev . 133.Pp 134The 135.Fn fido_dev_major 136function returns the CTAPHID major version number of 137.Fa dev . 138.Pp 139The 140.Fn fido_dev_minor 141function returns the CTAPHID minor version number of 142.Fa dev . 143.Pp 144For the format and meaning of the CTAPHID parameters returned by 145functions above, please refer to the FIDO Client to Authenticator 146Protocol (CTAP) specification. 147.Sh RETURN VALUES 148On success, 149.Fn fido_dev_open 150and 151.Fn fido_dev_close 152return 153.Dv FIDO_OK . 154On error, a different error code defined in 155.In fido/err.h 156is returned. 157.Sh SEE ALSO 158.Xr fido_dev_info_manifest 3 , 159.Xr fido_dev_set_io_functions 3 160