Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/openssl/src/crypto/dh/dh_ameth.c |
Switch to Source code | Preprocessed file |
Line | Source | Count | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | - | |||||||||||||||||||
2 | - | |||||||||||||||||||
3 | - | |||||||||||||||||||
4 | - | |||||||||||||||||||
5 | - | |||||||||||||||||||
6 | - | |||||||||||||||||||
7 | - | |||||||||||||||||||
8 | - | |||||||||||||||||||
9 | static DH *d2i_dhp(const EVP_PKEY *pkey, const unsigned char **pp, | - | ||||||||||||||||||
10 | long length) | - | ||||||||||||||||||
11 | { | - | ||||||||||||||||||
12 | if (pkey->ameth == &dhx_asn1_meth
| 28-2183 | ||||||||||||||||||
13 | return executed 2183 times by 1 test: d2i_DHxparams(return d2i_DHxparams( ((void *)0) , pp, length); Executed by:
executed 2183 times by 1 test: return d2i_DHxparams( ((void *)0) , pp, length); Executed by:
| 2183 | ||||||||||||||||||
14 | ((void *)0) executed 2183 times by 1 test: return d2i_DHxparams( ((void *)0) , pp, length); Executed by:
| 2183 | ||||||||||||||||||
15 | , pp, length); executed 2183 times by 1 test: return d2i_DHxparams( ((void *)0) , pp, length); Executed by:
| 2183 | ||||||||||||||||||
16 | return executed 28 times by 1 test: d2i_DHparams(return d2i_DHparams( ((void *)0) , pp, length); Executed by:
executed 28 times by 1 test: return d2i_DHparams( ((void *)0) , pp, length); Executed by:
| 28 | ||||||||||||||||||
17 | ((void *)0) executed 28 times by 1 test: return d2i_DHparams( ((void *)0) , pp, length); Executed by:
| 28 | ||||||||||||||||||
18 | , pp, length); executed 28 times by 1 test: return d2i_DHparams( ((void *)0) , pp, length); Executed by:
| 28 | ||||||||||||||||||
19 | } | - | ||||||||||||||||||
20 | - | |||||||||||||||||||
21 | static int i2d_dhp(const EVP_PKEY *pkey, const DH *a, unsigned char **pp) | - | ||||||||||||||||||
22 | { | - | ||||||||||||||||||
23 | if (pkey->ameth == &dhx_asn1_meth
| 0 | ||||||||||||||||||
24 | return never executed: i2d_DHxparams(a, pp);return i2d_DHxparams(a, pp); never executed: return i2d_DHxparams(a, pp); | 0 | ||||||||||||||||||
25 | return never executed: i2d_DHparams(a, pp);return i2d_DHparams(a, pp); never executed: return i2d_DHparams(a, pp); | 0 | ||||||||||||||||||
26 | } | - | ||||||||||||||||||
27 | - | |||||||||||||||||||
28 | static void int_dh_free(EVP_PKEY *pkey) | - | ||||||||||||||||||
29 | { | - | ||||||||||||||||||
30 | DH_free(pkey->pkey.dh); | - | ||||||||||||||||||
31 | } executed 3321 times by 1 test: end of block Executed by:
| 3321 | ||||||||||||||||||
32 | - | |||||||||||||||||||
33 | static int dh_pub_decode(EVP_PKEY *pkey, X509_PUBKEY *pubkey) | - | ||||||||||||||||||
34 | { | - | ||||||||||||||||||
35 | const unsigned char *p, *pm; | - | ||||||||||||||||||
36 | int pklen, pmlen; | - | ||||||||||||||||||
37 | int ptype; | - | ||||||||||||||||||
38 | const void *pval; | - | ||||||||||||||||||
39 | const ASN1_STRING *pstr; | - | ||||||||||||||||||
40 | X509_ALGOR *palg; | - | ||||||||||||||||||
41 | ASN1_INTEGER *public_key = | - | ||||||||||||||||||
42 | ((void *)0) | - | ||||||||||||||||||
43 | ; | - | ||||||||||||||||||
44 | - | |||||||||||||||||||
45 | DH *dh = | - | ||||||||||||||||||
46 | ((void *)0) | - | ||||||||||||||||||
47 | ; | - | ||||||||||||||||||
48 | - | |||||||||||||||||||
49 | if (!X509_PUBKEY_get0_param(
| 0-2410 | ||||||||||||||||||
50 | ((void *)0)
| 0-2410 | ||||||||||||||||||
51 | , &p, &pklen, &palg, pubkey)
| 0-2410 | ||||||||||||||||||
52 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||
53 | X509_ALGOR_get0( | - | ||||||||||||||||||
54 | ((void *)0) | - | ||||||||||||||||||
55 | , &ptype, &pval, palg); | - | ||||||||||||||||||
56 | - | |||||||||||||||||||
57 | if (ptype != 16
| 211-2199 | ||||||||||||||||||
58 | ERR_put_error(5,(108),(105),__FILE__,62); | - | ||||||||||||||||||
59 | goto executed 211 times by 1 test: err;goto err; Executed by:
executed 211 times by 1 test: goto err; Executed by:
| 211 | ||||||||||||||||||
60 | } | - | ||||||||||||||||||
61 | - | |||||||||||||||||||
62 | pstr = pval; | - | ||||||||||||||||||
63 | pm = pstr->data; | - | ||||||||||||||||||
64 | pmlen = pstr->length; | - | ||||||||||||||||||
65 | - | |||||||||||||||||||
66 | if ((
| 310-1889 | ||||||||||||||||||
67 | ((void *)0)
| 310-1889 | ||||||||||||||||||
68 | ) { | - | ||||||||||||||||||
69 | ERR_put_error(5,(108),(104),__FILE__,71); | - | ||||||||||||||||||
70 | goto executed 1889 times by 1 test: err;goto err; Executed by:
executed 1889 times by 1 test: goto err; Executed by:
| 1889 | ||||||||||||||||||
71 | } | - | ||||||||||||||||||
72 | - | |||||||||||||||||||
73 | if ((
| 44-266 | ||||||||||||||||||
74 | ((void *)0)
| 44-266 | ||||||||||||||||||
75 | , &p, pklen)) ==
| 44-266 | ||||||||||||||||||
76 | ((void *)0)
| 44-266 | ||||||||||||||||||
77 | ) { | - | ||||||||||||||||||
78 | ERR_put_error(5,(108),(104),__FILE__,76); | - | ||||||||||||||||||
79 | goto executed 266 times by 1 test: err;goto err; Executed by:
executed 266 times by 1 test: goto err; Executed by:
| 266 | ||||||||||||||||||
80 | } | - | ||||||||||||||||||
81 | - | |||||||||||||||||||
82 | - | |||||||||||||||||||
83 | if ((
| 0-44 | ||||||||||||||||||
84 | ((void *)0)
| 0-44 | ||||||||||||||||||
85 | )) ==
| 0-44 | ||||||||||||||||||
86 | ((void *)0)
| 0-44 | ||||||||||||||||||
87 | ) { | - | ||||||||||||||||||
88 | ERR_put_error(5,(108),(109),__FILE__,82); | - | ||||||||||||||||||
89 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
90 | } | - | ||||||||||||||||||
91 | - | |||||||||||||||||||
92 | ASN1_INTEGER_free(public_key); | - | ||||||||||||||||||
93 | EVP_PKEY_assign(pkey, pkey->ameth->pkey_id, dh); | - | ||||||||||||||||||
94 | return executed 44 times by 1 test: 1;return 1; Executed by:
executed 44 times by 1 test: return 1; Executed by:
| 44 | ||||||||||||||||||
95 | - | |||||||||||||||||||
96 | err: | - | ||||||||||||||||||
97 | ASN1_INTEGER_free(public_key); | - | ||||||||||||||||||
98 | DH_free(dh); | - | ||||||||||||||||||
99 | return executed 2366 times by 1 test: 0;return 0; Executed by:
executed 2366 times by 1 test: return 0; Executed by:
| 2366 | ||||||||||||||||||
100 | - | |||||||||||||||||||
101 | } | - | ||||||||||||||||||
102 | - | |||||||||||||||||||
103 | static int dh_pub_encode(X509_PUBKEY *pk, const EVP_PKEY *pkey) | - | ||||||||||||||||||
104 | { | - | ||||||||||||||||||
105 | DH *dh; | - | ||||||||||||||||||
106 | int ptype; | - | ||||||||||||||||||
107 | unsigned char *penc = | - | ||||||||||||||||||
108 | ((void *)0) | - | ||||||||||||||||||
109 | ; | - | ||||||||||||||||||
110 | int penclen; | - | ||||||||||||||||||
111 | ASN1_STRING *str; | - | ||||||||||||||||||
112 | ASN1_INTEGER *pub_key = | - | ||||||||||||||||||
113 | ((void *)0) | - | ||||||||||||||||||
114 | ; | - | ||||||||||||||||||
115 | - | |||||||||||||||||||
116 | dh = pkey->pkey.dh; | - | ||||||||||||||||||
117 | - | |||||||||||||||||||
118 | str = ASN1_STRING_new(); | - | ||||||||||||||||||
119 | if (str ==
| 0 | ||||||||||||||||||
120 | ((void *)0)
| 0 | ||||||||||||||||||
121 | ) { | - | ||||||||||||||||||
122 | ERR_put_error(5,(109),((1|64)),__FILE__,110); | - | ||||||||||||||||||
123 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
124 | } | - | ||||||||||||||||||
125 | str->length = i2d_dhp(pkey, dh, &str->data); | - | ||||||||||||||||||
126 | if (str->length <= 0
| 0 | ||||||||||||||||||
127 | ERR_put_error(5,(109),((1|64)),__FILE__,115); | - | ||||||||||||||||||
128 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
129 | } | - | ||||||||||||||||||
130 | ptype = 16; | - | ||||||||||||||||||
131 | - | |||||||||||||||||||
132 | pub_key = BN_to_ASN1_INTEGER(dh->pub_key, | - | ||||||||||||||||||
133 | ((void *)0) | - | ||||||||||||||||||
134 | ); | - | ||||||||||||||||||
135 | if (!pub_key
| 0 | ||||||||||||||||||
136 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
137 | - | |||||||||||||||||||
138 | penclen = i2d_ASN1_INTEGER(pub_key, &penc); | - | ||||||||||||||||||
139 | - | |||||||||||||||||||
140 | ASN1_INTEGER_free(pub_key); | - | ||||||||||||||||||
141 | - | |||||||||||||||||||
142 | if (penclen <= 0
| 0 | ||||||||||||||||||
143 | ERR_put_error(5,(109),((1|64)),__FILE__,129); | - | ||||||||||||||||||
144 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
145 | } | - | ||||||||||||||||||
146 | - | |||||||||||||||||||
147 | if (X509_PUBKEY_set0_param(pk, OBJ_nid2obj(pkey->ameth->pkey_id),
| 0 | ||||||||||||||||||
148 | ptype, str, penc, penclen)
| 0 | ||||||||||||||||||
149 | return never executed: 1;return 1; never executed: return 1; | 0 | ||||||||||||||||||
150 | - | |||||||||||||||||||
151 | err: code before this statement never executed: err: | 0 | ||||||||||||||||||
152 | CRYPTO_free(penc, __FILE__, 138); | - | ||||||||||||||||||
153 | ASN1_STRING_free(str); | - | ||||||||||||||||||
154 | - | |||||||||||||||||||
155 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||
156 | } | - | ||||||||||||||||||
157 | - | |||||||||||||||||||
158 | - | |||||||||||||||||||
159 | - | |||||||||||||||||||
160 | - | |||||||||||||||||||
161 | - | |||||||||||||||||||
162 | - | |||||||||||||||||||
163 | - | |||||||||||||||||||
164 | static int dh_priv_decode(EVP_PKEY *pkey, const PKCS8_PRIV_KEY_INFO *p8) | - | ||||||||||||||||||
165 | { | - | ||||||||||||||||||
166 | const unsigned char *p, *pm; | - | ||||||||||||||||||
167 | int pklen, pmlen; | - | ||||||||||||||||||
168 | int ptype; | - | ||||||||||||||||||
169 | const void *pval; | - | ||||||||||||||||||
170 | const ASN1_STRING *pstr; | - | ||||||||||||||||||
171 | const X509_ALGOR *palg; | - | ||||||||||||||||||
172 | ASN1_INTEGER *privkey = | - | ||||||||||||||||||
173 | ((void *)0) | - | ||||||||||||||||||
174 | ; | - | ||||||||||||||||||
175 | - | |||||||||||||||||||
176 | DH *dh = | - | ||||||||||||||||||
177 | ((void *)0) | - | ||||||||||||||||||
178 | ; | - | ||||||||||||||||||
179 | - | |||||||||||||||||||
180 | if (!PKCS8_pkey_get0(
| 0-14 | ||||||||||||||||||
181 | ((void *)0)
| 0-14 | ||||||||||||||||||
182 | , &p, &pklen, &palg, p8)
| 0-14 | ||||||||||||||||||
183 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||
184 | - | |||||||||||||||||||
185 | X509_ALGOR_get0( | - | ||||||||||||||||||
186 | ((void *)0) | - | ||||||||||||||||||
187 | , &ptype, &pval, palg); | - | ||||||||||||||||||
188 | - | |||||||||||||||||||
189 | if (ptype != 16
| 1-13 | ||||||||||||||||||
190 | goto executed 1 time by 1 test: decerr;goto decerr; Executed by:
executed 1 time by 1 test: goto decerr; Executed by:
| 1 | ||||||||||||||||||
191 | if ((
| 1-12 | ||||||||||||||||||
192 | ((void *)0)
| 1-12 | ||||||||||||||||||
193 | , &p, pklen)) ==
| 1-12 | ||||||||||||||||||
194 | ((void *)0)
| 1-12 | ||||||||||||||||||
195 | ) | - | ||||||||||||||||||
196 | goto executed 1 time by 1 test: decerr;goto decerr; Executed by:
executed 1 time by 1 test: goto decerr; Executed by:
| 1 | ||||||||||||||||||
197 | - | |||||||||||||||||||
198 | pstr = pval; | - | ||||||||||||||||||
199 | pm = pstr->data; | - | ||||||||||||||||||
200 | pmlen = pstr->length; | - | ||||||||||||||||||
201 | if ((
| 1-11 | ||||||||||||||||||
202 | ((void *)0)
| 1-11 | ||||||||||||||||||
203 | ) | - | ||||||||||||||||||
204 | goto executed 1 time by 1 test: decerr;goto decerr; Executed by:
executed 1 time by 1 test: goto decerr; Executed by:
| 1 | ||||||||||||||||||
205 | - | |||||||||||||||||||
206 | - | |||||||||||||||||||
207 | if ((
| 0-11 | ||||||||||||||||||
208 | ((void *)0)
| 0-11 | ||||||||||||||||||
209 | - | |||||||||||||||||||
210 | || !ASN1_INTEGER_to_BN(privkey, dh->priv_key)
| 0-11 | ||||||||||||||||||
211 | ERR_put_error(5,(110),(106),__FILE__,181); | - | ||||||||||||||||||
212 | goto never executed: dherr;goto dherr; never executed: goto dherr; | 0 | ||||||||||||||||||
213 | } | - | ||||||||||||||||||
214 | - | |||||||||||||||||||
215 | if (!DH_generate_key(dh)
| 0-11 | ||||||||||||||||||
216 | goto never executed: dherr;goto dherr; never executed: goto dherr; | 0 | ||||||||||||||||||
217 | - | |||||||||||||||||||
218 | EVP_PKEY_assign(pkey, pkey->ameth->pkey_id, dh); | - | ||||||||||||||||||
219 | - | |||||||||||||||||||
220 | ASN1_STRING_clear_free(privkey); | - | ||||||||||||||||||
221 | - | |||||||||||||||||||
222 | return executed 11 times by 1 test: 1;return 1; Executed by:
executed 11 times by 1 test: return 1; Executed by:
| 11 | ||||||||||||||||||
223 | - | |||||||||||||||||||
224 | decerr: | - | ||||||||||||||||||
225 | ERR_put_error(5,(110),(114),__FILE__,195); | - | ||||||||||||||||||
226 | dherr: code before this statement executed 3 times by 1 test: dherr: Executed by:
| 3 | ||||||||||||||||||
227 | DH_free(dh); | - | ||||||||||||||||||
228 | ASN1_STRING_clear_free(privkey); | - | ||||||||||||||||||
229 | return executed 3 times by 1 test: 0;return 0; Executed by:
executed 3 times by 1 test: return 0; Executed by:
| 3 | ||||||||||||||||||
230 | } | - | ||||||||||||||||||
231 | - | |||||||||||||||||||
232 | static int dh_priv_encode(PKCS8_PRIV_KEY_INFO *p8, const EVP_PKEY *pkey) | - | ||||||||||||||||||
233 | { | - | ||||||||||||||||||
234 | ASN1_STRING *params = | - | ||||||||||||||||||
235 | ((void *)0) | - | ||||||||||||||||||
236 | ; | - | ||||||||||||||||||
237 | ASN1_INTEGER *prkey = | - | ||||||||||||||||||
238 | ((void *)0) | - | ||||||||||||||||||
239 | ; | - | ||||||||||||||||||
240 | unsigned char *dp = | - | ||||||||||||||||||
241 | ((void *)0) | - | ||||||||||||||||||
242 | ; | - | ||||||||||||||||||
243 | int dplen; | - | ||||||||||||||||||
244 | - | |||||||||||||||||||
245 | params = ASN1_STRING_new(); | - | ||||||||||||||||||
246 | - | |||||||||||||||||||
247 | if (params ==
| 0 | ||||||||||||||||||
248 | ((void *)0)
| 0 | ||||||||||||||||||
249 | ) { | - | ||||||||||||||||||
250 | ERR_put_error(5,(111),((1|64)),__FILE__,212); | - | ||||||||||||||||||
251 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
252 | } | - | ||||||||||||||||||
253 | - | |||||||||||||||||||
254 | params->length = i2d_dhp(pkey, pkey->pkey.dh, ¶ms->data); | - | ||||||||||||||||||
255 | if (params->length <= 0
| 0 | ||||||||||||||||||
256 | ERR_put_error(5,(111),((1|64)),__FILE__,218); | - | ||||||||||||||||||
257 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
258 | } | - | ||||||||||||||||||
259 | params->type = 16; | - | ||||||||||||||||||
260 | - | |||||||||||||||||||
261 | - | |||||||||||||||||||
262 | prkey = BN_to_ASN1_INTEGER(pkey->pkey.dh->priv_key, | - | ||||||||||||||||||
263 | ((void *)0) | - | ||||||||||||||||||
264 | ); | - | ||||||||||||||||||
265 | - | |||||||||||||||||||
266 | if (!prkey
| 0 | ||||||||||||||||||
267 | ERR_put_error(5,(111),(106),__FILE__,227); | - | ||||||||||||||||||
268 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
269 | } | - | ||||||||||||||||||
270 | - | |||||||||||||||||||
271 | dplen = i2d_ASN1_INTEGER(prkey, &dp); | - | ||||||||||||||||||
272 | - | |||||||||||||||||||
273 | ASN1_STRING_clear_free(prkey); | - | ||||||||||||||||||
274 | prkey = | - | ||||||||||||||||||
275 | ((void *)0) | - | ||||||||||||||||||
276 | ; | - | ||||||||||||||||||
277 | - | |||||||||||||||||||
278 | if (!PKCS8_pkey_set0(p8, OBJ_nid2obj(pkey->ameth->pkey_id), 0,
| 0 | ||||||||||||||||||
279 | 16, params, dp, dplen)
| 0 | ||||||||||||||||||
280 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
281 | - | |||||||||||||||||||
282 | return never executed: 1;return 1; never executed: return 1; | 0 | ||||||||||||||||||
283 | - | |||||||||||||||||||
284 | err: | - | ||||||||||||||||||
285 | CRYPTO_free(dp, __FILE__, 243); | - | ||||||||||||||||||
286 | ASN1_STRING_free(params); | - | ||||||||||||||||||
287 | ASN1_STRING_clear_free(prkey); | - | ||||||||||||||||||
288 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||
289 | } | - | ||||||||||||||||||
290 | - | |||||||||||||||||||
291 | static int dh_param_decode(EVP_PKEY *pkey, | - | ||||||||||||||||||
292 | const unsigned char **pder, int derlen) | - | ||||||||||||||||||
293 | { | - | ||||||||||||||||||
294 | DH *dh; | - | ||||||||||||||||||
295 | - | |||||||||||||||||||
296 | if ((
| 0 | ||||||||||||||||||
297 | ((void *)0)
| 0 | ||||||||||||||||||
298 | ) { | - | ||||||||||||||||||
299 | ERR_put_error(5,(107),(5),__FILE__,255); | - | ||||||||||||||||||
300 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||
301 | } | - | ||||||||||||||||||
302 | EVP_PKEY_assign(pkey, pkey->ameth->pkey_id, dh); | - | ||||||||||||||||||
303 | return never executed: 1;return 1; never executed: return 1; | 0 | ||||||||||||||||||
304 | } | - | ||||||||||||||||||
305 | - | |||||||||||||||||||
306 | static int dh_param_encode(const EVP_PKEY *pkey, unsigned char **pder) | - | ||||||||||||||||||
307 | { | - | ||||||||||||||||||
308 | return never executed: i2d_dhp(pkey, pkey->pkey.dh, pder);return i2d_dhp(pkey, pkey->pkey.dh, pder); never executed: return i2d_dhp(pkey, pkey->pkey.dh, pder); | 0 | ||||||||||||||||||
309 | } | - | ||||||||||||||||||
310 | - | |||||||||||||||||||
311 | static int do_dh_print(BIO *bp, const DH *x, int indent, int ptype) | - | ||||||||||||||||||
312 | { | - | ||||||||||||||||||
313 | int reason = 7; | - | ||||||||||||||||||
314 | const char *ktype = | - | ||||||||||||||||||
315 | ((void *)0) | - | ||||||||||||||||||
316 | ; | - | ||||||||||||||||||
317 | BIGNUM *priv_key, *pub_key; | - | ||||||||||||||||||
318 | - | |||||||||||||||||||
319 | if (ptype == 2
| 0-63 | ||||||||||||||||||
320 | priv_key = x->priv_key; never executed: priv_key = x->priv_key; | 0 | ||||||||||||||||||
321 | else | - | ||||||||||||||||||
322 | priv_key = executed 63 times by 1 test: priv_key = ((void *)0) ; Executed by:
| 63 | ||||||||||||||||||
323 | ((void *)0) executed 63 times by 1 test: priv_key = ((void *)0) ; Executed by:
| 63 | ||||||||||||||||||
324 | ; executed 63 times by 1 test: priv_key = ((void *)0) ; Executed by:
| 63 | ||||||||||||||||||
325 | - | |||||||||||||||||||
326 | if (ptype > 0
| 10-53 | ||||||||||||||||||
327 | pub_key = x->pub_key; executed 10 times by 1 test: pub_key = x->pub_key; Executed by:
| 10 | ||||||||||||||||||
328 | else | - | ||||||||||||||||||
329 | pub_key = executed 53 times by 1 test: pub_key = ((void *)0) ; Executed by:
| 53 | ||||||||||||||||||
330 | ((void *)0) executed 53 times by 1 test: pub_key = ((void *)0) ; Executed by:
| 53 | ||||||||||||||||||
331 | ; executed 53 times by 1 test: pub_key = ((void *)0) ; Executed by:
| 53 | ||||||||||||||||||
332 | - | |||||||||||||||||||
333 | if (x->p ==
| 0-63 | ||||||||||||||||||
334 | ((void *)0)
| 0-63 | ||||||||||||||||||
335 | || (ptype == 2
| 0-63 | ||||||||||||||||||
336 | ((void *)0)
| 0 | ||||||||||||||||||
337 | ) | - | ||||||||||||||||||
338 | || (ptype > 0
| 0-53 | ||||||||||||||||||
339 | ((void *)0)
| 0-10 | ||||||||||||||||||
340 | )) { | - | ||||||||||||||||||
341 | reason = (3|64); | - | ||||||||||||||||||
342 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
343 | } | - | ||||||||||||||||||
344 | - | |||||||||||||||||||
345 | if (ptype == 2
| 0-63 | ||||||||||||||||||
346 | ktype = "DH Private-Key"; never executed: ktype = "DH Private-Key"; | 0 | ||||||||||||||||||
347 | else if (ptype == 1
| 10-53 | ||||||||||||||||||
348 | ktype = "DH Public-Key"; executed 10 times by 1 test: ktype = "DH Public-Key"; Executed by:
| 10 | ||||||||||||||||||
349 | else | - | ||||||||||||||||||
350 | ktype = "DH Parameters"; executed 53 times by 1 test: ktype = "DH Parameters"; Executed by:
| 53 | ||||||||||||||||||
351 | - | |||||||||||||||||||
352 | BIO_indent(bp, indent, 128); | - | ||||||||||||||||||
353 | if (BIO_printf(bp, "%s: (%d bit)\n", ktype, BN_num_bits(x->p)) <= 0
| 0-63 | ||||||||||||||||||
354 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
355 | indent += 4; | - | ||||||||||||||||||
356 | - | |||||||||||||||||||
357 | if (!ASN1_bn_print(bp, "private-key:", priv_key,
| 0-63 | ||||||||||||||||||
358 | ((void *)0)
| 0-63 | ||||||||||||||||||
359 | , indent)
| 0-63 | ||||||||||||||||||
360 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
361 | if (!ASN1_bn_print(bp, "public-key:", pub_key,
| 0-63 | ||||||||||||||||||
362 | ((void *)0)
| 0-63 | ||||||||||||||||||
363 | , indent)
| 0-63 | ||||||||||||||||||
364 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
365 | - | |||||||||||||||||||
366 | if (!ASN1_bn_print(bp, "prime:", x->p,
| 0-63 | ||||||||||||||||||
367 | ((void *)0)
| 0-63 | ||||||||||||||||||
368 | , indent)
| 0-63 | ||||||||||||||||||
369 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
370 | if (!ASN1_bn_print(bp, "generator:", x->g,
| 0-63 | ||||||||||||||||||
371 | ((void *)0)
| 0-63 | ||||||||||||||||||
372 | , indent)
| 0-63 | ||||||||||||||||||
373 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
374 | if (x->q
| 0-41 | ||||||||||||||||||
375 | ((void *)0)
| 0-41 | ||||||||||||||||||
376 | , indent)
| 0-41 | ||||||||||||||||||
377 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
378 | if (x->j
| 0-56 | ||||||||||||||||||
379 | ((void *)0)
| 0-7 | ||||||||||||||||||
380 | , indent)
| 0-7 | ||||||||||||||||||
381 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
382 | if (x->seed
| 13-50 | ||||||||||||||||||
383 | int i; | - | ||||||||||||||||||
384 | BIO_indent(bp, indent, 128); | - | ||||||||||||||||||
385 | BIO_puts(bp, "seed:"); | - | ||||||||||||||||||
386 | for (i = 0; i < x->seedlen
| 13-3571 | ||||||||||||||||||
387 | if ((
| 246-3325 | ||||||||||||||||||
388 | if (BIO_puts(bp, "\n") <= 0
| 0-246 | ||||||||||||||||||
389 | || !BIO_indent(bp, indent + 4, 128)
| 0-246 | ||||||||||||||||||
390 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
391 | } executed 246 times by 1 test: end of block Executed by:
| 246 | ||||||||||||||||||
392 | if (BIO_printf(bp, "%02x%s", x->seed[i],
| 0-3571 | ||||||||||||||||||
393 | ((i + 1) == x->seedlen) ? "" : ":") <= 0
| 0-3571 | ||||||||||||||||||
394 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
395 | } executed 3571 times by 1 test: end of block Executed by:
| 3571 | ||||||||||||||||||
396 | if (BIO_write(bp, "\n", 1) <= 0
| 0-13 | ||||||||||||||||||
397 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||
398 | } executed 13 times by 1 test: end of block Executed by:
| 13 | ||||||||||||||||||
399 | if (x->counter
| 0-48 | ||||||||||||||||||
400 | ((void *)0)
| 0-15 | ||||||||||||||||||
401 | , indent)
| 0-15 | ||||||||||||||||||
402 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
403 | if (x->length != 0
| 10-53 | ||||||||||||||||||
404 | BIO_indent(bp, indent, 128); | - | ||||||||||||||||||
405 | if (BIO_printf(bp, "recommended-private-length: %d bits\n",
| 0-10 | ||||||||||||||||||
406 | (int)x->length) <= 0
| 0-10 | ||||||||||||||||||
407 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
408 | } executed 10 times by 1 test: end of block Executed by:
| 10 | ||||||||||||||||||
409 | - | |||||||||||||||||||
410 | return executed 63 times by 1 test: 1;return 1; Executed by:
executed 63 times by 1 test: return 1; Executed by:
| 63 | ||||||||||||||||||
411 | - | |||||||||||||||||||
412 | err: | - | ||||||||||||||||||
413 | ERR_put_error(5,(100),(reason),__FILE__,343); | - | ||||||||||||||||||
414 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||
415 | } | - | ||||||||||||||||||
416 | - | |||||||||||||||||||
417 | static int int_dh_size(const EVP_PKEY *pkey) | - | ||||||||||||||||||
418 | { | - | ||||||||||||||||||
419 | return never executed: DH_size(pkey->pkey.dh);return DH_size(pkey->pkey.dh); never executed: return DH_size(pkey->pkey.dh); | 0 | ||||||||||||||||||
420 | } | - | ||||||||||||||||||
421 | - | |||||||||||||||||||
422 | static int dh_bits(const EVP_PKEY *pkey) | - | ||||||||||||||||||
423 | { | - | ||||||||||||||||||
424 | return executed 52 times by 1 test: BN_num_bits(pkey->pkey.dh->p);return BN_num_bits(pkey->pkey.dh->p); Executed by:
executed 52 times by 1 test: return BN_num_bits(pkey->pkey.dh->p); Executed by:
| 52 | ||||||||||||||||||
425 | } | - | ||||||||||||||||||
426 | - | |||||||||||||||||||
427 | static int dh_security_bits(const EVP_PKEY *pkey) | - | ||||||||||||||||||
428 | { | - | ||||||||||||||||||
429 | return executed 296 times by 1 test: DH_security_bits(pkey->pkey.dh);return DH_security_bits(pkey->pkey.dh); Executed by:
executed 296 times by 1 test: return DH_security_bits(pkey->pkey.dh); Executed by:
| 296 | ||||||||||||||||||
430 | } | - | ||||||||||||||||||
431 | - | |||||||||||||||||||
432 | static int dh_cmp_parameters(const EVP_PKEY *a, const EVP_PKEY *b) | - | ||||||||||||||||||
433 | { | - | ||||||||||||||||||
434 | if (BN_cmp(a->pkey.dh->p, b->pkey.dh->p)
| 0-246 | ||||||||||||||||||
435 | BN_cmp(a->pkey.dh->g, b->pkey.dh->g)
| 0-246 | ||||||||||||||||||
436 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||
437 | else if (a->ameth == &dhx_asn1_meth
| 2-244 | ||||||||||||||||||
438 | if (BN_cmp(a->pkey.dh->q, b->pkey.dh->q)
| 0-2 | ||||||||||||||||||
439 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||
440 | } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||||||||
441 | return executed 246 times by 1 test: 1;return 1; Executed by:
executed 246 times by 1 test: return 1; Executed by:
| 246 | ||||||||||||||||||
442 | } | - | ||||||||||||||||||
443 | - | |||||||||||||||||||
444 | static int int_dh_bn_cpy(BIGNUM **dst, const BIGNUM *src) | - | ||||||||||||||||||
445 | { | - | ||||||||||||||||||
446 | BIGNUM *a; | - | ||||||||||||||||||
447 | - | |||||||||||||||||||
448 | - | |||||||||||||||||||
449 | - | |||||||||||||||||||
450 | - | |||||||||||||||||||
451 | - | |||||||||||||||||||
452 | if (src ==
| 2-556 | ||||||||||||||||||
453 | ((void *)0)
| 2-556 | ||||||||||||||||||
454 | ) | - | ||||||||||||||||||
455 | a = executed 2 times by 1 test: a = ((void *)0) ; Executed by:
| 2 | ||||||||||||||||||
456 | ((void *)0) executed 2 times by 1 test: a = ((void *)0) ; Executed by:
| 2 | ||||||||||||||||||
457 | ; executed 2 times by 1 test: a = ((void *)0) ; Executed by:
| 2 | ||||||||||||||||||
458 | else if (BN_get_flags(src, 0x02)
| 0-556 | ||||||||||||||||||
459 | && !BN_get_flags(src, 0x01)
| 0 | ||||||||||||||||||
460 | a = (BIGNUM *)src; never executed: a = (BIGNUM *)src; | 0 | ||||||||||||||||||
461 | else if ((
| 0-556 | ||||||||||||||||||
462 | ((void *)0)
| 0-556 | ||||||||||||||||||
463 | ) | - | ||||||||||||||||||
464 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||
465 | BN_clear_free(*dst); | - | ||||||||||||||||||
466 | *dst = a; | - | ||||||||||||||||||
467 | return executed 558 times by 1 test: 1;return 1; Executed by:
executed 558 times by 1 test: return 1; Executed by:
| 558 | ||||||||||||||||||
468 | } | - | ||||||||||||||||||
469 | - | |||||||||||||||||||
470 | static int int_dh_param_copy(DH *to, const DH *from, int is_x942) | - | ||||||||||||||||||
471 | { | - | ||||||||||||||||||
472 | if (is_x942 == -1
| 2-275 | ||||||||||||||||||
473 | is_x942 = ! !from->q; executed 2 times by 1 test: is_x942 = ! !from->q; Executed by:
| 2 | ||||||||||||||||||
474 | if (!int_dh_bn_cpy(&to->p, from->p)
| 0-277 | ||||||||||||||||||
475 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||
476 | if (!int_dh_bn_cpy(&to->g, from->g)
| 0-277 | ||||||||||||||||||
477 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||
478 | if (is_x942
| 2-275 | ||||||||||||||||||
479 | if (!int_dh_bn_cpy(&to->q, from->q)
| 0-2 | ||||||||||||||||||
480 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||
481 | if (!int_dh_bn_cpy(&to->j, from->j)
| 0-2 | ||||||||||||||||||
482 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||
483 | CRYPTO_free(to->seed, __FILE__, 407); | - | ||||||||||||||||||
484 | to->seed = | - | ||||||||||||||||||
485 | ((void *)0) | - | ||||||||||||||||||
486 | ; | - | ||||||||||||||||||
487 | to->seedlen = 0; | - | ||||||||||||||||||
488 | if (from->seed
| 0-2 | ||||||||||||||||||
489 | to->seed = CRYPTO_memdup((from->seed), from->seedlen, __FILE__, 411); | - | ||||||||||||||||||
490 | if (!to->seed
| 0 | ||||||||||||||||||
491 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||
492 | to->seedlen = from->seedlen; | - | ||||||||||||||||||
493 | } never executed: end of block | 0 | ||||||||||||||||||
494 | } executed 2 times by 1 test: elseend of block Executed by:
| 2 | ||||||||||||||||||
495 | to->length = from->length; executed 275 times by 1 test: to->length = from->length; Executed by:
| 275 | ||||||||||||||||||
496 | return executed 277 times by 1 test: 1;return 1; Executed by:
executed 277 times by 1 test: return 1; Executed by:
| 277 | ||||||||||||||||||
497 | } | - | ||||||||||||||||||
498 | - | |||||||||||||||||||
499 | DH *DHparams_dup(DH *dh) | - | ||||||||||||||||||
500 | { | - | ||||||||||||||||||
501 | DH *ret; | - | ||||||||||||||||||
502 | ret = DH_new(); | - | ||||||||||||||||||
503 | if (ret ==
| 0-2 | ||||||||||||||||||
504 | ((void *)0)
| 0-2 | ||||||||||||||||||
505 | ) | - | ||||||||||||||||||
506 | return never executed: return ((void *)0) ; never executed: return ((void *)0) ; | 0 | ||||||||||||||||||
507 | ((void *)0) never executed: return ((void *)0) ; | 0 | ||||||||||||||||||
508 | ; never executed: return ((void *)0) ; | 0 | ||||||||||||||||||
509 | if (!int_dh_param_copy(ret, dh, -1)
| 0-2 | ||||||||||||||||||
510 | DH_free(ret); | - | ||||||||||||||||||
511 | return never executed: return ((void *)0) ; never executed: return ((void *)0) ; | 0 | ||||||||||||||||||
512 | ((void *)0) never executed: return ((void *)0) ; | 0 | ||||||||||||||||||
513 | ; never executed: return ((void *)0) ; | 0 | ||||||||||||||||||
514 | } | - | ||||||||||||||||||
515 | return executed 2 times by 1 test: ret;return ret; Executed by:
executed 2 times by 1 test: return ret; Executed by:
| 2 | ||||||||||||||||||
516 | } | - | ||||||||||||||||||
517 | - | |||||||||||||||||||
518 | static int dh_copy_parameters(EVP_PKEY *to, const EVP_PKEY *from) | - | ||||||||||||||||||
519 | { | - | ||||||||||||||||||
520 | if (to->pkey.dh ==
| 59-216 | ||||||||||||||||||
521 | ((void *)0)
| 59-216 | ||||||||||||||||||
522 | ) { | - | ||||||||||||||||||
523 | to->pkey.dh = DH_new(); | - | ||||||||||||||||||
524 | if (to->pkey.dh ==
| 0-59 | ||||||||||||||||||
525 | ((void *)0)
| 0-59 | ||||||||||||||||||
526 | ) | - | ||||||||||||||||||
527 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||
528 | } executed 59 times by 1 test: end of block Executed by:
| 59 | ||||||||||||||||||
529 | return executed 275 times by 1 test: int_dh_param_copy(to->pkey.dh, from->pkey.dh,return int_dh_param_copy(to->pkey.dh, from->pkey.dh, from->ameth == &dhx_asn1_meth); Executed by:
executed 275 times by 1 test: return int_dh_param_copy(to->pkey.dh, from->pkey.dh, from->ameth == &dhx_asn1_meth); Executed by:
| 275 | ||||||||||||||||||
530 | from->ameth == &dhx_asn1_meth); executed 275 times by 1 test: return int_dh_param_copy(to->pkey.dh, from->pkey.dh, from->ameth == &dhx_asn1_meth); Executed by:
| 275 | ||||||||||||||||||
531 | } | - | ||||||||||||||||||
532 | - | |||||||||||||||||||
533 | static int dh_missing_parameters(const EVP_PKEY *a) | - | ||||||||||||||||||
534 | { | - | ||||||||||||||||||
535 | if (a->pkey.dh ==
| 59-721 | ||||||||||||||||||
536 | ((void *)0)
| 59-721 | ||||||||||||||||||
537 | || a->pkey.dh->p ==
| 216-505 | ||||||||||||||||||
538 | ((void *)0)
| 216-505 | ||||||||||||||||||
539 | || a->pkey.dh->g ==
| 0-505 | ||||||||||||||||||
540 | ((void *)0)
| 0-505 | ||||||||||||||||||
541 | ) | - | ||||||||||||||||||
542 | return executed 275 times by 1 test: 1;return 1; Executed by:
executed 275 times by 1 test: return 1; Executed by:
| 275 | ||||||||||||||||||
543 | return executed 505 times by 1 test: 0;return 0; Executed by:
executed 505 times by 1 test: return 0; Executed by:
| 505 | ||||||||||||||||||
544 | } | - | ||||||||||||||||||
545 | - | |||||||||||||||||||
546 | static int dh_pub_cmp(const EVP_PKEY *a, const EVP_PKEY *b) | - | ||||||||||||||||||
547 | { | - | ||||||||||||||||||
548 | if (dh_cmp_parameters(a, b) == 0
| 0-10 | ||||||||||||||||||
549 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||
550 | if (BN_cmp(b->pkey.dh->pub_key, a->pkey.dh->pub_key) != 0
| 0-10 | ||||||||||||||||||
551 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||
552 | else | - | ||||||||||||||||||
553 | return executed 10 times by 1 test: 1;return 1; Executed by:
executed 10 times by 1 test: return 1; Executed by:
| 10 | ||||||||||||||||||
554 | } | - | ||||||||||||||||||
555 | - | |||||||||||||||||||
556 | static int dh_param_print(BIO *bp, const EVP_PKEY *pkey, int indent, | - | ||||||||||||||||||
557 | ASN1_PCTX *ctx) | - | ||||||||||||||||||
558 | { | - | ||||||||||||||||||
559 | return never executed: do_dh_print(bp, pkey->pkey.dh, indent, 0);return do_dh_print(bp, pkey->pkey.dh, indent, 0); never executed: return do_dh_print(bp, pkey->pkey.dh, indent, 0); | 0 | ||||||||||||||||||
560 | } | - | ||||||||||||||||||
561 | - | |||||||||||||||||||
562 | static int dh_public_print(BIO *bp, const EVP_PKEY *pkey, int indent, | - | ||||||||||||||||||
563 | ASN1_PCTX *ctx) | - | ||||||||||||||||||
564 | { | - | ||||||||||||||||||
565 | return executed 10 times by 1 test: do_dh_print(bp, pkey->pkey.dh, indent, 1);return do_dh_print(bp, pkey->pkey.dh, indent, 1); Executed by:
executed 10 times by 1 test: return do_dh_print(bp, pkey->pkey.dh, indent, 1); Executed by:
| 10 | ||||||||||||||||||
566 | } | - | ||||||||||||||||||
567 | - | |||||||||||||||||||
568 | static int dh_private_print(BIO *bp, const EVP_PKEY *pkey, int indent, | - | ||||||||||||||||||
569 | ASN1_PCTX *ctx) | - | ||||||||||||||||||
570 | { | - | ||||||||||||||||||
571 | return never executed: do_dh_print(bp, pkey->pkey.dh, indent, 2);return do_dh_print(bp, pkey->pkey.dh, indent, 2); never executed: return do_dh_print(bp, pkey->pkey.dh, indent, 2); | 0 | ||||||||||||||||||
572 | } | - | ||||||||||||||||||
573 | - | |||||||||||||||||||
574 | int DHparams_print(BIO *bp, const DH *x) | - | ||||||||||||||||||
575 | { | - | ||||||||||||||||||
576 | return executed 53 times by 1 test: do_dh_print(bp, x, 4, 0);return do_dh_print(bp, x, 4, 0); Executed by:
executed 53 times by 1 test: return do_dh_print(bp, x, 4, 0); Executed by:
| 53 | ||||||||||||||||||
577 | } | - | ||||||||||||||||||
578 | - | |||||||||||||||||||
579 | - | |||||||||||||||||||
580 | static int dh_cms_decrypt(CMS_RecipientInfo *ri); | - | ||||||||||||||||||
581 | static int dh_cms_encrypt(CMS_RecipientInfo *ri); | - | ||||||||||||||||||
582 | - | |||||||||||||||||||
583 | - | |||||||||||||||||||
584 | static int dh_pkey_ctrl(EVP_PKEY *pkey, int op, long arg1, void *arg2) | - | ||||||||||||||||||
585 | { | - | ||||||||||||||||||
586 | switch (op) { | - | ||||||||||||||||||
587 | - | |||||||||||||||||||
588 | - | |||||||||||||||||||
589 | case executed 2 times by 1 test: 0x7:case 0x7: Executed by:
executed 2 times by 1 test: case 0x7: Executed by:
| 2 | ||||||||||||||||||
590 | if (arg1 == 1
| 1 | ||||||||||||||||||
591 | return executed 1 time by 1 test: dh_cms_decrypt(arg2);return dh_cms_decrypt(arg2); Executed by:
executed 1 time by 1 test: return dh_cms_decrypt(arg2); Executed by:
| 1 | ||||||||||||||||||
592 | else if (arg1 == 0
| 0-1 | ||||||||||||||||||
593 | return executed 1 time by 1 test: dh_cms_encrypt(arg2);return dh_cms_encrypt(arg2); Executed by:
executed 1 time by 1 test: return dh_cms_encrypt(arg2); Executed by:
| 1 | ||||||||||||||||||
594 | return never executed: -2;return -2; never executed: return -2; | 0 | ||||||||||||||||||
595 | - | |||||||||||||||||||
596 | case executed 2 times by 1 test: 0x8:case 0x8: Executed by:
executed 2 times by 1 test: case 0x8: Executed by:
| 2 | ||||||||||||||||||
597 | *(int *)arg2 = 1; | - | ||||||||||||||||||
598 | return executed 2 times by 1 test: 1;return 1; Executed by:
executed 2 times by 1 test: return 1; Executed by:
| 2 | ||||||||||||||||||
599 | - | |||||||||||||||||||
600 | default never executed: :default: never executed: default: | 0 | ||||||||||||||||||
601 | return never executed: -2;return -2; never executed: return -2; | 0 | ||||||||||||||||||
602 | } | - | ||||||||||||||||||
603 | - | |||||||||||||||||||
604 | } | - | ||||||||||||||||||
605 | - | |||||||||||||||||||
606 | static int dh_pkey_public_check(const EVP_PKEY *pkey) | - | ||||||||||||||||||
607 | { | - | ||||||||||||||||||
608 | DH *dh = pkey->pkey.dh; | - | ||||||||||||||||||
609 | - | |||||||||||||||||||
610 | if (dh->pub_key ==
| 0 | ||||||||||||||||||
611 | ((void *)0)
| 0 | ||||||||||||||||||
612 | ) { | - | ||||||||||||||||||
613 | ERR_put_error(5,(124),(125),__FILE__,517); | - | ||||||||||||||||||
614 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||
615 | } | - | ||||||||||||||||||
616 | - | |||||||||||||||||||
617 | return never executed: DH_check_pub_key_ex(dh, dh->pub_key);return DH_check_pub_key_ex(dh, dh->pub_key); never executed: return DH_check_pub_key_ex(dh, dh->pub_key); | 0 | ||||||||||||||||||
618 | } | - | ||||||||||||||||||
619 | - | |||||||||||||||||||
620 | static int dh_pkey_param_check(const EVP_PKEY *pkey) | - | ||||||||||||||||||
621 | { | - | ||||||||||||||||||
622 | DH *dh = pkey->pkey.dh; | - | ||||||||||||||||||
623 | - | |||||||||||||||||||
624 | return never executed: DH_check_ex(dh);return DH_check_ex(dh); never executed: return DH_check_ex(dh); | 0 | ||||||||||||||||||
625 | } | - | ||||||||||||||||||
626 | - | |||||||||||||||||||
627 | const EVP_PKEY_ASN1_METHOD dh_asn1_meth = { | - | ||||||||||||||||||
628 | 28, | - | ||||||||||||||||||
629 | 28, | - | ||||||||||||||||||
630 | 0, | - | ||||||||||||||||||
631 | - | |||||||||||||||||||
632 | "DH", | - | ||||||||||||||||||
633 | "OpenSSL PKCS#3 DH method", | - | ||||||||||||||||||
634 | - | |||||||||||||||||||
635 | dh_pub_decode, | - | ||||||||||||||||||
636 | dh_pub_encode, | - | ||||||||||||||||||
637 | dh_pub_cmp, | - | ||||||||||||||||||
638 | dh_public_print, | - | ||||||||||||||||||
639 | - | |||||||||||||||||||
640 | dh_priv_decode, | - | ||||||||||||||||||
641 | dh_priv_encode, | - | ||||||||||||||||||
642 | dh_private_print, | - | ||||||||||||||||||
643 | - | |||||||||||||||||||
644 | int_dh_size, | - | ||||||||||||||||||
645 | dh_bits, | - | ||||||||||||||||||
646 | dh_security_bits, | - | ||||||||||||||||||
647 | - | |||||||||||||||||||
648 | dh_param_decode, | - | ||||||||||||||||||
649 | dh_param_encode, | - | ||||||||||||||||||
650 | dh_missing_parameters, | - | ||||||||||||||||||
651 | dh_copy_parameters, | - | ||||||||||||||||||
652 | dh_cmp_parameters, | - | ||||||||||||||||||
653 | dh_param_print, | - | ||||||||||||||||||
654 | 0, | - | ||||||||||||||||||
655 | - | |||||||||||||||||||
656 | int_dh_free, | - | ||||||||||||||||||
657 | 0, | - | ||||||||||||||||||
658 | - | |||||||||||||||||||
659 | 0, 0, 0, 0, 0, | - | ||||||||||||||||||
660 | - | |||||||||||||||||||
661 | 0, | - | ||||||||||||||||||
662 | dh_pkey_public_check, | - | ||||||||||||||||||
663 | dh_pkey_param_check | - | ||||||||||||||||||
664 | }; | - | ||||||||||||||||||
665 | - | |||||||||||||||||||
666 | const EVP_PKEY_ASN1_METHOD dhx_asn1_meth = { | - | ||||||||||||||||||
667 | 920, | - | ||||||||||||||||||
668 | 920, | - | ||||||||||||||||||
669 | 0, | - | ||||||||||||||||||
670 | - | |||||||||||||||||||
671 | "X9.42 DH", | - | ||||||||||||||||||
672 | "OpenSSL X9.42 DH method", | - | ||||||||||||||||||
673 | - | |||||||||||||||||||
674 | dh_pub_decode, | - | ||||||||||||||||||
675 | dh_pub_encode, | - | ||||||||||||||||||
676 | dh_pub_cmp, | - | ||||||||||||||||||
677 | dh_public_print, | - | ||||||||||||||||||
678 | - | |||||||||||||||||||
679 | dh_priv_decode, | - | ||||||||||||||||||
680 | dh_priv_encode, | - | ||||||||||||||||||
681 | dh_private_print, | - | ||||||||||||||||||
682 | - | |||||||||||||||||||
683 | int_dh_size, | - | ||||||||||||||||||
684 | dh_bits, | - | ||||||||||||||||||
685 | dh_security_bits, | - | ||||||||||||||||||
686 | - | |||||||||||||||||||
687 | dh_param_decode, | - | ||||||||||||||||||
688 | dh_param_encode, | - | ||||||||||||||||||
689 | dh_missing_parameters, | - | ||||||||||||||||||
690 | dh_copy_parameters, | - | ||||||||||||||||||
691 | dh_cmp_parameters, | - | ||||||||||||||||||
692 | dh_param_print, | - | ||||||||||||||||||
693 | 0, | - | ||||||||||||||||||
694 | - | |||||||||||||||||||
695 | int_dh_free, | - | ||||||||||||||||||
696 | dh_pkey_ctrl, | - | ||||||||||||||||||
697 | - | |||||||||||||||||||
698 | 0, 0, 0, 0, 0, | - | ||||||||||||||||||
699 | - | |||||||||||||||||||
700 | 0, | - | ||||||||||||||||||
701 | dh_pkey_public_check, | - | ||||||||||||||||||
702 | dh_pkey_param_check | - | ||||||||||||||||||
703 | }; | - | ||||||||||||||||||
704 | - | |||||||||||||||||||
705 | - | |||||||||||||||||||
706 | - | |||||||||||||||||||
707 | static int dh_cms_set_peerkey(EVP_PKEY_CTX *pctx, | - | ||||||||||||||||||
708 | X509_ALGOR *alg, ASN1_BIT_STRING *pubkey) | - | ||||||||||||||||||
709 | { | - | ||||||||||||||||||
710 | const ASN1_OBJECT *aoid; | - | ||||||||||||||||||
711 | int atype; | - | ||||||||||||||||||
712 | const void *aval; | - | ||||||||||||||||||
713 | ASN1_INTEGER *public_key = | - | ||||||||||||||||||
714 | ((void *)0) | - | ||||||||||||||||||
715 | ; | - | ||||||||||||||||||
716 | int rv = 0; | - | ||||||||||||||||||
717 | EVP_PKEY *pkpeer = | - | ||||||||||||||||||
718 | ((void *)0) | - | ||||||||||||||||||
719 | , *pk = | - | ||||||||||||||||||
720 | ((void *)0) | - | ||||||||||||||||||
721 | ; | - | ||||||||||||||||||
722 | DH *dhpeer = | - | ||||||||||||||||||
723 | ((void *)0) | - | ||||||||||||||||||
724 | ; | - | ||||||||||||||||||
725 | const unsigned char *p; | - | ||||||||||||||||||
726 | int plen; | - | ||||||||||||||||||
727 | - | |||||||||||||||||||
728 | X509_ALGOR_get0(&aoid, &atype, &aval, alg); | - | ||||||||||||||||||
729 | if (OBJ_obj2nid(aoid) != 920
| 0-1 | ||||||||||||||||||
730 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
731 | - | |||||||||||||||||||
732 | if (atype != -1
| 0-1 | ||||||||||||||||||
733 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
734 | - | |||||||||||||||||||
735 | pk = EVP_PKEY_CTX_get0_pkey(pctx); | - | ||||||||||||||||||
736 | if (!pk
| 0-1 | ||||||||||||||||||
737 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
738 | if (pk->type != 920
| 0-1 | ||||||||||||||||||
739 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
740 | - | |||||||||||||||||||
741 | dhpeer = DHparams_dup(pk->pkey.dh); | - | ||||||||||||||||||
742 | - | |||||||||||||||||||
743 | plen = ASN1_STRING_length(pubkey); | - | ||||||||||||||||||
744 | p = ASN1_STRING_get0_data(pubkey); | - | ||||||||||||||||||
745 | if (!p
| 0-1 | ||||||||||||||||||
746 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
747 | - | |||||||||||||||||||
748 | if ((
| 0-1 | ||||||||||||||||||
749 | ((void *)0)
| 0-1 | ||||||||||||||||||
750 | , &p, plen)) ==
| 0-1 | ||||||||||||||||||
751 | ((void *)0)
| 0-1 | ||||||||||||||||||
752 | ) { | - | ||||||||||||||||||
753 | ERR_put_error(5,(115),(104),__FILE__,645); | - | ||||||||||||||||||
754 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
755 | } | - | ||||||||||||||||||
756 | - | |||||||||||||||||||
757 | - | |||||||||||||||||||
758 | if ((
| 0-1 | ||||||||||||||||||
759 | ((void *)0)
| 0-1 | ||||||||||||||||||
760 | )) ==
| 0-1 | ||||||||||||||||||
761 | ((void *)0)
| 0-1 | ||||||||||||||||||
762 | ) { | - | ||||||||||||||||||
763 | ERR_put_error(5,(115),(109),__FILE__,651); | - | ||||||||||||||||||
764 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
765 | } | - | ||||||||||||||||||
766 | - | |||||||||||||||||||
767 | pkpeer = EVP_PKEY_new(); | - | ||||||||||||||||||
768 | if (pkpeer ==
| 0-1 | ||||||||||||||||||
769 | ((void *)0)
| 0-1 | ||||||||||||||||||
770 | ) | - | ||||||||||||||||||
771 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
772 | EVP_PKEY_assign(pkpeer, pk->ameth->pkey_id, dhpeer); | - | ||||||||||||||||||
773 | dhpeer = | - | ||||||||||||||||||
774 | ((void *)0) | - | ||||||||||||||||||
775 | ; | - | ||||||||||||||||||
776 | if (EVP_PKEY_derive_set_peer(pctx, pkpeer) > 0
| 0-1 | ||||||||||||||||||
777 | rv = 1; executed 1 time by 1 test: rv = 1; Executed by:
| 1 | ||||||||||||||||||
778 | err: code before this statement executed 1 time by 1 test: err: Executed by:
| 1 | ||||||||||||||||||
779 | ASN1_INTEGER_free(public_key); | - | ||||||||||||||||||
780 | EVP_PKEY_free(pkpeer); | - | ||||||||||||||||||
781 | DH_free(dhpeer); | - | ||||||||||||||||||
782 | return executed 1 time by 1 test: rv;return rv; Executed by:
executed 1 time by 1 test: return rv; Executed by:
| 1 | ||||||||||||||||||
783 | } | - | ||||||||||||||||||
784 | - | |||||||||||||||||||
785 | static int dh_cms_set_shared_info(EVP_PKEY_CTX *pctx, CMS_RecipientInfo *ri) | - | ||||||||||||||||||
786 | { | - | ||||||||||||||||||
787 | int rv = 0; | - | ||||||||||||||||||
788 | - | |||||||||||||||||||
789 | X509_ALGOR *alg, *kekalg = | - | ||||||||||||||||||
790 | ((void *)0) | - | ||||||||||||||||||
791 | ; | - | ||||||||||||||||||
792 | ASN1_OCTET_STRING *ukm; | - | ||||||||||||||||||
793 | const unsigned char *p; | - | ||||||||||||||||||
794 | unsigned char *dukm = | - | ||||||||||||||||||
795 | ((void *)0) | - | ||||||||||||||||||
796 | ; | - | ||||||||||||||||||
797 | size_t dukmlen = 0; | - | ||||||||||||||||||
798 | int keylen, plen; | - | ||||||||||||||||||
799 | const EVP_CIPHER *kekcipher; | - | ||||||||||||||||||
800 | EVP_CIPHER_CTX *kekctx; | - | ||||||||||||||||||
801 | - | |||||||||||||||||||
802 | if (!CMS_RecipientInfo_kari_get0_alg(ri, &alg, &ukm)
| 0-1 | ||||||||||||||||||
803 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
804 | - | |||||||||||||||||||
805 | - | |||||||||||||||||||
806 | - | |||||||||||||||||||
807 | - | |||||||||||||||||||
808 | - | |||||||||||||||||||
809 | if (OBJ_obj2nid(alg->algorithm) != 245
| 0-1 | ||||||||||||||||||
810 | ERR_put_error(5,(116),(112),__FILE__,690); | - | ||||||||||||||||||
811 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
812 | } | - | ||||||||||||||||||
813 | - | |||||||||||||||||||
814 | if (EVP_PKEY_CTX_ctrl(pctx, 920, (1<<10), (0x1000 + 6), 2,
| 0-1 | ||||||||||||||||||
815 | ((void *)0)
| 0-1 | ||||||||||||||||||
816 | ) <= 0
| 0-1 | ||||||||||||||||||
817 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
818 | - | |||||||||||||||||||
819 | if (EVP_PKEY_CTX_ctrl(pctx, 920, (1<<10), (0x1000 + 7), 0, (void *)(EVP_sha1())) <= 0
| 0-1 | ||||||||||||||||||
820 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
821 | - | |||||||||||||||||||
822 | if (alg->parameter->type != 16
| 0-1 | ||||||||||||||||||
823 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
824 | - | |||||||||||||||||||
825 | p = alg->parameter->value.sequence->data; | - | ||||||||||||||||||
826 | plen = alg->parameter->value.sequence->length; | - | ||||||||||||||||||
827 | kekalg = d2i_X509_ALGOR( | - | ||||||||||||||||||
828 | ((void *)0) | - | ||||||||||||||||||
829 | , &p, plen); | - | ||||||||||||||||||
830 | if (!kekalg
| 0-1 | ||||||||||||||||||
831 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
832 | kekctx = CMS_RecipientInfo_kari_get0_ctx(ri); | - | ||||||||||||||||||
833 | if (!kekctx
| 0-1 | ||||||||||||||||||
834 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
835 | kekcipher = EVP_get_cipherbyname(OBJ_nid2sn(OBJ_obj2nid(kekalg->algorithm))); | - | ||||||||||||||||||
836 | if (!kekcipher
| 0-1 | ||||||||||||||||||
837 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
838 | if (!EVP_EncryptInit_ex(kekctx, kekcipher,
| 0-1 | ||||||||||||||||||
839 | ((void *)0)
| 0-1 | ||||||||||||||||||
840 | ,
| 0-1 | ||||||||||||||||||
841 | ((void *)0)
| 0-1 | ||||||||||||||||||
842 | ,
| 0-1 | ||||||||||||||||||
843 | ((void *)0)
| 0-1 | ||||||||||||||||||
844 | )
| 0-1 | ||||||||||||||||||
845 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
846 | if (EVP_CIPHER_asn1_to_param(kekctx, kekalg->parameter) <= 0
| 0-1 | ||||||||||||||||||
847 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
848 | - | |||||||||||||||||||
849 | keylen = EVP_CIPHER_CTX_key_length(kekctx); | - | ||||||||||||||||||
850 | if (EVP_PKEY_CTX_ctrl(pctx, 920, (1<<10), (0x1000 + 9), keylen,
| 0-1 | ||||||||||||||||||
851 | ((void *)0)
| 0-1 | ||||||||||||||||||
852 | ) <= 0
| 0-1 | ||||||||||||||||||
853 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
854 | - | |||||||||||||||||||
855 | if (EVP_PKEY_CTX_ctrl(pctx, 920, (1<<10), (0x1000 + 13), 0, (void *)(OBJ_nid2obj(EVP_CIPHER_type(kekcipher))))
| 0-1 | ||||||||||||||||||
856 | 0-1 | |||||||||||||||||||
857 | <= 0
| 0-1 | ||||||||||||||||||
858 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
859 | - | |||||||||||||||||||
860 | if (ukm
| 0-1 | ||||||||||||||||||
861 | dukmlen = ASN1_STRING_length(ukm); | - | ||||||||||||||||||
862 | dukm = CRYPTO_memdup((ASN1_STRING_get0_data(ukm)), dukmlen, __FILE__, 730); | - | ||||||||||||||||||
863 | if (!dukm
| 0 | ||||||||||||||||||
864 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
865 | } never executed: end of block | 0 | ||||||||||||||||||
866 | - | |||||||||||||||||||
867 | if (EVP_PKEY_CTX_ctrl(pctx, 920, (1<<10), (0x1000 + 11), dukmlen, (void *)(dukm)) <= 0
| 0-1 | ||||||||||||||||||
868 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
869 | dukm = | - | ||||||||||||||||||
870 | ((void *)0) | - | ||||||||||||||||||
871 | ; | - | ||||||||||||||||||
872 | - | |||||||||||||||||||
873 | rv = 1; | - | ||||||||||||||||||
874 | err: code before this statement executed 1 time by 1 test: err: Executed by:
| 1 | ||||||||||||||||||
875 | X509_ALGOR_free(kekalg); | - | ||||||||||||||||||
876 | CRYPTO_free(dukm, __FILE__, 742); | - | ||||||||||||||||||
877 | return executed 1 time by 1 test: rv;return rv; Executed by:
executed 1 time by 1 test: return rv; Executed by:
| 1 | ||||||||||||||||||
878 | } | - | ||||||||||||||||||
879 | - | |||||||||||||||||||
880 | static int dh_cms_decrypt(CMS_RecipientInfo *ri) | - | ||||||||||||||||||
881 | { | - | ||||||||||||||||||
882 | EVP_PKEY_CTX *pctx; | - | ||||||||||||||||||
883 | pctx = CMS_RecipientInfo_get0_pkey_ctx(ri); | - | ||||||||||||||||||
884 | if (!pctx
| 0-1 | ||||||||||||||||||
885 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||
886 | - | |||||||||||||||||||
887 | if (!EVP_PKEY_CTX_get0_peerkey(pctx)
| 0-1 | ||||||||||||||||||
888 | X509_ALGOR *alg; | - | ||||||||||||||||||
889 | ASN1_BIT_STRING *pubkey; | - | ||||||||||||||||||
890 | if (!CMS_RecipientInfo_kari_get0_orig_id(ri, &alg, &pubkey,
| 0-1 | ||||||||||||||||||
891 |
| 0-1 | ||||||||||||||||||
892 | ((void *)0)
| 0-1 | ||||||||||||||||||
893 | ,
| 0-1 | ||||||||||||||||||
894 | ((void *)0)
| 0-1 | ||||||||||||||||||
895 | ,
| 0-1 | ||||||||||||||||||
896 | ((void *)0)
| 0-1 | ||||||||||||||||||
897 | )
| 0-1 | ||||||||||||||||||
898 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||
899 | if (!alg
| 0-1 | ||||||||||||||||||
900 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||
901 | if (!dh_cms_set_peerkey(pctx, alg, pubkey)
| 0-1 | ||||||||||||||||||
902 | ERR_put_error(5,(114),(111),__FILE__,762); | - | ||||||||||||||||||
903 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||
904 | } | - | ||||||||||||||||||
905 | } executed 1 time by 1 test: end of block Executed by:
| 1 | ||||||||||||||||||
906 | - | |||||||||||||||||||
907 | if (!dh_cms_set_shared_info(pctx, ri)
| 0-1 | ||||||||||||||||||
908 | ERR_put_error(5,(114),(113),__FILE__,768); | - | ||||||||||||||||||
909 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||
910 | } | - | ||||||||||||||||||
911 | return executed 1 time by 1 test: 1;return 1; Executed by:
executed 1 time by 1 test: return 1; Executed by:
| 1 | ||||||||||||||||||
912 | } | - | ||||||||||||||||||
913 | - | |||||||||||||||||||
914 | static int dh_cms_encrypt(CMS_RecipientInfo *ri) | - | ||||||||||||||||||
915 | { | - | ||||||||||||||||||
916 | EVP_PKEY_CTX *pctx; | - | ||||||||||||||||||
917 | EVP_PKEY *pkey; | - | ||||||||||||||||||
918 | EVP_CIPHER_CTX *ctx; | - | ||||||||||||||||||
919 | int keylen; | - | ||||||||||||||||||
920 | X509_ALGOR *talg, *wrap_alg = | - | ||||||||||||||||||
921 | ((void *)0) | - | ||||||||||||||||||
922 | ; | - | ||||||||||||||||||
923 | const ASN1_OBJECT *aoid; | - | ||||||||||||||||||
924 | ASN1_BIT_STRING *pubkey; | - | ||||||||||||||||||
925 | ASN1_STRING *wrap_str; | - | ||||||||||||||||||
926 | ASN1_OCTET_STRING *ukm; | - | ||||||||||||||||||
927 | unsigned char *penc = | - | ||||||||||||||||||
928 | ((void *)0) | - | ||||||||||||||||||
929 | , *dukm = | - | ||||||||||||||||||
930 | ((void *)0) | - | ||||||||||||||||||
931 | ; | - | ||||||||||||||||||
932 | int penclen; | - | ||||||||||||||||||
933 | size_t dukmlen = 0; | - | ||||||||||||||||||
934 | int rv = 0; | - | ||||||||||||||||||
935 | int kdf_type, wrap_nid; | - | ||||||||||||||||||
936 | const EVP_MD *kdf_md; | - | ||||||||||||||||||
937 | pctx = CMS_RecipientInfo_get0_pkey_ctx(ri); | - | ||||||||||||||||||
938 | if (!pctx
| 0-1 | ||||||||||||||||||
939 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||
940 | - | |||||||||||||||||||
941 | pkey = EVP_PKEY_CTX_get0_pkey(pctx); | - | ||||||||||||||||||
942 | if (!CMS_RecipientInfo_kari_get0_orig_id(ri, &talg, &pubkey,
| 0-1 | ||||||||||||||||||
943 |
| 0-1 | ||||||||||||||||||
944 | ((void *)0)
| 0-1 | ||||||||||||||||||
945 | ,
| 0-1 | ||||||||||||||||||
946 | ((void *)0)
| 0-1 | ||||||||||||||||||
947 | ,
| 0-1 | ||||||||||||||||||
948 | ((void *)0)
| 0-1 | ||||||||||||||||||
949 | )
| 0-1 | ||||||||||||||||||
950 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
951 | X509_ALGOR_get0(&aoid, | - | ||||||||||||||||||
952 | ((void *)0) | - | ||||||||||||||||||
953 | , | - | ||||||||||||||||||
954 | ((void *)0) | - | ||||||||||||||||||
955 | , talg); | - | ||||||||||||||||||
956 | - | |||||||||||||||||||
957 | if (aoid == OBJ_nid2obj(0)
| 0-1 | ||||||||||||||||||
958 | ASN1_INTEGER *pubk = BN_to_ASN1_INTEGER(pkey->pkey.dh->pub_key, | - | ||||||||||||||||||
959 | ((void *)0) | - | ||||||||||||||||||
960 | ); | - | ||||||||||||||||||
961 | if (!pubk
| 0-1 | ||||||||||||||||||
962 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
963 | - | |||||||||||||||||||
964 | - | |||||||||||||||||||
965 | penclen = i2d_ASN1_INTEGER(pubk, &penc); | - | ||||||||||||||||||
966 | ASN1_INTEGER_free(pubk); | - | ||||||||||||||||||
967 | if (penclen <= 0
| 0-1 | ||||||||||||||||||
968 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
969 | ASN1_STRING_set0(pubkey, penc, penclen); | - | ||||||||||||||||||
970 | pubkey->flags &= ~(0x08 | 0x07); | - | ||||||||||||||||||
971 | pubkey->flags |= 0x08; | - | ||||||||||||||||||
972 | - | |||||||||||||||||||
973 | penc = | - | ||||||||||||||||||
974 | ((void *)0) | - | ||||||||||||||||||
975 | ; | - | ||||||||||||||||||
976 | X509_ALGOR_set0(talg, OBJ_nid2obj(920), | - | ||||||||||||||||||
977 | -1, | - | ||||||||||||||||||
978 | ((void *)0) | - | ||||||||||||||||||
979 | ); | - | ||||||||||||||||||
980 | } executed 1 time by 1 test: end of block Executed by:
| 1 | ||||||||||||||||||
981 | - | |||||||||||||||||||
982 | - | |||||||||||||||||||
983 | kdf_type = EVP_PKEY_CTX_ctrl(pctx, 920, (1<<10), (0x1000 + 6), -2, | - | ||||||||||||||||||
984 | ((void *)0) | - | ||||||||||||||||||
985 | ); | - | ||||||||||||||||||
986 | if (kdf_type <= 0
| 0-1 | ||||||||||||||||||
987 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
988 | if (!EVP_PKEY_CTX_ctrl(pctx, 920, (1<<10), (0x1000 + 8), 0, (void *)(&kdf_md))
| 0-1 | ||||||||||||||||||
989 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
990 | - | |||||||||||||||||||
991 | if (kdf_type == 1
| 0-1 | ||||||||||||||||||
992 | kdf_type = 2; | - | ||||||||||||||||||
993 | if (EVP_PKEY_CTX_ctrl(pctx, 920, (1<<10), (0x1000 + 6), kdf_type,
| 0-1 | ||||||||||||||||||
994 | ((void *)0)
| 0-1 | ||||||||||||||||||
995 | ) <= 0
| 0-1 | ||||||||||||||||||
996 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
997 | } executed 1 time by 1 test: else if (kdf_type != 2end of block Executed by:
| 0-1 | ||||||||||||||||||
998 | - | |||||||||||||||||||
999 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
1000 | if (kdf_md ==
| 0-1 | ||||||||||||||||||
1001 | ((void *)0)
| 0-1 | ||||||||||||||||||
1002 | ) { | - | ||||||||||||||||||
1003 | - | |||||||||||||||||||
1004 | kdf_md = EVP_sha1(); | - | ||||||||||||||||||
1005 | if (EVP_PKEY_CTX_ctrl(pctx, 920, (1<<10), (0x1000 + 7), 0, (void *)(kdf_md)) <= 0
| 0-1 | ||||||||||||||||||
1006 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
1007 | } executed 1 time by 1 test: else if (EVP_MD_type(kdf_md) != 64end of block Executed by:
| 0-1 | ||||||||||||||||||
1008 | - | |||||||||||||||||||
1009 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
1010 | - | |||||||||||||||||||
1011 | if (!CMS_RecipientInfo_kari_get0_alg(ri, &talg, &ukm)
| 0-1 | ||||||||||||||||||
1012 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
1013 | - | |||||||||||||||||||
1014 | - | |||||||||||||||||||
1015 | ctx = CMS_RecipientInfo_kari_get0_ctx(ri); | - | ||||||||||||||||||
1016 | wrap_nid = EVP_CIPHER_type(EVP_CIPHER_CTX_cipher(ctx)); | - | ||||||||||||||||||
1017 | if (EVP_PKEY_CTX_ctrl(pctx, 920, (1<<10), (0x1000 + 13), 0, (void *)(OBJ_nid2obj(wrap_nid))) <= 0
| 0-1 | ||||||||||||||||||
1018 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
1019 | keylen = EVP_CIPHER_CTX_key_length(ctx); | - | ||||||||||||||||||
1020 | - | |||||||||||||||||||
1021 | - | |||||||||||||||||||
1022 | - | |||||||||||||||||||
1023 | wrap_alg = X509_ALGOR_new(); | - | ||||||||||||||||||
1024 | if (wrap_alg ==
| 0-1 | ||||||||||||||||||
1025 | ((void *)0)
| 0-1 | ||||||||||||||||||
1026 | ) | - | ||||||||||||||||||
1027 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
1028 | wrap_alg->algorithm = OBJ_nid2obj(wrap_nid); | - | ||||||||||||||||||
1029 | wrap_alg->parameter = ASN1_TYPE_new(); | - | ||||||||||||||||||
1030 | if (wrap_alg->parameter ==
| 0-1 | ||||||||||||||||||
1031 | ((void *)0)
| 0-1 | ||||||||||||||||||
1032 | ) | - | ||||||||||||||||||
1033 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
1034 | if (EVP_CIPHER_param_to_asn1(ctx, wrap_alg->parameter) <= 0
| 0-1 | ||||||||||||||||||
1035 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
1036 | if (ASN1_TYPE_get(wrap_alg->parameter) == 0
| 0-1 | ||||||||||||||||||
1037 | ASN1_TYPE_free(wrap_alg->parameter); | - | ||||||||||||||||||
1038 | wrap_alg->parameter = | - | ||||||||||||||||||
1039 | ((void *)0) | - | ||||||||||||||||||
1040 | ; | - | ||||||||||||||||||
1041 | } executed 1 time by 1 test: end of block Executed by:
| 1 | ||||||||||||||||||
1042 | - | |||||||||||||||||||
1043 | if (EVP_PKEY_CTX_ctrl(pctx, 920, (1<<10), (0x1000 + 9), keylen,
| 0-1 | ||||||||||||||||||
1044 | ((void *)0)
| 0-1 | ||||||||||||||||||
1045 | ) <= 0
| 0-1 | ||||||||||||||||||
1046 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
1047 | - | |||||||||||||||||||
1048 | if (ukm
| 0-1 | ||||||||||||||||||
1049 | dukmlen = ASN1_STRING_length(ukm); | - | ||||||||||||||||||
1050 | dukm = CRYPTO_memdup((ASN1_STRING_get0_data(ukm)), dukmlen, __FILE__, 874); | - | ||||||||||||||||||
1051 | if (!dukm
| 0 | ||||||||||||||||||
1052 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
1053 | } never executed: end of block | 0 | ||||||||||||||||||
1054 | - | |||||||||||||||||||
1055 | if (EVP_PKEY_CTX_ctrl(pctx, 920, (1<<10), (0x1000 + 11), dukmlen, (void *)(dukm)) <= 0
| 0-1 | ||||||||||||||||||
1056 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
1057 | dukm = | - | ||||||||||||||||||
1058 | ((void *)0) | - | ||||||||||||||||||
1059 | ; | - | ||||||||||||||||||
1060 | - | |||||||||||||||||||
1061 | - | |||||||||||||||||||
1062 | - | |||||||||||||||||||
1063 | - | |||||||||||||||||||
1064 | - | |||||||||||||||||||
1065 | penc = | - | ||||||||||||||||||
1066 | ((void *)0) | - | ||||||||||||||||||
1067 | ; | - | ||||||||||||||||||
1068 | penclen = i2d_X509_ALGOR(wrap_alg, &penc); | - | ||||||||||||||||||
1069 | if (!penc
| 0-1 | ||||||||||||||||||
1070 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
1071 | wrap_str = ASN1_STRING_new(); | - | ||||||||||||||||||
1072 | if (wrap_str ==
| 0-1 | ||||||||||||||||||
1073 | ((void *)0)
| 0-1 | ||||||||||||||||||
1074 | ) | - | ||||||||||||||||||
1075 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
1076 | ASN1_STRING_set0(wrap_str, penc, penclen); | - | ||||||||||||||||||
1077 | penc = | - | ||||||||||||||||||
1078 | ((void *)0) | - | ||||||||||||||||||
1079 | ; | - | ||||||||||||||||||
1080 | X509_ALGOR_set0(talg, OBJ_nid2obj(245), | - | ||||||||||||||||||
1081 | 16, wrap_str); | - | ||||||||||||||||||
1082 | - | |||||||||||||||||||
1083 | rv = 1; | - | ||||||||||||||||||
1084 | - | |||||||||||||||||||
1085 | err: code before this statement executed 1 time by 1 test: err: Executed by:
| 1 | ||||||||||||||||||
1086 | CRYPTO_free(penc, __FILE__, 902); | - | ||||||||||||||||||
1087 | X509_ALGOR_free(wrap_alg); | - | ||||||||||||||||||
1088 | return executed 1 time by 1 test: rv;return rv; Executed by:
executed 1 time by 1 test: return rv; Executed by:
| 1 | ||||||||||||||||||
1089 | } | - | ||||||||||||||||||
Switch to Source code | Preprocessed file |