Coverage Report

Created: 2021-03-26 11:35

/libfido2/src/reset.c
Line
Count
Source
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
#include "fido.h"
8
9
static int
10
fido_dev_reset_tx(fido_dev_t *dev)
11
121
{
12
121
        const unsigned char cbor[] = { CTAP_CBOR_RESET };
13
121
14
121
        if (fido_tx(dev, CTAP_CMD_CBOR, cbor, sizeof(cbor)) < 0) {
15
2
                fido_log_debug("%s: fido_tx", __func__);
16
2
                return (FIDO_ERR_TX);
17
2
        }
18
119
19
119
        return (FIDO_OK);
20
119
}
21
22
static int
23
fido_dev_reset_wait(fido_dev_t *dev, int ms)
24
121
{
25
121
        int r;
26
121
27
121
        if ((r = fido_dev_reset_tx(dev)) != FIDO_OK ||
28
121
            (r = fido_rx_cbor_status(dev, ms)) != FIDO_OK)
29
121
                return (r);
30
4
31
4
        if (dev->flags & FIDO_DEV_PIN_SET) {
32
1
                dev->flags &= ~FIDO_DEV_PIN_SET;
33
1
                dev->flags |= FIDO_DEV_PIN_UNSET;
34
1
        }
35
4
36
4
        return (FIDO_OK);
37
4
}
38
39
int
40
fido_dev_reset(fido_dev_t *dev)
41
121
{
42
121
        return (fido_dev_reset_wait(dev, -1));
43
121
}