Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/openssl/src/crypto/engine/tb_pkmeth.c |
Source code | Switch to Preprocessed file |
Line | Source | Count | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | /* | - | ||||||||||||
2 | * Copyright 2006-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 | #include <openssl/evp.h> | - | ||||||||||||
12 | - | |||||||||||||
13 | static ENGINE_TABLE *pkey_meth_table = NULL; | - | ||||||||||||
14 | - | |||||||||||||
15 | void ENGINE_unregister_pkey_meths(ENGINE *e) | - | ||||||||||||
16 | { | - | ||||||||||||
17 | engine_table_unregister(&pkey_meth_table, e); | - | ||||||||||||
18 | } never executed: end of block | 0 | ||||||||||||
19 | - | |||||||||||||
20 | static void engine_unregister_all_pkey_meths(void) | - | ||||||||||||
21 | { | - | ||||||||||||
22 | engine_table_cleanup(&pkey_meth_table); | - | ||||||||||||
23 | } never executed: end of block | 0 | ||||||||||||
24 | - | |||||||||||||
25 | int ENGINE_register_pkey_meths(ENGINE *e) | - | ||||||||||||
26 | { | - | ||||||||||||
27 | if (e->pkey_meths) {
| 0-3748 | ||||||||||||
28 | const int *nids; | - | ||||||||||||
29 | int num_nids = e->pkey_meths(e, NULL, &nids, 0); | - | ||||||||||||
30 | if (num_nids > 0)
| 0 | ||||||||||||
31 | return engine_table_register(&pkey_meth_table, never executed: return engine_table_register(&pkey_meth_table, engine_unregister_all_pkey_meths, e, nids, num_nids, 0); | 0 | ||||||||||||
32 | engine_unregister_all_pkey_meths, e, never executed: return engine_table_register(&pkey_meth_table, engine_unregister_all_pkey_meths, e, nids, num_nids, 0); | 0 | ||||||||||||
33 | nids, num_nids, 0); never executed: return engine_table_register(&pkey_meth_table, engine_unregister_all_pkey_meths, e, nids, num_nids, 0); | 0 | ||||||||||||
34 | } never executed: end of block | 0 | ||||||||||||
35 | return 1; executed 3748 times by 1 test: return 1; Executed by:
| 3748 | ||||||||||||
36 | } | - | ||||||||||||
37 | - | |||||||||||||
38 | void ENGINE_register_all_pkey_meths(void) | - | ||||||||||||
39 | { | - | ||||||||||||
40 | ENGINE *e; | - | ||||||||||||
41 | - | |||||||||||||
42 | for (e = ENGINE_get_first(); e; e = ENGINE_get_next(e))
| 0 | ||||||||||||
43 | ENGINE_register_pkey_meths(e); never executed: ENGINE_register_pkey_meths(e); | 0 | ||||||||||||
44 | } never executed: end of block | 0 | ||||||||||||
45 | - | |||||||||||||
46 | int ENGINE_set_default_pkey_meths(ENGINE *e) | - | ||||||||||||
47 | { | - | ||||||||||||
48 | if (e->pkey_meths) {
| 0-367 | ||||||||||||
49 | const int *nids; | - | ||||||||||||
50 | int num_nids = e->pkey_meths(e, NULL, &nids, 0); | - | ||||||||||||
51 | if (num_nids > 0)
| 0 | ||||||||||||
52 | return engine_table_register(&pkey_meth_table, never executed: return engine_table_register(&pkey_meth_table, engine_unregister_all_pkey_meths, e, nids, num_nids, 1); | 0 | ||||||||||||
53 | engine_unregister_all_pkey_meths, e, never executed: return engine_table_register(&pkey_meth_table, engine_unregister_all_pkey_meths, e, nids, num_nids, 1); | 0 | ||||||||||||
54 | nids, num_nids, 1); never executed: return engine_table_register(&pkey_meth_table, engine_unregister_all_pkey_meths, e, nids, num_nids, 1); | 0 | ||||||||||||
55 | } never executed: end of block | 0 | ||||||||||||
56 | return 1; executed 367 times by 1 test: return 1; Executed by:
| 367 | ||||||||||||
57 | } | - | ||||||||||||
58 | - | |||||||||||||
59 | /* | - | ||||||||||||
60 | * Exposed API function to get a functional reference from the implementation | - | ||||||||||||
61 | * table (ie. try to get a functional reference from the tabled structural | - | ||||||||||||
62 | * references) for a given pkey_meth 'nid' | - | ||||||||||||
63 | */ | - | ||||||||||||
64 | ENGINE *ENGINE_get_pkey_meth_engine(int nid) | - | ||||||||||||
65 | { | - | ||||||||||||
66 | return engine_table_select(&pkey_meth_table, nid); executed 82152 times by 1 test: return engine_table_select(&pkey_meth_table, nid); Executed by:
| 82152 | ||||||||||||
67 | } | - | ||||||||||||
68 | - | |||||||||||||
69 | /* Obtains a pkey_meth implementation from an ENGINE functional reference */ | - | ||||||||||||
70 | const EVP_PKEY_METHOD *ENGINE_get_pkey_meth(ENGINE *e, int nid) | - | ||||||||||||
71 | { | - | ||||||||||||
72 | EVP_PKEY_METHOD *ret; | - | ||||||||||||
73 | ENGINE_PKEY_METHS_PTR fn = ENGINE_get_pkey_meths(e); | - | ||||||||||||
74 | if (!fn || !fn(e, &ret, NULL, nid)) {
| 0-4 | ||||||||||||
75 | ENGINEerr(ENGINE_F_ENGINE_GET_PKEY_METH, | - | ||||||||||||
76 | ENGINE_R_UNIMPLEMENTED_PUBLIC_KEY_METHOD); | - | ||||||||||||
77 | return NULL; executed 2 times by 1 test: return ((void *)0) ; Executed by:
| 2 | ||||||||||||
78 | } | - | ||||||||||||
79 | return ret; executed 4 times by 1 test: return ret; Executed by:
| 4 | ||||||||||||
80 | } | - | ||||||||||||
81 | - | |||||||||||||
82 | /* Gets the pkey_meth callback from an ENGINE structure */ | - | ||||||||||||
83 | ENGINE_PKEY_METHS_PTR ENGINE_get_pkey_meths(const ENGINE *e) | - | ||||||||||||
84 | { | - | ||||||||||||
85 | return e->pkey_meths; executed 6 times by 1 test: return e->pkey_meths; Executed by:
| 6 | ||||||||||||
86 | } | - | ||||||||||||
87 | - | |||||||||||||
88 | /* Sets the pkey_meth callback in an ENGINE structure */ | - | ||||||||||||
89 | int ENGINE_set_pkey_meths(ENGINE *e, ENGINE_PKEY_METHS_PTR f) | - | ||||||||||||
90 | { | - | ||||||||||||
91 | e->pkey_meths = f; | - | ||||||||||||
92 | return 1; executed 1 time by 1 test: return 1; Executed by:
| 1 | ||||||||||||
93 | } | - | ||||||||||||
94 | - | |||||||||||||
95 | /* | - | ||||||||||||
96 | * Internal function to free up EVP_PKEY_METHOD structures before an ENGINE | - | ||||||||||||
97 | * is destroyed | - | ||||||||||||
98 | */ | - | ||||||||||||
99 | - | |||||||||||||
100 | void engine_pkey_meths_free(ENGINE *e) | - | ||||||||||||
101 | { | - | ||||||||||||
102 | int i; | - | ||||||||||||
103 | EVP_PKEY_METHOD *pkm; | - | ||||||||||||
104 | if (e->pkey_meths) {
| 1-2843 | ||||||||||||
105 | const int *pknids; | - | ||||||||||||
106 | int npknids; | - | ||||||||||||
107 | npknids = e->pkey_meths(e, NULL, &pknids, 0); | - | ||||||||||||
108 | for (i = 0; i < npknids; i++) {
| 1 | ||||||||||||
109 | if (e->pkey_meths(e, &pkm, NULL, pknids[i])) {
| 0-1 | ||||||||||||
110 | EVP_PKEY_meth_free(pkm); | - | ||||||||||||
111 | } executed 1 time by 1 test: end of block Executed by:
| 1 | ||||||||||||
112 | } executed 1 time by 1 test: end of block Executed by:
| 1 | ||||||||||||
113 | } executed 1 time by 1 test: end of block Executed by:
| 1 | ||||||||||||
114 | } executed 2844 times by 1 test: end of block Executed by:
| 2844 | ||||||||||||
Source code | Switch to Preprocessed file |