Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/openssl/src/crypto/engine/tb_cipher.c |
Source code | Switch to Preprocessed file |
Line | Source | Count | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | /* | - | ||||||||||||
2 | * Copyright 2001-2018 The OpenSSL Project Authors. All Rights Reserved. | - | ||||||||||||
3 | * | - | ||||||||||||
4 | * Licensed under the OpenSSL license (the "License"). You may not use | - | ||||||||||||
5 | * this file except in compliance with the License. You can obtain a copy | - | ||||||||||||
6 | * in the file LICENSE in the source distribution or at | - | ||||||||||||
7 | * https://www.openssl.org/source/license.html | - | ||||||||||||
8 | */ | - | ||||||||||||
9 | - | |||||||||||||
10 | #include "eng_int.h" | - | ||||||||||||
11 | - | |||||||||||||
12 | static ENGINE_TABLE *cipher_table = NULL; | - | ||||||||||||
13 | - | |||||||||||||
14 | void ENGINE_unregister_ciphers(ENGINE *e) | - | ||||||||||||
15 | { | - | ||||||||||||
16 | engine_table_unregister(&cipher_table, e); | - | ||||||||||||
17 | } never executed: end of block | 0 | ||||||||||||
18 | - | |||||||||||||
19 | static void engine_unregister_all_ciphers(void) | - | ||||||||||||
20 | { | - | ||||||||||||
21 | engine_table_cleanup(&cipher_table); | - | ||||||||||||
22 | } executed 367 times by 1 test: end of block Executed by:
| 367 | ||||||||||||
23 | - | |||||||||||||
24 | int ENGINE_register_ciphers(ENGINE *e) | - | ||||||||||||
25 | { | - | ||||||||||||
26 | if (e->ciphers) {
| 0-3748 | ||||||||||||
27 | const int *nids; | - | ||||||||||||
28 | int num_nids = e->ciphers(e, NULL, &nids, 0); | - | ||||||||||||
29 | if (num_nids > 0)
| 0 | ||||||||||||
30 | return engine_table_register(&cipher_table, never executed: return engine_table_register(&cipher_table, engine_unregister_all_ciphers, e, nids, num_nids, 0); | 0 | ||||||||||||
31 | engine_unregister_all_ciphers, e, never executed: return engine_table_register(&cipher_table, engine_unregister_all_ciphers, e, nids, num_nids, 0); | 0 | ||||||||||||
32 | nids, num_nids, 0); never executed: return engine_table_register(&cipher_table, engine_unregister_all_ciphers, e, nids, num_nids, 0); | 0 | ||||||||||||
33 | } never executed: end of block | 0 | ||||||||||||
34 | return 1; executed 3748 times by 1 test: return 1; Executed by:
| 3748 | ||||||||||||
35 | } | - | ||||||||||||
36 | - | |||||||||||||
37 | void ENGINE_register_all_ciphers(void) | - | ||||||||||||
38 | { | - | ||||||||||||
39 | ENGINE *e; | - | ||||||||||||
40 | - | |||||||||||||
41 | for (e = ENGINE_get_first(); e; e = ENGINE_get_next(e))
| 0 | ||||||||||||
42 | ENGINE_register_ciphers(e); never executed: ENGINE_register_ciphers(e); | 0 | ||||||||||||
43 | } never executed: end of block | 0 | ||||||||||||
44 | - | |||||||||||||
45 | int ENGINE_set_default_ciphers(ENGINE *e) | - | ||||||||||||
46 | { | - | ||||||||||||
47 | if (e->ciphers) {
| 0-367 | ||||||||||||
48 | const int *nids; | - | ||||||||||||
49 | int num_nids = e->ciphers(e, NULL, &nids, 0); | - | ||||||||||||
50 | if (num_nids > 0)
| 0-367 | ||||||||||||
51 | return engine_table_register(&cipher_table, executed 367 times by 1 test: return engine_table_register(&cipher_table, engine_unregister_all_ciphers, e, nids, num_nids, 1); Executed by:
| 367 | ||||||||||||
52 | engine_unregister_all_ciphers, e, executed 367 times by 1 test: return engine_table_register(&cipher_table, engine_unregister_all_ciphers, e, nids, num_nids, 1); Executed by:
| 367 | ||||||||||||
53 | nids, num_nids, 1); executed 367 times by 1 test: return engine_table_register(&cipher_table, engine_unregister_all_ciphers, e, nids, num_nids, 1); Executed by:
| 367 | ||||||||||||
54 | } never executed: end of block | 0 | ||||||||||||
55 | return 1; never executed: return 1; | 0 | ||||||||||||
56 | } | - | ||||||||||||
57 | - | |||||||||||||
58 | /* | - | ||||||||||||
59 | * Exposed API function to get a functional reference from the implementation | - | ||||||||||||
60 | * table (ie. try to get a functional reference from the tabled structural | - | ||||||||||||
61 | * references) for a given cipher 'nid' | - | ||||||||||||
62 | */ | - | ||||||||||||
63 | ENGINE *ENGINE_get_cipher_engine(int nid) | - | ||||||||||||
64 | { | - | ||||||||||||
65 | return engine_table_select(&cipher_table, nid); executed 3192459 times by 2 tests: return engine_table_select(&cipher_table, nid); Executed by:
| 3192459 | ||||||||||||
66 | } | - | ||||||||||||
67 | - | |||||||||||||
68 | /* Obtains a cipher implementation from an ENGINE functional reference */ | - | ||||||||||||
69 | const EVP_CIPHER *ENGINE_get_cipher(ENGINE *e, int nid) | - | ||||||||||||
70 | { | - | ||||||||||||
71 | const EVP_CIPHER *ret; | - | ||||||||||||
72 | ENGINE_CIPHERS_PTR fn = ENGINE_get_ciphers(e); | - | ||||||||||||
73 | if (!fn || !fn(e, &ret, NULL, nid)) {
| 0-757 | ||||||||||||
74 | ENGINEerr(ENGINE_F_ENGINE_GET_CIPHER, ENGINE_R_UNIMPLEMENTED_CIPHER); | - | ||||||||||||
75 | return NULL; never executed: return ((void *)0) ; | 0 | ||||||||||||
76 | } | - | ||||||||||||
77 | return ret; executed 757 times by 1 test: return ret; Executed by:
| 757 | ||||||||||||
78 | } | - | ||||||||||||
79 | - | |||||||||||||
80 | /* Gets the cipher callback from an ENGINE structure */ | - | ||||||||||||
81 | ENGINE_CIPHERS_PTR ENGINE_get_ciphers(const ENGINE *e) | - | ||||||||||||
82 | { | - | ||||||||||||
83 | return e->ciphers; executed 757 times by 1 test: return e->ciphers; Executed by:
| 757 | ||||||||||||
84 | } | - | ||||||||||||
85 | - | |||||||||||||
86 | /* Sets the cipher callback in an ENGINE structure */ | - | ||||||||||||
87 | int ENGINE_set_ciphers(ENGINE *e, ENGINE_CIPHERS_PTR f) | - | ||||||||||||
88 | { | - | ||||||||||||
89 | e->ciphers = f; | - | ||||||||||||
90 | return 1; executed 368 times by 1 test: return 1; Executed by:
| 368 | ||||||||||||
91 | } | - | ||||||||||||
Source code | Switch to Preprocessed file |