Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/openssl/src/crypto/engine/eng_lib.c |
Switch to Source code | Preprocessed file |
Line | Source | Count | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | - | |||||||||||||
2 | - | |||||||||||||
3 | - | |||||||||||||
4 | CRYPTO_RWLOCK *global_engine_lock; | - | ||||||||||||
5 | - | |||||||||||||
6 | CRYPTO_ONCE engine_lock_init = | - | ||||||||||||
7 | 0 | - | ||||||||||||
8 | ; | - | ||||||||||||
9 | - | |||||||||||||
10 | - | |||||||||||||
11 | - | |||||||||||||
12 | static int do_engine_lock_init(void); int do_engine_lock_init_ossl_ret_ = 0; void do_engine_lock_init_ossl_(void) { do_engine_lock_init_ossl_ret_ = do_engine_lock_init(); } executed 1960 times by 1 test: static int do_engine_lock_init(void)end of block Executed by:
| 1960 | ||||||||||||
13 | { | - | ||||||||||||
14 | if (!OPENSSL_init_crypto(0,
| 0-1960 | ||||||||||||
15 | ((void *)0)
| 0-1960 | ||||||||||||
16 | )
| 0-1960 | ||||||||||||
17 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||
18 | global_engine_lock = CRYPTO_THREAD_lock_new(); | - | ||||||||||||
19 | return executed 1960 times by 1 test: global_engine_lock != return global_engine_lock != ((void *)0) ; Executed by:
executed 1960 times by 1 test: return global_engine_lock != ((void *)0) ; Executed by:
| 1960 | ||||||||||||
20 | ((void *)0) executed 1960 times by 1 test: return global_engine_lock != ((void *)0) ; Executed by:
| 1960 | ||||||||||||
21 | ; executed 1960 times by 1 test: return global_engine_lock != ((void *)0) ; Executed by:
| 1960 | ||||||||||||
22 | } | - | ||||||||||||
23 | - | |||||||||||||
24 | ENGINE *ENGINE_new(void) | - | ||||||||||||
25 | { | - | ||||||||||||
26 | ENGINE *ret; | - | ||||||||||||
27 | - | |||||||||||||
28 | if (!(CRYPTO_THREAD_run_once(&engine_lock_init, do_engine_lock_init_ossl_) ? do_engine_lock_init_ossl_ret_ : 0)
| 0-2844 | ||||||||||||
29 | || (
| 0-2844 | ||||||||||||
30 | ((void *)0)
| 0-2844 | ||||||||||||
31 | ) { | - | ||||||||||||
32 | ERR_put_error(38,(122),((1|64)),__FILE__,35); | - | ||||||||||||
33 | return never executed: return ((void *)0) ; never executed: return ((void *)0) ; | 0 | ||||||||||||
34 | ((void *)0) never executed: return ((void *)0) ; | 0 | ||||||||||||
35 | ; never executed: return ((void *)0) ; | 0 | ||||||||||||
36 | } | - | ||||||||||||
37 | ret->struct_ref = 1; | - | ||||||||||||
38 | ; | - | ||||||||||||
39 | if (!CRYPTO_new_ex_data(10, ret, &ret->ex_data)
| 0-2844 | ||||||||||||
40 | CRYPTO_free(ret, __FILE__, 41); | - | ||||||||||||
41 | return never executed: return ((void *)0) ; never executed: return ((void *)0) ; | 0 | ||||||||||||
42 | ((void *)0) never executed: return ((void *)0) ; | 0 | ||||||||||||
43 | ; never executed: return ((void *)0) ; | 0 | ||||||||||||
44 | } | - | ||||||||||||
45 | return executed 2844 times by 1 test: ret;return ret; Executed by:
executed 2844 times by 1 test: return ret; Executed by:
| 2844 | ||||||||||||
46 | } | - | ||||||||||||
47 | - | |||||||||||||
48 | - | |||||||||||||
49 | - | |||||||||||||
50 | - | |||||||||||||
51 | - | |||||||||||||
52 | - | |||||||||||||
53 | void engine_set_all_null(ENGINE *e) | - | ||||||||||||
54 | { | - | ||||||||||||
55 | e->id = | - | ||||||||||||
56 | ((void *)0) | - | ||||||||||||
57 | ; | - | ||||||||||||
58 | e->name = | - | ||||||||||||
59 | ((void *)0) | - | ||||||||||||
60 | ; | - | ||||||||||||
61 | e->rsa_meth = | - | ||||||||||||
62 | ((void *)0) | - | ||||||||||||
63 | ; | - | ||||||||||||
64 | e->dsa_meth = | - | ||||||||||||
65 | ((void *)0) | - | ||||||||||||
66 | ; | - | ||||||||||||
67 | e->dh_meth = | - | ||||||||||||
68 | ((void *)0) | - | ||||||||||||
69 | ; | - | ||||||||||||
70 | e->rand_meth = | - | ||||||||||||
71 | ((void *)0) | - | ||||||||||||
72 | ; | - | ||||||||||||
73 | e->ciphers = | - | ||||||||||||
74 | ((void *)0) | - | ||||||||||||
75 | ; | - | ||||||||||||
76 | e->digests = | - | ||||||||||||
77 | ((void *)0) | - | ||||||||||||
78 | ; | - | ||||||||||||
79 | e->destroy = | - | ||||||||||||
80 | ((void *)0) | - | ||||||||||||
81 | ; | - | ||||||||||||
82 | e->init = | - | ||||||||||||
83 | ((void *)0) | - | ||||||||||||
84 | ; | - | ||||||||||||
85 | e->finish = | - | ||||||||||||
86 | ((void *)0) | - | ||||||||||||
87 | ; | - | ||||||||||||
88 | e->ctrl = | - | ||||||||||||
89 | ((void *)0) | - | ||||||||||||
90 | ; | - | ||||||||||||
91 | e->load_privkey = | - | ||||||||||||
92 | ((void *)0) | - | ||||||||||||
93 | ; | - | ||||||||||||
94 | e->load_pubkey = | - | ||||||||||||
95 | ((void *)0) | - | ||||||||||||
96 | ; | - | ||||||||||||
97 | e->cmd_defns = | - | ||||||||||||
98 | ((void *)0) | - | ||||||||||||
99 | ; | - | ||||||||||||
100 | e->flags = 0; | - | ||||||||||||
101 | } executed 368 times by 1 test: end of block Executed by:
| 368 | ||||||||||||
102 | - | |||||||||||||
103 | int engine_free_util(ENGINE *e, int not_locked) | - | ||||||||||||
104 | { | - | ||||||||||||
105 | int i; | - | ||||||||||||
106 | - | |||||||||||||
107 | if (e ==
| 42-63980 | ||||||||||||
108 | ((void *)0)
| 42-63980 | ||||||||||||
109 | ) | - | ||||||||||||
110 | return executed 42 times by 1 test: 1;return 1; Executed by:
executed 42 times by 1 test: return 1; Executed by:
| 42 | ||||||||||||
111 | if (not_locked
| 7112-56868 | ||||||||||||
112 | CRYPTO_DOWN_REF(&e->struct_ref, &i, global_engine_lock); executed 7112 times by 1 test: CRYPTO_DOWN_REF(&e->struct_ref, &i, global_engine_lock); Executed by:
| 7112 | ||||||||||||
113 | else | - | ||||||||||||
114 | i = --e->struct_ref; executed 56868 times by 1 test: i = --e->struct_ref; Executed by:
| 56868 | ||||||||||||
115 | ; | - | ||||||||||||
116 | if (i > 0
| 2844-61136 | ||||||||||||
117 | return executed 61136 times by 1 test: 1;return 1; Executed by:
executed 61136 times by 1 test: return 1; Executed by:
| 61136 | ||||||||||||
118 | ; | - | ||||||||||||
119 | - | |||||||||||||
120 | engine_pkey_meths_free(e); | - | ||||||||||||
121 | engine_pkey_asn1_meths_free(e); | - | ||||||||||||
122 | - | |||||||||||||
123 | - | |||||||||||||
124 | - | |||||||||||||
125 | - | |||||||||||||
126 | if (e->destroy
| 368-2476 | ||||||||||||
127 | e->destroy(e); executed 368 times by 1 test: e->destroy(e); Executed by:
| 368 | ||||||||||||
128 | CRYPTO_free_ex_data(10, e, &e->ex_data); | - | ||||||||||||
129 | CRYPTO_free(e, __FILE__, 96); | - | ||||||||||||
130 | return executed 2844 times by 1 test: 1;return 1; Executed by:
executed 2844 times by 1 test: return 1; Executed by:
| 2844 | ||||||||||||
131 | } | - | ||||||||||||
132 | - | |||||||||||||
133 | int ENGINE_free(ENGINE *e) | - | ||||||||||||
134 | { | - | ||||||||||||
135 | return executed 7154 times by 1 test: engine_free_util(e, 1);return engine_free_util(e, 1); Executed by:
executed 7154 times by 1 test: return engine_free_util(e, 1); Executed by:
| 7154 | ||||||||||||
136 | } | - | ||||||||||||
137 | static struct stack_st_ENGINE_CLEANUP_ITEM *cleanup_stack = | - | ||||||||||||
138 | ((void *)0) | - | ||||||||||||
139 | ; | - | ||||||||||||
140 | static int int_cleanup_check(int create) | - | ||||||||||||
141 | { | - | ||||||||||||
142 | if (cleanup_stack
| 2076-3064 | ||||||||||||
143 | return executed 3064 times by 1 test: 1;return 1; Executed by:
executed 3064 times by 1 test: return 1; Executed by:
| 3064 | ||||||||||||
144 | if (!create
| 116-1960 | ||||||||||||
145 | return executed 116 times by 12 tests: 0;return 0; Executed by:
executed 116 times by 12 tests: return 0; Executed by:
| 116 | ||||||||||||
146 | cleanup_stack = sk_ENGINE_CLEANUP_ITEM_new_null(); | - | ||||||||||||
147 | return executed 1960 times by 1 test: (cleanup_stackreturn (cleanup_stack ? 1 : 0); Executed by:
executed 1960 times by 1 test: return (cleanup_stack ? 1 : 0); Executed by:
| 0-1960 | ||||||||||||
148 | } | - | ||||||||||||
149 | - | |||||||||||||
150 | static ENGINE_CLEANUP_ITEM *int_cleanup_item(ENGINE_CLEANUP_CB *cb) | - | ||||||||||||
151 | { | - | ||||||||||||
152 | ENGINE_CLEANUP_ITEM *item; | - | ||||||||||||
153 | - | |||||||||||||
154 | if ((
| 0-3064 | ||||||||||||
155 | ((void *)0)
| 0-3064 | ||||||||||||
156 | ) { | - | ||||||||||||
157 | ERR_put_error(38,(199),((1|64)),__FILE__,129); | - | ||||||||||||
158 | return never executed: return ((void *)0) ; never executed: return ((void *)0) ; | 0 | ||||||||||||
159 | ((void *)0) never executed: return ((void *)0) ; | 0 | ||||||||||||
160 | ; never executed: return ((void *)0) ; | 0 | ||||||||||||
161 | } | - | ||||||||||||
162 | item->cb = cb; | - | ||||||||||||
163 | return executed 3064 times by 1 test: item;return item; Executed by:
executed 3064 times by 1 test: return item; Executed by:
| 3064 | ||||||||||||
164 | } | - | ||||||||||||
165 | - | |||||||||||||
166 | void engine_cleanup_add_first(ENGINE_CLEANUP_CB *cb) | - | ||||||||||||
167 | { | - | ||||||||||||
168 | ENGINE_CLEANUP_ITEM *item; | - | ||||||||||||
169 | - | |||||||||||||
170 | if (!int_cleanup_check(1)
| 0-1101 | ||||||||||||
171 | return; never executed: return; | 0 | ||||||||||||
172 | item = int_cleanup_item(cb); | - | ||||||||||||
173 | if (item
| 0-1101 | ||||||||||||
174 | sk_ENGINE_CLEANUP_ITEM_insert(cleanup_stack, item, 0); executed 1101 times by 1 test: sk_ENGINE_CLEANUP_ITEM_insert(cleanup_stack, item, 0); Executed by:
| 1101 | ||||||||||||
175 | } executed 1101 times by 1 test: end of block Executed by:
| 1101 | ||||||||||||
176 | - | |||||||||||||
177 | void engine_cleanup_add_last(ENGINE_CLEANUP_CB *cb) | - | ||||||||||||
178 | { | - | ||||||||||||
179 | ENGINE_CLEANUP_ITEM *item; | - | ||||||||||||
180 | if (!int_cleanup_check(1)
| 0-1963 | ||||||||||||
181 | return; never executed: return; | 0 | ||||||||||||
182 | item = int_cleanup_item(cb); | - | ||||||||||||
183 | if (item !=
| 0-1963 | ||||||||||||
184 | ((void *)0)
| 0-1963 | ||||||||||||
185 | ) { | - | ||||||||||||
186 | if (sk_ENGINE_CLEANUP_ITEM_push(cleanup_stack, item) <= 0
| 0-1963 | ||||||||||||
187 | CRYPTO_free(item, __FILE__, 155); never executed: CRYPTO_free(item, __FILE__, 155); | 0 | ||||||||||||
188 | } executed 1963 times by 1 test: end of block Executed by:
| 1963 | ||||||||||||
189 | } executed 1963 times by 1 test: end of block Executed by:
| 1963 | ||||||||||||
190 | - | |||||||||||||
191 | - | |||||||||||||
192 | static void engine_cleanup_cb_free(ENGINE_CLEANUP_ITEM *item) | - | ||||||||||||
193 | { | - | ||||||||||||
194 | (*(item->cb)) (); | - | ||||||||||||
195 | CRYPTO_free(item, __FILE__, 163); | - | ||||||||||||
196 | } executed 3064 times by 1 test: end of block Executed by:
| 3064 | ||||||||||||
197 | - | |||||||||||||
198 | void engine_cleanup_int(void) | - | ||||||||||||
199 | { | - | ||||||||||||
200 | if (int_cleanup_check(0)
| 116-1960 | ||||||||||||
201 | sk_ENGINE_CLEANUP_ITEM_pop_free(cleanup_stack, | - | ||||||||||||
202 | engine_cleanup_cb_free); | - | ||||||||||||
203 | cleanup_stack = | - | ||||||||||||
204 | ((void *)0) | - | ||||||||||||
205 | ; | - | ||||||||||||
206 | } executed 1960 times by 1 test: end of block Executed by:
| 1960 | ||||||||||||
207 | CRYPTO_THREAD_lock_free(global_engine_lock); | - | ||||||||||||
208 | } executed 2076 times by 12 tests: end of block Executed by:
| 2076 | ||||||||||||
209 | - | |||||||||||||
210 | - | |||||||||||||
211 | - | |||||||||||||
212 | int ENGINE_set_ex_data(ENGINE *e, int idx, void *arg) | - | ||||||||||||
213 | { | - | ||||||||||||
214 | return executed 368 times by 1 test: CRYPTO_set_ex_data(&e->ex_data, idx, arg);return CRYPTO_set_ex_data(&e->ex_data, idx, arg); Executed by:
executed 368 times by 1 test: return CRYPTO_set_ex_data(&e->ex_data, idx, arg); Executed by:
| 368 | ||||||||||||
215 | } | - | ||||||||||||
216 | - | |||||||||||||
217 | void *ENGINE_get_ex_data(const ENGINE *e, int idx) | - | ||||||||||||
218 | { | - | ||||||||||||
219 | return executed 2208 times by 1 test: CRYPTO_get_ex_data(&e->ex_data, idx);return CRYPTO_get_ex_data(&e->ex_data, idx); Executed by:
executed 2208 times by 1 test: return CRYPTO_get_ex_data(&e->ex_data, idx); Executed by:
| 2208 | ||||||||||||
220 | } | - | ||||||||||||
221 | - | |||||||||||||
222 | - | |||||||||||||
223 | - | |||||||||||||
224 | - | |||||||||||||
225 | - | |||||||||||||
226 | - | |||||||||||||
227 | int ENGINE_set_id(ENGINE *e, const char *id) | - | ||||||||||||
228 | { | - | ||||||||||||
229 | if (id ==
| 0-2844 | ||||||||||||
230 | ((void *)0)
| 0-2844 | ||||||||||||
231 | ) { | - | ||||||||||||
232 | ERR_put_error(38,(129),((3|64)),__FILE__,196); | - | ||||||||||||
233 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||
234 | } | - | ||||||||||||
235 | e->id = id; | - | ||||||||||||
236 | return executed 2844 times by 1 test: 1;return 1; Executed by:
executed 2844 times by 1 test: return 1; Executed by:
| 2844 | ||||||||||||
237 | } | - | ||||||||||||
238 | - | |||||||||||||
239 | int ENGINE_set_name(ENGINE *e, const char *name) | - | ||||||||||||
240 | { | - | ||||||||||||
241 | if (name ==
| 0-2844 | ||||||||||||
242 | ((void *)0)
| 0-2844 | ||||||||||||
243 | ) { | - | ||||||||||||
244 | ERR_put_error(38,(130),((3|64)),__FILE__,206); | - | ||||||||||||
245 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||
246 | } | - | ||||||||||||
247 | e->name = name; | - | ||||||||||||
248 | return executed 2844 times by 1 test: 1;return 1; Executed by:
executed 2844 times by 1 test: return 1; Executed by:
| 2844 | ||||||||||||
249 | } | - | ||||||||||||
250 | - | |||||||||||||
251 | int ENGINE_set_destroy_function(ENGINE *e, ENGINE_GEN_INT_FUNC_PTR destroy_f) | - | ||||||||||||
252 | { | - | ||||||||||||
253 | e->destroy = destroy_f; | - | ||||||||||||
254 | return executed 368 times by 1 test: 1;return 1; Executed by:
executed 368 times by 1 test: return 1; Executed by:
| 368 | ||||||||||||
255 | } | - | ||||||||||||
256 | - | |||||||||||||
257 | int ENGINE_set_init_function(ENGINE *e, ENGINE_GEN_INT_FUNC_PTR init_f) | - | ||||||||||||
258 | { | - | ||||||||||||
259 | e->init = init_f; | - | ||||||||||||
260 | return executed 2327 times by 1 test: 1;return 1; Executed by:
executed 2327 times by 1 test: return 1; Executed by:
| 2327 | ||||||||||||
261 | } | - | ||||||||||||
262 | - | |||||||||||||
263 | int ENGINE_set_finish_function(ENGINE *e, ENGINE_GEN_INT_FUNC_PTR finish_f) | - | ||||||||||||
264 | { | - | ||||||||||||
265 | e->finish = finish_f; | - | ||||||||||||
266 | return executed 2327 times by 1 test: 1;return 1; Executed by:
executed 2327 times by 1 test: return 1; Executed by:
| 2327 | ||||||||||||
267 | } | - | ||||||||||||
268 | - | |||||||||||||
269 | int ENGINE_set_ctrl_function(ENGINE *e, ENGINE_CTRL_FUNC_PTR ctrl_f) | - | ||||||||||||
270 | { | - | ||||||||||||
271 | e->ctrl = ctrl_f; | - | ||||||||||||
272 | return executed 1959 times by 1 test: 1;return 1; Executed by:
executed 1959 times by 1 test: return 1; Executed by:
| 1959 | ||||||||||||
273 | } | - | ||||||||||||
274 | - | |||||||||||||
275 | int ENGINE_set_flags(ENGINE *e, int flags) | - | ||||||||||||
276 | { | - | ||||||||||||
277 | e->flags = flags; | - | ||||||||||||
278 | return executed 1959 times by 1 test: 1;return 1; Executed by:
executed 1959 times by 1 test: return 1; Executed by:
| 1959 | ||||||||||||
279 | } | - | ||||||||||||
280 | - | |||||||||||||
281 | int ENGINE_set_cmd_defns(ENGINE *e, const ENGINE_CMD_DEFN *defns) | - | ||||||||||||
282 | { | - | ||||||||||||
283 | e->cmd_defns = defns; | - | ||||||||||||
284 | return executed 1959 times by 1 test: 1;return 1; Executed by:
executed 1959 times by 1 test: return 1; Executed by:
| 1959 | ||||||||||||
285 | } | - | ||||||||||||
286 | - | |||||||||||||
287 | const char *ENGINE_get_id(const ENGINE *e) | - | ||||||||||||
288 | { | - | ||||||||||||
289 | return executed 886 times by 1 test: e->id;return e->id; Executed by:
executed 886 times by 1 test: return e->id; Executed by:
| 886 | ||||||||||||
290 | } | - | ||||||||||||
291 | - | |||||||||||||
292 | const char *ENGINE_get_name(const ENGINE *e) | - | ||||||||||||
293 | { | - | ||||||||||||
294 | return executed 519 times by 1 test: e->name;return e->name; Executed by:
executed 519 times by 1 test: return e->name; Executed by:
| 519 | ||||||||||||
295 | } | - | ||||||||||||
296 | - | |||||||||||||
297 | ENGINE_GEN_INT_FUNC_PTR ENGINE_get_destroy_function(const ENGINE *e) | - | ||||||||||||
298 | { | - | ||||||||||||
299 | return never executed: e->destroy;return e->destroy; never executed: return e->destroy; | 0 | ||||||||||||
300 | } | - | ||||||||||||
301 | - | |||||||||||||
302 | ENGINE_GEN_INT_FUNC_PTR ENGINE_get_init_function(const ENGINE *e) | - | ||||||||||||
303 | { | - | ||||||||||||
304 | return never executed: e->init;return e->init; never executed: return e->init; | 0 | ||||||||||||
305 | } | - | ||||||||||||
306 | - | |||||||||||||
307 | ENGINE_GEN_INT_FUNC_PTR ENGINE_get_finish_function(const ENGINE *e) | - | ||||||||||||
308 | { | - | ||||||||||||
309 | return never executed: e->finish;return e->finish; never executed: return e->finish; | 0 | ||||||||||||
310 | } | - | ||||||||||||
311 | - | |||||||||||||
312 | ENGINE_CTRL_FUNC_PTR ENGINE_get_ctrl_function(const ENGINE *e) | - | ||||||||||||
313 | { | - | ||||||||||||
314 | return never executed: e->ctrl;return e->ctrl; never executed: return e->ctrl; | 0 | ||||||||||||
315 | } | - | ||||||||||||
316 | - | |||||||||||||
317 | int ENGINE_get_flags(const ENGINE *e) | - | ||||||||||||
318 | { | - | ||||||||||||
319 | return never executed: e->flags;return e->flags; never executed: return e->flags; | 0 | ||||||||||||
320 | } | - | ||||||||||||
321 | - | |||||||||||||
322 | const ENGINE_CMD_DEFN *ENGINE_get_cmd_defns(const ENGINE *e) | - | ||||||||||||
323 | { | - | ||||||||||||
324 | return never executed: e->cmd_defns;return e->cmd_defns; never executed: return e->cmd_defns; | 0 | ||||||||||||
325 | } | - | ||||||||||||
326 | - | |||||||||||||
327 | - | |||||||||||||
328 | - | |||||||||||||
329 | - | |||||||||||||
330 | - | |||||||||||||
331 | - | |||||||||||||
332 | static int internal_static_hack = 0; | - | ||||||||||||
333 | - | |||||||||||||
334 | void *ENGINE_get_static_state(void) | - | ||||||||||||
335 | { | - | ||||||||||||
336 | return executed 736 times by 1 test: &internal_static_hack;return &internal_static_hack; Executed by:
executed 736 times by 1 test: return &internal_static_hack; Executed by:
| 736 | ||||||||||||
337 | } | - | ||||||||||||
Switch to Source code | Preprocessed file |