Coverage Report

Created: 2020-03-07 10:10

/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 <stdlib.h>
8
#include "fido.h"
9
10
static int
11
fido_dev_reset_tx(fido_dev_t *dev)
12
291
{
13
291
        const unsigned char cbor[] = { CTAP_CBOR_RESET };
14
291
15
291
        if (fido_tx(dev, CTAP_CMD_CBOR, cbor, sizeof(cbor)) < 0) {
16
1
                fido_log_debug("%s: fido_tx", __func__);
17
1
                return (FIDO_ERR_TX);
18
1
        }
19
290
20
290
        return (FIDO_OK);
21
290
}
22
23
static int
24
fido_dev_reset_wait(fido_dev_t *dev, int ms)
25
291
{
26
291
        int r;
27
291
28
291
        if ((r = fido_dev_reset_tx(dev)) != FIDO_OK ||
29
291
            (r = fido_rx_cbor_status(dev, ms)) != FIDO_OK)
30
291
                return (r);
31
16
32
16
        return (FIDO_OK);
33
16
}
34
35
int
36
fido_dev_reset(fido_dev_t *dev)
37
291
{
38
291
        return (fido_dev_reset_wait(dev, -1));
39
291
}