Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/freebsd-src
Path: blob/main/contrib/libfido2/examples/reset.c
39536 views
1
/*
2
* Copyright (c) 2018-2021 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
* SPDX-License-Identifier: BSD-2-Clause
6
*/
7
8
/*
9
* Perform a factory reset on a given authenticator.
10
*/
11
12
#include <fido.h>
13
#include <stdio.h>
14
#include <stdlib.h>
15
16
#include "../openbsd-compat/openbsd-compat.h"
17
#include "extern.h"
18
19
int
20
main(int argc, char **argv)
21
{
22
fido_dev_t *dev;
23
int r;
24
25
if (argc != 2) {
26
fprintf(stderr, "usage: reset <device>\n");
27
exit(EXIT_FAILURE);
28
}
29
30
fido_init(0);
31
32
if ((dev = fido_dev_new()) == NULL)
33
errx(1, "fido_dev_new");
34
35
if ((r = fido_dev_open(dev, argv[1])) != FIDO_OK)
36
errx(1, "fido_dev_open: %s (0x%x)", fido_strerr(r), r);
37
38
if ((r = fido_dev_reset(dev)) != FIDO_OK) {
39
fido_dev_cancel(dev);
40
errx(1, "fido_dev_reset: %s (0x%x)", fido_strerr(r), r);
41
}
42
43
if ((r = fido_dev_close(dev)) != FIDO_OK)
44
errx(1, "fido_dev_close: %s (0x%x)", fido_strerr(r), r);
45
46
fido_dev_free(&dev);
47
48
exit(0);
49
}
50
51