Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/libressl/src/crypto/asn1/ameth_lib.c |
Switch to Source code | Preprocessed file |
Line | Source | Count | ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | - | |||||||||||||||||||||||||
2 | - | |||||||||||||||||||||||||
3 | - | |||||||||||||||||||||||||
4 | - | |||||||||||||||||||||||||
5 | - | |||||||||||||||||||||||||
6 | - | |||||||||||||||||||||||||
7 | - | |||||||||||||||||||||||||
8 | extern const EVP_PKEY_ASN1_METHOD rsa_asn1_meths[]; | - | ||||||||||||||||||||||||
9 | extern const EVP_PKEY_ASN1_METHOD dsa_asn1_meths[]; | - | ||||||||||||||||||||||||
10 | extern const EVP_PKEY_ASN1_METHOD dh_asn1_meth; | - | ||||||||||||||||||||||||
11 | extern const EVP_PKEY_ASN1_METHOD eckey_asn1_meth; | - | ||||||||||||||||||||||||
12 | extern const EVP_PKEY_ASN1_METHOD gostr01_asn1_meths[]; | - | ||||||||||||||||||||||||
13 | extern const EVP_PKEY_ASN1_METHOD gostimit_asn1_meth; | - | ||||||||||||||||||||||||
14 | extern const EVP_PKEY_ASN1_METHOD hmac_asn1_meth; | - | ||||||||||||||||||||||||
15 | extern const EVP_PKEY_ASN1_METHOD cmac_asn1_meth; | - | ||||||||||||||||||||||||
16 | - | |||||||||||||||||||||||||
17 | - | |||||||||||||||||||||||||
18 | static const EVP_PKEY_ASN1_METHOD *standard_methods[] = { | - | ||||||||||||||||||||||||
19 | - | |||||||||||||||||||||||||
20 | &rsa_asn1_meths[0], | - | ||||||||||||||||||||||||
21 | &rsa_asn1_meths[1], | - | ||||||||||||||||||||||||
22 | - | |||||||||||||||||||||||||
23 | - | |||||||||||||||||||||||||
24 | &dh_asn1_meth, | - | ||||||||||||||||||||||||
25 | - | |||||||||||||||||||||||||
26 | - | |||||||||||||||||||||||||
27 | &dsa_asn1_meths[0], | - | ||||||||||||||||||||||||
28 | &dsa_asn1_meths[1], | - | ||||||||||||||||||||||||
29 | &dsa_asn1_meths[2], | - | ||||||||||||||||||||||||
30 | &dsa_asn1_meths[3], | - | ||||||||||||||||||||||||
31 | &dsa_asn1_meths[4], | - | ||||||||||||||||||||||||
32 | - | |||||||||||||||||||||||||
33 | - | |||||||||||||||||||||||||
34 | &eckey_asn1_meth, | - | ||||||||||||||||||||||||
35 | - | |||||||||||||||||||||||||
36 | - | |||||||||||||||||||||||||
37 | &gostr01_asn1_meths[0], | - | ||||||||||||||||||||||||
38 | &gostimit_asn1_meth, | - | ||||||||||||||||||||||||
39 | - | |||||||||||||||||||||||||
40 | &hmac_asn1_meth, | - | ||||||||||||||||||||||||
41 | &cmac_asn1_meth, | - | ||||||||||||||||||||||||
42 | - | |||||||||||||||||||||||||
43 | &gostr01_asn1_meths[1], | - | ||||||||||||||||||||||||
44 | &gostr01_asn1_meths[2], | - | ||||||||||||||||||||||||
45 | - | |||||||||||||||||||||||||
46 | }; | - | ||||||||||||||||||||||||
47 | - | |||||||||||||||||||||||||
48 | typedef int sk_cmp_fn_type(const char * const *a, const char * const *b); | - | ||||||||||||||||||||||||
49 | struct stack_st_EVP_PKEY_ASN1_METHOD { _STACK stack; }; | - | ||||||||||||||||||||||||
50 | static struct stack_st_EVP_PKEY_ASN1_METHOD *app_methods = | - | ||||||||||||||||||||||||
51 | ((void *)0) | - | ||||||||||||||||||||||||
52 | ; | - | ||||||||||||||||||||||||
53 | - | |||||||||||||||||||||||||
54 | static int ameth_cmp_BSEARCH_CMP_FN(const void *, const void *); | - | ||||||||||||||||||||||||
55 | static int ameth_cmp(const EVP_PKEY_ASN1_METHOD * const *, const EVP_PKEY_ASN1_METHOD * const *); | - | ||||||||||||||||||||||||
56 | static const EVP_PKEY_ASN1_METHOD * *OBJ_bsearch_ameth(const EVP_PKEY_ASN1_METHOD * *key, const EVP_PKEY_ASN1_METHOD * const *base, int num); | - | ||||||||||||||||||||||||
57 | - | |||||||||||||||||||||||||
58 | static int | - | ||||||||||||||||||||||||
59 | ameth_cmp(const EVP_PKEY_ASN1_METHOD * const *a, | - | ||||||||||||||||||||||||
60 | const EVP_PKEY_ASN1_METHOD * const *b) | - | ||||||||||||||||||||||||
61 | { | - | ||||||||||||||||||||||||
62 | return executed 4961 times by 8 tests: ((*a)->pkey_id - (*b)->pkey_id);return ((*a)->pkey_id - (*b)->pkey_id); Executed by:
executed 4961 times by 8 tests: return ((*a)->pkey_id - (*b)->pkey_id); Executed by:
| 4961 | ||||||||||||||||||||||||
63 | } | - | ||||||||||||||||||||||||
64 | - | |||||||||||||||||||||||||
65 | - | |||||||||||||||||||||||||
66 | static int | - | ||||||||||||||||||||||||
67 | ameth_cmp_BSEARCH_CMP_FN(const void *a_, const void *b_) | - | ||||||||||||||||||||||||
68 | { | - | ||||||||||||||||||||||||
69 | const EVP_PKEY_ASN1_METHOD * const *a = a_; | - | ||||||||||||||||||||||||
70 | const EVP_PKEY_ASN1_METHOD * const *b = b_; | - | ||||||||||||||||||||||||
71 | return executed 4961 times by 8 tests: ameth_cmp(a, b);return ameth_cmp(a, b); Executed by:
executed 4961 times by 8 tests: return ameth_cmp(a, b); Executed by:
| 4961 | ||||||||||||||||||||||||
72 | } | - | ||||||||||||||||||||||||
73 | - | |||||||||||||||||||||||||
74 | static const EVP_PKEY_ASN1_METHOD * * | - | ||||||||||||||||||||||||
75 | OBJ_bsearch_ameth(const EVP_PKEY_ASN1_METHOD * *key, const EVP_PKEY_ASN1_METHOD * const *base, int num) | - | ||||||||||||||||||||||||
76 | { | - | ||||||||||||||||||||||||
77 | return executed 2149 times by 8 tests: (const EVP_PKEY_ASN1_METHOD * *)OBJ_bsearch_(key, base, num, sizeof(const EVP_PKEY_ASN1_METHOD *),return (const EVP_PKEY_ASN1_METHOD * *)OBJ_bsearch_(key, base, num, sizeof(const EVP_PKEY_ASN1_METHOD *), ameth_cmp_BSEARCH_CMP_FN); Executed by:
executed 2149 times by 8 tests: return (const EVP_PKEY_ASN1_METHOD * *)OBJ_bsearch_(key, base, num, sizeof(const EVP_PKEY_ASN1_METHOD *), ameth_cmp_BSEARCH_CMP_FN); Executed by:
| 2149 | ||||||||||||||||||||||||
78 | ameth_cmp_BSEARCH_CMP_FN); executed 2149 times by 8 tests: return (const EVP_PKEY_ASN1_METHOD * *)OBJ_bsearch_(key, base, num, sizeof(const EVP_PKEY_ASN1_METHOD *), ameth_cmp_BSEARCH_CMP_FN); Executed by:
| 2149 | ||||||||||||||||||||||||
79 | } | - | ||||||||||||||||||||||||
80 | - | |||||||||||||||||||||||||
81 | int | - | ||||||||||||||||||||||||
82 | EVP_PKEY_asn1_get_count(void) | - | ||||||||||||||||||||||||
83 | { | - | ||||||||||||||||||||||||
84 | int num = sizeof(standard_methods) / sizeof(EVP_PKEY_ASN1_METHOD *); | - | ||||||||||||||||||||||||
85 | if (app_methods
| 0-154 | ||||||||||||||||||||||||
86 | num += sk_num(((_STACK*) (1 ? (app_methods) : (struct stack_st_EVP_PKEY_ASN1_METHOD*)0))); never executed: num += sk_num(((_STACK*) (1 ? (app_methods) : (struct stack_st_EVP_PKEY_ASN1_METHOD*)0))); | 0 | ||||||||||||||||||||||||
87 | return executed 154 times by 5 tests: num;return num; Executed by:
executed 154 times by 5 tests: return num; Executed by:
| 154 | ||||||||||||||||||||||||
88 | } | - | ||||||||||||||||||||||||
89 | - | |||||||||||||||||||||||||
90 | const EVP_PKEY_ASN1_METHOD * | - | ||||||||||||||||||||||||
91 | EVP_PKEY_asn1_get0(int idx) | - | ||||||||||||||||||||||||
92 | { | - | ||||||||||||||||||||||||
93 | int num = sizeof(standard_methods) / sizeof(EVP_PKEY_ASN1_METHOD *); | - | ||||||||||||||||||||||||
94 | if (idx < 0
| 0-154 | ||||||||||||||||||||||||
95 | return never executed: return ((void *)0) ; never executed: return ((void *)0) ; | 0 | ||||||||||||||||||||||||
96 | ((void *)0) never executed: return ((void *)0) ; | 0 | ||||||||||||||||||||||||
97 | ; never executed: return ((void *)0) ; | 0 | ||||||||||||||||||||||||
98 | if (idx < num
| 0-154 | ||||||||||||||||||||||||
99 | return executed 154 times by 5 tests: standard_methods[idx];return standard_methods[idx]; Executed by:
executed 154 times by 5 tests: return standard_methods[idx]; Executed by:
| 154 | ||||||||||||||||||||||||
100 | idx -= num; | - | ||||||||||||||||||||||||
101 | return never executed: ((EVP_PKEY_ASN1_METHOD *)sk_value(((_STACK*) (1 ? (app_methods) : (struct stack_st_EVP_PKEY_ASN1_METHOD*)0)), (idx)));return ((EVP_PKEY_ASN1_METHOD *)sk_value(((_STACK*) (1 ? (app_methods) : (struct stack_st_EVP_PKEY_ASN1_METHOD*)0)), (idx))); never executed: return ((EVP_PKEY_ASN1_METHOD *)sk_value(((_STACK*) (1 ? (app_methods) : (struct stack_st_EVP_PKEY_ASN1_METHOD*)0)), (idx))); | 0 | ||||||||||||||||||||||||
102 | } | - | ||||||||||||||||||||||||
103 | - | |||||||||||||||||||||||||
104 | static const EVP_PKEY_ASN1_METHOD * | - | ||||||||||||||||||||||||
105 | pkey_asn1_find(int type) | - | ||||||||||||||||||||||||
106 | { | - | ||||||||||||||||||||||||
107 | EVP_PKEY_ASN1_METHOD tmp; | - | ||||||||||||||||||||||||
108 | const EVP_PKEY_ASN1_METHOD *t = &tmp, **ret; | - | ||||||||||||||||||||||||
109 | tmp.pkey_id = type; | - | ||||||||||||||||||||||||
110 | if (app_methods
| 0-2149 | ||||||||||||||||||||||||
111 | int idx; | - | ||||||||||||||||||||||||
112 | idx = sk_find(((_STACK*) (1 ? (app_methods) : (struct stack_st_EVP_PKEY_ASN1_METHOD*)0)), ((void*) (1 ? (&tmp) : (EVP_PKEY_ASN1_METHOD*)0))); | - | ||||||||||||||||||||||||
113 | if (idx >= 0
| 0 | ||||||||||||||||||||||||
114 | return never executed: ((EVP_PKEY_ASN1_METHOD *)sk_value(((_STACK*) (1 ? (app_methods) : (struct stack_st_EVP_PKEY_ASN1_METHOD*)0)), (idx)));return ((EVP_PKEY_ASN1_METHOD *)sk_value(((_STACK*) (1 ? (app_methods) : (struct stack_st_EVP_PKEY_ASN1_METHOD*)0)), (idx))); never executed: return ((EVP_PKEY_ASN1_METHOD *)sk_value(((_STACK*) (1 ? (app_methods) : (struct stack_st_EVP_PKEY_ASN1_METHOD*)0)), (idx))); | 0 | ||||||||||||||||||||||||
115 | } never executed: end of block | 0 | ||||||||||||||||||||||||
116 | ret = OBJ_bsearch_ameth(&t, standard_methods, | - | ||||||||||||||||||||||||
117 | sizeof(standard_methods) / sizeof(EVP_PKEY_ASN1_METHOD *)); | - | ||||||||||||||||||||||||
118 | if (!ret
| 0-2149 | ||||||||||||||||||||||||
119 | return never executed: return ((void *)0) ; never executed: return ((void *)0) ; | 0 | ||||||||||||||||||||||||
120 | ((void *)0) never executed: return ((void *)0) ; | 0 | ||||||||||||||||||||||||
121 | ; never executed: return ((void *)0) ; | 0 | ||||||||||||||||||||||||
122 | return executed 2149 times by 8 tests: *ret;return *ret; Executed by:
executed 2149 times by 8 tests: return *ret; Executed by:
| 2149 | ||||||||||||||||||||||||
123 | } | - | ||||||||||||||||||||||||
124 | - | |||||||||||||||||||||||||
125 | - | |||||||||||||||||||||||||
126 | - | |||||||||||||||||||||||||
127 | - | |||||||||||||||||||||||||
128 | - | |||||||||||||||||||||||||
129 | - | |||||||||||||||||||||||||
130 | - | |||||||||||||||||||||||||
131 | const EVP_PKEY_ASN1_METHOD * | - | ||||||||||||||||||||||||
132 | EVP_PKEY_asn1_find(ENGINE **pe, int type) | - | ||||||||||||||||||||||||
133 | { | - | ||||||||||||||||||||||||
134 | const EVP_PKEY_ASN1_METHOD *t; | - | ||||||||||||||||||||||||
135 | - | |||||||||||||||||||||||||
136 | for (;;) { | - | ||||||||||||||||||||||||
137 | t = pkey_asn1_find(type); | - | ||||||||||||||||||||||||
138 | if (!t
| 0-2149 | ||||||||||||||||||||||||
139 | break; executed 2149 times by 8 tests: break; Executed by:
| 2149 | ||||||||||||||||||||||||
140 | type = t->pkey_base_id; | - | ||||||||||||||||||||||||
141 | } never executed: end of block | 0 | ||||||||||||||||||||||||
142 | if (pe
| 7-2142 | ||||||||||||||||||||||||
143 | - | |||||||||||||||||||||||||
144 | ENGINE *e; | - | ||||||||||||||||||||||||
145 | - | |||||||||||||||||||||||||
146 | e = ENGINE_get_pkey_asn1_meth_engine(type); | - | ||||||||||||||||||||||||
147 | if (e
| 0-2142 | ||||||||||||||||||||||||
148 | *pe = e; | - | ||||||||||||||||||||||||
149 | return never executed: ENGINE_get_pkey_asn1_meth(e, type);return ENGINE_get_pkey_asn1_meth(e, type); never executed: return ENGINE_get_pkey_asn1_meth(e, type); | 0 | ||||||||||||||||||||||||
150 | } | - | ||||||||||||||||||||||||
151 | - | |||||||||||||||||||||||||
152 | *pe = | - | ||||||||||||||||||||||||
153 | ((void *)0) | - | ||||||||||||||||||||||||
154 | ; | - | ||||||||||||||||||||||||
155 | } executed 2142 times by 8 tests: end of block Executed by:
| 2142 | ||||||||||||||||||||||||
156 | return executed 2149 times by 8 tests: t;return t; Executed by:
executed 2149 times by 8 tests: return t; Executed by:
| 2149 | ||||||||||||||||||||||||
157 | } | - | ||||||||||||||||||||||||
158 | - | |||||||||||||||||||||||||
159 | const EVP_PKEY_ASN1_METHOD * | - | ||||||||||||||||||||||||
160 | EVP_PKEY_asn1_find_str(ENGINE **pe, const char *str, int len) | - | ||||||||||||||||||||||||
161 | { | - | ||||||||||||||||||||||||
162 | int i; | - | ||||||||||||||||||||||||
163 | const EVP_PKEY_ASN1_METHOD *ameth; | - | ||||||||||||||||||||||||
164 | if (len == -1
| 0-133 | ||||||||||||||||||||||||
165 | len = strlen(str); never executed: len = strlen(str); | 0 | ||||||||||||||||||||||||
166 | if (pe
| 2-131 | ||||||||||||||||||||||||
167 | - | |||||||||||||||||||||||||
168 | ENGINE *e; | - | ||||||||||||||||||||||||
169 | ameth = ENGINE_pkey_asn1_find_str(&e, str, len); | - | ||||||||||||||||||||||||
170 | if (ameth
| 0-2 | ||||||||||||||||||||||||
171 | - | |||||||||||||||||||||||||
172 | - | |||||||||||||||||||||||||
173 | - | |||||||||||||||||||||||||
174 | if (!ENGINE_init(e)
| 0 | ||||||||||||||||||||||||
175 | ameth = never executed: ameth = ((void *)0) ; | 0 | ||||||||||||||||||||||||
176 | ((void *)0) never executed: ameth = ((void *)0) ; | 0 | ||||||||||||||||||||||||
177 | ; never executed: ameth = ((void *)0) ; | 0 | ||||||||||||||||||||||||
178 | ENGINE_free(e); | - | ||||||||||||||||||||||||
179 | *pe = e; | - | ||||||||||||||||||||||||
180 | return never executed: ameth;return ameth; never executed: return ameth; | 0 | ||||||||||||||||||||||||
181 | } | - | ||||||||||||||||||||||||
182 | - | |||||||||||||||||||||||||
183 | *pe = | - | ||||||||||||||||||||||||
184 | ((void *)0) | - | ||||||||||||||||||||||||
185 | ; | - | ||||||||||||||||||||||||
186 | } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||||||||||||||
187 | for (i = 0; i < EVP_PKEY_asn1_get_count()
| 0-154 | ||||||||||||||||||||||||
188 | ameth = EVP_PKEY_asn1_get0(i); | - | ||||||||||||||||||||||||
189 | if (ameth->pkey_flags & 0x1
| 15-139 | ||||||||||||||||||||||||
190 | continue; executed 15 times by 1 test: continue; Executed by:
| 15 | ||||||||||||||||||||||||
191 | if (((
| 3-136 | ||||||||||||||||||||||||
192 | !strncasecmp(ameth->pem_str, str, len)
| 3-133 | ||||||||||||||||||||||||
193 | return executed 133 times by 5 tests: ameth;return ameth; Executed by:
executed 133 times by 5 tests: return ameth; Executed by:
| 133 | ||||||||||||||||||||||||
194 | } executed 6 times by 1 test: end of block Executed by:
| 6 | ||||||||||||||||||||||||
195 | return never executed: return ((void *)0) ; never executed: return ((void *)0) ; | 0 | ||||||||||||||||||||||||
196 | ((void *)0) never executed: return ((void *)0) ; | 0 | ||||||||||||||||||||||||
197 | ; never executed: return ((void *)0) ; | 0 | ||||||||||||||||||||||||
198 | } | - | ||||||||||||||||||||||||
199 | - | |||||||||||||||||||||||||
200 | int | - | ||||||||||||||||||||||||
201 | EVP_PKEY_asn1_add0(const EVP_PKEY_ASN1_METHOD *ameth) | - | ||||||||||||||||||||||||
202 | { | - | ||||||||||||||||||||||||
203 | if (app_methods ==
| 0 | ||||||||||||||||||||||||
204 | ((void *)0)
| 0 | ||||||||||||||||||||||||
205 | ) { | - | ||||||||||||||||||||||||
206 | app_methods = ((struct stack_st_EVP_PKEY_ASN1_METHOD *)sk_new(((int (*)(const void *, const void *)) ((1 ? (ameth_cmp) : (int (*)(const EVP_PKEY_ASN1_METHOD * const *, const EVP_PKEY_ASN1_METHOD * const *))0))))); | - | ||||||||||||||||||||||||
207 | if (!app_methods
| 0 | ||||||||||||||||||||||||
208 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||
209 | } never executed: end of block | 0 | ||||||||||||||||||||||||
210 | if (!sk_push(((_STACK*) (1 ? (app_methods) : (struct stack_st_EVP_PKEY_ASN1_METHOD*)0)), ((void*) (1 ? (ameth) : (EVP_PKEY_ASN1_METHOD*)0)))
| 0 | ||||||||||||||||||||||||
211 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||
212 | sk_sort(((_STACK*) (1 ? (app_methods) : (struct stack_st_EVP_PKEY_ASN1_METHOD*)0))); | - | ||||||||||||||||||||||||
213 | return never executed: 1;return 1; never executed: return 1; | 0 | ||||||||||||||||||||||||
214 | } | - | ||||||||||||||||||||||||
215 | - | |||||||||||||||||||||||||
216 | int | - | ||||||||||||||||||||||||
217 | EVP_PKEY_asn1_add_alias(int to, int from) | - | ||||||||||||||||||||||||
218 | { | - | ||||||||||||||||||||||||
219 | EVP_PKEY_ASN1_METHOD *ameth; | - | ||||||||||||||||||||||||
220 | - | |||||||||||||||||||||||||
221 | ameth = EVP_PKEY_asn1_new(from, 0x1, | - | ||||||||||||||||||||||||
222 | ((void *)0) | - | ||||||||||||||||||||||||
223 | , | - | ||||||||||||||||||||||||
224 | ((void *)0) | - | ||||||||||||||||||||||||
225 | ); | - | ||||||||||||||||||||||||
226 | if (!ameth
| 0 | ||||||||||||||||||||||||
227 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||
228 | ameth->pkey_base_id = to; | - | ||||||||||||||||||||||||
229 | if (!EVP_PKEY_asn1_add0(ameth)
| 0 | ||||||||||||||||||||||||
230 | EVP_PKEY_asn1_free(ameth); | - | ||||||||||||||||||||||||
231 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||
232 | } | - | ||||||||||||||||||||||||
233 | return never executed: 1;return 1; never executed: return 1; | 0 | ||||||||||||||||||||||||
234 | } | - | ||||||||||||||||||||||||
235 | - | |||||||||||||||||||||||||
236 | int | - | ||||||||||||||||||||||||
237 | EVP_PKEY_asn1_get0_info(int *ppkey_id, int *ppkey_base_id, int *ppkey_flags, | - | ||||||||||||||||||||||||
238 | const char **pinfo, const char **ppem_str, | - | ||||||||||||||||||||||||
239 | const EVP_PKEY_ASN1_METHOD *ameth) | - | ||||||||||||||||||||||||
240 | { | - | ||||||||||||||||||||||||
241 | if (!ameth
| 0-2 | ||||||||||||||||||||||||
242 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||
243 | if (ppkey_id
| 0-2 | ||||||||||||||||||||||||
244 | * never executed: ppkey_id = ameth->pkey_id;*ppkey_id = ameth->pkey_id; never executed: *ppkey_id = ameth->pkey_id; | 0 | ||||||||||||||||||||||||
245 | if (ppkey_base_id
| 1 | ||||||||||||||||||||||||
246 | * executed 1 time by 1 test: ppkey_base_id = ameth->pkey_base_id;*ppkey_base_id = ameth->pkey_base_id; Executed by:
executed 1 time by 1 test: *ppkey_base_id = ameth->pkey_base_id; Executed by:
| 1 | ||||||||||||||||||||||||
247 | if (ppkey_flags
| 0-2 | ||||||||||||||||||||||||
248 | * never executed: ppkey_flags = ameth->pkey_flags;*ppkey_flags = ameth->pkey_flags; never executed: *ppkey_flags = ameth->pkey_flags; | 0 | ||||||||||||||||||||||||
249 | if (pinfo
| 0-2 | ||||||||||||||||||||||||
250 | * never executed: pinfo = ameth->info;*pinfo = ameth->info; never executed: *pinfo = ameth->info; | 0 | ||||||||||||||||||||||||
251 | if (ppem_str
| 1 | ||||||||||||||||||||||||
252 | * executed 1 time by 1 test: ppem_str = ameth->pem_str;*ppem_str = ameth->pem_str; Executed by:
executed 1 time by 1 test: *ppem_str = ameth->pem_str; Executed by:
| 1 | ||||||||||||||||||||||||
253 | return executed 2 times by 1 test: 1;return 1; Executed by:
executed 2 times by 1 test: return 1; Executed by:
| 2 | ||||||||||||||||||||||||
254 | } | - | ||||||||||||||||||||||||
255 | - | |||||||||||||||||||||||||
256 | const EVP_PKEY_ASN1_METHOD* | - | ||||||||||||||||||||||||
257 | EVP_PKEY_get0_asn1(const EVP_PKEY *pkey) | - | ||||||||||||||||||||||||
258 | { | - | ||||||||||||||||||||||||
259 | return never executed: pkey->ameth;return pkey->ameth; never executed: return pkey->ameth; | 0 | ||||||||||||||||||||||||
260 | } | - | ||||||||||||||||||||||||
261 | - | |||||||||||||||||||||||||
262 | EVP_PKEY_ASN1_METHOD* | - | ||||||||||||||||||||||||
263 | EVP_PKEY_asn1_new(int id, int flags, const char *pem_str, const char *info) | - | ||||||||||||||||||||||||
264 | { | - | ||||||||||||||||||||||||
265 | EVP_PKEY_ASN1_METHOD *ameth; | - | ||||||||||||||||||||||||
266 | - | |||||||||||||||||||||||||
267 | if ((
| 0 | ||||||||||||||||||||||||
268 | ((void *)0)
| 0 | ||||||||||||||||||||||||
269 | ) | - | ||||||||||||||||||||||||
270 | return never executed: return ((void *)0) ; never executed: return ((void *)0) ; | 0 | ||||||||||||||||||||||||
271 | ((void *)0) never executed: return ((void *)0) ; | 0 | ||||||||||||||||||||||||
272 | ; never executed: return ((void *)0) ; | 0 | ||||||||||||||||||||||||
273 | - | |||||||||||||||||||||||||
274 | ameth->pkey_id = id; | - | ||||||||||||||||||||||||
275 | ameth->pkey_base_id = id; | - | ||||||||||||||||||||||||
276 | ameth->pkey_flags = flags | 0x2; | - | ||||||||||||||||||||||||
277 | - | |||||||||||||||||||||||||
278 | if (info !=
| 0 | ||||||||||||||||||||||||
279 | ((void *)0)
| 0 | ||||||||||||||||||||||||
280 | ) { | - | ||||||||||||||||||||||||
281 | if ((
| 0 | ||||||||||||||||||||||||
282 | (__extension__ (__builtin_constant_p (
| 0 | ||||||||||||||||||||||||
283 | info
| 0 | ||||||||||||||||||||||||
284 | )
| 0 | ||||||||||||||||||||||||
285 | info
| 0 | ||||||||||||||||||||||||
286 | ) + 1) - (size_t)(const void *)(
| 0 | ||||||||||||||||||||||||
287 | info
| 0 | ||||||||||||||||||||||||
288 | ) == 1)
| 0 | ||||||||||||||||||||||||
289 | info
| 0 | ||||||||||||||||||||||||
290 | ))[0] == '\0'
| 0 | ||||||||||||||||||||||||
291 | info
| 0 | ||||||||||||||||||||||||
292 | ) + 1; char *__retval = (char *) malloc (__len); if (__retval != ((void *)0)
never executed: __retval = (char *) memcpy (__retval, info , __len); | 0 | ||||||||||||||||||||||||
293 | info
never executed: __retval = (char *) memcpy (__retval, info , __len); | 0 | ||||||||||||||||||||||||
294 | , __len); __retval; })) : __strdup (
| 0 | ||||||||||||||||||||||||
295 | info
| 0 | ||||||||||||||||||||||||
296 | )))
| 0 | ||||||||||||||||||||||||
297 | ) ==
| 0 | ||||||||||||||||||||||||
298 | ((void *)0)
| 0 | ||||||||||||||||||||||||
299 | ) | - | ||||||||||||||||||||||||
300 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||||||||
301 | } never executed: end of block | 0 | ||||||||||||||||||||||||
302 | - | |||||||||||||||||||||||||
303 | if (pem_str !=
| 0 | ||||||||||||||||||||||||
304 | ((void *)0)
| 0 | ||||||||||||||||||||||||
305 | ) { | - | ||||||||||||||||||||||||
306 | if ((
| 0 | ||||||||||||||||||||||||
307 | (__extension__ (__builtin_constant_p (
| 0 | ||||||||||||||||||||||||
308 | pem_str
| 0 | ||||||||||||||||||||||||
309 | )
| 0 | ||||||||||||||||||||||||
310 | pem_str
| 0 | ||||||||||||||||||||||||
311 | ) + 1) - (size_t)(const void *)(
| 0 | ||||||||||||||||||||||||
312 | pem_str
| 0 | ||||||||||||||||||||||||
313 | ) == 1)
| 0 | ||||||||||||||||||||||||
314 | pem_str
| 0 | ||||||||||||||||||||||||
315 | ))[0] == '\0'
| 0 | ||||||||||||||||||||||||
316 | pem_str
| 0 | ||||||||||||||||||||||||
317 | ) + 1; char *__retval = (char *) malloc (__len); if (__retval != ((void *)0)
never executed: __retval = (char *) memcpy (__retval, pem_str , __len); | 0 | ||||||||||||||||||||||||
318 | pem_str
never executed: __retval = (char *) memcpy (__retval, pem_str , __len); | 0 | ||||||||||||||||||||||||
319 | , __len); __retval; })) : __strdup (
| 0 | ||||||||||||||||||||||||
320 | pem_str
| 0 | ||||||||||||||||||||||||
321 | )))
| 0 | ||||||||||||||||||||||||
322 | ) ==
| 0 | ||||||||||||||||||||||||
323 | ((void *)0)
| 0 | ||||||||||||||||||||||||
324 | ) | - | ||||||||||||||||||||||||
325 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||||||||
326 | } never executed: end of block | 0 | ||||||||||||||||||||||||
327 | - | |||||||||||||||||||||||||
328 | return never executed: ameth;return ameth; never executed: return ameth; | 0 | ||||||||||||||||||||||||
329 | - | |||||||||||||||||||||||||
330 | err: | - | ||||||||||||||||||||||||
331 | EVP_PKEY_asn1_free(ameth); | - | ||||||||||||||||||||||||
332 | return never executed: return ((void *)0) ; never executed: return ((void *)0) ; | 0 | ||||||||||||||||||||||||
333 | ((void *)0) never executed: return ((void *)0) ; | 0 | ||||||||||||||||||||||||
334 | ; never executed: return ((void *)0) ; | 0 | ||||||||||||||||||||||||
335 | } | - | ||||||||||||||||||||||||
336 | - | |||||||||||||||||||||||||
337 | void | - | ||||||||||||||||||||||||
338 | EVP_PKEY_asn1_copy(EVP_PKEY_ASN1_METHOD *dst, const EVP_PKEY_ASN1_METHOD *src) | - | ||||||||||||||||||||||||
339 | { | - | ||||||||||||||||||||||||
340 | dst->pub_decode = src->pub_decode; | - | ||||||||||||||||||||||||
341 | dst->pub_encode = src->pub_encode; | - | ||||||||||||||||||||||||
342 | dst->pub_cmp = src->pub_cmp; | - | ||||||||||||||||||||||||
343 | dst->pub_print = src->pub_print; | - | ||||||||||||||||||||||||
344 | - | |||||||||||||||||||||||||
345 | dst->priv_decode = src->priv_decode; | - | ||||||||||||||||||||||||
346 | dst->priv_encode = src->priv_encode; | - | ||||||||||||||||||||||||
347 | dst->priv_print = src->priv_print; | - | ||||||||||||||||||||||||
348 | - | |||||||||||||||||||||||||
349 | dst->old_priv_encode = src->old_priv_encode; | - | ||||||||||||||||||||||||
350 | dst->old_priv_decode = src->old_priv_decode; | - | ||||||||||||||||||||||||
351 | - | |||||||||||||||||||||||||
352 | dst->pkey_size = src->pkey_size; | - | ||||||||||||||||||||||||
353 | dst->pkey_bits = src->pkey_bits; | - | ||||||||||||||||||||||||
354 | - | |||||||||||||||||||||||||
355 | dst->param_decode = src->param_decode; | - | ||||||||||||||||||||||||
356 | dst->param_encode = src->param_encode; | - | ||||||||||||||||||||||||
357 | dst->param_missing = src->param_missing; | - | ||||||||||||||||||||||||
358 | dst->param_copy = src->param_copy; | - | ||||||||||||||||||||||||
359 | dst->param_cmp = src->param_cmp; | - | ||||||||||||||||||||||||
360 | dst->param_print = src->param_print; | - | ||||||||||||||||||||||||
361 | dst->sig_print = src->sig_print; | - | ||||||||||||||||||||||||
362 | - | |||||||||||||||||||||||||
363 | dst->pkey_free = src->pkey_free; | - | ||||||||||||||||||||||||
364 | dst->pkey_ctrl = src->pkey_ctrl; | - | ||||||||||||||||||||||||
365 | - | |||||||||||||||||||||||||
366 | dst->item_sign = src->item_sign; | - | ||||||||||||||||||||||||
367 | dst->item_verify = src->item_verify; | - | ||||||||||||||||||||||||
368 | } never executed: end of block | 0 | ||||||||||||||||||||||||
369 | - | |||||||||||||||||||||||||
370 | void | - | ||||||||||||||||||||||||
371 | EVP_PKEY_asn1_free(EVP_PKEY_ASN1_METHOD *ameth) | - | ||||||||||||||||||||||||
372 | { | - | ||||||||||||||||||||||||
373 | if (ameth
| 0-1 | ||||||||||||||||||||||||
374 | free(ameth->pem_str); | - | ||||||||||||||||||||||||
375 | free(ameth->info); | - | ||||||||||||||||||||||||
376 | free(ameth); | - | ||||||||||||||||||||||||
377 | } never executed: end of block | 0 | ||||||||||||||||||||||||
378 | } executed 1 time by 1 test: end of block Executed by:
| 1 | ||||||||||||||||||||||||
379 | - | |||||||||||||||||||||||||
380 | void | - | ||||||||||||||||||||||||
381 | EVP_PKEY_asn1_set_public(EVP_PKEY_ASN1_METHOD *ameth, | - | ||||||||||||||||||||||||
382 | int (*pub_decode)(EVP_PKEY *pk, X509_PUBKEY *pub), | - | ||||||||||||||||||||||||
383 | int (*pub_encode)(X509_PUBKEY *pub, const EVP_PKEY *pk), | - | ||||||||||||||||||||||||
384 | int (*pub_cmp)(const EVP_PKEY *a, const EVP_PKEY *b), | - | ||||||||||||||||||||||||
385 | int (*pub_print)(BIO *out, const EVP_PKEY *pkey, int indent, | - | ||||||||||||||||||||||||
386 | ASN1_PCTX *pctx), | - | ||||||||||||||||||||||||
387 | int (*pkey_size)(const EVP_PKEY *pk), | - | ||||||||||||||||||||||||
388 | int (*pkey_bits)(const EVP_PKEY *pk)) | - | ||||||||||||||||||||||||
389 | { | - | ||||||||||||||||||||||||
390 | ameth->pub_decode = pub_decode; | - | ||||||||||||||||||||||||
391 | ameth->pub_encode = pub_encode; | - | ||||||||||||||||||||||||
392 | ameth->pub_cmp = pub_cmp; | - | ||||||||||||||||||||||||
393 | ameth->pub_print = pub_print; | - | ||||||||||||||||||||||||
394 | ameth->pkey_size = pkey_size; | - | ||||||||||||||||||||||||
395 | ameth->pkey_bits = pkey_bits; | - | ||||||||||||||||||||||||
396 | } never executed: end of block | 0 | ||||||||||||||||||||||||
397 | - | |||||||||||||||||||||||||
398 | void | - | ||||||||||||||||||||||||
399 | EVP_PKEY_asn1_set_private(EVP_PKEY_ASN1_METHOD *ameth, | - | ||||||||||||||||||||||||
400 | int (*priv_decode)(EVP_PKEY *pk, const PKCS8_PRIV_KEY_INFO *p8inf), | - | ||||||||||||||||||||||||
401 | int (*priv_encode)(PKCS8_PRIV_KEY_INFO *p8, const EVP_PKEY *pk), | - | ||||||||||||||||||||||||
402 | int (*priv_print)(BIO *out, const EVP_PKEY *pkey, int indent, | - | ||||||||||||||||||||||||
403 | ASN1_PCTX *pctx)) | - | ||||||||||||||||||||||||
404 | { | - | ||||||||||||||||||||||||
405 | ameth->priv_decode = priv_decode; | - | ||||||||||||||||||||||||
406 | ameth->priv_encode = priv_encode; | - | ||||||||||||||||||||||||
407 | ameth->priv_print = priv_print; | - | ||||||||||||||||||||||||
408 | } never executed: end of block | 0 | ||||||||||||||||||||||||
409 | - | |||||||||||||||||||||||||
410 | void | - | ||||||||||||||||||||||||
411 | EVP_PKEY_asn1_set_param(EVP_PKEY_ASN1_METHOD *ameth, | - | ||||||||||||||||||||||||
412 | int (*param_decode)(EVP_PKEY *pkey, const unsigned char **pder, int derlen), | - | ||||||||||||||||||||||||
413 | int (*param_encode)(const EVP_PKEY *pkey, unsigned char **pder), | - | ||||||||||||||||||||||||
414 | int (*param_missing)(const EVP_PKEY *pk), | - | ||||||||||||||||||||||||
415 | int (*param_copy)(EVP_PKEY *to, const EVP_PKEY *from), | - | ||||||||||||||||||||||||
416 | int (*param_cmp)(const EVP_PKEY *a, const EVP_PKEY *b), | - | ||||||||||||||||||||||||
417 | int (*param_print)(BIO *out, const EVP_PKEY *pkey, int indent, | - | ||||||||||||||||||||||||
418 | ASN1_PCTX *pctx)) | - | ||||||||||||||||||||||||
419 | { | - | ||||||||||||||||||||||||
420 | ameth->param_decode = param_decode; | - | ||||||||||||||||||||||||
421 | ameth->param_encode = param_encode; | - | ||||||||||||||||||||||||
422 | ameth->param_missing = param_missing; | - | ||||||||||||||||||||||||
423 | ameth->param_copy = param_copy; | - | ||||||||||||||||||||||||
424 | ameth->param_cmp = param_cmp; | - | ||||||||||||||||||||||||
425 | ameth->param_print = param_print; | - | ||||||||||||||||||||||||
426 | } never executed: end of block | 0 | ||||||||||||||||||||||||
427 | - | |||||||||||||||||||||||||
428 | void | - | ||||||||||||||||||||||||
429 | EVP_PKEY_asn1_set_free(EVP_PKEY_ASN1_METHOD *ameth, | - | ||||||||||||||||||||||||
430 | void (*pkey_free)(EVP_PKEY *pkey)) | - | ||||||||||||||||||||||||
431 | { | - | ||||||||||||||||||||||||
432 | ameth->pkey_free = pkey_free; | - | ||||||||||||||||||||||||
433 | } never executed: end of block | 0 | ||||||||||||||||||||||||
434 | - | |||||||||||||||||||||||||
435 | void | - | ||||||||||||||||||||||||
436 | EVP_PKEY_asn1_set_ctrl(EVP_PKEY_ASN1_METHOD *ameth, | - | ||||||||||||||||||||||||
437 | int (*pkey_ctrl)(EVP_PKEY *pkey, int op, long arg1, void *arg2)) | - | ||||||||||||||||||||||||
438 | { | - | ||||||||||||||||||||||||
439 | ameth->pkey_ctrl = pkey_ctrl; | - | ||||||||||||||||||||||||
440 | } never executed: end of block | 0 | ||||||||||||||||||||||||
Switch to Source code | Preprocessed file |