xref: /openbsd-src/lib/libfido2/man/fido_assert_set_authdata.3 (revision ab19a69ebe1d1275c01611de862453c36b3d15b9)
1.\" Copyright (c) 2018-2022 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: August 29 2022 $
6.Dt FIDO_ASSERT_SET_AUTHDATA 3
7.Os
8.Sh NAME
9.Nm fido_assert_set_authdata ,
10.Nm fido_assert_set_authdata_raw ,
11.Nm fido_assert_set_clientdata ,
12.Nm fido_assert_set_clientdata_hash ,
13.Nm fido_assert_set_count ,
14.Nm fido_assert_set_extensions ,
15.Nm fido_assert_set_hmac_salt ,
16.Nm fido_assert_set_hmac_secret ,
17.Nm fido_assert_set_up ,
18.Nm fido_assert_set_uv ,
19.Nm fido_assert_set_rp ,
20.Nm fido_assert_set_sig
21.Nd set parameters of a FIDO2 assertion
22.Sh SYNOPSIS
23.In fido.h
24.Bd -literal
25typedef enum {
26	FIDO_OPT_OMIT = 0, /* use authenticator's default */
27	FIDO_OPT_FALSE,    /* explicitly set option to false */
28        FIDO_OPT_TRUE,     /* explicitly set option to true */
29} fido_opt_t;
30.Ed
31.Ft int
32.Fn fido_assert_set_authdata "fido_assert_t *assert" "size_t idx" "const unsigned char *ptr" "size_t len"
33.Ft int
34.Fn fido_assert_set_authdata_raw "fido_assert_t *assert" "size_t idx" "const unsigned char *ptr" "size_t len"
35.Ft int
36.Fn fido_assert_set_clientdata "fido_assert_t *assert" "const unsigned char *ptr" "size_t len"
37.Ft int
38.Fn fido_assert_set_clientdata_hash "fido_assert_t *assert" "const unsigned char *ptr" "size_t len"
39.Ft int
40.Fn fido_assert_set_count "fido_assert_t *assert" "size_t n"
41.Ft int
42.Fn fido_assert_set_extensions "fido_assert_t *assert" "int flags"
43.Ft int
44.Fn fido_assert_set_hmac_salt "fido_assert_t *assert" "const unsigned char *ptr" "size_t len"
45.Ft int
46.Fn fido_assert_set_hmac_secret "fido_assert_t *assert" "size_t idx" "const unsigned char *ptr" "size_t len"
47.Ft int
48.Fn fido_assert_set_up "fido_assert_t *assert" "fido_opt_t up"
49.Ft int
50.Fn fido_assert_set_uv "fido_assert_t *assert" "fido_opt_t uv"
51.Ft int
52.Fn fido_assert_set_rp "fido_assert_t *assert" "const char *id"
53.Ft int
54.Fn fido_assert_set_sig "fido_assert_t *assert" "size_t idx" "const unsigned char *ptr" "size_t len"
55.Sh DESCRIPTION
56The
57.Nm
58set of functions define the various parameters of a FIDO2
59assertion, allowing a
60.Fa fido_assert_t
61type to be prepared for a subsequent call to
62.Xr fido_dev_get_assert 3
63or
64.Xr fido_assert_verify 3 .
65For the complete specification of a FIDO2 assertion and the format
66of its constituent parts, please refer to the Web Authentication
67(webauthn) standard.
68.Pp
69The
70.Fn fido_assert_set_count
71function sets the number of assertion statements in
72.Fa assert
73to
74.Fa n .
75.Pp
76The
77.Fn fido_assert_set_authdata
78and
79.Fn fido_assert_set_sig
80functions set the authenticator data and signature parts of the
81statement with index
82.Fa idx
83of
84.Fa assert
85to
86.Fa ptr ,
87where
88.Fa ptr
89points to
90.Fa len
91bytes.
92A copy of
93.Fa ptr
94is made, and no references to the passed pointer are kept.
95Please note that the first assertion statement of
96.Fa assert
97has an
98.Fa idx
99of
100.Em 0 .
101The authenticator data passed to
102.Fn fido_assert_set_authdata
103must be a CBOR-encoded byte string, as obtained from
104.Fn fido_assert_authdata_ptr .
105Alternatively, a raw binary blob may be passed to
106.Fn fido_assert_set_authdata_raw .
107.Pp
108The
109.Fn fido_assert_set_clientdata_hash
110function sets the client data hash of
111.Fa assert
112to
113.Fa ptr ,
114where
115.Fa ptr
116points to
117.Fa len
118bytes.
119A copy of
120.Fa ptr
121is made, and no references to the passed pointer are kept.
122.Pp
123The
124.Fn fido_assert_set_clientdata
125function allows an application to set the client data hash of
126.Fa assert
127by specifying the assertion's unhashed client data.
128This is required by Windows Hello, which calculates the client data
129hash internally.
130For compatibility with Windows Hello, applications should use
131.Fn fido_assert_set_clientdata
132instead of
133.Fn fido_assert_set_clientdata_hash .
134.Pp
135The
136.Fn fido_assert_set_rp
137function sets the relying party
138.Fa id
139of
140.Fa assert ,
141where
142.Fa id
143is a NUL-terminated UTF-8 string.
144The content of
145.Fa id
146is copied, and no references to the passed pointer are kept.
147.Pp
148The
149.Fn fido_assert_set_extensions
150function sets the extensions of
151.Fa assert
152to the bitmask
153.Fa flags .
154At the moment, only the
155.Dv FIDO_EXT_CRED_BLOB ,
156.Dv FIDO_EXT_HMAC_SECRET ,
157and
158.Dv FIDO_EXT_LARGEBLOB_KEY
159extensions are supported.
160If
161.Fa flags
162is zero, the extensions of
163.Fa assert
164are cleared.
165.Pp
166The
167.Fn fido_assert_set_hmac_salt
168and
169.Fn fido_assert_set_hmac_secret
170functions set the hmac-salt and hmac-secret parts of
171.Fa assert
172to
173.Fa ptr ,
174where
175.Fa ptr
176points to
177.Fa len
178bytes.
179A copy of
180.Fa ptr
181is made, and no references to the passed pointer are kept.
182The HMAC Secret
183.Pq hmac-secret
184Extension is a CTAP 2.0 extension.
185Note that the resulting hmac-secret varies according to whether
186user verification was performed by the authenticator.
187The
188.Fn fido_assert_set_hmac_secret
189function is normally only useful when writing tests.
190.Pp
191The
192.Fn fido_assert_set_up
193and
194.Fn fido_assert_set_uv
195functions set the
196.Fa up
197(user presence) and
198.Fa uv
199(user verification)
200attributes of
201.Fa assert .
202Both are
203.Dv FIDO_OPT_OMIT
204by default, allowing the authenticator to use its default settings.
205.Pp
206Use of the
207.Nm
208set of functions may happen in two distinct situations:
209when asking a FIDO2 device to produce a series of assertion
210statements, prior to
211.Xr fido_dev_get_assert 3
212(i.e, in the context of a FIDO2 client), or when verifying assertion
213statements using
214.Xr fido_assert_verify 3
215(i.e, in the context of a FIDO2 server).
216.Pp
217For a complete description of the generation of a FIDO2 assertion
218and its verification, please refer to the FIDO2 specification.
219An example of how to use the
220.Nm
221set of functions can be found in the
222.Pa examples/assert.c
223file shipped with
224.Em libfido2 .
225.Sh RETURN VALUES
226The
227.Nm
228functions return
229.Dv FIDO_OK
230on success.
231The error codes returned by the
232.Nm
233set of functions are defined in
234.In fido/err.h .
235.Sh SEE ALSO
236.Xr fido_assert_allow_cred 3 ,
237.Xr fido_assert_verify 3 ,
238.Xr fido_dev_get_assert 3
239