Coverage Report

Created: 2026-05-30 06:06

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/openssl/include/crypto/sparse_array.h
Line
Count
Source
1
/*
2
 * Copyright 2019-2021 The OpenSSL Project Authors. All Rights Reserved.
3
 * Copyright (c) 2019, Oracle and/or its affiliates.  All rights reserved.
4
 *
5
 * Licensed under the Apache License 2.0 (the "License").  You may not use
6
 * this file except in compliance with the License.  You can obtain a copy
7
 * in the file LICENSE in the source distribution or at
8
 * https://www.openssl.org/source/license.html
9
 */
10
11
#ifndef OSSL_CRYPTO_SPARSE_ARRAY_H
12
#define OSSL_CRYPTO_SPARSE_ARRAY_H
13
#pragma once
14
15
#include <openssl/e_os2.h>
16
17
#ifdef __cplusplus
18
extern "C" {
19
#endif
20
21
0
#define SPARSE_ARRAY_OF(type) struct sparse_array_st_##type
22
23
#define DEFINE_SPARSE_ARRAY_OF_INTERNAL(type, ctype)                                                               \
24
    SPARSE_ARRAY_OF(type);                                                                                         \
25
    typedef void (*sa_##type##_leaffunc)(ossl_uintmax_t idx, type *t);                                             \
26
    typedef void (*sa_##type##_leaffunc_arg)(ossl_uintmax_t idx, type *t, void *arg);                              \
27
    static ossl_unused ossl_inline SPARSE_ARRAY_OF(type) * ossl_sa_##type##_new(void)                              \
28
98
    {                                                                                                              \
29
98
        return (SPARSE_ARRAY_OF(type) *)ossl_sa_new();                                                             \
30
98
    }                                                                                                              \
threads_common.c:ossl_sa_CTX_TABLE_ENTRY_new
Line
Count
Source
28
2
    {                                                                                                              \
29
2
        return (SPARSE_ARRAY_OF(type) *)ossl_sa_new();                                                             \
30
2
    }                                                                                                              \
property.c:ossl_sa_ALGORITHM_new
Line
Count
Source
28
96
    {                                                                                                              \
29
96
        return (SPARSE_ARRAY_OF(type) *)ossl_sa_new();                                                             \
30
96
    }                                                                                                              \
Unexecuted instantiation: rsa_ossl.c:ossl_sa_BN_BLINDING_new
31
    static ossl_unused ossl_inline void                                                                            \
32
    ossl_sa_##type##_free(SPARSE_ARRAY_OF(type) * sa)                                                              \
33
0
    {                                                                                                              \
34
0
        ossl_sa_free((OPENSSL_SA *)sa);                                                                            \
35
0
    }                                                                                                              \
Unexecuted instantiation: threads_common.c:ossl_sa_CTX_TABLE_ENTRY_free
Unexecuted instantiation: property.c:ossl_sa_ALGORITHM_free
Unexecuted instantiation: rsa_ossl.c:ossl_sa_BN_BLINDING_free
36
    static ossl_unused ossl_inline void                                                                            \
37
    ossl_sa_##type##_free_leaves(SPARSE_ARRAY_OF(type) * sa)                                                       \
38
0
    {                                                                                                              \
39
0
        ossl_sa_free_leaves((OPENSSL_SA *)sa);                                                                     \
40
0
    }                                                                                                              \
Unexecuted instantiation: threads_common.c:ossl_sa_CTX_TABLE_ENTRY_free_leaves
Unexecuted instantiation: property.c:ossl_sa_ALGORITHM_free_leaves
Unexecuted instantiation: rsa_ossl.c:ossl_sa_BN_BLINDING_free_leaves
41
    static ossl_unused ossl_inline size_t                                                                          \
42
    ossl_sa_##type##_num(const SPARSE_ARRAY_OF(type) * sa)                                                         \
43
0
    {                                                                                                              \
44
0
        return ossl_sa_num((OPENSSL_SA *)sa);                                                                      \
45
0
    }                                                                                                              \
Unexecuted instantiation: threads_common.c:ossl_sa_CTX_TABLE_ENTRY_num
Unexecuted instantiation: property.c:ossl_sa_ALGORITHM_num
Unexecuted instantiation: rsa_ossl.c:ossl_sa_BN_BLINDING_num
46
    static ossl_unused void                                                                                        \
47
    ossl_sa_##type##_doall_thunk(ossl_uintmax_t idx, void *leaf, void *arg)                                        \
48
0
    {                                                                                                              \
49
0
        sa_##type##_leaffunc fn = *(sa_##type##_leaffunc *)arg;                                                    \
50
0
        (*fn)(idx, (type *)leaf);                                                                                  \
51
0
    }                                                                                                              \
Unexecuted instantiation: threads_common.c:ossl_sa_CTX_TABLE_ENTRY_doall_thunk
Unexecuted instantiation: property.c:ossl_sa_ALGORITHM_doall_thunk
Unexecuted instantiation: rsa_ossl.c:ossl_sa_BN_BLINDING_doall_thunk
52
    static ossl_unused ossl_inline void                                                                            \
53
    ossl_sa_##type##_doall(const SPARSE_ARRAY_OF(type) * sa,                                                       \
54
        void (*leaf)(ossl_uintmax_t, type *))                                                                      \
55
0
    {                                                                                                              \
56
0
        ossl_sa_doall_arg((OPENSSL_SA *)sa, ossl_sa_##type##_doall_thunk, &leaf);                                  \
57
0
    }                                                                                                              \
Unexecuted instantiation: threads_common.c:ossl_sa_CTX_TABLE_ENTRY_doall
Unexecuted instantiation: property.c:ossl_sa_ALGORITHM_doall
Unexecuted instantiation: rsa_ossl.c:ossl_sa_BN_BLINDING_doall
58
    struct ossl_sa_##type##_doall_thunk {                                                                          \
59
        sa_##type##_leaffunc_arg fn;                                                                               \
60
        void *arg;                                                                                                 \
61
    };                                                                                                             \
62
    static ossl_unused void                                                                                        \
63
    ossl_sa_##type##_doall_arg_thunk(ossl_uintmax_t idx, void *leaf, void *arg)                                    \
64
0
    {                                                                                                              \
65
0
        struct ossl_sa_##type##_doall_thunk *t = arg;                                                              \
66
0
                                                                                                                   \
67
0
        (*t->fn)(idx, (type *)leaf, t->arg);                                                                       \
68
0
    }                                                                                                              \
Unexecuted instantiation: threads_common.c:ossl_sa_CTX_TABLE_ENTRY_doall_arg_thunk
Unexecuted instantiation: property.c:ossl_sa_ALGORITHM_doall_arg_thunk
Unexecuted instantiation: rsa_ossl.c:ossl_sa_BN_BLINDING_doall_arg_thunk
69
    static ossl_unused ossl_inline void                                                                            \
70
    ossl_sa_##type##_doall_arg(const SPARSE_ARRAY_OF(type) * sa,                                                   \
71
        void (*leaf)(ossl_uintmax_t, type *, void *),                                                              \
72
        void *arg)                                                                                                 \
73
0
    {                                                                                                              \
74
0
        struct ossl_sa_##type##_doall_thunk t;                                                                     \
75
0
                                                                                                                   \
76
0
        t.fn = leaf;                                                                                               \
77
0
        t.arg = arg;                                                                                               \
78
0
        ossl_sa_doall_arg((OPENSSL_SA *)sa,                                                                        \
79
0
            ossl_sa_##type##_doall_arg_thunk, &t);                                                                 \
80
0
    }                                                                                                              \
Unexecuted instantiation: threads_common.c:ossl_sa_CTX_TABLE_ENTRY_doall_arg
Unexecuted instantiation: property.c:ossl_sa_ALGORITHM_doall_arg
Unexecuted instantiation: rsa_ossl.c:ossl_sa_BN_BLINDING_doall_arg
81
    static ossl_unused ossl_inline ctype *ossl_sa_##type##_get(const SPARSE_ARRAY_OF(type) * sa, ossl_uintmax_t n) \
82
712k
    {                                                                                                              \
83
712k
        return (type *)ossl_sa_get((OPENSSL_SA *)sa, n);                                                           \
84
712k
    }                                                                                                              \
threads_common.c:ossl_sa_CTX_TABLE_ENTRY_get
Line
Count
Source
82
3.29k
    {                                                                                                              \
83
3.29k
        return (type *)ossl_sa_get((OPENSSL_SA *)sa, n);                                                           \
84
3.29k
    }                                                                                                              \
property.c:ossl_sa_ALGORITHM_get
Line
Count
Source
82
709k
    {                                                                                                              \
83
709k
        return (type *)ossl_sa_get((OPENSSL_SA *)sa, n);                                                           \
84
709k
    }                                                                                                              \
Unexecuted instantiation: rsa_ossl.c:ossl_sa_BN_BLINDING_get
85
    static ossl_unused ossl_inline int                                                                             \
86
    ossl_sa_##type##_set(SPARSE_ARRAY_OF(type) * sa,                                                               \
87
        ossl_uintmax_t n, ctype *val)                                                                              \
88
232
    {                                                                                                              \
89
232
        return ossl_sa_set((OPENSSL_SA *)sa, n, (void *)val);                                                      \
90
232
    }                                                                                                              \
threads_common.c:ossl_sa_CTX_TABLE_ENTRY_set
Line
Count
Source
88
8
    {                                                                                                              \
89
8
        return ossl_sa_set((OPENSSL_SA *)sa, n, (void *)val);                                                      \
90
8
    }                                                                                                              \
property.c:ossl_sa_ALGORITHM_set
Line
Count
Source
88
224
    {                                                                                                              \
89
224
        return ossl_sa_set((OPENSSL_SA *)sa, n, (void *)val);                                                      \
90
224
    }                                                                                                              \
Unexecuted instantiation: rsa_ossl.c:ossl_sa_BN_BLINDING_set
91
    SPARSE_ARRAY_OF(type)
92
93
#define DEFINE_SPARSE_ARRAY_OF(type) \
94
    DEFINE_SPARSE_ARRAY_OF_INTERNAL(type, type)
95
#define DEFINE_SPARSE_ARRAY_OF_CONST(type) \
96
    DEFINE_SPARSE_ARRAY_OF_INTERNAL(type, const type)
97
98
typedef struct sparse_array_st OPENSSL_SA;
99
OPENSSL_SA *ossl_sa_new(void);
100
void ossl_sa_free(OPENSSL_SA *sa);
101
void ossl_sa_free_leaves(OPENSSL_SA *sa);
102
size_t ossl_sa_num(const OPENSSL_SA *sa);
103
void ossl_sa_doall(const OPENSSL_SA *sa, void (*leaf)(ossl_uintmax_t, void *));
104
void ossl_sa_doall_arg(const OPENSSL_SA *sa,
105
    void (*leaf)(ossl_uintmax_t, void *, void *), void *);
106
void *ossl_sa_get(const OPENSSL_SA *sa, ossl_uintmax_t n);
107
int ossl_sa_set(OPENSSL_SA *sa, ossl_uintmax_t n, void *val);
108
109
#ifdef __cplusplus
110
}
111
#endif
112
#endif