summaryrefslogtreecommitdiff
path: root/examples/retries.c
diff options
context:
space:
mode:
Diffstat (limited to 'examples/retries.c')
-rw-r--r--examples/retries.c52
1 files changed, 52 insertions, 0 deletions
diff --git a/examples/retries.c b/examples/retries.c
new file mode 100644
index 0000000..3ed7558
--- /dev/null
+++ b/examples/retries.c
@@ -0,0 +1,52 @@
1/*
2 * Copyright (c) 2018 Yubico AB. All rights reserved.
3 * Use of this source code is governed by a BSD-style
4 * license that can be found in the LICENSE file.
5 */
6
7/*
8 * Get an authenticator's number of PIN attempts left.
9 */
10
11#include <openssl/ec.h>
12
13#include <stdbool.h>
14#include <stdio.h>
15#include <stdlib.h>
16
17#include "../openbsd-compat/openbsd-compat.h"
18
19#include "fido.h"
20
21int
22main(int argc, char **argv)
23{
24 fido_dev_t *dev;
25 int n;
26 int r;
27
28 if (argc != 2) {
29 fprintf(stderr, "usage: retries <device>\n");
30 exit(EXIT_FAILURE);
31 }
32
33 fido_init(0);
34
35 if ((dev = fido_dev_new()) == NULL)
36 errx(1, "fido_dev_new");
37
38 if ((r = fido_dev_open(dev, argv[1])) != FIDO_OK)
39 errx(1, "fido_open: %s (0x%x)", fido_strerr(r), r);
40
41 if ((r = fido_dev_get_retry_count(dev, &n)) != FIDO_OK)
42 errx(1, "fido_get_retries: %s (0x%x)", fido_strerr(r), r);
43
44 if ((r = fido_dev_close(dev)) != FIDO_OK)
45 errx(1, "fido_close: %s (0x%x)", fido_strerr(r), r);
46
47 fido_dev_free(&dev);
48
49 printf("%d\n", n);
50
51 exit(0);
52}