## Coverage Report

#### Created: 2025-03-01 02:43

next uncovered line (L), next uncovered region (R), next uncovered branch (B)

    /libfido2/src/fido.h

    Line
    Count
    Source
    1
    /*
    2
     * Copyright (c) 2018-2024 Yubico AB. All rights reserved.
    3
     * SPDX-License-Identifier: BSD-2-Clause
    4
     *
    5
     * Redistribution and use in source and binary forms, with or without
    6
     * modification, are permitted provided that the following conditions are
    7
     * met:
    8
     *
    9
     *    1. Redistributions of source code must retain the above copyright
    10
     *       notice, this list of conditions and the following disclaimer.
    11
     *    2. Redistributions in binary form must reproduce the above copyright
    12
     *       notice, this list of conditions and the following disclaimer in
    13
     *       the documentation and/or other materials provided with the
    14
     *       distribution.
    15
     *
    16
     * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
    17
     * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
    18
     * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
    19
     * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
    20
     * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
    21
     * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
    22
     * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
    23
     * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
    24
     * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
    25
     * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
    26
     * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    27
     */
    28
    29
    #ifndef _FIDO_H
    30
    #define _FIDO_H
    31
    32
    #include <openssl/ec.h>
    33
    #include <openssl/evp.h>
    34
    35
    #include <stdbool.h>
    36
    #include <stdint.h>
    37
    #include <stdlib.h>
    38
    39
    #ifdef _FIDO_INTERNAL
    40
    #include <sys/types.h>
    41
    42
    #include <cbor.h>
    43
    #include <limits.h>
    44
    45
    #include "../openbsd-compat/openbsd-compat.h"
    46
    #include "blob.h"
    47
    #include "iso7816.h"
    48
    #include "extern.h"
    49
    #endif
    50
    51
    #include "fido/err.h"
    52
    #include "fido/param.h"
    53
    #include "fido/types.h"
    54
    55
    #ifdef __cplusplus
    56
    extern "C" {
    57
    #endif /* __cplusplus */
    58
    59
    fido_assert_t *fido_assert_new(void);
    60
    fido_cred_t *fido_cred_new(void);
    61
    fido_dev_t *fido_dev_new(void);
    62
    fido_dev_t *fido_dev_new_with_info(const fido_dev_info_t *);
    63
    fido_dev_info_t *fido_dev_info_new(size_t);
    64
    fido_cbor_info_t *fido_cbor_info_new(void);
    65
    void *fido_dev_io_handle(const fido_dev_t *);
    66
    67
    void fido_assert_free(fido_assert_t **);
    68
    void fido_cbor_info_free(fido_cbor_info_t **);
    69
    void fido_cred_free(fido_cred_t **);
    70
    void fido_dev_force_fido2(fido_dev_t *);
    71
    void fido_dev_force_u2f(fido_dev_t *);
    72
    void fido_dev_free(fido_dev_t **);
    73
    void fido_dev_info_free(fido_dev_info_t **, size_t);
    74
    75
    /* fido_init() flags. */
    76
    340k
    #define FIDO_DEBUG      0x01
    77
    170k
    #define FIDO_DISABLE_U2F_FALLBACK 0x02
    78
    79
    void fido_init(int);
    80
    void fido_set_log_handler(fido_log_handler_t *);
    81
    82
    const unsigned char *fido_assert_authdata_ptr(const fido_assert_t *, size_t);
    83
    const unsigned char *fido_assert_authdata_raw_ptr(const fido_assert_t *,
    84
        size_t);
    85
    const unsigned char *fido_assert_clientdata_hash_ptr(const fido_assert_t *);
    86
    const unsigned char *fido_assert_hmac_secret_ptr(const fido_assert_t *, size_t);
    87
    const unsigned char *fido_assert_id_ptr(const fido_assert_t *, size_t);
    88
    const unsigned char *fido_assert_largeblob_key_ptr(const fido_assert_t *, size_t);
    89
    const unsigned char *fido_assert_sig_ptr(const fido_assert_t *, size_t);
    90
    const unsigned char *fido_assert_user_id_ptr(const fido_assert_t *, size_t);
    91
    const unsigned char *fido_assert_blob_ptr(const fido_assert_t *, size_t);
    92
    93
    char **fido_cbor_info_certs_name_ptr(const fido_cbor_info_t *);
    94
    char **fido_cbor_info_extensions_ptr(const fido_cbor_info_t *);
    95
    char **fido_cbor_info_options_name_ptr(const fido_cbor_info_t *);
    96
    char **fido_cbor_info_transports_ptr(const fido_cbor_info_t *);
    97
    char **fido_cbor_info_versions_ptr(const fido_cbor_info_t *);
    98
    const bool *fido_cbor_info_options_value_ptr(const fido_cbor_info_t *);
    99
    const char *fido_assert_rp_id(const fido_assert_t *);
    100
    const char *fido_assert_user_display_name(const fido_assert_t *, size_t);
    101
    const char *fido_assert_user_icon(const fido_assert_t *, size_t);
    102
    const char *fido_assert_user_name(const fido_assert_t *, size_t);
    103
    const char *fido_cbor_info_algorithm_type(const fido_cbor_info_t *, size_t);
    104
    const char *fido_cred_display_name(const fido_cred_t *);
    105
    const char *fido_cred_fmt(const fido_cred_t *);
    106
    const char *fido_cred_rp_id(const fido_cred_t *);
    107
    const char *fido_cred_rp_name(const fido_cred_t *);
    108
    const char *fido_cred_user_name(const fido_cred_t *);
    109
    const char *fido_dev_info_manufacturer_string(const fido_dev_info_t *);
    110
    const char *fido_dev_info_path(const fido_dev_info_t *);
    111
    const char *fido_dev_info_product_string(const fido_dev_info_t *);
    112
    const fido_dev_info_t *fido_dev_info_ptr(const fido_dev_info_t *, size_t);
    113
    const uint8_t *fido_cbor_info_protocols_ptr(const fido_cbor_info_t *);
    114
    const uint64_t *fido_cbor_info_certs_value_ptr(const fido_cbor_info_t *);
    115
    const unsigned char *fido_cbor_info_aaguid_ptr(const fido_cbor_info_t *);
    116
    const unsigned char *fido_cred_aaguid_ptr(const fido_cred_t *);
    117
    const unsigned char *fido_cred_attstmt_ptr(const fido_cred_t *);
    118
    const unsigned char *fido_cred_authdata_ptr(const fido_cred_t *);
    119
    const unsigned char *fido_cred_authdata_raw_ptr(const fido_cred_t *);
    120
    const unsigned char *fido_cred_clientdata_hash_ptr(const fido_cred_t *);
    121
    const unsigned char *fido_cred_id_ptr(const fido_cred_t *);
    122
    const unsigned char *fido_cred_largeblob_key_ptr(const fido_cred_t *);
    123
    const unsigned char *fido_cred_pubkey_ptr(const fido_cred_t *);
    124
    const unsigned char *fido_cred_sig_ptr(const fido_cred_t *);
    125
    const unsigned char *fido_cred_user_id_ptr(const fido_cred_t *);
    126
    const unsigned char *fido_cred_x5c_ptr(const fido_cred_t *);
    127
    const unsigned char *fido_cred_x5c_list_ptr(const fido_cred_t *, size_t);
    128
    129
    int fido_assert_allow_cred(fido_assert_t *, const unsigned char *, size_t);
    130
    int fido_assert_empty_allow_list(fido_assert_t *);
    131
    int fido_assert_set_authdata(fido_assert_t *, size_t, const unsigned char *,
    132
        size_t);
    133
    int fido_assert_set_authdata_raw(fido_assert_t *, size_t, const unsigned char *,
    134
        size_t);
    135
    int fido_assert_set_clientdata(fido_assert_t *, const unsigned char *, size_t);
    136
    int fido_assert_set_clientdata_hash(fido_assert_t *, const unsigned char *,
    137
        size_t);
    138
    int fido_assert_set_count(fido_assert_t *, size_t);
    139
    int fido_assert_set_extensions(fido_assert_t *, int);
    140
    int fido_assert_set_hmac_salt(fido_assert_t *, const unsigned char *, size_t);
    141
    int fido_assert_set_hmac_secret(fido_assert_t *, size_t, const unsigned char *,
    142
        size_t);
    143
    int fido_assert_set_options(fido_assert_t *, bool, bool);
    144
    int fido_assert_set_rp(fido_assert_t *, const char *);
    145
    int fido_assert_set_up(fido_assert_t *, fido_opt_t);
    146
    int fido_assert_set_uv(fido_assert_t *, fido_opt_t);
    147
    int fido_assert_set_sig(fido_assert_t *, size_t, const unsigned char *, size_t);
    148
    int fido_assert_set_winhello_appid(fido_assert_t *, const char *);
    149
    int fido_assert_verify(const fido_assert_t *, size_t, int, const void *);
    150
    int fido_cbor_info_algorithm_cose(const fido_cbor_info_t *, size_t);
    151
    int fido_cred_empty_exclude_list(fido_cred_t *);
    152
    bool fido_cred_entattest(const fido_cred_t *);
    153
    int fido_cred_exclude(fido_cred_t *, const unsigned char *, size_t);
    154
    int fido_cred_prot(const fido_cred_t *);
    155
    int fido_cred_set_attstmt(fido_cred_t *, const unsigned char *, size_t);
    156
    int fido_cred_set_attobj(fido_cred_t *, const unsigned char *, size_t);
    157
    int fido_cred_set_authdata(fido_cred_t *, const unsigned char *, size_t);
    158
    int fido_cred_set_authdata_raw(fido_cred_t *, const unsigned char *, size_t);
    159
    int fido_cred_set_blob(fido_cred_t *, const unsigned char *, size_t);
    160
    int fido_cred_set_clientdata(fido_cred_t *, const unsigned char *, size_t);
    161
    int fido_cred_set_clientdata_hash(fido_cred_t *, const unsigned char *, size_t);
    162
    int fido_cred_set_entattest(fido_cred_t *, int);
    163
    int fido_cred_set_extensions(fido_cred_t *, int);
    164
    int fido_cred_set_fmt(fido_cred_t *, const char *);
    165
    int fido_cred_set_id(fido_cred_t *, const unsigned char *, size_t);
    166
    int fido_cred_set_options(fido_cred_t *, bool, bool);
    167
    int fido_cred_set_pin_minlen(fido_cred_t *, size_t);
    168
    int fido_cred_set_prot(fido_cred_t *, int);
    169
    int fido_cred_set_rk(fido_cred_t *, fido_opt_t);
    170
    int fido_cred_set_rp(fido_cred_t *, const char *, const char *);
    171
    int fido_cred_set_sig(fido_cred_t *, const unsigned char *, size_t);
    172
    int fido_cred_set_type(fido_cred_t *, int);
    173
    int fido_cred_set_uv(fido_cred_t *, fido_opt_t);
    174
    int fido_cred_type(const fido_cred_t *);
    175
    int fido_cred_set_user(fido_cred_t *, const unsigned char *, size_t,
    176
        const char *, const char *, const char *);
    177
    int fido_cred_set_x509(fido_cred_t *, const unsigned char *, size_t);
    178
    int fido_cred_verify(const fido_cred_t *);
    179
    int fido_cred_verify_self(const fido_cred_t *);
    180
    #ifdef _FIDO_SIGSET_DEFINED
    181
    int fido_dev_set_sigmask(fido_dev_t *, const fido_sigset_t *);
    182
    #endif
    183
    int fido_dev_cancel(fido_dev_t *);
    184
    int fido_dev_close(fido_dev_t *);
    185
    int fido_dev_get_assert(fido_dev_t *, fido_assert_t *, const char *);
    186
    int fido_dev_get_cbor_info(fido_dev_t *, fido_cbor_info_t *);
    187
    int fido_dev_get_retry_count(fido_dev_t *, int *);
    188
    int fido_dev_get_uv_retry_count(fido_dev_t *, int *);
    189
    int fido_dev_get_touch_begin(fido_dev_t *);
    190
    int fido_dev_get_touch_status(fido_dev_t *, int *, int);
    191
    int fido_dev_info_manifest(fido_dev_info_t *, size_t, size_t *);
    192
    int fido_dev_info_set(fido_dev_info_t *, size_t, const char *, const char *,
    193
        const char *, const fido_dev_io_t *, const fido_dev_transport_t *);
    194
    int fido_dev_make_cred(fido_dev_t *, fido_cred_t *, const char *);
    195
    int fido_dev_open_with_info(fido_dev_t *);
    196
    int fido_dev_open(fido_dev_t *, const char *);
    197
    int fido_dev_reset(fido_dev_t *);
    198
    int fido_dev_set_io_functions(fido_dev_t *, const fido_dev_io_t *);
    199
    int fido_dev_set_pin(fido_dev_t *, const char *, const char *);
    200
    int fido_dev_set_transport_functions(fido_dev_t *, const fido_dev_transport_t *);
    201
    int fido_dev_set_timeout(fido_dev_t *, int);
    202
    203
    size_t fido_assert_authdata_len(const fido_assert_t *, size_t);
    204
    size_t fido_assert_authdata_raw_len(const fido_assert_t *, size_t);
    205
    size_t fido_assert_clientdata_hash_len(const fido_assert_t *);
    206
    size_t fido_assert_count(const fido_assert_t *);
    207
    size_t fido_assert_hmac_secret_len(const fido_assert_t *, size_t);
    208
    size_t fido_assert_id_len(const fido_assert_t *, size_t);
    209
    size_t fido_assert_largeblob_key_len(const fido_assert_t *, size_t);
    210
    size_t fido_assert_sig_len(const fido_assert_t *, size_t);
    211
    size_t fido_assert_user_id_len(const fido_assert_t *, size_t);
    212
    size_t fido_assert_blob_len(const fido_assert_t *, size_t);
    213
    size_t fido_cbor_info_aaguid_len(const fido_cbor_info_t *);
    214
    size_t fido_cbor_info_algorithm_count(const fido_cbor_info_t *);
    215
    size_t fido_cbor_info_certs_len(const fido_cbor_info_t *);
    216
    size_t fido_cbor_info_extensions_len(const fido_cbor_info_t *);
    217
    size_t fido_cbor_info_options_len(const fido_cbor_info_t *);
    218
    size_t fido_cbor_info_protocols_len(const fido_cbor_info_t *);
    219
    size_t fido_cbor_info_transports_len(const fido_cbor_info_t *);
    220
    size_t fido_cbor_info_versions_len(const fido_cbor_info_t *);
    221
    size_t fido_cred_aaguid_len(const fido_cred_t *);
    222
    size_t fido_cred_attstmt_len(const fido_cred_t *);
    223
    size_t fido_cred_authdata_len(const fido_cred_t *);
    224
    size_t fido_cred_authdata_raw_len(const fido_cred_t *);
    225
    size_t fido_cred_clientdata_hash_len(const fido_cred_t *);
    226
    size_t fido_cred_id_len(const fido_cred_t *);
    227
    size_t fido_cred_largeblob_key_len(const fido_cred_t *);
    228
    size_t fido_cred_pin_minlen(const fido_cred_t *);
    229
    size_t fido_cred_pubkey_len(const fido_cred_t *);
    230
    size_t fido_cred_sig_len(const fido_cred_t *);
    231
    size_t fido_cred_user_id_len(const fido_cred_t *);
    232
    size_t fido_cred_x5c_len(const fido_cred_t *);
    233
    size_t fido_cred_x5c_list_count(const fido_cred_t *);
    234
    size_t fido_cred_x5c_list_len(const fido_cred_t *, size_t);
    235
    236
    uint8_t  fido_assert_flags(const fido_assert_t *, size_t);
    237
    uint32_t fido_assert_sigcount(const fido_assert_t *, size_t);
    238
    uint8_t  fido_cred_flags(const fido_cred_t *);
    239
    uint32_t fido_cred_sigcount(const fido_cred_t *);
    240
    uint8_t  fido_dev_protocol(const fido_dev_t *);
    241
    uint8_t  fido_dev_major(const fido_dev_t *);
    242
    uint8_t  fido_dev_minor(const fido_dev_t *);
    243
    uint8_t  fido_dev_build(const fido_dev_t *);
    244
    uint8_t  fido_dev_flags(const fido_dev_t *);
    245
    int16_t  fido_dev_info_vendor(const fido_dev_info_t *);
    246
    int16_t  fido_dev_info_product(const fido_dev_info_t *);
    247
    uint64_t fido_cbor_info_fwversion(const fido_cbor_info_t *);
    248
    uint64_t fido_cbor_info_maxcredbloblen(const fido_cbor_info_t *);
    249
    uint64_t fido_cbor_info_maxcredcntlst(const fido_cbor_info_t *);
    250
    uint64_t fido_cbor_info_maxcredidlen(const fido_cbor_info_t *);
    251
    uint64_t fido_cbor_info_maxlargeblob(const fido_cbor_info_t *);
    252
    uint64_t fido_cbor_info_maxmsgsiz(const fido_cbor_info_t *);
    253
    uint64_t fido_cbor_info_maxrpid_minpinlen(const fido_cbor_info_t *);
    254
    uint64_t fido_cbor_info_minpinlen(const fido_cbor_info_t *);
    255
    uint64_t fido_cbor_info_uv_attempts(const fido_cbor_info_t *);
    256
    uint64_t fido_cbor_info_uv_modality(const fido_cbor_info_t *);
    257
    int64_t  fido_cbor_info_rk_remaining(const fido_cbor_info_t *);
    258
    259
    bool fido_dev_has_pin(const fido_dev_t *);
    260
    bool fido_dev_has_uv(const fido_dev_t *);
    261
    bool fido_dev_is_fido2(const fido_dev_t *);
    262
    bool fido_dev_is_winhello(const fido_dev_t *);
    263
    bool fido_dev_supports_credman(const fido_dev_t *);
    264
    bool fido_dev_supports_cred_prot(const fido_dev_t *);
    265
    bool fido_dev_supports_permissions(const fido_dev_t *);
    266
    bool fido_dev_supports_pin(const fido_dev_t *);
    267
    bool fido_dev_supports_uv(const fido_dev_t *);
    268
    bool fido_cbor_info_new_pin_required(const fido_cbor_info_t *);
    269
    270
    int fido_dev_largeblob_get(fido_dev_t *, const unsigned char *, size_t,
    271
        unsigned char **, size_t *);
    272
    int fido_dev_largeblob_set(fido_dev_t *, const unsigned char *, size_t,
    273
        const unsigned char *, size_t, const char *);
    274
    int fido_dev_largeblob_remove(fido_dev_t *, const unsigned char *, size_t,
    275
        const char *);
    276
    int fido_dev_largeblob_get_array(fido_dev_t *, unsigned char **, size_t *);
    277
    int fido_dev_largeblob_set_array(fido_dev_t *, const unsigned char *, size_t,
    278
        const char *);
    279
    280
    #ifdef __cplusplus
    281
    } /* extern "C" */
    282
    #endif /* __cplusplus */
    283
    284
    #endif /* !_FIDO_H */