xref: /freebsd-src/contrib/libfido2/man/fido_dev_info_manifest.3 (revision 2ccfa855b2fc331819953e3de1b1c15ce5b95a7e)
10afa8e06SEd Maste.\" Copyright (c) 2018 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: March 30 2022 $
290afa8e06SEd Maste.Dt FIDO_DEV_INFO_MANIFEST 3
300afa8e06SEd Maste.Os
310afa8e06SEd Maste.Sh NAME
320afa8e06SEd Maste.Nm fido_dev_info_manifest ,
330afa8e06SEd Maste.Nm fido_dev_info_new ,
340afa8e06SEd Maste.Nm fido_dev_info_free ,
350afa8e06SEd Maste.Nm fido_dev_info_ptr ,
360afa8e06SEd Maste.Nm fido_dev_info_path ,
370afa8e06SEd Maste.Nm fido_dev_info_product ,
380afa8e06SEd Maste.Nm fido_dev_info_vendor ,
390afa8e06SEd Maste.Nm fido_dev_info_manufacturer_string ,
403e696dfbSEd Maste.Nm fido_dev_info_product_string ,
413e696dfbSEd Maste.Nm fido_dev_info_set
420afa8e06SEd Maste.Nd FIDO2 device discovery functions
430afa8e06SEd Maste.Sh SYNOPSIS
440afa8e06SEd Maste.In fido.h
450afa8e06SEd Maste.Ft int
460afa8e06SEd Maste.Fn fido_dev_info_manifest "fido_dev_info_t *devlist" "size_t ilen" "size_t *olen"
470afa8e06SEd Maste.Ft fido_dev_info_t *
480afa8e06SEd Maste.Fn fido_dev_info_new "size_t n"
490afa8e06SEd Maste.Ft void
500afa8e06SEd Maste.Fn fido_dev_info_free "fido_dev_info_t **devlist_p" "size_t n"
510afa8e06SEd Maste.Ft const fido_dev_info_t *
520afa8e06SEd Maste.Fn fido_dev_info_ptr "const fido_dev_info_t *devlist" "size_t i"
530afa8e06SEd Maste.Ft const char *
540afa8e06SEd Maste.Fn fido_dev_info_path "const fido_dev_info_t *di"
550afa8e06SEd Maste.Ft int16_t
560afa8e06SEd Maste.Fn fido_dev_info_product "const fido_dev_info_t *di"
570afa8e06SEd Maste.Ft int16_t
580afa8e06SEd Maste.Fn fido_dev_info_vendor "const fido_dev_info_t *di"
590afa8e06SEd Maste.Ft const char *
600afa8e06SEd Maste.Fn fido_dev_info_manufacturer_string "const fido_dev_info_t *di"
610afa8e06SEd Maste.Ft const char *
620afa8e06SEd Maste.Fn fido_dev_info_product_string "const fido_dev_info_t *di"
633e696dfbSEd Maste.Ft int
643e696dfbSEd Maste.Fn fido_dev_info_set "fido_dev_info_t *devlist" "size_t i" "const char *path" "const char *manufacturer" "const char *product" "const fido_dev_io_t *io" "const fido_dev_transport_t *transport"
650afa8e06SEd Maste.Sh DESCRIPTION
660afa8e06SEd MasteThe
670afa8e06SEd Maste.Fn fido_dev_info_manifest
680afa8e06SEd Mastefunction fills
690afa8e06SEd Maste.Fa devlist
700afa8e06SEd Mastewith up to
710afa8e06SEd Maste.Fa ilen
723e696dfbSEd MasteFIDO2 devices found by the underlying operating system.
730afa8e06SEd MasteCurrently only USB HID devices are supported.
740afa8e06SEd MasteThe number of discovered devices is returned in
750afa8e06SEd Maste.Fa olen ,
760afa8e06SEd Mastewhere
770afa8e06SEd Maste.Fa olen
780afa8e06SEd Masteis an addressable pointer.
790afa8e06SEd Maste.Pp
800afa8e06SEd MasteThe
810afa8e06SEd Maste.Fn fido_dev_info_new
820afa8e06SEd Mastefunction returns a pointer to a newly allocated, empty device list
830afa8e06SEd Mastewith
840afa8e06SEd Maste.Fa n
850afa8e06SEd Masteavailable slots.
860afa8e06SEd MasteIf memory is not available, NULL is returned.
870afa8e06SEd Maste.Pp
880afa8e06SEd MasteThe
890afa8e06SEd Maste.Fn fido_dev_info_free
900afa8e06SEd Mastefunction releases the memory backing
910afa8e06SEd Maste.Fa *devlist_p ,
920afa8e06SEd Mastewhere
930afa8e06SEd Maste.Fa *devlist_p
940afa8e06SEd Mastemust have been previously allocated by
950afa8e06SEd Maste.Fn fido_dev_info_new .
960afa8e06SEd MasteThe number
970afa8e06SEd Maste.Fa n
980afa8e06SEd Masteof allocated slots must also be provided.
990afa8e06SEd MasteOn return,
1000afa8e06SEd Maste.Fa *devlist_p
1010afa8e06SEd Masteis set to NULL.
1020afa8e06SEd MasteEither
1030afa8e06SEd Maste.Fa devlist_p
1040afa8e06SEd Masteor
1050afa8e06SEd Maste.Fa *devlist_p
1060afa8e06SEd Mastemay be NULL, in which case
1070afa8e06SEd Maste.Fn fido_dev_info_free
1080afa8e06SEd Masteis a NOP.
1090afa8e06SEd Maste.Pp
1100afa8e06SEd MasteThe
1110afa8e06SEd Maste.Fn fido_dev_info_ptr
1120afa8e06SEd Mastefunction returns a pointer to slot number
1130afa8e06SEd Maste.Fa i
1140afa8e06SEd Masteof
1150afa8e06SEd Maste.Fa devlist .
1160afa8e06SEd MasteIt is the caller's responsibility to ensure that
1170afa8e06SEd Maste.Fa i
1180afa8e06SEd Masteis bounded.
1190afa8e06SEd MastePlease note that the first slot has index 0.
1200afa8e06SEd Maste.Pp
1210afa8e06SEd MasteThe
1220afa8e06SEd Maste.Fn fido_dev_info_path
123*2ccfa855SEd Mastefunction returns the filesystem path or subsystem-specific identification
1240afa8e06SEd Mastestring of
1250afa8e06SEd Maste.Fa di .
1260afa8e06SEd Maste.Pp
1270afa8e06SEd MasteThe
1280afa8e06SEd Maste.Fn fido_dev_info_product
1290afa8e06SEd Mastefunction returns the product ID of
1300afa8e06SEd Maste.Fa di .
1310afa8e06SEd Maste.Pp
1320afa8e06SEd MasteThe
1330afa8e06SEd Maste.Fn fido_dev_info_vendor
1340afa8e06SEd Mastefunction returns the vendor ID of
1350afa8e06SEd Maste.Fa di .
1360afa8e06SEd Maste.Pp
1370afa8e06SEd MasteThe
1380afa8e06SEd Maste.Fn fido_dev_info_manufacturer_string
1390afa8e06SEd Mastefunction returns the manufacturer string of
1400afa8e06SEd Maste.Fa di .
141f540a430SEd MasteIf
142f540a430SEd Maste.Fa di
143f540a430SEd Mastedoes not have an associated manufacturer string,
144f540a430SEd Maste.Fn fido_dev_info_manufacturer_string
145f540a430SEd Mastereturns an empty string.
1460afa8e06SEd Maste.Pp
1470afa8e06SEd MasteThe
1480afa8e06SEd Maste.Fn fido_dev_info_product_string
1490afa8e06SEd Mastefunction returns the product string of
1500afa8e06SEd Maste.Fa di .
151f540a430SEd MasteIf
152f540a430SEd Maste.Fa di
153f540a430SEd Mastedoes not have an associated product string,
154f540a430SEd Maste.Fn fido_dev_info_product_string
155f540a430SEd Mastereturns an empty string.
1560afa8e06SEd Maste.Pp
1570afa8e06SEd MasteAn example of how to use the functions described in this document
1580afa8e06SEd Mastecan be found in the
1590afa8e06SEd Maste.Pa examples/manifest.c
1600afa8e06SEd Mastefile shipped with
1610afa8e06SEd Maste.Em libfido2 .
1623e696dfbSEd Maste.Pp
1633e696dfbSEd MasteThe
1643e696dfbSEd Maste.Fn fido_dev_info_set
1653e696dfbSEd Mastefunction initializes an entry in a device list allocated by
1663e696dfbSEd Maste.Fn fido_dev_info_new
1673e696dfbSEd Mastewith the specified path, manufacturer, and product strings, and with
1683e696dfbSEd Mastethe specified I/O handlers and, optionally, transport functions, as
1693e696dfbSEd Mastedescribed in
1703e696dfbSEd Maste.Xr fido_dev_set_io_functions 3 .
1713e696dfbSEd MasteThe
1723e696dfbSEd Maste.Fa io
1733e696dfbSEd Masteargument must be specified; the
1743e696dfbSEd Maste.Fa transport
1753e696dfbSEd Masteargument may be
1763e696dfbSEd Maste.Dv NULL .
1773e696dfbSEd MasteThe path, I/O handlers, and transport functions will be used
1783e696dfbSEd Masteautomatically by
1793e696dfbSEd Maste.Xr fido_dev_new_with_info 3
1803e696dfbSEd Masteand
1813e696dfbSEd Maste.Xr fido_dev_open_with_info 3 .
1823e696dfbSEd MasteAn application can use this, for example, to substitute mock FIDO2
1833e696dfbSEd Mastedevices in testing for the real ones that
1843e696dfbSEd Maste.Fn fido_dev_info_manifest
1853e696dfbSEd Mastewould discover.
1860afa8e06SEd Maste.Sh RETURN VALUES
1870afa8e06SEd MasteThe
1880afa8e06SEd Maste.Fn fido_dev_info_manifest
1890afa8e06SEd Mastefunction always returns
1900afa8e06SEd Maste.Dv FIDO_OK .
1910afa8e06SEd MasteIf a discovery error occurs, the
1920afa8e06SEd Maste.Fa olen
1930afa8e06SEd Mastepointer is set to 0.
1940afa8e06SEd Maste.Pp
1953e696dfbSEd MasteOn success, the
1963e696dfbSEd Maste.Fn fido_dev_info_set
1973e696dfbSEd Mastefunction returns
1983e696dfbSEd Maste.Dv FIDO_OK .
1993e696dfbSEd MasteOn error, a different error code defined in
2003e696dfbSEd Maste.In fido/err.h
2013e696dfbSEd Masteis returned.
2023e696dfbSEd Maste.Pp
2030afa8e06SEd MasteThe pointers returned by
2040afa8e06SEd Maste.Fn fido_dev_info_ptr ,
2050afa8e06SEd Maste.Fn fido_dev_info_path ,
2060afa8e06SEd Maste.Fn fido_dev_info_manufacturer_string ,
2070afa8e06SEd Masteand
2080afa8e06SEd Maste.Fn fido_dev_info_product_string
2090afa8e06SEd Masteare guaranteed to exist until
2100afa8e06SEd Maste.Fn fido_dev_info_free
2110afa8e06SEd Masteis called on the corresponding device list.
212