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