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 <fido.h> 12 #include <stdio.h> 13 #include <stdlib.h> 14 15 #include "../openbsd-compat/openbsd-compat.h" 16 17 int 18 main(int argc, char **argv) 19 { 20 fido_dev_t *dev; 21 int n; 22 int r; 23 24 if (argc != 2) { 25 fprintf(stderr, "usage: retries <device>\n"); 26 exit(EXIT_FAILURE); 27 } 28 29 fido_init(0); 30 31 if ((dev = fido_dev_new()) == NULL) 32 errx(1, "fido_dev_new"); 33 34 if ((r = fido_dev_open(dev, argv[1])) != FIDO_OK) 35 errx(1, "fido_open: %s (0x%x)", fido_strerr(r), r); 36 37 if ((r = fido_dev_get_retry_count(dev, &n)) != FIDO_OK) 38 errx(1, "fido_get_retries: %s (0x%x)", fido_strerr(r), r); 39 40 if ((r = fido_dev_close(dev)) != FIDO_OK) 41 errx(1, "fido_close: %s (0x%x)", fido_strerr(r), r); 42 43 fido_dev_free(&dev); 44 45 printf("%d\n", n); 46 47 exit(0); 48 } 49