Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/openssl/src/crypto/rsa/rsa_ameth.c |
Switch to Source code | Preprocessed file |
Line | Source | Count | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | - | |||||||||||||||||||
2 | - | |||||||||||||||||||
3 | - | |||||||||||||||||||
4 | static int rsa_cms_sign(CMS_SignerInfo *si); | - | ||||||||||||||||||
5 | static int rsa_cms_verify(CMS_SignerInfo *si); | - | ||||||||||||||||||
6 | static int rsa_cms_decrypt(CMS_RecipientInfo *ri); | - | ||||||||||||||||||
7 | static int rsa_cms_encrypt(CMS_RecipientInfo *ri); | - | ||||||||||||||||||
8 | - | |||||||||||||||||||
9 | - | |||||||||||||||||||
10 | static RSA_PSS_PARAMS *rsa_pss_decode(const X509_ALGOR *alg); | - | ||||||||||||||||||
11 | - | |||||||||||||||||||
12 | - | |||||||||||||||||||
13 | static int rsa_param_encode(const EVP_PKEY *pkey, | - | ||||||||||||||||||
14 | ASN1_STRING **pstr, int *pstrtype) | - | ||||||||||||||||||
15 | { | - | ||||||||||||||||||
16 | const RSA *rsa = pkey->pkey.rsa; | - | ||||||||||||||||||
17 | - | |||||||||||||||||||
18 | *pstr = | - | ||||||||||||||||||
19 | ((void *)0) | - | ||||||||||||||||||
20 | ; | - | ||||||||||||||||||
21 | - | |||||||||||||||||||
22 | if (pkey->ameth->pkey_id == 6
| 0-1692 | ||||||||||||||||||
23 | *pstrtype = 5; | - | ||||||||||||||||||
24 | return executed 1692 times by 1 test: 1;return 1; Executed by:
executed 1692 times by 1 test: return 1; Executed by:
| 1692 | ||||||||||||||||||
25 | } | - | ||||||||||||||||||
26 | - | |||||||||||||||||||
27 | if (rsa->pss ==
| 0 | ||||||||||||||||||
28 | ((void *)0)
| 0 | ||||||||||||||||||
29 | ) { | - | ||||||||||||||||||
30 | *pstrtype = -1; | - | ||||||||||||||||||
31 | return never executed: 1;return 1; never executed: return 1; | 0 | ||||||||||||||||||
32 | } | - | ||||||||||||||||||
33 | - | |||||||||||||||||||
34 | if (ASN1_item_pack(rsa->pss, (&(RSA_PSS_PARAMS_it)), pstr) ==
| 0 | ||||||||||||||||||
35 | ((void *)0)
| 0 | ||||||||||||||||||
36 | ) | - | ||||||||||||||||||
37 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||
38 | - | |||||||||||||||||||
39 | *pstrtype = 16; | - | ||||||||||||||||||
40 | return never executed: 1;return 1; never executed: return 1; | 0 | ||||||||||||||||||
41 | } | - | ||||||||||||||||||
42 | - | |||||||||||||||||||
43 | static int rsa_param_decode(RSA *rsa, const X509_ALGOR *alg) | - | ||||||||||||||||||
44 | { | - | ||||||||||||||||||
45 | const ASN1_OBJECT *algoid; | - | ||||||||||||||||||
46 | const void *algp; | - | ||||||||||||||||||
47 | int algptype; | - | ||||||||||||||||||
48 | - | |||||||||||||||||||
49 | X509_ALGOR_get0(&algoid, &algptype, &algp, alg); | - | ||||||||||||||||||
50 | if (OBJ_obj2nid(algoid) == 6
| 58-12305 | ||||||||||||||||||
51 | return executed 12305 times by 1 test: 1;return 1; Executed by:
executed 12305 times by 1 test: return 1; Executed by:
| 12305 | ||||||||||||||||||
52 | if (algptype == -1
| 22-36 | ||||||||||||||||||
53 | return executed 22 times by 1 test: 1;return 1; Executed by:
executed 22 times by 1 test: return 1; Executed by:
| 22 | ||||||||||||||||||
54 | if (algptype != 16
| 8-28 | ||||||||||||||||||
55 | ERR_put_error(4,(164),(149),__FILE__,66); | - | ||||||||||||||||||
56 | return executed 28 times by 1 test: 0;return 0; Executed by:
executed 28 times by 1 test: return 0; Executed by:
| 28 | ||||||||||||||||||
57 | } | - | ||||||||||||||||||
58 | rsa->pss = rsa_pss_decode(alg); | - | ||||||||||||||||||
59 | if (rsa->pss ==
| 1-7 | ||||||||||||||||||
60 | ((void *)0)
| 1-7 | ||||||||||||||||||
61 | ) | - | ||||||||||||||||||
62 | return executed 1 time by 1 test: 0;return 0; Executed by:
executed 1 time by 1 test: return 0; Executed by:
| 1 | ||||||||||||||||||
63 | return executed 7 times by 1 test: 1;return 1; Executed by:
executed 7 times by 1 test: return 1; Executed by:
| 7 | ||||||||||||||||||
64 | } | - | ||||||||||||||||||
65 | - | |||||||||||||||||||
66 | static int rsa_pub_encode(X509_PUBKEY *pk, const EVP_PKEY *pkey) | - | ||||||||||||||||||
67 | { | - | ||||||||||||||||||
68 | unsigned char *penc = | - | ||||||||||||||||||
69 | ((void *)0) | - | ||||||||||||||||||
70 | ; | - | ||||||||||||||||||
71 | int penclen; | - | ||||||||||||||||||
72 | ASN1_STRING *str; | - | ||||||||||||||||||
73 | int strtype; | - | ||||||||||||||||||
74 | - | |||||||||||||||||||
75 | if (!rsa_param_encode(pkey, &str, &strtype)
| 0-1676 | ||||||||||||||||||
76 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||
77 | penclen = i2d_RSAPublicKey(pkey->pkey.rsa, &penc); | - | ||||||||||||||||||
78 | if (penclen <= 0
| 0-1676 | ||||||||||||||||||
79 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||
80 | if (X509_PUBKEY_set0_param(pk, OBJ_nid2obj(pkey->ameth->pkey_id),
| 0-1676 | ||||||||||||||||||
81 | strtype, str, penc, penclen)
| 0-1676 | ||||||||||||||||||
82 | return executed 1676 times by 1 test: 1;return 1; Executed by:
executed 1676 times by 1 test: return 1; Executed by:
| 1676 | ||||||||||||||||||
83 | - | |||||||||||||||||||
84 | CRYPTO_free(penc, __FILE__, 91); | - | ||||||||||||||||||
85 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||
86 | } | - | ||||||||||||||||||
87 | - | |||||||||||||||||||
88 | static int rsa_pub_decode(EVP_PKEY *pkey, X509_PUBKEY *pubkey) | - | ||||||||||||||||||
89 | { | - | ||||||||||||||||||
90 | const unsigned char *p; | - | ||||||||||||||||||
91 | int pklen; | - | ||||||||||||||||||
92 | X509_ALGOR *alg; | - | ||||||||||||||||||
93 | RSA *rsa = | - | ||||||||||||||||||
94 | ((void *)0) | - | ||||||||||||||||||
95 | ; | - | ||||||||||||||||||
96 | - | |||||||||||||||||||
97 | if (!X509_PUBKEY_get0_param(
| 0-11012 | ||||||||||||||||||
98 | ((void *)0)
| 0-11012 | ||||||||||||||||||
99 | , &p, &pklen, &alg, pubkey)
| 0-11012 | ||||||||||||||||||
100 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||
101 | if ((
| 377-10635 | ||||||||||||||||||
102 | ((void *)0)
| 377-10635 | ||||||||||||||||||
103 | , &p, pklen)) ==
| 377-10635 | ||||||||||||||||||
104 | ((void *)0)
| 377-10635 | ||||||||||||||||||
105 | ) { | - | ||||||||||||||||||
106 | ERR_put_error(4,(139),(4),__FILE__,105); | - | ||||||||||||||||||
107 | return executed 377 times by 1 test: 0;return 0; Executed by:
executed 377 times by 1 test: return 0; Executed by:
| 377 | ||||||||||||||||||
108 | } | - | ||||||||||||||||||
109 | if (!rsa_param_decode(rsa, alg)
| 29-10606 | ||||||||||||||||||
110 | RSA_free(rsa); | - | ||||||||||||||||||
111 | return executed 29 times by 1 test: 0;return 0; Executed by:
executed 29 times by 1 test: return 0; Executed by:
| 29 | ||||||||||||||||||
112 | } | - | ||||||||||||||||||
113 | EVP_PKEY_assign(pkey, pkey->ameth->pkey_id, rsa); | - | ||||||||||||||||||
114 | return executed 10606 times by 1 test: 1;return 1; Executed by:
executed 10606 times by 1 test: return 1; Executed by:
| 10606 | ||||||||||||||||||
115 | } | - | ||||||||||||||||||
116 | - | |||||||||||||||||||
117 | static int rsa_pub_cmp(const EVP_PKEY *a, const EVP_PKEY *b) | - | ||||||||||||||||||
118 | { | - | ||||||||||||||||||
119 | if (BN_cmp(b->pkey.rsa->n, a->pkey.rsa->n) != 0
| 3-4533 | ||||||||||||||||||
120 | || BN_cmp(b->pkey.rsa->e, a->pkey.rsa->e) != 0
| 0-4533 | ||||||||||||||||||
121 | return executed 3 times by 1 test: 0;return 0; Executed by:
executed 3 times by 1 test: return 0; Executed by:
| 3 | ||||||||||||||||||
122 | return executed 4533 times by 1 test: 1;return 1; Executed by:
executed 4533 times by 1 test: return 1; Executed by:
| 4533 | ||||||||||||||||||
123 | } | - | ||||||||||||||||||
124 | - | |||||||||||||||||||
125 | static int old_rsa_priv_decode(EVP_PKEY *pkey, | - | ||||||||||||||||||
126 | const unsigned char **pder, int derlen) | - | ||||||||||||||||||
127 | { | - | ||||||||||||||||||
128 | RSA *rsa; | - | ||||||||||||||||||
129 | - | |||||||||||||||||||
130 | if ((
| 645-2334 | ||||||||||||||||||
131 | ((void *)0)
| 645-2334 | ||||||||||||||||||
132 | , pder, derlen)) ==
| 645-2334 | ||||||||||||||||||
133 | ((void *)0)
| 645-2334 | ||||||||||||||||||
134 | ) { | - | ||||||||||||||||||
135 | ERR_put_error(4,(147),(4),__FILE__,130); | - | ||||||||||||||||||
136 | return executed 2334 times by 1 test: 0;return 0; Executed by:
executed 2334 times by 1 test: return 0; Executed by:
| 2334 | ||||||||||||||||||
137 | } | - | ||||||||||||||||||
138 | EVP_PKEY_assign(pkey, pkey->ameth->pkey_id, rsa); | - | ||||||||||||||||||
139 | return executed 645 times by 1 test: 1;return 1; Executed by:
executed 645 times by 1 test: return 1; Executed by:
| 645 | ||||||||||||||||||
140 | } | - | ||||||||||||||||||
141 | - | |||||||||||||||||||
142 | static int old_rsa_priv_encode(const EVP_PKEY *pkey, unsigned char **pder) | - | ||||||||||||||||||
143 | { | - | ||||||||||||||||||
144 | return executed 95 times by 1 test: i2d_RSAPrivateKey(pkey->pkey.rsa, pder);return i2d_RSAPrivateKey(pkey->pkey.rsa, pder); Executed by:
executed 95 times by 1 test: return i2d_RSAPrivateKey(pkey->pkey.rsa, pder); Executed by:
| 95 | ||||||||||||||||||
145 | } | - | ||||||||||||||||||
146 | - | |||||||||||||||||||
147 | static int rsa_priv_encode(PKCS8_PRIV_KEY_INFO *p8, const EVP_PKEY *pkey) | - | ||||||||||||||||||
148 | { | - | ||||||||||||||||||
149 | unsigned char *rk = | - | ||||||||||||||||||
150 | ((void *)0) | - | ||||||||||||||||||
151 | ; | - | ||||||||||||||||||
152 | int rklen; | - | ||||||||||||||||||
153 | ASN1_STRING *str; | - | ||||||||||||||||||
154 | int strtype; | - | ||||||||||||||||||
155 | - | |||||||||||||||||||
156 | if (!rsa_param_encode(pkey, &str, &strtype)
| 0-16 | ||||||||||||||||||
157 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||
158 | rklen = i2d_RSAPrivateKey(pkey->pkey.rsa, &rk); | - | ||||||||||||||||||
159 | - | |||||||||||||||||||
160 | if (rklen <= 0
| 0-16 | ||||||||||||||||||
161 | ERR_put_error(4,(138),((1|64)),__FILE__,154); | - | ||||||||||||||||||
162 | ASN1_STRING_free(str); | - | ||||||||||||||||||
163 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||
164 | } | - | ||||||||||||||||||
165 | - | |||||||||||||||||||
166 | if (!PKCS8_pkey_set0(p8, OBJ_nid2obj(pkey->ameth->pkey_id), 0,
| 0-16 | ||||||||||||||||||
167 | strtype, str, rk, rklen)
| 0-16 | ||||||||||||||||||
168 | ERR_put_error(4,(138),((1|64)),__FILE__,161); | - | ||||||||||||||||||
169 | ASN1_STRING_free(str); | - | ||||||||||||||||||
170 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||
171 | } | - | ||||||||||||||||||
172 | - | |||||||||||||||||||
173 | return executed 16 times by 1 test: 1;return 1; Executed by:
executed 16 times by 1 test: return 1; Executed by:
| 16 | ||||||||||||||||||
174 | } | - | ||||||||||||||||||
175 | - | |||||||||||||||||||
176 | static int rsa_priv_decode(EVP_PKEY *pkey, const PKCS8_PRIV_KEY_INFO *p8) | - | ||||||||||||||||||
177 | { | - | ||||||||||||||||||
178 | const unsigned char *p; | - | ||||||||||||||||||
179 | RSA *rsa; | - | ||||||||||||||||||
180 | int pklen; | - | ||||||||||||||||||
181 | const X509_ALGOR *alg; | - | ||||||||||||||||||
182 | - | |||||||||||||||||||
183 | if (!PKCS8_pkey_get0(
| 0-1729 | ||||||||||||||||||
184 | ((void *)0)
| 0-1729 | ||||||||||||||||||
185 | , &p, &pklen, &alg, p8)
| 0-1729 | ||||||||||||||||||
186 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||
187 | rsa = d2i_RSAPrivateKey( | - | ||||||||||||||||||
188 | ((void *)0) | - | ||||||||||||||||||
189 | , &p, pklen); | - | ||||||||||||||||||
190 | if (rsa ==
| 1-1728 | ||||||||||||||||||
191 | ((void *)0)
| 1-1728 | ||||||||||||||||||
192 | ) { | - | ||||||||||||||||||
193 | ERR_put_error(4,(150),(4),__FILE__,180); | - | ||||||||||||||||||
194 | return executed 1 time by 1 test: 0;return 0; Executed by:
executed 1 time by 1 test: return 0; Executed by:
| 1 | ||||||||||||||||||
195 | } | - | ||||||||||||||||||
196 | if (!rsa_param_decode(rsa, alg)
| 0-1728 | ||||||||||||||||||
197 | RSA_free(rsa); | - | ||||||||||||||||||
198 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||
199 | } | - | ||||||||||||||||||
200 | EVP_PKEY_assign(pkey, pkey->ameth->pkey_id, rsa); | - | ||||||||||||||||||
201 | return executed 1728 times by 1 test: 1;return 1; Executed by:
executed 1728 times by 1 test: return 1; Executed by:
| 1728 | ||||||||||||||||||
202 | } | - | ||||||||||||||||||
203 | - | |||||||||||||||||||
204 | static int int_rsa_size(const EVP_PKEY *pkey) | - | ||||||||||||||||||
205 | { | - | ||||||||||||||||||
206 | return executed 7980 times by 1 test: RSA_size(pkey->pkey.rsa);return RSA_size(pkey->pkey.rsa); Executed by:
executed 7980 times by 1 test: return RSA_size(pkey->pkey.rsa); Executed by:
| 7980 | ||||||||||||||||||
207 | } | - | ||||||||||||||||||
208 | - | |||||||||||||||||||
209 | static int rsa_bits(const EVP_PKEY *pkey) | - | ||||||||||||||||||
210 | { | - | ||||||||||||||||||
211 | return executed 234 times by 1 test: BN_num_bits(pkey->pkey.rsa->n);return BN_num_bits(pkey->pkey.rsa->n); Executed by:
executed 234 times by 1 test: return BN_num_bits(pkey->pkey.rsa->n); Executed by:
| 234 | ||||||||||||||||||
212 | } | - | ||||||||||||||||||
213 | - | |||||||||||||||||||
214 | static int rsa_security_bits(const EVP_PKEY *pkey) | - | ||||||||||||||||||
215 | { | - | ||||||||||||||||||
216 | return executed 8547 times by 1 test: RSA_security_bits(pkey->pkey.rsa);return RSA_security_bits(pkey->pkey.rsa); Executed by:
executed 8547 times by 1 test: return RSA_security_bits(pkey->pkey.rsa); Executed by:
| 8547 | ||||||||||||||||||
217 | } | - | ||||||||||||||||||
218 | - | |||||||||||||||||||
219 | static void int_rsa_free(EVP_PKEY *pkey) | - | ||||||||||||||||||
220 | { | - | ||||||||||||||||||
221 | RSA_free(pkey->pkey.rsa); | - | ||||||||||||||||||
222 | } executed 17571 times by 1 test: end of block Executed by:
| 17571 | ||||||||||||||||||
223 | - | |||||||||||||||||||
224 | static X509_ALGOR *rsa_mgf1_decode(X509_ALGOR *alg) | - | ||||||||||||||||||
225 | { | - | ||||||||||||||||||
226 | if (OBJ_obj2nid(alg->algorithm) != 911
| 7-56 | ||||||||||||||||||
227 | return executed 7 times by 1 test: return ((void *)0) ; Executed by:
executed 7 times by 1 test: return ((void *)0) ; Executed by:
| 7 | ||||||||||||||||||
228 | ((void *)0) executed 7 times by 1 test: return ((void *)0) ; Executed by:
| 7 | ||||||||||||||||||
229 | ; executed 7 times by 1 test: return ((void *)0) ; Executed by:
| 7 | ||||||||||||||||||
230 | return executed 56 times by 1 test: ASN1_TYPE_unpack_sequence((&(X509_ALGOR_it)),return ASN1_TYPE_unpack_sequence((&(X509_ALGOR_it)), alg->parameter); Executed by:
executed 56 times by 1 test: return ASN1_TYPE_unpack_sequence((&(X509_ALGOR_it)), alg->parameter); Executed by:
| 56 | ||||||||||||||||||
231 | alg->parameter); executed 56 times by 1 test: return ASN1_TYPE_unpack_sequence((&(X509_ALGOR_it)), alg->parameter); Executed by:
| 56 | ||||||||||||||||||
232 | } | - | ||||||||||||||||||
233 | - | |||||||||||||||||||
234 | static int rsa_pss_param_print(BIO *bp, int pss_key, RSA_PSS_PARAMS *pss, | - | ||||||||||||||||||
235 | int indent) | - | ||||||||||||||||||
236 | { | - | ||||||||||||||||||
237 | int rv = 0; | - | ||||||||||||||||||
238 | X509_ALGOR *maskHash = | - | ||||||||||||||||||
239 | ((void *)0) | - | ||||||||||||||||||
240 | ; | - | ||||||||||||||||||
241 | - | |||||||||||||||||||
242 | if (!BIO_indent(bp, indent, 128)
| 0-195 | ||||||||||||||||||
243 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
244 | if (pss_key
| 2-193 | ||||||||||||||||||
245 | if (pss ==
| 1 | ||||||||||||||||||
246 | ((void *)0)
| 1 | ||||||||||||||||||
247 | ) { | - | ||||||||||||||||||
248 | if (BIO_puts(bp, "No PSS parameter restrictions\n") <= 0
| 0-1 | ||||||||||||||||||
249 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||
250 | return executed 1 time by 1 test: 1;return 1; Executed by:
executed 1 time by 1 test: return 1; Executed by:
| 1 | ||||||||||||||||||
251 | } else { | - | ||||||||||||||||||
252 | if (BIO_puts(bp, "PSS parameter restrictions:") <= 0
| 0-1 | ||||||||||||||||||
253 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||
254 | } executed 1 time by 1 test: end of block Executed by:
| 1 | ||||||||||||||||||
255 | } else if (pss ==
| 39-154 | ||||||||||||||||||
256 | ((void *)0)
| 39-154 | ||||||||||||||||||
257 | ) { | - | ||||||||||||||||||
258 | if (BIO_puts(bp,"(INVALID PSS PARAMETERS)\n") <= 0
| 0-154 | ||||||||||||||||||
259 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||
260 | return executed 154 times by 1 test: 1;return 1; Executed by:
executed 154 times by 1 test: return 1; Executed by:
| 154 | ||||||||||||||||||
261 | } | - | ||||||||||||||||||
262 | if (BIO_puts(bp, "\n") <= 0
| 0-40 | ||||||||||||||||||
263 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
264 | if (pss_key
| 1-39 | ||||||||||||||||||
265 | indent += 2; executed 1 time by 1 test: indent += 2; Executed by:
| 1 | ||||||||||||||||||
266 | if (!BIO_indent(bp, indent, 128)
| 0-40 | ||||||||||||||||||
267 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
268 | if (BIO_puts(bp, "Hash Algorithm: ") <= 0
| 0-40 | ||||||||||||||||||
269 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
270 | - | |||||||||||||||||||
271 | if (pss->hashAlgorithm
| 10-30 | ||||||||||||||||||
272 | if (i2a_ASN1_OBJECT(bp, pss->hashAlgorithm->algorithm) <= 0
| 0-10 | ||||||||||||||||||
273 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
274 | } executed 10 times by 1 test: else if (BIO_puts(bp, "sha1 (default)") <= 0end of block Executed by:
| 0-30 | ||||||||||||||||||
275 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
276 | } | - | ||||||||||||||||||
277 | - | |||||||||||||||||||
278 | if (BIO_puts(bp, "\n") <= 0
| 0-40 | ||||||||||||||||||
279 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
280 | - | |||||||||||||||||||
281 | if (!BIO_indent(bp, indent, 128)
| 0-40 | ||||||||||||||||||
282 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
283 | - | |||||||||||||||||||
284 | if (BIO_puts(bp, "Mask Algorithm: ") <= 0
| 0-40 | ||||||||||||||||||
285 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
286 | if (pss->maskGenAlgorithm
| 20 | ||||||||||||||||||
287 | if (i2a_ASN1_OBJECT(bp, pss->maskGenAlgorithm->algorithm) <= 0
| 0-20 | ||||||||||||||||||
288 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
289 | if (BIO_puts(bp, " with ") <= 0
| 0-20 | ||||||||||||||||||
290 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
291 | maskHash = rsa_mgf1_decode(pss->maskGenAlgorithm); | - | ||||||||||||||||||
292 | if (maskHash !=
| 0-20 | ||||||||||||||||||
293 | ((void *)0)
| 0-20 | ||||||||||||||||||
294 | ) { | - | ||||||||||||||||||
295 | if (i2a_ASN1_OBJECT(bp, maskHash->algorithm) <= 0
| 0-20 | ||||||||||||||||||
296 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
297 | } executed 20 times by 1 test: else if (BIO_puts(bp, "INVALID") <= 0end of block Executed by:
| 0-20 | ||||||||||||||||||
298 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
299 | } | - | ||||||||||||||||||
300 | } executed 20 times by 1 test: else if (BIO_puts(bp, "mgf1 with sha1 (default)") <= 0end of block Executed by:
| 0-20 | ||||||||||||||||||
301 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
302 | } | - | ||||||||||||||||||
303 | BIO_puts(bp, "\n"); | - | ||||||||||||||||||
304 | - | |||||||||||||||||||
305 | if (!BIO_indent(bp, indent, 128)
| 0-40 | ||||||||||||||||||
306 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
307 | if (BIO_printf(bp, "%s Salt Length: 0x", pss_key ? "Minimum" : "") <= 0
| 0-40 | ||||||||||||||||||
308 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
309 | if (pss->saltLength
| 6-34 | ||||||||||||||||||
310 | if (i2a_ASN1_INTEGER(bp, pss->saltLength) <= 0
| 0-6 | ||||||||||||||||||
311 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
312 | } executed 6 times by 1 test: else if (BIO_puts(bp, "14 (default)") <= 0end of block Executed by:
| 0-34 | ||||||||||||||||||
313 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
314 | } | - | ||||||||||||||||||
315 | BIO_puts(bp, "\n"); | - | ||||||||||||||||||
316 | - | |||||||||||||||||||
317 | if (!BIO_indent(bp, indent, 128)
| 0-40 | ||||||||||||||||||
318 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
319 | if (BIO_puts(bp, "Trailer Field: 0x") <= 0
| 0-40 | ||||||||||||||||||
320 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
321 | if (pss->trailerField
| 6-34 | ||||||||||||||||||
322 | if (i2a_ASN1_INTEGER(bp, pss->trailerField) <= 0
| 0-6 | ||||||||||||||||||
323 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
324 | } executed 6 times by 1 test: else if (BIO_puts(bp, "BC (default)") <= 0end of block Executed by:
| 0-34 | ||||||||||||||||||
325 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
326 | } | - | ||||||||||||||||||
327 | BIO_puts(bp, "\n"); | - | ||||||||||||||||||
328 | - | |||||||||||||||||||
329 | rv = 1; | - | ||||||||||||||||||
330 | - | |||||||||||||||||||
331 | err: code before this statement executed 40 times by 1 test: err: Executed by:
| 40 | ||||||||||||||||||
332 | X509_ALGOR_free(maskHash); | - | ||||||||||||||||||
333 | return executed 40 times by 1 test: rv;return rv; Executed by:
executed 40 times by 1 test: return rv; Executed by:
| 40 | ||||||||||||||||||
334 | - | |||||||||||||||||||
335 | } | - | ||||||||||||||||||
336 | - | |||||||||||||||||||
337 | static int pkey_rsa_print(BIO *bp, const EVP_PKEY *pkey, int off, int priv) | - | ||||||||||||||||||
338 | { | - | ||||||||||||||||||
339 | const RSA *x = pkey->pkey.rsa; | - | ||||||||||||||||||
340 | char *str; | - | ||||||||||||||||||
341 | const char *s; | - | ||||||||||||||||||
342 | int ret = 0, mod_len = 0, ex_primes; | - | ||||||||||||||||||
343 | - | |||||||||||||||||||
344 | if (x->n !=
| 0-274 | ||||||||||||||||||
345 | ((void *)0)
| 0-274 | ||||||||||||||||||
346 | ) | - | ||||||||||||||||||
347 | mod_len = BN_num_bits(x->n); executed 274 times by 1 test: mod_len = BN_num_bits(x->n); Executed by:
| 274 | ||||||||||||||||||
348 | ex_primes = sk_RSA_PRIME_INFO_num(x->prime_infos); | - | ||||||||||||||||||
349 | - | |||||||||||||||||||
350 | if (!BIO_indent(bp, off, 128)
| 0-274 | ||||||||||||||||||
351 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
352 | - | |||||||||||||||||||
353 | if (BIO_printf(bp, "%s ", (pkey->ameth->pkey_id == 912) ? "RSA-PSS" : "RSA") <= 0
| 0-274 | ||||||||||||||||||
354 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
355 | - | |||||||||||||||||||
356 | if (priv
| 10-174 | ||||||||||||||||||
357 | if (BIO_printf(bp, "Private-Key: (%d bit, %d primes)\n",
| 0-90 | ||||||||||||||||||
358 | mod_len, ex_primes <= 0 ? 2 : ex_primes + 2) <= 0
| 0-90 | ||||||||||||||||||
359 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
360 | str = "modulus:"; | - | ||||||||||||||||||
361 | s = "publicExponent:"; | - | ||||||||||||||||||
362 | } executed 90 times by 1 test: else {end of block Executed by:
| 90 | ||||||||||||||||||
363 | if (BIO_printf(bp, "Public-Key: (%d bit)\n", mod_len) <= 0
| 0-184 | ||||||||||||||||||
364 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
365 | str = "Modulus:"; | - | ||||||||||||||||||
366 | s = "Exponent:"; | - | ||||||||||||||||||
367 | } executed 184 times by 1 test: end of block Executed by:
| 184 | ||||||||||||||||||
368 | if (!ASN1_bn_print(bp, str, x->n,
| 0-274 | ||||||||||||||||||
369 | ((void *)0)
| 0-274 | ||||||||||||||||||
370 | , off)
| 0-274 | ||||||||||||||||||
371 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
372 | if (!ASN1_bn_print(bp, s, x->e,
| 0-274 | ||||||||||||||||||
373 | ((void *)0)
| 0-274 | ||||||||||||||||||
374 | , off)
| 0-274 | ||||||||||||||||||
375 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
376 | if (priv
| 100-174 | ||||||||||||||||||
377 | int i; | - | ||||||||||||||||||
378 | - | |||||||||||||||||||
379 | if (!ASN1_bn_print(bp, "privateExponent:", x->d,
| 0-100 | ||||||||||||||||||
380 | ((void *)0)
| 0-100 | ||||||||||||||||||
381 | , off)
| 0-100 | ||||||||||||||||||
382 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
383 | if (!ASN1_bn_print(bp, "prime1:", x->p,
| 0-100 | ||||||||||||||||||
384 | ((void *)0)
| 0-100 | ||||||||||||||||||
385 | , off)
| 0-100 | ||||||||||||||||||
386 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
387 | if (!ASN1_bn_print(bp, "prime2:", x->q,
| 0-100 | ||||||||||||||||||
388 | ((void *)0)
| 0-100 | ||||||||||||||||||
389 | , off)
| 0-100 | ||||||||||||||||||
390 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
391 | if (!ASN1_bn_print(bp, "exponent1:", x->dmp1,
| 0-100 | ||||||||||||||||||
392 | ((void *)0)
| 0-100 | ||||||||||||||||||
393 | , off)
| 0-100 | ||||||||||||||||||
394 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
395 | if (!ASN1_bn_print(bp, "exponent2:", x->dmq1,
| 0-100 | ||||||||||||||||||
396 | ((void *)0)
| 0-100 | ||||||||||||||||||
397 | , off)
| 0-100 | ||||||||||||||||||
398 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
399 | if (!ASN1_bn_print(bp, "coefficient:", x->iqmp,
| 0-100 | ||||||||||||||||||
400 | ((void *)0)
| 0-100 | ||||||||||||||||||
401 | , off)
| 0-100 | ||||||||||||||||||
402 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
403 | for (i = 0; i < sk_RSA_PRIME_INFO_num(x->prime_infos)
| 100-3459 | ||||||||||||||||||
404 | - | |||||||||||||||||||
405 | BIGNUM *bn = | - | ||||||||||||||||||
406 | ((void *)0) | - | ||||||||||||||||||
407 | ; | - | ||||||||||||||||||
408 | RSA_PRIME_INFO *pinfo; | - | ||||||||||||||||||
409 | int j; | - | ||||||||||||||||||
410 | - | |||||||||||||||||||
411 | pinfo = sk_RSA_PRIME_INFO_value(x->prime_infos, i); | - | ||||||||||||||||||
412 | for (j = 0; j < 3
| 3459-10377 | ||||||||||||||||||
413 | if (!BIO_indent(bp, off, 128)
| 0-10377 | ||||||||||||||||||
414 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
415 | switch (j) { | - | ||||||||||||||||||
416 | case executed 3459 times by 1 test: 0:case 0: Executed by:
executed 3459 times by 1 test: case 0: Executed by:
| 3459 | ||||||||||||||||||
417 | if (BIO_printf(bp, "prime%d:", i + 3) <= 0
| 0-3459 | ||||||||||||||||||
418 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
419 | bn = pinfo->r; | - | ||||||||||||||||||
420 | break; executed 3459 times by 1 test: break; Executed by:
| 3459 | ||||||||||||||||||
421 | case executed 3459 times by 1 test: 1:case 1: Executed by:
executed 3459 times by 1 test: case 1: Executed by:
| 3459 | ||||||||||||||||||
422 | if (BIO_printf(bp, "exponent%d:", i + 3) <= 0
| 0-3459 | ||||||||||||||||||
423 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
424 | bn = pinfo->d; | - | ||||||||||||||||||
425 | break; executed 3459 times by 1 test: break; Executed by:
| 3459 | ||||||||||||||||||
426 | case executed 3459 times by 1 test: 2:case 2: Executed by:
executed 3459 times by 1 test: case 2: Executed by:
| 3459 | ||||||||||||||||||
427 | if (BIO_printf(bp, "coefficient%d:", i + 3) <= 0
| 0-3459 | ||||||||||||||||||
428 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
429 | bn = pinfo->t; | - | ||||||||||||||||||
430 | break; executed 3459 times by 1 test: break; Executed by:
| 3459 | ||||||||||||||||||
431 | default never executed: :default: never executed: default: | 0 | ||||||||||||||||||
432 | break; never executed: break; | 0 | ||||||||||||||||||
433 | } | - | ||||||||||||||||||
434 | if (!ASN1_bn_print(bp, "", bn,
| 0-10377 | ||||||||||||||||||
435 | ((void *)0)
| 0-10377 | ||||||||||||||||||
436 | , off)
| 0-10377 | ||||||||||||||||||
437 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
438 | } executed 10377 times by 1 test: end of block Executed by:
| 10377 | ||||||||||||||||||
439 | } executed 3459 times by 1 test: end of block Executed by:
| 3459 | ||||||||||||||||||
440 | } executed 100 times by 1 test: end of block Executed by:
| 100 | ||||||||||||||||||
441 | if ((
| 0-272 | ||||||||||||||||||
442 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
443 | ret = 1; | - | ||||||||||||||||||
444 | err: code before this statement executed 274 times by 1 test: err: Executed by:
| 274 | ||||||||||||||||||
445 | return executed 274 times by 1 test: ret;return ret; Executed by:
executed 274 times by 1 test: return ret; Executed by:
| 274 | ||||||||||||||||||
446 | } | - | ||||||||||||||||||
447 | - | |||||||||||||||||||
448 | static int rsa_pub_print(BIO *bp, const EVP_PKEY *pkey, int indent, | - | ||||||||||||||||||
449 | ASN1_PCTX *ctx) | - | ||||||||||||||||||
450 | { | - | ||||||||||||||||||
451 | return executed 174 times by 1 test: pkey_rsa_print(bp, pkey, indent, 0);return pkey_rsa_print(bp, pkey, indent, 0); Executed by:
executed 174 times by 1 test: return pkey_rsa_print(bp, pkey, indent, 0); Executed by:
| 174 | ||||||||||||||||||
452 | } | - | ||||||||||||||||||
453 | - | |||||||||||||||||||
454 | static int rsa_priv_print(BIO *bp, const EVP_PKEY *pkey, int indent, | - | ||||||||||||||||||
455 | ASN1_PCTX *ctx) | - | ||||||||||||||||||
456 | { | - | ||||||||||||||||||
457 | return executed 100 times by 1 test: pkey_rsa_print(bp, pkey, indent, 1);return pkey_rsa_print(bp, pkey, indent, 1); Executed by:
executed 100 times by 1 test: return pkey_rsa_print(bp, pkey, indent, 1); Executed by:
| 100 | ||||||||||||||||||
458 | } | - | ||||||||||||||||||
459 | - | |||||||||||||||||||
460 | static RSA_PSS_PARAMS *rsa_pss_decode(const X509_ALGOR *alg) | - | ||||||||||||||||||
461 | { | - | ||||||||||||||||||
462 | RSA_PSS_PARAMS *pss; | - | ||||||||||||||||||
463 | - | |||||||||||||||||||
464 | pss = ASN1_TYPE_unpack_sequence((&(RSA_PSS_PARAMS_it)), | - | ||||||||||||||||||
465 | alg->parameter); | - | ||||||||||||||||||
466 | - | |||||||||||||||||||
467 | if (pss ==
| 74-179 | ||||||||||||||||||
468 | ((void *)0)
| 74-179 | ||||||||||||||||||
469 | ) | - | ||||||||||||||||||
470 | return executed 179 times by 1 test: return ((void *)0) ; Executed by:
executed 179 times by 1 test: return ((void *)0) ; Executed by:
| 179 | ||||||||||||||||||
471 | ((void *)0) executed 179 times by 1 test: return ((void *)0) ; Executed by:
| 179 | ||||||||||||||||||
472 | ; executed 179 times by 1 test: return ((void *)0) ; Executed by:
| 179 | ||||||||||||||||||
473 | - | |||||||||||||||||||
474 | if (pss->maskGenAlgorithm !=
| 32-42 | ||||||||||||||||||
475 | ((void *)0)
| 32-42 | ||||||||||||||||||
476 | ) { | - | ||||||||||||||||||
477 | pss->maskHash = rsa_mgf1_decode(pss->maskGenAlgorithm); | - | ||||||||||||||||||
478 | if (pss->maskHash ==
| 15-27 | ||||||||||||||||||
479 | ((void *)0)
| 15-27 | ||||||||||||||||||
480 | ) { | - | ||||||||||||||||||
481 | RSA_PSS_PARAMS_free(pss); | - | ||||||||||||||||||
482 | return executed 15 times by 1 test: return ((void *)0) ; Executed by:
executed 15 times by 1 test: return ((void *)0) ; Executed by:
| 15 | ||||||||||||||||||
483 | ((void *)0) executed 15 times by 1 test: return ((void *)0) ; Executed by:
| 15 | ||||||||||||||||||
484 | ; executed 15 times by 1 test: return ((void *)0) ; Executed by:
| 15 | ||||||||||||||||||
485 | } | - | ||||||||||||||||||
486 | } executed 27 times by 1 test: end of block Executed by:
| 27 | ||||||||||||||||||
487 | - | |||||||||||||||||||
488 | return executed 59 times by 1 test: pss;return pss; Executed by:
executed 59 times by 1 test: return pss; Executed by:
| 59 | ||||||||||||||||||
489 | } | - | ||||||||||||||||||
490 | - | |||||||||||||||||||
491 | static int rsa_sig_print(BIO *bp, const X509_ALGOR *sigalg, | - | ||||||||||||||||||
492 | const ASN1_STRING *sig, int indent, ASN1_PCTX *pctx) | - | ||||||||||||||||||
493 | { | - | ||||||||||||||||||
494 | if (OBJ_obj2nid(sigalg->algorithm) == 912
| 193-665 | ||||||||||||||||||
495 | int rv; | - | ||||||||||||||||||
496 | RSA_PSS_PARAMS *pss = rsa_pss_decode(sigalg); | - | ||||||||||||||||||
497 | - | |||||||||||||||||||
498 | rv = rsa_pss_param_print(bp, 0, pss, indent); | - | ||||||||||||||||||
499 | RSA_PSS_PARAMS_free(pss); | - | ||||||||||||||||||
500 | if (!rv
| 0-193 | ||||||||||||||||||
501 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||
502 | } executed 193 times by 1 test: else if (!sigend of block Executed by:
| 0-355 | ||||||||||||||||||
503 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||
504 | } | - | ||||||||||||||||||
505 | if (sig
| 422-436 | ||||||||||||||||||
506 | return executed 436 times by 1 test: X509_signature_dump(bp, sig, indent);return X509_signature_dump(bp, sig, indent); Executed by:
executed 436 times by 1 test: return X509_signature_dump(bp, sig, indent); Executed by:
| 436 | ||||||||||||||||||
507 | return executed 422 times by 1 test: 1;return 1; Executed by:
executed 422 times by 1 test: return 1; Executed by:
| 422 | ||||||||||||||||||
508 | } | - | ||||||||||||||||||
509 | - | |||||||||||||||||||
510 | static int rsa_pkey_ctrl(EVP_PKEY *pkey, int op, long arg1, void *arg2) | - | ||||||||||||||||||
511 | { | - | ||||||||||||||||||
512 | X509_ALGOR *alg = | - | ||||||||||||||||||
513 | ((void *)0) | - | ||||||||||||||||||
514 | ; | - | ||||||||||||||||||
515 | - | |||||||||||||||||||
516 | switch (op) { | - | ||||||||||||||||||
517 | - | |||||||||||||||||||
518 | case executed 13 times by 1 test: 0x1:case 0x1: Executed by:
executed 13 times by 1 test: case 0x1: Executed by:
| 13 | ||||||||||||||||||
519 | if (arg1 == 0
| 0-13 | ||||||||||||||||||
520 | PKCS7_SIGNER_INFO_get0_algs(arg2, executed 13 times by 1 test: PKCS7_SIGNER_INFO_get0_algs(arg2, ((void *)0) , ((void *)0) , &alg); Executed by:
| 13 | ||||||||||||||||||
521 | ((void *)0) executed 13 times by 1 test: PKCS7_SIGNER_INFO_get0_algs(arg2, ((void *)0) , ((void *)0) , &alg); Executed by:
| 13 | ||||||||||||||||||
522 | , executed 13 times by 1 test: PKCS7_SIGNER_INFO_get0_algs(arg2, ((void *)0) , ((void *)0) , &alg); Executed by:
| 13 | ||||||||||||||||||
523 | ((void *)0) executed 13 times by 1 test: PKCS7_SIGNER_INFO_get0_algs(arg2, ((void *)0) , ((void *)0) , &alg); Executed by:
| 13 | ||||||||||||||||||
524 | , &alg); executed 13 times by 1 test: PKCS7_SIGNER_INFO_get0_algs(arg2, ((void *)0) , ((void *)0) , &alg); Executed by:
| 13 | ||||||||||||||||||
525 | break; executed 13 times by 1 test: break; Executed by:
| 13 | ||||||||||||||||||
526 | - | |||||||||||||||||||
527 | case executed 12 times by 1 test: 0x2:case 0x2: Executed by:
executed 12 times by 1 test: case 0x2: Executed by:
| 12 | ||||||||||||||||||
528 | if ((
| 0-12 | ||||||||||||||||||
529 | return never executed: -2;return -2; never executed: return -2; | 0 | ||||||||||||||||||
530 | if (arg1 == 0
| 0-12 | ||||||||||||||||||
531 | PKCS7_RECIP_INFO_get0_alg(arg2, &alg); executed 12 times by 1 test: PKCS7_RECIP_INFO_get0_alg(arg2, &alg); Executed by:
| 12 | ||||||||||||||||||
532 | break; executed 12 times by 1 test: break; Executed by:
| 12 | ||||||||||||||||||
533 | - | |||||||||||||||||||
534 | case executed 70 times by 1 test: 0x5:case 0x5: Executed by:
executed 70 times by 1 test: case 0x5: Executed by:
| 70 | ||||||||||||||||||
535 | if (arg1 == 0
| 35 | ||||||||||||||||||
536 | return executed 35 times by 1 test: rsa_cms_sign(arg2);return rsa_cms_sign(arg2); Executed by:
executed 35 times by 1 test: return rsa_cms_sign(arg2); Executed by:
| 35 | ||||||||||||||||||
537 | else if (arg1 == 1
| 0-35 | ||||||||||||||||||
538 | return executed 35 times by 1 test: rsa_cms_verify(arg2);return rsa_cms_verify(arg2); Executed by:
executed 35 times by 1 test: return rsa_cms_verify(arg2); Executed by:
| 35 | ||||||||||||||||||
539 | break; never executed: break; | 0 | ||||||||||||||||||
540 | - | |||||||||||||||||||
541 | case executed 46 times by 1 test: 0x7:case 0x7: Executed by:
executed 46 times by 1 test: case 0x7: Executed by:
| 46 | ||||||||||||||||||
542 | if ((
| 0-46 | ||||||||||||||||||
543 | return never executed: -2;return -2; never executed: return -2; | 0 | ||||||||||||||||||
544 | if (arg1 == 0
| 16-30 | ||||||||||||||||||
545 | return executed 30 times by 1 test: rsa_cms_encrypt(arg2);return rsa_cms_encrypt(arg2); Executed by:
executed 30 times by 1 test: return rsa_cms_encrypt(arg2); Executed by:
| 30 | ||||||||||||||||||
546 | else if (arg1 == 1
| 0-16 | ||||||||||||||||||
547 | return executed 16 times by 1 test: rsa_cms_decrypt(arg2);return rsa_cms_decrypt(arg2); Executed by:
executed 16 times by 1 test: return rsa_cms_decrypt(arg2); Executed by:
| 16 | ||||||||||||||||||
548 | break; never executed: break; | 0 | ||||||||||||||||||
549 | - | |||||||||||||||||||
550 | case executed 42 times by 1 test: 0x8:case 0x8: Executed by:
executed 42 times by 1 test: case 0x8: Executed by:
| 42 | ||||||||||||||||||
551 | if ((
| 0-42 | ||||||||||||||||||
552 | return never executed: -2;return -2; never executed: return -2; | 0 | ||||||||||||||||||
553 | *(int *)arg2 = 0; | - | ||||||||||||||||||
554 | return executed 42 times by 1 test: 1;return 1; Executed by:
executed 42 times by 1 test: return 1; Executed by:
| 42 | ||||||||||||||||||
555 | - | |||||||||||||||||||
556 | - | |||||||||||||||||||
557 | case executed 65 times by 1 test: 0x3:case 0x3: Executed by:
executed 65 times by 1 test: case 0x3: Executed by:
| 65 | ||||||||||||||||||
558 | *(int *)arg2 = 672; | - | ||||||||||||||||||
559 | return executed 65 times by 1 test: 1;return 1; Executed by:
executed 65 times by 1 test: return 1; Executed by:
| 65 | ||||||||||||||||||
560 | - | |||||||||||||||||||
561 | default never executed: :default: never executed: default: | 0 | ||||||||||||||||||
562 | return never executed: -2;return -2; never executed: return -2; | 0 | ||||||||||||||||||
563 | - | |||||||||||||||||||
564 | } | - | ||||||||||||||||||
565 | - | |||||||||||||||||||
566 | if (alg
| 0-25 | ||||||||||||||||||
567 | X509_ALGOR_set0(alg, OBJ_nid2obj(6), 5, 0); executed 25 times by 1 test: X509_ALGOR_set0(alg, OBJ_nid2obj(6), 5, 0); Executed by:
| 25 | ||||||||||||||||||
568 | - | |||||||||||||||||||
569 | return executed 25 times by 1 test: 1;return 1; Executed by:
executed 25 times by 1 test: return 1; Executed by:
| 25 | ||||||||||||||||||
570 | - | |||||||||||||||||||
571 | } | - | ||||||||||||||||||
572 | - | |||||||||||||||||||
573 | - | |||||||||||||||||||
574 | static int rsa_md_to_algor(X509_ALGOR **palg, const EVP_MD *md) | - | ||||||||||||||||||
575 | { | - | ||||||||||||||||||
576 | if (md ==
| 0-15 | ||||||||||||||||||
577 | ((void *)0)
| 0-15 | ||||||||||||||||||
578 | || EVP_MD_type(md) == 64
| 1-14 | ||||||||||||||||||
579 | return executed 1 time by 1 test: 1;return 1; Executed by:
executed 1 time by 1 test: return 1; Executed by:
| 1 | ||||||||||||||||||
580 | *palg = X509_ALGOR_new(); | - | ||||||||||||||||||
581 | if (*
| 0-14 | ||||||||||||||||||
582 | ((void *)0)
| 0-14 | ||||||||||||||||||
583 | ) | - | ||||||||||||||||||
584 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||
585 | X509_ALGOR_set_md(*palg, md); | - | ||||||||||||||||||
586 | return executed 14 times by 1 test: 1;return 1; Executed by:
executed 14 times by 1 test: return 1; Executed by:
| 14 | ||||||||||||||||||
587 | } | - | ||||||||||||||||||
588 | - | |||||||||||||||||||
589 | - | |||||||||||||||||||
590 | static int rsa_md_to_mgf1(X509_ALGOR **palg, const EVP_MD *mgf1md) | - | ||||||||||||||||||
591 | { | - | ||||||||||||||||||
592 | X509_ALGOR *algtmp = | - | ||||||||||||||||||
593 | ((void *)0) | - | ||||||||||||||||||
594 | ; | - | ||||||||||||||||||
595 | ASN1_STRING *stmp = | - | ||||||||||||||||||
596 | ((void *)0) | - | ||||||||||||||||||
597 | ; | - | ||||||||||||||||||
598 | - | |||||||||||||||||||
599 | *palg = | - | ||||||||||||||||||
600 | ((void *)0) | - | ||||||||||||||||||
601 | ; | - | ||||||||||||||||||
602 | if (mgf1md ==
| 0-6 | ||||||||||||||||||
603 | ((void *)0)
| 0-6 | ||||||||||||||||||
604 | || EVP_MD_type(mgf1md) == 64
| 1-5 | ||||||||||||||||||
605 | return executed 1 time by 1 test: 1;return 1; Executed by:
executed 1 time by 1 test: return 1; Executed by:
| 1 | ||||||||||||||||||
606 | - | |||||||||||||||||||
607 | if (!rsa_md_to_algor(&algtmp, mgf1md)
| 0-5 | ||||||||||||||||||
608 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
609 | if (ASN1_item_pack(algtmp, (&(X509_ALGOR_it)), &stmp) ==
| 0-5 | ||||||||||||||||||
610 | ((void *)0)
| 0-5 | ||||||||||||||||||
611 | ) | - | ||||||||||||||||||
612 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
613 | *palg = X509_ALGOR_new(); | - | ||||||||||||||||||
614 | if (*
| 0-5 | ||||||||||||||||||
615 | ((void *)0)
| 0-5 | ||||||||||||||||||
616 | ) | - | ||||||||||||||||||
617 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
618 | X509_ALGOR_set0(*palg, OBJ_nid2obj(911), 16, stmp); | - | ||||||||||||||||||
619 | stmp = | - | ||||||||||||||||||
620 | ((void *)0) | - | ||||||||||||||||||
621 | ; | - | ||||||||||||||||||
622 | err: code before this statement executed 5 times by 1 test: err: Executed by:
| 5 | ||||||||||||||||||
623 | ASN1_STRING_free(stmp); | - | ||||||||||||||||||
624 | X509_ALGOR_free(algtmp); | - | ||||||||||||||||||
625 | if (*
| 0-5 | ||||||||||||||||||
626 | return executed 5 times by 1 test: 1;return 1; Executed by:
executed 5 times by 1 test: return 1; Executed by:
| 5 | ||||||||||||||||||
627 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||
628 | } | - | ||||||||||||||||||
629 | - | |||||||||||||||||||
630 | - | |||||||||||||||||||
631 | static const EVP_MD *rsa_algor_to_md(X509_ALGOR *alg) | - | ||||||||||||||||||
632 | { | - | ||||||||||||||||||
633 | const EVP_MD *md; | - | ||||||||||||||||||
634 | - | |||||||||||||||||||
635 | if (!alg
| 22-34 | ||||||||||||||||||
636 | return executed 34 times by 1 test: EVP_sha1();return EVP_sha1(); Executed by:
executed 34 times by 1 test: return EVP_sha1(); Executed by:
| 34 | ||||||||||||||||||
637 | md = EVP_get_digestbyname(OBJ_nid2sn(OBJ_obj2nid(alg->algorithm))); | - | ||||||||||||||||||
638 | if (md ==
| 0-22 | ||||||||||||||||||
639 | ((void *)0)
| 0-22 | ||||||||||||||||||
640 | ) | - | ||||||||||||||||||
641 | ERR_put_error(4,(156),(166),__FILE__,560); never executed: ERR_put_error(4,(156),(166),__FILE__,560); | 0 | ||||||||||||||||||
642 | return executed 22 times by 1 test: md;return md; Executed by:
executed 22 times by 1 test: return md; Executed by:
| 22 | ||||||||||||||||||
643 | } | - | ||||||||||||||||||
644 | - | |||||||||||||||||||
645 | - | |||||||||||||||||||
646 | - | |||||||||||||||||||
647 | - | |||||||||||||||||||
648 | - | |||||||||||||||||||
649 | - | |||||||||||||||||||
650 | static RSA_PSS_PARAMS *rsa_ctx_to_pss(EVP_PKEY_CTX *pkctx) | - | ||||||||||||||||||
651 | { | - | ||||||||||||||||||
652 | const EVP_MD *sigmd, *mgf1md; | - | ||||||||||||||||||
653 | EVP_PKEY *pk = EVP_PKEY_CTX_get0_pkey(pkctx); | - | ||||||||||||||||||
654 | int saltlen; | - | ||||||||||||||||||
655 | - | |||||||||||||||||||
656 | if (EVP_PKEY_CTX_ctrl(pkctx, -1, ((1<<3) | (1<<4) | (1<<5) | (1<<6) | (1<<7)), 13, 0, (void *)(&sigmd)) <= 0
| 0-3 | ||||||||||||||||||
657 | return never executed: return ((void *)0) ; never executed: return ((void *)0) ; | 0 | ||||||||||||||||||
658 | ((void *)0) never executed: return ((void *)0) ; | 0 | ||||||||||||||||||
659 | ; never executed: return ((void *)0) ; | 0 | ||||||||||||||||||
660 | if (RSA_pkey_ctx_ctrl(pkctx, ((1<<3) | (1<<4) | (1<<5) | (1<<6) | (1<<7)) | ((1<<8) | (1<<9)), (0x1000 + 8), 0, (void *)(&mgf1md)) <= 0
| 0-3 | ||||||||||||||||||
661 | return never executed: return ((void *)0) ; never executed: return ((void *)0) ; | 0 | ||||||||||||||||||
662 | ((void *)0) never executed: return ((void *)0) ; | 0 | ||||||||||||||||||
663 | ; never executed: return ((void *)0) ; | 0 | ||||||||||||||||||
664 | if (!RSA_pkey_ctx_ctrl(pkctx, ((1<<3)|(1<<4)), (0x1000 + 7), 0, &saltlen)
| 0-3 | ||||||||||||||||||
665 | return never executed: return ((void *)0) ; never executed: return ((void *)0) ; | 0 | ||||||||||||||||||
666 | ((void *)0) never executed: return ((void *)0) ; | 0 | ||||||||||||||||||
667 | ; never executed: return ((void *)0) ; | 0 | ||||||||||||||||||
668 | if (saltlen == -1
| 0-3 | ||||||||||||||||||
669 | saltlen = EVP_MD_size(sigmd); | - | ||||||||||||||||||
670 | } never executed: else if (saltlen == -2end of block
| 0-3 | ||||||||||||||||||
671 | saltlen = EVP_PKEY_size(pk) - EVP_MD_size(sigmd) - 2; | - | ||||||||||||||||||
672 | if ((
| 0-3 | ||||||||||||||||||
673 | saltlen--; never executed: saltlen--; | 0 | ||||||||||||||||||
674 | } executed 3 times by 1 test: end of block Executed by:
| 3 | ||||||||||||||||||
675 | - | |||||||||||||||||||
676 | return executed 3 times by 1 test: rsa_pss_params_create(sigmd, mgf1md, saltlen);return rsa_pss_params_create(sigmd, mgf1md, saltlen); Executed by:
executed 3 times by 1 test: return rsa_pss_params_create(sigmd, mgf1md, saltlen); Executed by:
| 3 | ||||||||||||||||||
677 | } | - | ||||||||||||||||||
678 | - | |||||||||||||||||||
679 | RSA_PSS_PARAMS *rsa_pss_params_create(const EVP_MD *sigmd, | - | ||||||||||||||||||
680 | const EVP_MD *mgf1md, int saltlen) | - | ||||||||||||||||||
681 | { | - | ||||||||||||||||||
682 | RSA_PSS_PARAMS *pss = RSA_PSS_PARAMS_new(); | - | ||||||||||||||||||
683 | - | |||||||||||||||||||
684 | if (pss ==
| 0-4 | ||||||||||||||||||
685 | ((void *)0)
| 0-4 | ||||||||||||||||||
686 | ) | - | ||||||||||||||||||
687 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
688 | if (saltlen != 20
| 0-4 | ||||||||||||||||||
689 | pss->saltLength = ASN1_INTEGER_new(); | - | ||||||||||||||||||
690 | if (pss->saltLength ==
| 0-4 | ||||||||||||||||||
691 | ((void *)0)
| 0-4 | ||||||||||||||||||
692 | ) | - | ||||||||||||||||||
693 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
694 | if (!ASN1_INTEGER_set(pss->saltLength, saltlen)
| 0-4 | ||||||||||||||||||
695 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
696 | } executed 4 times by 1 test: end of block Executed by:
| 4 | ||||||||||||||||||
697 | if (!rsa_md_to_algor(&pss->hashAlgorithm, sigmd)
| 0-4 | ||||||||||||||||||
698 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
699 | if (mgf1md ==
| 0-4 | ||||||||||||||||||
700 | ((void *)0)
| 0-4 | ||||||||||||||||||
701 | ) | - | ||||||||||||||||||
702 | mgf1md = sigmd; never executed: mgf1md = sigmd; | 0 | ||||||||||||||||||
703 | if (!rsa_md_to_mgf1(&pss->maskGenAlgorithm, mgf1md)
| 0-4 | ||||||||||||||||||
704 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
705 | if (!rsa_md_to_algor(&pss->maskHash, mgf1md)
| 0-4 | ||||||||||||||||||
706 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
707 | return executed 4 times by 1 test: pss;return pss; Executed by:
executed 4 times by 1 test: return pss; Executed by:
| 4 | ||||||||||||||||||
708 | err: | - | ||||||||||||||||||
709 | RSA_PSS_PARAMS_free(pss); | - | ||||||||||||||||||
710 | return never executed: return ((void *)0) ; never executed: return ((void *)0) ; | 0 | ||||||||||||||||||
711 | ((void *)0) never executed: return ((void *)0) ; | 0 | ||||||||||||||||||
712 | ; never executed: return ((void *)0) ; | 0 | ||||||||||||||||||
713 | } | - | ||||||||||||||||||
714 | - | |||||||||||||||||||
715 | static ASN1_STRING *rsa_ctx_to_pss_string(EVP_PKEY_CTX *pkctx) | - | ||||||||||||||||||
716 | { | - | ||||||||||||||||||
717 | RSA_PSS_PARAMS *pss = rsa_ctx_to_pss(pkctx); | - | ||||||||||||||||||
718 | ASN1_STRING *os; | - | ||||||||||||||||||
719 | - | |||||||||||||||||||
720 | if (pss ==
| 0-3 | ||||||||||||||||||
721 | ((void *)0)
| 0-3 | ||||||||||||||||||
722 | ) | - | ||||||||||||||||||
723 | return never executed: return ((void *)0) ; never executed: return ((void *)0) ; | 0 | ||||||||||||||||||
724 | ((void *)0) never executed: return ((void *)0) ; | 0 | ||||||||||||||||||
725 | ; never executed: return ((void *)0) ; | 0 | ||||||||||||||||||
726 | - | |||||||||||||||||||
727 | os = ASN1_item_pack(pss, (&(RSA_PSS_PARAMS_it)), | - | ||||||||||||||||||
728 | ((void *)0) | - | ||||||||||||||||||
729 | ); | - | ||||||||||||||||||
730 | RSA_PSS_PARAMS_free(pss); | - | ||||||||||||||||||
731 | return executed 3 times by 1 test: os;return os; Executed by:
executed 3 times by 1 test: return os; Executed by:
| 3 | ||||||||||||||||||
732 | } | - | ||||||||||||||||||
733 | - | |||||||||||||||||||
734 | - | |||||||||||||||||||
735 | - | |||||||||||||||||||
736 | - | |||||||||||||||||||
737 | - | |||||||||||||||||||
738 | - | |||||||||||||||||||
739 | - | |||||||||||||||||||
740 | static int rsa_pss_to_ctx(EVP_MD_CTX *ctx, EVP_PKEY_CTX *pkctx, | - | ||||||||||||||||||
741 | X509_ALGOR *sigalg, EVP_PKEY *pkey) | - | ||||||||||||||||||
742 | { | - | ||||||||||||||||||
743 | int rv = -1; | - | ||||||||||||||||||
744 | int saltlen; | - | ||||||||||||||||||
745 | const EVP_MD *mgf1md = | - | ||||||||||||||||||
746 | ((void *)0) | - | ||||||||||||||||||
747 | , *md = | - | ||||||||||||||||||
748 | ((void *)0) | - | ||||||||||||||||||
749 | ; | - | ||||||||||||||||||
750 | RSA_PSS_PARAMS *pss; | - | ||||||||||||||||||
751 | - | |||||||||||||||||||
752 | - | |||||||||||||||||||
753 | if (OBJ_obj2nid(sigalg->algorithm) != 912
| 0-6 | ||||||||||||||||||
754 | ERR_put_error(4,(155),(155),__FILE__,649); | - | ||||||||||||||||||
755 | return never executed: -1;return -1; never executed: return -1; | 0 | ||||||||||||||||||
756 | } | - | ||||||||||||||||||
757 | - | |||||||||||||||||||
758 | pss = rsa_pss_decode(sigalg); | - | ||||||||||||||||||
759 | - | |||||||||||||||||||
760 | if (!rsa_pss_get_param(pss, &md, &mgf1md, &saltlen)
| 0-6 | ||||||||||||||||||
761 | ERR_put_error(4,(155),(149),__FILE__,656); | - | ||||||||||||||||||
762 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
763 | } | - | ||||||||||||||||||
764 | - | |||||||||||||||||||
765 | - | |||||||||||||||||||
766 | if (pkey
| 3 | ||||||||||||||||||
767 | if (!EVP_DigestVerifyInit(ctx, &pkctx, md,
| 0-3 | ||||||||||||||||||
768 | ((void *)0)
| 0-3 | ||||||||||||||||||
769 | , pkey)
| 0-3 | ||||||||||||||||||
770 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
771 | } executed 3 times by 1 test: else {end of block Executed by:
| 3 | ||||||||||||||||||
772 | const EVP_MD *checkmd; | - | ||||||||||||||||||
773 | if (EVP_PKEY_CTX_ctrl(pkctx, -1, ((1<<3) | (1<<4) | (1<<5) | (1<<6) | (1<<7)), 13, 0, (void *)(&checkmd)) <= 0
| 0-3 | ||||||||||||||||||
774 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
775 | if (EVP_MD_type(md) != EVP_MD_type(checkmd)
| 0-3 | ||||||||||||||||||
776 | ERR_put_error(4,(155),(158),__FILE__,669); | - | ||||||||||||||||||
777 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
778 | } | - | ||||||||||||||||||
779 | } executed 3 times by 1 test: end of block Executed by:
| 3 | ||||||||||||||||||
780 | - | |||||||||||||||||||
781 | if (RSA_pkey_ctx_ctrl(pkctx, -1, (0x1000 + 1), 6,
| 0-6 | ||||||||||||||||||
782 | ((void *)0)
| 0-6 | ||||||||||||||||||
783 | ) <= 0
| 0-6 | ||||||||||||||||||
784 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
785 | - | |||||||||||||||||||
786 | if (RSA_pkey_ctx_ctrl(pkctx, ((1<<3)|(1<<4)), (0x1000 + 2), saltlen,
| 0-6 | ||||||||||||||||||
787 | ((void *)0)
| 0-6 | ||||||||||||||||||
788 | ) <= 0
| 0-6 | ||||||||||||||||||
789 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
790 | - | |||||||||||||||||||
791 | if (RSA_pkey_ctx_ctrl(pkctx, ((1<<3) | (1<<4) | (1<<5) | (1<<6) | (1<<7)) | ((1<<8) | (1<<9)), (0x1000 + 5), 0, (void *)(mgf1md)) <= 0
| 0-6 | ||||||||||||||||||
792 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
793 | - | |||||||||||||||||||
794 | rv = 1; | - | ||||||||||||||||||
795 | - | |||||||||||||||||||
796 | err: code before this statement executed 6 times by 1 test: err: Executed by:
| 6 | ||||||||||||||||||
797 | RSA_PSS_PARAMS_free(pss); | - | ||||||||||||||||||
798 | return executed 6 times by 1 test: rv;return rv; Executed by:
executed 6 times by 1 test: return rv; Executed by:
| 6 | ||||||||||||||||||
799 | } | - | ||||||||||||||||||
800 | - | |||||||||||||||||||
801 | int rsa_pss_get_param(const RSA_PSS_PARAMS *pss, const EVP_MD **pmd, | - | ||||||||||||||||||
802 | const EVP_MD **pmgf1md, int *psaltlen) | - | ||||||||||||||||||
803 | { | - | ||||||||||||||||||
804 | if (pss ==
| 26-39 | ||||||||||||||||||
805 | ((void *)0)
| 26-39 | ||||||||||||||||||
806 | ) | - | ||||||||||||||||||
807 | return executed 39 times by 1 test: 0;return 0; Executed by:
executed 39 times by 1 test: return 0; Executed by:
| 39 | ||||||||||||||||||
808 | *pmd = rsa_algor_to_md(pss->hashAlgorithm); | - | ||||||||||||||||||
809 | if (*
| 0-26 | ||||||||||||||||||
810 | ((void *)0)
| 0-26 | ||||||||||||||||||
811 | ) | - | ||||||||||||||||||
812 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||
813 | *pmgf1md = rsa_algor_to_md(pss->maskHash); | - | ||||||||||||||||||
814 | if (*
| 0-26 | ||||||||||||||||||
815 | ((void *)0)
| 0-26 | ||||||||||||||||||
816 | ) | - | ||||||||||||||||||
817 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||
818 | if (pss->saltLength
| 12-14 | ||||||||||||||||||
819 | *psaltlen = ASN1_INTEGER_get(pss->saltLength); | - | ||||||||||||||||||
820 | if (*
| 1-11 | ||||||||||||||||||
821 | ERR_put_error(4,(151),(150),__FILE__,704); | - | ||||||||||||||||||
822 | return executed 1 time by 1 test: 0;return 0; Executed by:
executed 1 time by 1 test: return 0; Executed by:
| 1 | ||||||||||||||||||
823 | } | - | ||||||||||||||||||
824 | } executed 11 times by 1 test: else {end of block Executed by:
| 11 | ||||||||||||||||||
825 | *psaltlen = 20; | - | ||||||||||||||||||
826 | } executed 14 times by 1 test: end of block Executed by:
| 14 | ||||||||||||||||||
827 | - | |||||||||||||||||||
828 | - | |||||||||||||||||||
829 | - | |||||||||||||||||||
830 | - | |||||||||||||||||||
831 | - | |||||||||||||||||||
832 | if (pss->trailerField
| 0-25 | ||||||||||||||||||
833 | ERR_put_error(4,(151),(139),__FILE__,716); | - | ||||||||||||||||||
834 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||
835 | } | - | ||||||||||||||||||
836 | - | |||||||||||||||||||
837 | return executed 25 times by 1 test: 1;return 1; Executed by:
executed 25 times by 1 test: return 1; Executed by:
| 25 | ||||||||||||||||||
838 | } | - | ||||||||||||||||||
839 | - | |||||||||||||||||||
840 | - | |||||||||||||||||||
841 | static int rsa_cms_verify(CMS_SignerInfo *si) | - | ||||||||||||||||||
842 | { | - | ||||||||||||||||||
843 | int nid, nid2; | - | ||||||||||||||||||
844 | X509_ALGOR *alg; | - | ||||||||||||||||||
845 | EVP_PKEY_CTX *pkctx = CMS_SignerInfo_get0_pkey_ctx(si); | - | ||||||||||||||||||
846 | - | |||||||||||||||||||
847 | CMS_SignerInfo_get0_algs(si, | - | ||||||||||||||||||
848 | ((void *)0) | - | ||||||||||||||||||
849 | , | - | ||||||||||||||||||
850 | ((void *)0) | - | ||||||||||||||||||
851 | , | - | ||||||||||||||||||
852 | ((void *)0) | - | ||||||||||||||||||
853 | , &alg); | - | ||||||||||||||||||
854 | nid = OBJ_obj2nid(alg->algorithm); | - | ||||||||||||||||||
855 | if (nid == 912
| 3-32 | ||||||||||||||||||
856 | return executed 3 times by 1 test: rsa_pss_to_ctx(return rsa_pss_to_ctx( ((void *)0) , pkctx, alg, ((void *)0) ); Executed by:
executed 3 times by 1 test: return rsa_pss_to_ctx( ((void *)0) , pkctx, alg, ((void *)0) ); Executed by:
| 3 | ||||||||||||||||||
857 | ((void *)0) executed 3 times by 1 test: return rsa_pss_to_ctx( ((void *)0) , pkctx, alg, ((void *)0) ); Executed by:
| 3 | ||||||||||||||||||
858 | , pkctx, alg, executed 3 times by 1 test: return rsa_pss_to_ctx( ((void *)0) , pkctx, alg, ((void *)0) ); Executed by:
| 3 | ||||||||||||||||||
859 | ((void *)0) executed 3 times by 1 test: return rsa_pss_to_ctx( ((void *)0) , pkctx, alg, ((void *)0) ); Executed by:
| 3 | ||||||||||||||||||
860 | ); executed 3 times by 1 test: return rsa_pss_to_ctx( ((void *)0) , pkctx, alg, ((void *)0) ); Executed by:
| 3 | ||||||||||||||||||
861 | - | |||||||||||||||||||
862 | if ((
| 0-32 | ||||||||||||||||||
863 | ERR_put_error(4,(158),(144),__FILE__,736); | - | ||||||||||||||||||
864 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||
865 | } | - | ||||||||||||||||||
866 | if (nid == 6
| 0-32 | ||||||||||||||||||
867 | return executed 32 times by 1 test: 1;return 1; Executed by:
executed 32 times by 1 test: return 1; Executed by:
| 32 | ||||||||||||||||||
868 | - | |||||||||||||||||||
869 | if (OBJ_find_sigid_algs(nid,
| 0 | ||||||||||||||||||
870 | ((void *)0)
| 0 | ||||||||||||||||||
871 | , &nid2)
| 0 | ||||||||||||||||||
872 | if (nid2 == 6
| 0 | ||||||||||||||||||
873 | return never executed: 1;return 1; never executed: return 1; | 0 | ||||||||||||||||||
874 | } never executed: end of block | 0 | ||||||||||||||||||
875 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||
876 | } | - | ||||||||||||||||||
877 | - | |||||||||||||||||||
878 | - | |||||||||||||||||||
879 | - | |||||||||||||||||||
880 | - | |||||||||||||||||||
881 | - | |||||||||||||||||||
882 | - | |||||||||||||||||||
883 | - | |||||||||||||||||||
884 | static int rsa_item_verify(EVP_MD_CTX *ctx, const ASN1_ITEM *it, void *asn, | - | ||||||||||||||||||
885 | X509_ALGOR *sigalg, ASN1_BIT_STRING *sig, | - | ||||||||||||||||||
886 | EVP_PKEY *pkey) | - | ||||||||||||||||||
887 | { | - | ||||||||||||||||||
888 | - | |||||||||||||||||||
889 | if (OBJ_obj2nid(sigalg->algorithm) != 912
| 0-3 | ||||||||||||||||||
890 | ERR_put_error(4,(148),(155),__FILE__,761); | - | ||||||||||||||||||
891 | return never executed: -1;return -1; never executed: return -1; | 0 | ||||||||||||||||||
892 | } | - | ||||||||||||||||||
893 | if (rsa_pss_to_ctx(ctx,
| 0-3 | ||||||||||||||||||
894 | ((void *)0)
| 0-3 | ||||||||||||||||||
895 | , sigalg, pkey) > 0
| 0-3 | ||||||||||||||||||
896 | - | |||||||||||||||||||
897 | return executed 3 times by 1 test: 2;return 2; Executed by:
executed 3 times by 1 test: return 2; Executed by:
| 3 | ||||||||||||||||||
898 | } | - | ||||||||||||||||||
899 | return never executed: -1;return -1; never executed: return -1; | 0 | ||||||||||||||||||
900 | } | - | ||||||||||||||||||
901 | - | |||||||||||||||||||
902 | - | |||||||||||||||||||
903 | static int rsa_cms_sign(CMS_SignerInfo *si) | - | ||||||||||||||||||
904 | { | - | ||||||||||||||||||
905 | int pad_mode = 1; | - | ||||||||||||||||||
906 | X509_ALGOR *alg; | - | ||||||||||||||||||
907 | EVP_PKEY_CTX *pkctx = CMS_SignerInfo_get0_pkey_ctx(si); | - | ||||||||||||||||||
908 | ASN1_STRING *os = | - | ||||||||||||||||||
909 | ((void *)0) | - | ||||||||||||||||||
910 | ; | - | ||||||||||||||||||
911 | - | |||||||||||||||||||
912 | CMS_SignerInfo_get0_algs(si, | - | ||||||||||||||||||
913 | ((void *)0) | - | ||||||||||||||||||
914 | , | - | ||||||||||||||||||
915 | ((void *)0) | - | ||||||||||||||||||
916 | , | - | ||||||||||||||||||
917 | ((void *)0) | - | ||||||||||||||||||
918 | , &alg); | - | ||||||||||||||||||
919 | if (pkctx
| 3-32 | ||||||||||||||||||
920 | if (RSA_pkey_ctx_ctrl(pkctx, -1, (0x1000 + 6), 0, &pad_mode) <= 0
| 0-3 | ||||||||||||||||||
921 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||
922 | } executed 3 times by 1 test: end of block Executed by:
| 3 | ||||||||||||||||||
923 | if (pad_mode == 1
| 3-32 | ||||||||||||||||||
924 | X509_ALGOR_set0(alg, OBJ_nid2obj(6), 5, 0); | - | ||||||||||||||||||
925 | return executed 32 times by 1 test: 1;return 1; Executed by:
executed 32 times by 1 test: return 1; Executed by:
| 32 | ||||||||||||||||||
926 | } | - | ||||||||||||||||||
927 | - | |||||||||||||||||||
928 | if (pad_mode != 6
| 0-3 | ||||||||||||||||||
929 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||
930 | os = rsa_ctx_to_pss_string(pkctx); | - | ||||||||||||||||||
931 | if (!os
| 0-3 | ||||||||||||||||||
932 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||
933 | X509_ALGOR_set0(alg, OBJ_nid2obj(912), 16, os); | - | ||||||||||||||||||
934 | return executed 3 times by 1 test: 1;return 1; Executed by:
executed 3 times by 1 test: return 1; Executed by:
| 3 | ||||||||||||||||||
935 | } | - | ||||||||||||||||||
936 | - | |||||||||||||||||||
937 | - | |||||||||||||||||||
938 | static int rsa_item_sign(EVP_MD_CTX *ctx, const ASN1_ITEM *it, void *asn, | - | ||||||||||||||||||
939 | X509_ALGOR *alg1, X509_ALGOR *alg2, | - | ||||||||||||||||||
940 | ASN1_BIT_STRING *sig) | - | ||||||||||||||||||
941 | { | - | ||||||||||||||||||
942 | int pad_mode; | - | ||||||||||||||||||
943 | EVP_PKEY_CTX *pkctx = EVP_MD_CTX_pkey_ctx(ctx); | - | ||||||||||||||||||
944 | - | |||||||||||||||||||
945 | if (RSA_pkey_ctx_ctrl(pkctx, -1, (0x1000 + 6), 0, &pad_mode) <= 0
| 0-20 | ||||||||||||||||||
946 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||
947 | if (pad_mode == 1
| 0-20 | ||||||||||||||||||
948 | return executed 20 times by 1 test: 2;return 2; Executed by:
executed 20 times by 1 test: return 2; Executed by:
| 20 | ||||||||||||||||||
949 | if (pad_mode == 6
| 0 | ||||||||||||||||||
950 | ASN1_STRING *os1 = | - | ||||||||||||||||||
951 | ((void *)0) | - | ||||||||||||||||||
952 | ; | - | ||||||||||||||||||
953 | os1 = rsa_ctx_to_pss_string(pkctx); | - | ||||||||||||||||||
954 | if (!os1
| 0 | ||||||||||||||||||
955 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||
956 | - | |||||||||||||||||||
957 | if (alg2
| 0 | ||||||||||||||||||
958 | ASN1_STRING *os2 = ASN1_STRING_dup(os1); | - | ||||||||||||||||||
959 | if (!os2
| 0 | ||||||||||||||||||
960 | ASN1_STRING_free(os1); | - | ||||||||||||||||||
961 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||
962 | } | - | ||||||||||||||||||
963 | X509_ALGOR_set0(alg2, OBJ_nid2obj(912), | - | ||||||||||||||||||
964 | 16, os2); | - | ||||||||||||||||||
965 | } never executed: end of block | 0 | ||||||||||||||||||
966 | X509_ALGOR_set0(alg1, OBJ_nid2obj(912), | - | ||||||||||||||||||
967 | 16, os1); | - | ||||||||||||||||||
968 | return never executed: 3;return 3; never executed: return 3; | 0 | ||||||||||||||||||
969 | } | - | ||||||||||||||||||
970 | return never executed: 2;return 2; never executed: return 2; | 0 | ||||||||||||||||||
971 | } | - | ||||||||||||||||||
972 | - | |||||||||||||||||||
973 | static int rsa_sig_info_set(X509_SIG_INFO *siginf, const X509_ALGOR *sigalg, | - | ||||||||||||||||||
974 | const ASN1_STRING *sig) | - | ||||||||||||||||||
975 | { | - | ||||||||||||||||||
976 | int rv = 0; | - | ||||||||||||||||||
977 | int mdnid, saltlen; | - | ||||||||||||||||||
978 | uint32_t flags; | - | ||||||||||||||||||
979 | const EVP_MD *mgf1md = | - | ||||||||||||||||||
980 | ((void *)0) | - | ||||||||||||||||||
981 | , *md = | - | ||||||||||||||||||
982 | ((void *)0) | - | ||||||||||||||||||
983 | ; | - | ||||||||||||||||||
984 | RSA_PSS_PARAMS *pss; | - | ||||||||||||||||||
985 | - | |||||||||||||||||||
986 | - | |||||||||||||||||||
987 | if (OBJ_obj2nid(sigalg->algorithm) != 912
| 0-46 | ||||||||||||||||||
988 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||
989 | - | |||||||||||||||||||
990 | pss = rsa_pss_decode(sigalg); | - | ||||||||||||||||||
991 | if (!rsa_pss_get_param(pss, &md, &mgf1md, &saltlen)
| 7-39 | ||||||||||||||||||
992 | goto executed 39 times by 1 test: err;goto err; Executed by:
executed 39 times by 1 test: goto err; Executed by:
| 39 | ||||||||||||||||||
993 | mdnid = EVP_MD_type(md); | - | ||||||||||||||||||
994 | - | |||||||||||||||||||
995 | - | |||||||||||||||||||
996 | - | |||||||||||||||||||
997 | - | |||||||||||||||||||
998 | if ((mdnid == 672
| 0-5 | ||||||||||||||||||
999 | && mdnid == EVP_MD_type(mgf1md)
| 0-2 | ||||||||||||||||||
1000 | flags = 0x2; executed 2 times by 1 test: flags = 0x2; Executed by:
| 2 | ||||||||||||||||||
1001 | else | - | ||||||||||||||||||
1002 | flags = 0; executed 5 times by 1 test: flags = 0; Executed by:
| 5 | ||||||||||||||||||
1003 | - | |||||||||||||||||||
1004 | X509_SIG_INFO_set(siginf, mdnid, 912, EVP_MD_size(md) * 4, | - | ||||||||||||||||||
1005 | flags); | - | ||||||||||||||||||
1006 | rv = 1; | - | ||||||||||||||||||
1007 | err: code before this statement executed 7 times by 1 test: err: Executed by:
| 7 | ||||||||||||||||||
1008 | RSA_PSS_PARAMS_free(pss); | - | ||||||||||||||||||
1009 | return executed 46 times by 1 test: rv;return rv; Executed by:
executed 46 times by 1 test: return rv; Executed by:
| 46 | ||||||||||||||||||
1010 | } | - | ||||||||||||||||||
1011 | - | |||||||||||||||||||
1012 | - | |||||||||||||||||||
1013 | static RSA_OAEP_PARAMS *rsa_oaep_decode(const X509_ALGOR *alg) | - | ||||||||||||||||||
1014 | { | - | ||||||||||||||||||
1015 | RSA_OAEP_PARAMS *oaep; | - | ||||||||||||||||||
1016 | - | |||||||||||||||||||
1017 | oaep = ASN1_TYPE_unpack_sequence((&(RSA_OAEP_PARAMS_it)), | - | ||||||||||||||||||
1018 | alg->parameter); | - | ||||||||||||||||||
1019 | - | |||||||||||||||||||
1020 | if (oaep ==
| 0-2 | ||||||||||||||||||
1021 | ((void *)0)
| 0-2 | ||||||||||||||||||
1022 | ) | - | ||||||||||||||||||
1023 | return never executed: return ((void *)0) ; never executed: return ((void *)0) ; | 0 | ||||||||||||||||||
1024 | ((void *)0) never executed: return ((void *)0) ; | 0 | ||||||||||||||||||
1025 | ; never executed: return ((void *)0) ; | 0 | ||||||||||||||||||
1026 | - | |||||||||||||||||||
1027 | if (oaep->maskGenFunc !=
| 1 | ||||||||||||||||||
1028 | ((void *)0)
| 1 | ||||||||||||||||||
1029 | ) { | - | ||||||||||||||||||
1030 | oaep->maskHash = rsa_mgf1_decode(oaep->maskGenFunc); | - | ||||||||||||||||||
1031 | if (oaep->maskHash ==
| 0-1 | ||||||||||||||||||
1032 | ((void *)0)
| 0-1 | ||||||||||||||||||
1033 | ) { | - | ||||||||||||||||||
1034 | RSA_OAEP_PARAMS_free(oaep); | - | ||||||||||||||||||
1035 | return never executed: return ((void *)0) ; never executed: return ((void *)0) ; | 0 | ||||||||||||||||||
1036 | ((void *)0) never executed: return ((void *)0) ; | 0 | ||||||||||||||||||
1037 | ; never executed: return ((void *)0) ; | 0 | ||||||||||||||||||
1038 | } | - | ||||||||||||||||||
1039 | } executed 1 time by 1 test: end of block Executed by:
| 1 | ||||||||||||||||||
1040 | return executed 2 times by 1 test: oaep;return oaep; Executed by:
executed 2 times by 1 test: return oaep; Executed by:
| 2 | ||||||||||||||||||
1041 | } | - | ||||||||||||||||||
1042 | - | |||||||||||||||||||
1043 | static int rsa_cms_decrypt(CMS_RecipientInfo *ri) | - | ||||||||||||||||||
1044 | { | - | ||||||||||||||||||
1045 | EVP_PKEY_CTX *pkctx; | - | ||||||||||||||||||
1046 | X509_ALGOR *cmsalg; | - | ||||||||||||||||||
1047 | int nid; | - | ||||||||||||||||||
1048 | int rv = -1; | - | ||||||||||||||||||
1049 | unsigned char *label = | - | ||||||||||||||||||
1050 | ((void *)0) | - | ||||||||||||||||||
1051 | ; | - | ||||||||||||||||||
1052 | int labellen = 0; | - | ||||||||||||||||||
1053 | const EVP_MD *mgf1md = | - | ||||||||||||||||||
1054 | ((void *)0) | - | ||||||||||||||||||
1055 | , *md = | - | ||||||||||||||||||
1056 | ((void *)0) | - | ||||||||||||||||||
1057 | ; | - | ||||||||||||||||||
1058 | RSA_OAEP_PARAMS *oaep; | - | ||||||||||||||||||
1059 | - | |||||||||||||||||||
1060 | pkctx = CMS_RecipientInfo_get0_pkey_ctx(ri); | - | ||||||||||||||||||
1061 | if (pkctx ==
| 0-16 | ||||||||||||||||||
1062 | ((void *)0)
| 0-16 | ||||||||||||||||||
1063 | ) | - | ||||||||||||||||||
1064 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||
1065 | if (!CMS_RecipientInfo_ktri_get0_algs(ri,
| 0-16 | ||||||||||||||||||
1066 | ((void *)0)
| 0-16 | ||||||||||||||||||
1067 | ,
| 0-16 | ||||||||||||||||||
1068 | ((void *)0)
| 0-16 | ||||||||||||||||||
1069 | , &cmsalg)
| 0-16 | ||||||||||||||||||
1070 | return never executed: -1;return -1; never executed: return -1; | 0 | ||||||||||||||||||
1071 | nid = OBJ_obj2nid(cmsalg->algorithm); | - | ||||||||||||||||||
1072 | if (nid == 6
| 2-14 | ||||||||||||||||||
1073 | return executed 14 times by 1 test: 1;return 1; Executed by:
executed 14 times by 1 test: return 1; Executed by:
| 14 | ||||||||||||||||||
1074 | if (nid != 919
| 0-2 | ||||||||||||||||||
1075 | ERR_put_error(4,(159),(162),__FILE__,908); | - | ||||||||||||||||||
1076 | return never executed: -1;return -1; never executed: return -1; | 0 | ||||||||||||||||||
1077 | } | - | ||||||||||||||||||
1078 | - | |||||||||||||||||||
1079 | oaep = rsa_oaep_decode(cmsalg); | - | ||||||||||||||||||
1080 | - | |||||||||||||||||||
1081 | if (oaep ==
| 0-2 | ||||||||||||||||||
1082 | ((void *)0)
| 0-2 | ||||||||||||||||||
1083 | ) { | - | ||||||||||||||||||
1084 | ERR_put_error(4,(159),(161),__FILE__,915); | - | ||||||||||||||||||
1085 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
1086 | } | - | ||||||||||||||||||
1087 | - | |||||||||||||||||||
1088 | mgf1md = rsa_algor_to_md(oaep->maskHash); | - | ||||||||||||||||||
1089 | if (mgf1md ==
| 0-2 | ||||||||||||||||||
1090 | ((void *)0)
| 0-2 | ||||||||||||||||||
1091 | ) | - | ||||||||||||||||||
1092 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
1093 | md = rsa_algor_to_md(oaep->hashFunc); | - | ||||||||||||||||||
1094 | if (md ==
| 0-2 | ||||||||||||||||||
1095 | ((void *)0)
| 0-2 | ||||||||||||||||||
1096 | ) | - | ||||||||||||||||||
1097 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
1098 | - | |||||||||||||||||||
1099 | if (oaep->pSourceFunc !=
| 0-2 | ||||||||||||||||||
1100 | ((void *)0)
| 0-2 | ||||||||||||||||||
1101 | ) { | - | ||||||||||||||||||
1102 | X509_ALGOR *plab = oaep->pSourceFunc; | - | ||||||||||||||||||
1103 | - | |||||||||||||||||||
1104 | if (OBJ_obj2nid(plab->algorithm) != 935
| 0 | ||||||||||||||||||
1105 | ERR_put_error(4,(159),(163),__FILE__,930); | - | ||||||||||||||||||
1106 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
1107 | } | - | ||||||||||||||||||
1108 | if (plab->parameter->type != 4
| 0 | ||||||||||||||||||
1109 | ERR_put_error(4,(159),(160),__FILE__,934); | - | ||||||||||||||||||
1110 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
1111 | } | - | ||||||||||||||||||
1112 | - | |||||||||||||||||||
1113 | label = plab->parameter->value.octet_string->data; | - | ||||||||||||||||||
1114 | - | |||||||||||||||||||
1115 | plab->parameter->value.octet_string->data = | - | ||||||||||||||||||
1116 | ((void *)0) | - | ||||||||||||||||||
1117 | ; | - | ||||||||||||||||||
1118 | labellen = plab->parameter->value.octet_string->length; | - | ||||||||||||||||||
1119 | } never executed: end of block | 0 | ||||||||||||||||||
1120 | - | |||||||||||||||||||
1121 | if (RSA_pkey_ctx_ctrl(pkctx, -1, (0x1000 + 1), 4,
| 0-2 | ||||||||||||||||||
1122 | ((void *)0)
| 0-2 | ||||||||||||||||||
1123 | ) <= 0
| 0-2 | ||||||||||||||||||
1124 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
1125 | if (EVP_PKEY_CTX_ctrl(pkctx, 6, ((1<<8) | (1<<9)), (0x1000 + 9), 0, (void *)(md)) <= 0
| 0-2 | ||||||||||||||||||
1126 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
1127 | if (RSA_pkey_ctx_ctrl(pkctx, ((1<<3) | (1<<4) | (1<<5) | (1<<6) | (1<<7)) | ((1<<8) | (1<<9)), (0x1000 + 5), 0, (void *)(mgf1md)) <= 0
| 0-2 | ||||||||||||||||||
1128 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
1129 | if (EVP_PKEY_CTX_ctrl(pkctx, 6, ((1<<8) | (1<<9)), (0x1000 + 10), labellen, (void *)(label)) <= 0
| 0-2 | ||||||||||||||||||
1130 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
1131 | - | |||||||||||||||||||
1132 | rv = 1; | - | ||||||||||||||||||
1133 | - | |||||||||||||||||||
1134 | err: code before this statement executed 2 times by 1 test: err: Executed by:
| 2 | ||||||||||||||||||
1135 | RSA_OAEP_PARAMS_free(oaep); | - | ||||||||||||||||||
1136 | return executed 2 times by 1 test: rv;return rv; Executed by:
executed 2 times by 1 test: return rv; Executed by:
| 2 | ||||||||||||||||||
1137 | } | - | ||||||||||||||||||
1138 | - | |||||||||||||||||||
1139 | static int rsa_cms_encrypt(CMS_RecipientInfo *ri) | - | ||||||||||||||||||
1140 | { | - | ||||||||||||||||||
1141 | const EVP_MD *md, *mgf1md; | - | ||||||||||||||||||
1142 | RSA_OAEP_PARAMS *oaep = | - | ||||||||||||||||||
1143 | ((void *)0) | - | ||||||||||||||||||
1144 | ; | - | ||||||||||||||||||
1145 | ASN1_STRING *os = | - | ||||||||||||||||||
1146 | ((void *)0) | - | ||||||||||||||||||
1147 | ; | - | ||||||||||||||||||
1148 | X509_ALGOR *alg; | - | ||||||||||||||||||
1149 | EVP_PKEY_CTX *pkctx = CMS_RecipientInfo_get0_pkey_ctx(ri); | - | ||||||||||||||||||
1150 | int pad_mode = 1, rv = 0, labellen; | - | ||||||||||||||||||
1151 | unsigned char *label; | - | ||||||||||||||||||
1152 | - | |||||||||||||||||||
1153 | if (CMS_RecipientInfo_ktri_get0_algs(ri,
| 0-30 | ||||||||||||||||||
1154 | ((void *)0)
| 0-30 | ||||||||||||||||||
1155 | ,
| 0-30 | ||||||||||||||||||
1156 | ((void *)0)
| 0-30 | ||||||||||||||||||
1157 | , &alg) <= 0
| 0-30 | ||||||||||||||||||
1158 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||
1159 | if (pkctx
| 2-28 | ||||||||||||||||||
1160 | if (RSA_pkey_ctx_ctrl(pkctx, -1, (0x1000 + 6), 0, &pad_mode) <= 0
| 0-2 | ||||||||||||||||||
1161 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||
1162 | } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||||||||
1163 | if (pad_mode == 1
| 2-28 | ||||||||||||||||||
1164 | X509_ALGOR_set0(alg, OBJ_nid2obj(6), 5, 0); | - | ||||||||||||||||||
1165 | return executed 28 times by 1 test: 1;return 1; Executed by:
executed 28 times by 1 test: return 1; Executed by:
| 28 | ||||||||||||||||||
1166 | } | - | ||||||||||||||||||
1167 | - | |||||||||||||||||||
1168 | if (pad_mode != 4
| 0-2 | ||||||||||||||||||
1169 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||
1170 | if (EVP_PKEY_CTX_ctrl(pkctx, 6, ((1<<8) | (1<<9)), (0x1000 + 11), 0, (void *)(&md)) <= 0
| 0-2 | ||||||||||||||||||
1171 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
1172 | if (RSA_pkey_ctx_ctrl(pkctx, ((1<<3) | (1<<4) | (1<<5) | (1<<6) | (1<<7)) | ((1<<8) | (1<<9)), (0x1000 + 8), 0, (void *)(&mgf1md)) <= 0
| 0-2 | ||||||||||||||||||
1173 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
1174 | labellen = EVP_PKEY_CTX_ctrl(pkctx, 6, ((1<<8) | (1<<9)), (0x1000 + 12), 0, (void *)(&label)); | - | ||||||||||||||||||
1175 | if (labellen < 0
| 0-2 | ||||||||||||||||||
1176 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
1177 | oaep = RSA_OAEP_PARAMS_new(); | - | ||||||||||||||||||
1178 | if (oaep ==
| 0-2 | ||||||||||||||||||
1179 | ((void *)0)
| 0-2 | ||||||||||||||||||
1180 | ) | - | ||||||||||||||||||
1181 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
1182 | if (!rsa_md_to_algor(&oaep->hashFunc, md)
| 0-2 | ||||||||||||||||||
1183 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
1184 | if (!rsa_md_to_mgf1(&oaep->maskGenFunc, mgf1md)
| 0-2 | ||||||||||||||||||
1185 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
1186 | if (labellen > 0
| 0-2 | ||||||||||||||||||
1187 | ASN1_OCTET_STRING *los; | - | ||||||||||||||||||
1188 | oaep->pSourceFunc = X509_ALGOR_new(); | - | ||||||||||||||||||
1189 | if (oaep->pSourceFunc ==
| 0 | ||||||||||||||||||
1190 | ((void *)0)
| 0 | ||||||||||||||||||
1191 | ) | - | ||||||||||||||||||
1192 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
1193 | los = ASN1_OCTET_STRING_new(); | - | ||||||||||||||||||
1194 | if (los ==
| 0 | ||||||||||||||||||
1195 | ((void *)0)
| 0 | ||||||||||||||||||
1196 | ) | - | ||||||||||||||||||
1197 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
1198 | if (!ASN1_OCTET_STRING_set(los, label, labellen)
| 0 | ||||||||||||||||||
1199 | ASN1_OCTET_STRING_free(los); | - | ||||||||||||||||||
1200 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
1201 | } | - | ||||||||||||||||||
1202 | X509_ALGOR_set0(oaep->pSourceFunc, OBJ_nid2obj(935), | - | ||||||||||||||||||
1203 | 4, los); | - | ||||||||||||||||||
1204 | } never executed: end of block | 0 | ||||||||||||||||||
1205 | - | |||||||||||||||||||
1206 | if (!ASN1_item_pack(oaep, (&(RSA_OAEP_PARAMS_it)), &os)
| 0-2 | ||||||||||||||||||
1207 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
1208 | X509_ALGOR_set0(alg, OBJ_nid2obj(919), 16, os); | - | ||||||||||||||||||
1209 | os = | - | ||||||||||||||||||
1210 | ((void *)0) | - | ||||||||||||||||||
1211 | ; | - | ||||||||||||||||||
1212 | rv = 1; | - | ||||||||||||||||||
1213 | err: code before this statement executed 2 times by 1 test: err: Executed by:
| 2 | ||||||||||||||||||
1214 | RSA_OAEP_PARAMS_free(oaep); | - | ||||||||||||||||||
1215 | ASN1_STRING_free(os); | - | ||||||||||||||||||
1216 | return executed 2 times by 1 test: rv;return rv; Executed by:
executed 2 times by 1 test: return rv; Executed by:
| 2 | ||||||||||||||||||
1217 | } | - | ||||||||||||||||||
1218 | - | |||||||||||||||||||
1219 | - | |||||||||||||||||||
1220 | static int rsa_pkey_check(const EVP_PKEY *pkey) | - | ||||||||||||||||||
1221 | { | - | ||||||||||||||||||
1222 | return executed 2 times by 1 test: RSA_check_key_ex(pkey->pkey.rsa, return RSA_check_key_ex(pkey->pkey.rsa, ((void *)0) ); Executed by:
executed 2 times by 1 test: return RSA_check_key_ex(pkey->pkey.rsa, ((void *)0) ); Executed by:
| 2 | ||||||||||||||||||
1223 | ((void *)0) executed 2 times by 1 test: return RSA_check_key_ex(pkey->pkey.rsa, ((void *)0) ); Executed by:
| 2 | ||||||||||||||||||
1224 | ); executed 2 times by 1 test: return RSA_check_key_ex(pkey->pkey.rsa, ((void *)0) ); Executed by:
| 2 | ||||||||||||||||||
1225 | } | - | ||||||||||||||||||
1226 | - | |||||||||||||||||||
1227 | const EVP_PKEY_ASN1_METHOD rsa_asn1_meths[2] = { | - | ||||||||||||||||||
1228 | { | - | ||||||||||||||||||
1229 | 6, | - | ||||||||||||||||||
1230 | 6, | - | ||||||||||||||||||
1231 | 0x4, | - | ||||||||||||||||||
1232 | - | |||||||||||||||||||
1233 | "RSA", | - | ||||||||||||||||||
1234 | "OpenSSL RSA method", | - | ||||||||||||||||||
1235 | - | |||||||||||||||||||
1236 | rsa_pub_decode, | - | ||||||||||||||||||
1237 | rsa_pub_encode, | - | ||||||||||||||||||
1238 | rsa_pub_cmp, | - | ||||||||||||||||||
1239 | rsa_pub_print, | - | ||||||||||||||||||
1240 | - | |||||||||||||||||||
1241 | rsa_priv_decode, | - | ||||||||||||||||||
1242 | rsa_priv_encode, | - | ||||||||||||||||||
1243 | rsa_priv_print, | - | ||||||||||||||||||
1244 | - | |||||||||||||||||||
1245 | int_rsa_size, | - | ||||||||||||||||||
1246 | rsa_bits, | - | ||||||||||||||||||
1247 | rsa_security_bits, | - | ||||||||||||||||||
1248 | - | |||||||||||||||||||
1249 | 0, 0, 0, 0, 0, 0, | - | ||||||||||||||||||
1250 | - | |||||||||||||||||||
1251 | rsa_sig_print, | - | ||||||||||||||||||
1252 | int_rsa_free, | - | ||||||||||||||||||
1253 | rsa_pkey_ctrl, | - | ||||||||||||||||||
1254 | old_rsa_priv_decode, | - | ||||||||||||||||||
1255 | old_rsa_priv_encode, | - | ||||||||||||||||||
1256 | rsa_item_verify, | - | ||||||||||||||||||
1257 | rsa_item_sign, | - | ||||||||||||||||||
1258 | rsa_sig_info_set, | - | ||||||||||||||||||
1259 | rsa_pkey_check | - | ||||||||||||||||||
1260 | }, | - | ||||||||||||||||||
1261 | - | |||||||||||||||||||
1262 | { | - | ||||||||||||||||||
1263 | 19, | - | ||||||||||||||||||
1264 | 6, | - | ||||||||||||||||||
1265 | 0x1} | - | ||||||||||||||||||
1266 | }; | - | ||||||||||||||||||
1267 | - | |||||||||||||||||||
1268 | const EVP_PKEY_ASN1_METHOD rsa_pss_asn1_meth = { | - | ||||||||||||||||||
1269 | 912, | - | ||||||||||||||||||
1270 | 912, | - | ||||||||||||||||||
1271 | 0x4, | - | ||||||||||||||||||
1272 | - | |||||||||||||||||||
1273 | "RSA-PSS", | - | ||||||||||||||||||
1274 | "OpenSSL RSA-PSS method", | - | ||||||||||||||||||
1275 | - | |||||||||||||||||||
1276 | rsa_pub_decode, | - | ||||||||||||||||||
1277 | rsa_pub_encode, | - | ||||||||||||||||||
1278 | rsa_pub_cmp, | - | ||||||||||||||||||
1279 | rsa_pub_print, | - | ||||||||||||||||||
1280 | - | |||||||||||||||||||
1281 | rsa_priv_decode, | - | ||||||||||||||||||
1282 | rsa_priv_encode, | - | ||||||||||||||||||
1283 | rsa_priv_print, | - | ||||||||||||||||||
1284 | - | |||||||||||||||||||
1285 | int_rsa_size, | - | ||||||||||||||||||
1286 | rsa_bits, | - | ||||||||||||||||||
1287 | rsa_security_bits, | - | ||||||||||||||||||
1288 | - | |||||||||||||||||||
1289 | 0, 0, 0, 0, 0, 0, | - | ||||||||||||||||||
1290 | - | |||||||||||||||||||
1291 | rsa_sig_print, | - | ||||||||||||||||||
1292 | int_rsa_free, | - | ||||||||||||||||||
1293 | rsa_pkey_ctrl, | - | ||||||||||||||||||
1294 | 0, 0, | - | ||||||||||||||||||
1295 | rsa_item_verify, | - | ||||||||||||||||||
1296 | rsa_item_sign, | - | ||||||||||||||||||
1297 | 0, | - | ||||||||||||||||||
1298 | rsa_pkey_check | - | ||||||||||||||||||
1299 | }; | - | ||||||||||||||||||
Switch to Source code | Preprocessed file |