---
name: "fido_dev_set_pin"
section: "3"
platform: "linux"
package: "libfido2"
version: "1.17.0-1"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/fido_dev_set_pin"
---

# fido\_dev\_set\_pin(3)

FIDO2 device management functions

## NAME

**fido\_dev\_set\_pin**, **fido\_dev\_get\_retry\_count**, **fido\_dev\_get\_uv\_retry\_count**, **fido\_dev\_reset** – FIDO2 device management functions

## SYNOPSIS

**#include \<fido.h\>**

*int*\

**fido\_dev\_set\_pin**(*fido\_dev\_t \*dev*, *const char \*pin*, *const char \*oldpin*);

*int*\

**fido\_dev\_get\_retry\_count**(*fido\_dev\_t \*dev*, *int \*retries*);

*int*\

**fido\_dev\_get\_uv\_retry\_count**(*fido\_dev\_t \*dev*, *int \*retries*);

*int*\

**fido\_dev\_reset**(*fido\_dev\_t \*dev*);

## DESCRIPTION

The **fido\_dev\_set\_pin**() function sets the PIN of device *dev* to *pin*, where *pin* is a NUL-terminated UTF-8 string. If *oldpin* is not NULL, the device's PIN is changed from *oldpin* to *pin*, where *pin* and *oldpin* are NUL-terminated UTF-8 strings.

The **fido\_dev\_get\_retry\_count**() function fills *retries* with the number of PIN retries left in *dev* before lock-out, where *retries* is an addressable pointer.

The **fido\_dev\_get\_uv\_retry\_count**() function fills *retries* with the number of built-in UV retries left in *dev* before built-in UV is disabled, where *retries* is an addressable pointer.

The **fido\_dev\_reset**() function performs a reset on *dev*, resetting the device's PIN and erasing credentials stored on the device.

Please note that **fido\_dev\_set\_pin**(), **fido\_dev\_get\_retry\_count**(), **fido\_dev\_get\_uv\_retry\_count**(), and **fido\_dev\_reset**() are synchronous and will block if necessary.

## RETURN VALUES

The error codes returned by **fido\_dev\_set\_pin**(), **fido\_dev\_get\_retry\_count**(), **fido\_dev\_get\_uv\_retry\_count**(), and **fido\_dev\_reset**() are defined in ⟨fido/err.h⟩. On success, FIDO\_OK is returned.

## SEE ALSO

[fido\_cbor\_info\_uv\_attempts(3)](/fido_cbor_info_uv_attempts/3.md)

## CAVEATS

Regarding **fido\_dev\_reset**(), the actual user-flow to perform a reset is outside the scope of the FIDO2 specification, and may therefore vary depending on the authenticator. Yubico authenticators will return FIDO\_ERR\_NOT\_ALLOWED if a reset is issued later than 5 seconds after power-up, and FIDO\_ERR\_ACTION\_TIMEOUT if the user fails to confirm the reset by touching the key within 30 seconds.
