Coverage Report

Created: 2026-10-16 07:31

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-2026 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
53.7k
#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
54.0k
    {                                                                                                             \
29
54.0k
        return (SPARSE_ARRAY_OF(type) *)ossl_sa_new();                                                            \
30
54.0k
    }                                                                                                             \
threads_common.c:ossl_sa_CTX_TABLE_ENTRY_new
Line
Count
Source
28
48
    {                                                                                                             \
29
48
        return (SPARSE_ARRAY_OF(type) *)ossl_sa_new();                                                            \
30
48
    }                                                                                                             \
property.c:ossl_sa_ALGORITHM_new
Line
Count
Source
28
256
    {                                                                                                             \
29
256
        return (SPARSE_ARRAY_OF(type) *)ossl_sa_new();                                                            \
30
256
    }                                                                                                             \
rsa_ossl.c:ossl_sa_BN_BLINDING_new
Line
Count
Source
28
53.7k
    {                                                                                                             \
29
53.7k
        return (SPARSE_ARRAY_OF(type) *)ossl_sa_new();                                                            \
30
53.7k
    }                                                                                                             \
31
    static ossl_unused ossl_inline void                                                                           \
32
    ossl_sa_##type##_free(SPARSE_ARRAY_OF(type) *sa)                                                              \
33
53.7k
    {                                                                                                             \
34
53.7k
        ossl_sa_free((OPENSSL_SA *)sa);                                                                           \
35
53.7k
    }                                                                                                             \
Unexecuted instantiation: threads_common.c:ossl_sa_CTX_TABLE_ENTRY_free
Unexecuted instantiation: property.c:ossl_sa_ALGORITHM_free
rsa_ossl.c:ossl_sa_BN_BLINDING_free
Line
Count
Source
33
53.7k
    {                                                                                                             \
34
53.7k
        ossl_sa_free((OPENSSL_SA *)sa);                                                                           \
35
53.7k
    }                                                                                                             \
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
53.7k
    {                                                                                                             \
74
53.7k
        struct ossl_sa_##type##_doall_thunk t;                                                                    \
75
53.7k
                                                                                                                  \
76
53.7k
        t.fn = leaf;                                                                                              \
77
53.7k
        t.arg = arg;                                                                                              \
78
53.7k
        ossl_sa_doall_arg((OPENSSL_SA *)sa,                                                                       \
79
53.7k
            ossl_sa_##type##_doall_arg_thunk, &t);                                                                \
80
53.7k
    }                                                                                                             \
Unexecuted instantiation: threads_common.c:ossl_sa_CTX_TABLE_ENTRY_doall_arg
Unexecuted instantiation: property.c:ossl_sa_ALGORITHM_doall_arg
rsa_ossl.c:ossl_sa_BN_BLINDING_doall_arg
Line
Count
Source
73
53.7k
    {                                                                                                             \
74
53.7k
        struct ossl_sa_##type##_doall_thunk t;                                                                    \
75
53.7k
                                                                                                                  \
76
53.7k
        t.fn = leaf;                                                                                              \
77
53.7k
        t.arg = arg;                                                                                              \
78
53.7k
        ossl_sa_doall_arg((OPENSSL_SA *)sa,                                                                       \
79
53.7k
            ossl_sa_##type##_doall_arg_thunk, &t);                                                                \
80
53.7k
    }                                                                                                             \
81
    static ossl_unused ossl_inline ctype *ossl_sa_##type##_get(const SPARSE_ARRAY_OF(type) *sa, ossl_uintmax_t n) \
82
252k
    {                                                                                                             \
83
252k
        return (type *)ossl_sa_get((OPENSSL_SA *)sa, n);                                                          \
84
252k
    }                                                                                                             \
threads_common.c:ossl_sa_CTX_TABLE_ENTRY_get
Line
Count
Source
82
246k
    {                                                                                                             \
83
246k
        return (type *)ossl_sa_get((OPENSSL_SA *)sa, n);                                                          \
84
246k
    }                                                                                                             \
property.c:ossl_sa_ALGORITHM_get
Line
Count
Source
82
5.39k
    {                                                                                                             \
83
5.39k
        return (type *)ossl_sa_get((OPENSSL_SA *)sa, n);                                                          \
84
5.39k
    }                                                                                                             \
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
2.76k
    {                                                                                                             \
89
2.76k
        return ossl_sa_set((OPENSSL_SA *)sa, n, (void *)val);                                                     \
90
2.76k
    }                                                                                                             \
threads_common.c:ossl_sa_CTX_TABLE_ENTRY_set
Line
Count
Source
88
112
    {                                                                                                             \
89
112
        return ossl_sa_set((OPENSSL_SA *)sa, n, (void *)val);                                                     \
90
112
    }                                                                                                             \
property.c:ossl_sa_ALGORITHM_set
Line
Count
Source
88
2.65k
    {                                                                                                             \
89
2.65k
        return ossl_sa_set((OPENSSL_SA *)sa, n, (void *)val);                                                     \
90
2.65k
    }                                                                                                             \
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