FIDO_DEV_IO_HANDLE(3)
β¨ FIDO_DEV_IO_HANDLE β FIDO2 device I/O interface β¨
okay bestie, so this is the fido_dev_set_io_functions family of functions from the Library Functions Manual β the whole vibe is that libfido2 lets you swap out how it talks to your FIDO2 device. plug in your own handlers, plug in your own transports, set a timeout, set a signal mask, peek at the handle. it's giving customization π and it lives in section 3, so it's a library function, iykyk.
π NAME π
fido_dev_set_io_functions, fido_dev_set_sigmask, fido_dev_set_timeout, fido_dev_set_transport_functions, fido_dev_io_handle β FIDO2 device I/O interface
π¦ SYNOPSIS π¦
#include <fido.h>
typedef void *fido_dev_io_open_t(const char *);
typedef void fido_dev_io_close_t(void *);
typedef int fido_dev_io_read_t(void *, unsigned char *, size_t, int);
typedef int fido_dev_io_write_t(void *, const unsigned char *, size_t);
typedef struct fido_dev_io {
fido_dev_io_open_t *open;
fido_dev_io_close_t *close;
fido_dev_io_read_t *read;
fido_dev_io_write_t *write;
} fido_dev_io_t;
#ifdef _WIN32
typedef int fido_sigset_t;
#else
typedef sigset_t fido_sigset_t;
#endif
typedef int fido_dev_rx_t(struct fido_dev *,
uint8_t, unsigned char *, size_t, int);
typedef int fido_dev_tx_t(struct fido_dev *,
uint8_t, const unsigned char *, size_t);
typedef struct fido_dev_transport {
fido_dev_rx_t *rx;
fido_dev_tx_t *tx;
} fido_dev_transport_t;
int
fido_dev_set_io_functions(fido_dev_t *dev, const fido_dev_io_t *io);
int
fido_dev_set_sigmask(fido_dev_t *dev, const fido_sigset_t *sigmask);
int
fido_dev_set_timeout(fido_dev_t *dev, int ms);
int
fido_dev_set_transport_functions(fido_dev_t *dev,
const fido_dev_transport_t *t);
void *
fido_dev_io_handle(const fido_dev_t *dev);
π DESCRIPTION π
πΈ the I/O handlers (aka your custom open/close/read/write era)
The fido_dev_set_io_functions() function sets the I/O handlers used by libfido2 to talk to dev. By default, these handlers are set to the operating system's native HID or NFC interfaces. They are defined as follows:
fido_dev_open_tβ Receives aconst char *holding a path and opens the corresponding device, returning a non-NULLopaque pointer on success andNULLon error. no cap, that pointer is your whole ticket to the device ποΈfido_dev_close_tβ Receives the opaque pointer returned byfido_dev_open_tand closes the device. say bye bestie πfido_dev_read_tβ Reads a single transmission unit (HID report, APDU) from a device. The first parameter is the opaque pointer returned byfido_dev_open_t. The second parameter is the read buffer, and the third parameter is the read buffer size. The fourth parameter is the number of milliseconds the caller is willing to sleep, should the call need to block. If this value holds-1,fido_dev_read_tmay block indefinitely. On success, the number of bytes read is returned. On error,-1is returned.fido_dev_write_tβ Writes a single transmission unit (HID report, APDU) to dev. The first parameter is the opaque pointer returned byfido_dev_open_t. The second parameter is the write buffer, and the third parameter is the number of bytes to be written. Afido_dev_write_tmay block. On success, the number of bytes written is returned. On error,-1is returned.
β οΈ When callingfido_dev_set_io_functions(), theopen,close,read, andwritefields of io may not beNULL. like, all four of them. no skipping. periodt.
No references to io are held by fido_dev_set_io_functions().
π the signal mask era
The fido_dev_set_sigmask() function may be used to specify a non-NULL signal mask sigmask to be used while libfido2's default I/O handlers wait on dev. On UNIX-like operating systems, fido_sigset_t is defined as sigset_t. On Windows, fido_sigset_t is defined as int and fido_dev_set_sigmask() is a no-op. π windows besties we're so sorry
No references to sigmask are held by fido_dev_set_sigmask().
β° the timeout era
The fido_dev_set_timeout() function informs libfido2 not to block for more than ms milliseconds while communicating with dev. If a timeout occurs, the corresponding fido_dev_* function will fail with FIDO_ERR_RX. If ms is -1, then libfido2 may block indefinitely. This is the default behaviour. When using the Windows Hello backend, ms is used as a guidance and may be overwritten by the platform.
π the transport functions era
The fido_dev_set_transport_functions() function sets the transport functions used by libfido2 to talk to dev. While the I/O handlers are responsible for sending and receiving transmission units of initialization and continuation packets already formatted by libfido2, the transport handlers are responsible for sending and receiving the CTAPHID commands and data directly, as defined in the FIDO Client to Authenticator Protocol (CTAP) standard. They are defined as follows:
fido_dev_tx_tβ Receives a device, a CTAPHID command to transmit, a data buffer to transmit, and the length of the data buffer. On success,0is returned. On error,-1is returned.fido_dev_rx_tβ Receives a device, a CTAPHID command whose response the caller expects to receive, a data buffer to receive into, the size of the data buffer determining the maximum length of a response, and the maximum number of milliseconds to wait for a response. On success, the number of bytes read into the data buffer is returned. On error,-1is returned.
π When transport functions are specified, libfido2 will use them instead of thereadandwritefunctions of the I/O handlers. However, the I/O handlers must still be specified to open and close the device. so yes, you still need the wholefido_dev_io_tsituation, you just don't use the middle bits. it's giving "renting the whole apartment but only using the kitchen" π
π and the handle itself
The fido_dev_io_handle() function returns the opaque pointer returned by the open function of the I/O handlers. This is useful mainly for the transport functions, which unlike the I/O handlers are passed the fido_dev_t pointer instead of the opaque I/O handle. like, here's your way back to your own stuff, go get it π«Ά
π RETURN VALUES π
On success, fido_dev_set_io_functions(), fido_dev_set_transport_functions(), fido_dev_set_sigmask(), and fido_dev_set_timeout() return FIDO_OK. On error, a different error code defined in <fido/err.h> is returned.
π SEE ALSO π
fido_dev_info_manifest(3),fido_dev_open(3)- Client to Authenticator Protocol (CTAP),
https://fidoalliance.org/specs/fido-v2.1-ps-20210615/fido-client-to-authenticator-protocol-v2.1-ps-20210615.html, FIDO Alliance, 2021-06-15, Proposed Standard, Version 2.1.
and that's the whole page, bestie π this one came out of the Debian squad, dated May 25, 2018, filed under FIDO_DEV_SET_IO_FUNCTIONS(3) in the Library Functions Manual. go forth and swap your I/O handlers, you absolute icon β¨
π¦ where this page comes from
- alpine 3.22: libfido2-doc 1.16.0-r0 Β· BSD-2-Clause
- alpine 3.23: libfido2-doc 1.16.0-r2 Β· BSD-2-Clause
- alpine 3.24: libfido2-doc 1.16.0-r4 Β· BSD-2-Clause
- arch rolling: libfido2 1.17.0-1 Β· BSD-2-Clause
- centos-stream 10: libfido2-devel 1.14.0-7.el10 Β· BSD-2-Clause
- centos-stream 9: libfido2-devel 1.13.0-2.el9 Β· BSD
- centos-stream 9: libfido2-devel 1.13.0-2.el9 Β· BSD
- debian bookworm: libfido2-doc 1.12.0-2 Β· BSD-2-Clause
- debian trixie: libfido2-doc 1.15.0-1 Β· BSD-2-Clause
- fedora 43: libfido2-devel 1.16.0-3.fc43 Β· BSD-2-Clause
- fedora 43: libfido2-devel 1.16.0-3.fc43 Β· BSD-2-Clause
- fedora 44: libfido2-devel 1.16.0-5.fc44 Β· BSD-2-Clause
- fedora 44: libfido2-devel 1.16.0-5.fc44 Β· BSD-2-Clause
- nixos 26.05: fido2-manage 0-unstable-2025-06-06
- nixpkgs unstable: fido2-manage 0-unstable-2025-06-06
- nixpkgs unstable: libfido2 1.17.0
- opensuse-leap 16.0: libfido2-devel 1.15.0-160000.3.2 Β· BSD-2-Clause
- opensuse-leap 16.0: libfido2-devel 1.15.0-160000.3.2 Β· BSD-2-Clause
- opensuse-leap 16.0: libfido2-devel 1.15.0-160000.3.2 Β· BSD-2-Clause
- opensuse-leap 16.0: libfido2-devel 1.15.0-160000.3.2 Β· BSD-2-Clause
- ubuntu noble: libfido2-doc 1.14.0-1build3 Β· BSD-2-Clause
- ubuntu questing: libfido2-doc 1.16.0-2
- ubuntu resolute: libfido2-doc 1.16.0-2build1 Β· BSD-2-Clause
- ubuntu stonking: libfido2-doc 1.17.0-2build1 Β· BSD-2-Clause
- π the page's license: BSD-2-Clause
- Copyright (c) 2018-2021 Yubico AB. All rights reserved
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms