Path: blob/main/contrib/libfido2/examples/retries.c
39483 views
/*1* Copyright (c) 2018 Yubico AB. All rights reserved.2* Use of this source code is governed by a BSD-style3* license that can be found in the LICENSE file.4* SPDX-License-Identifier: BSD-2-Clause5*/67/*8* Get an authenticator's number of PIN attempts left.9*/1011#include <fido.h>12#include <stdio.h>13#include <stdlib.h>1415#include "../openbsd-compat/openbsd-compat.h"1617int18main(int argc, char **argv)19{20fido_dev_t *dev;21int n;22int r;2324if (argc != 2) {25fprintf(stderr, "usage: retries <device>\n");26exit(EXIT_FAILURE);27}2829fido_init(0);3031if ((dev = fido_dev_new()) == NULL)32errx(1, "fido_dev_new");3334if ((r = fido_dev_open(dev, argv[1])) != FIDO_OK)35errx(1, "fido_open: %s (0x%x)", fido_strerr(r), r);3637if ((r = fido_dev_get_retry_count(dev, &n)) != FIDO_OK)38errx(1, "fido_dev_get_retry_count: %s (0x%x)", fido_strerr(r), r);3940if ((r = fido_dev_close(dev)) != FIDO_OK)41errx(1, "fido_close: %s (0x%x)", fido_strerr(r), r);4243fido_dev_free(&dev);4445printf("%d\n", n);4647exit(0);48}495051