## Coverage Report

#### Created: 2023-09-23 17:42

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