Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/openssl/src/ssl/t1_enc.c |
Switch to Source code | Preprocessed file |
Line | Source | Count | ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | - | |||||||||||||||||||||||||
2 | - | |||||||||||||||||||||||||
3 | - | |||||||||||||||||||||||||
4 | - | |||||||||||||||||||||||||
5 | static int tls1_PRF(SSL *s, | - | ||||||||||||||||||||||||
6 | const void *seed1, size_t seed1_len, | - | ||||||||||||||||||||||||
7 | const void *seed2, size_t seed2_len, | - | ||||||||||||||||||||||||
8 | const void *seed3, size_t seed3_len, | - | ||||||||||||||||||||||||
9 | const void *seed4, size_t seed4_len, | - | ||||||||||||||||||||||||
10 | const void *seed5, size_t seed5_len, | - | ||||||||||||||||||||||||
11 | const unsigned char *sec, size_t slen, | - | ||||||||||||||||||||||||
12 | unsigned char *out, size_t olen, int fatal) | - | ||||||||||||||||||||||||
13 | { | - | ||||||||||||||||||||||||
14 | const EVP_MD *md = ssl_prf_md(s); | - | ||||||||||||||||||||||||
15 | EVP_PKEY_CTX *pctx = | - | ||||||||||||||||||||||||
16 | ((void *)0) | - | ||||||||||||||||||||||||
17 | ; | - | ||||||||||||||||||||||||
18 | int ret = 0; | - | ||||||||||||||||||||||||
19 | - | |||||||||||||||||||||||||
20 | if (md ==
| 0-9903 | ||||||||||||||||||||||||
21 | ((void *)0)
| 0-9903 | ||||||||||||||||||||||||
22 | ) { | - | ||||||||||||||||||||||||
23 | - | |||||||||||||||||||||||||
24 | if (fatal
| 0 | ||||||||||||||||||||||||
25 | ossl_statem_fatal((s), (80), (284), ((4|64)), never executed: ossl_statem_fatal((s), (80), (284), ((4|64)), __FILE__ , 36 ) ; | 0 | ||||||||||||||||||||||||
26 | __FILE__ never executed: ossl_statem_fatal((s), (80), (284), ((4|64)), __FILE__ , 36 ) ; | 0 | ||||||||||||||||||||||||
27 | , never executed: ossl_statem_fatal((s), (80), (284), ((4|64)), __FILE__ , 36 ) ; | 0 | ||||||||||||||||||||||||
28 | 36 never executed: ossl_statem_fatal((s), (80), (284), ((4|64)), __FILE__ , 36 ) ; | 0 | ||||||||||||||||||||||||
29 | ) never executed: ossl_statem_fatal((s), (80), (284), ((4|64)), __FILE__ , 36 ) ; | 0 | ||||||||||||||||||||||||
30 | ; never executed: ossl_statem_fatal((s), (80), (284), ((4|64)), __FILE__ , 36 ) ; | 0 | ||||||||||||||||||||||||
31 | else | - | ||||||||||||||||||||||||
32 | ERR_put_error(20,(284),((4|64)),__FILE__,38); never executed: ERR_put_error(20,(284),((4|64)),__FILE__,38); | 0 | ||||||||||||||||||||||||
33 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||
34 | } | - | ||||||||||||||||||||||||
35 | pctx = EVP_PKEY_CTX_new_id(1021, | - | ||||||||||||||||||||||||
36 | ((void *)0) | - | ||||||||||||||||||||||||
37 | ); | - | ||||||||||||||||||||||||
38 | if (pctx ==
| 0-9903 | ||||||||||||||||||||||||
39 | ((void *)0)
| 0-9903 | ||||||||||||||||||||||||
40 | || EVP_PKEY_derive_init(pctx) <= 0
| 0-9903 | ||||||||||||||||||||||||
41 | || EVP_PKEY_CTX_ctrl(pctx, -1, (1<<10), (0x1000), 0, (void *)(md)) <= 0
| 0-9903 | ||||||||||||||||||||||||
42 | || EVP_PKEY_CTX_ctrl(pctx, -1, (1<<10), (0x1000 + 1), (int)slen, (void *)(sec)) <= 0
| 0-9903 | ||||||||||||||||||||||||
43 | || EVP_PKEY_CTX_ctrl(pctx, -1, (1<<10), (0x1000 + 2), (int)seed1_len, (void *)(seed1)) <= 0
| 0-9903 | ||||||||||||||||||||||||
44 | || EVP_PKEY_CTX_ctrl(pctx, -1, (1<<10), (0x1000 + 2), (int)seed2_len, (void *)(seed2)) <= 0
| 0-9903 | ||||||||||||||||||||||||
45 | || EVP_PKEY_CTX_ctrl(pctx, -1, (1<<10), (0x1000 + 2), (int)seed3_len, (void *)(seed3)) <= 0
| 0-9903 | ||||||||||||||||||||||||
46 | || EVP_PKEY_CTX_ctrl(pctx, -1, (1<<10), (0x1000 + 2), (int)seed4_len, (void *)(seed4)) <= 0
| 0-9903 | ||||||||||||||||||||||||
47 | || EVP_PKEY_CTX_ctrl(pctx, -1, (1<<10), (0x1000 + 2), (int)seed5_len, (void *)(seed5)) <= 0
| 0-9903 | ||||||||||||||||||||||||
48 | || EVP_PKEY_derive(pctx, out, &olen) <= 0
| 0-9903 | ||||||||||||||||||||||||
49 | if (fatal
| 0 | ||||||||||||||||||||||||
50 | ossl_statem_fatal((s), (80), (284), ((4|64)), never executed: ossl_statem_fatal((s), (80), (284), ((4|64)), __FILE__ , 53 ) ; | 0 | ||||||||||||||||||||||||
51 | __FILE__ never executed: ossl_statem_fatal((s), (80), (284), ((4|64)), __FILE__ , 53 ) ; | 0 | ||||||||||||||||||||||||
52 | , never executed: ossl_statem_fatal((s), (80), (284), ((4|64)), __FILE__ , 53 ) ; | 0 | ||||||||||||||||||||||||
53 | 53 never executed: ossl_statem_fatal((s), (80), (284), ((4|64)), __FILE__ , 53 ) ; | 0 | ||||||||||||||||||||||||
54 | ) never executed: ossl_statem_fatal((s), (80), (284), ((4|64)), __FILE__ , 53 ) ; | 0 | ||||||||||||||||||||||||
55 | ; never executed: ossl_statem_fatal((s), (80), (284), ((4|64)), __FILE__ , 53 ) ; | 0 | ||||||||||||||||||||||||
56 | else | - | ||||||||||||||||||||||||
57 | ERR_put_error(20,(284),((4|64)),__FILE__,55); never executed: ERR_put_error(20,(284),((4|64)),__FILE__,55); | 0 | ||||||||||||||||||||||||
58 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||||||||
59 | } | - | ||||||||||||||||||||||||
60 | - | |||||||||||||||||||||||||
61 | ret = 1; | - | ||||||||||||||||||||||||
62 | - | |||||||||||||||||||||||||
63 | err: code before this statement executed 9903 times by 1 test: err: Executed by:
| 9903 | ||||||||||||||||||||||||
64 | EVP_PKEY_CTX_free(pctx); | - | ||||||||||||||||||||||||
65 | return executed 9903 times by 1 test: ret;return ret; Executed by:
executed 9903 times by 1 test: return ret; Executed by:
| 9903 | ||||||||||||||||||||||||
66 | } | - | ||||||||||||||||||||||||
67 | - | |||||||||||||||||||||||||
68 | static int tls1_generate_key_block(SSL *s, unsigned char *km, size_t num) | - | ||||||||||||||||||||||||
69 | { | - | ||||||||||||||||||||||||
70 | int ret; | - | ||||||||||||||||||||||||
71 | - | |||||||||||||||||||||||||
72 | - | |||||||||||||||||||||||||
73 | ret = tls1_PRF(s, | - | ||||||||||||||||||||||||
74 | "key expansion", | - | ||||||||||||||||||||||||
75 | 13, s->s3->server_random, | - | ||||||||||||||||||||||||
76 | 32, s->s3->client_random, 32, | - | ||||||||||||||||||||||||
77 | - | |||||||||||||||||||||||||
78 | ((void *)0) | - | ||||||||||||||||||||||||
79 | , 0, | - | ||||||||||||||||||||||||
80 | ((void *)0) | - | ||||||||||||||||||||||||
81 | , 0, s->session->master_key, | - | ||||||||||||||||||||||||
82 | s->session->master_key_length, km, num, 1); | - | ||||||||||||||||||||||||
83 | - | |||||||||||||||||||||||||
84 | return executed 2685 times by 1 test: ret;return ret; Executed by:
executed 2685 times by 1 test: return ret; Executed by:
| 2685 | ||||||||||||||||||||||||
85 | } | - | ||||||||||||||||||||||||
86 | - | |||||||||||||||||||||||||
87 | int tls1_change_cipher_state(SSL *s, int which) | - | ||||||||||||||||||||||||
88 | { | - | ||||||||||||||||||||||||
89 | unsigned char *p, *mac_secret; | - | ||||||||||||||||||||||||
90 | unsigned char tmp1[64]; | - | ||||||||||||||||||||||||
91 | unsigned char tmp2[64]; | - | ||||||||||||||||||||||||
92 | unsigned char iv1[16 * 2]; | - | ||||||||||||||||||||||||
93 | unsigned char iv2[16 * 2]; | - | ||||||||||||||||||||||||
94 | unsigned char *ms, *key, *iv; | - | ||||||||||||||||||||||||
95 | EVP_CIPHER_CTX *dd; | - | ||||||||||||||||||||||||
96 | const EVP_CIPHER *c; | - | ||||||||||||||||||||||||
97 | - | |||||||||||||||||||||||||
98 | const SSL_COMP *comp; | - | ||||||||||||||||||||||||
99 | - | |||||||||||||||||||||||||
100 | const EVP_MD *m; | - | ||||||||||||||||||||||||
101 | int mac_type; | - | ||||||||||||||||||||||||
102 | size_t *mac_secret_size; | - | ||||||||||||||||||||||||
103 | EVP_MD_CTX *mac_ctx; | - | ||||||||||||||||||||||||
104 | EVP_PKEY *mac_key; | - | ||||||||||||||||||||||||
105 | size_t n, i, j, k, cl; | - | ||||||||||||||||||||||||
106 | int reuse_dd = 0; | - | ||||||||||||||||||||||||
107 | - | |||||||||||||||||||||||||
108 | c = s->s3->tmp.new_sym_enc; | - | ||||||||||||||||||||||||
109 | m = s->s3->tmp.new_hash; | - | ||||||||||||||||||||||||
110 | mac_type = s->s3->tmp.new_mac_pkey_type; | - | ||||||||||||||||||||||||
111 | - | |||||||||||||||||||||||||
112 | comp = s->s3->tmp.new_compression; | - | ||||||||||||||||||||||||
113 | - | |||||||||||||||||||||||||
114 | - | |||||||||||||||||||||||||
115 | if (which & 0x001
| 2469-2522 | ||||||||||||||||||||||||
116 | if (s->ext.use_etm
| 1085-1384 | ||||||||||||||||||||||||
117 | s->s3->flags |= 0x0100; executed 1085 times by 1 test: s->s3->flags |= 0x0100; Executed by:
| 1085 | ||||||||||||||||||||||||
118 | else | - | ||||||||||||||||||||||||
119 | s->s3->flags &= ~0x0100; executed 1384 times by 1 test: s->s3->flags &= ~0x0100; Executed by:
| 1384 | ||||||||||||||||||||||||
120 | - | |||||||||||||||||||||||||
121 | if (s->s3->tmp.new_cipher->algorithm2 & 0x10000
| 0-2469 | ||||||||||||||||||||||||
122 | s->mac_flags |= 1; never executed: s->mac_flags |= 1; | 0 | ||||||||||||||||||||||||
123 | else | - | ||||||||||||||||||||||||
124 | s->mac_flags &= ~1; executed 2469 times by 1 test: s->mac_flags &= ~1; Executed by:
| 2469 | ||||||||||||||||||||||||
125 | - | |||||||||||||||||||||||||
126 | if (s->enc_read_ctx !=
| 44-2425 | ||||||||||||||||||||||||
127 | ((void *)0)
| 44-2425 | ||||||||||||||||||||||||
128 | ) { | - | ||||||||||||||||||||||||
129 | reuse_dd = 1; | - | ||||||||||||||||||||||||
130 | } executed 44 times by 1 test: else if ((end of block Executed by:
| 0-2425 | ||||||||||||||||||||||||
131 | ((void *)0)
| 0-2425 | ||||||||||||||||||||||||
132 | ) { | - | ||||||||||||||||||||||||
133 | ossl_statem_fatal((s), (80), (209), ((1|64)), | - | ||||||||||||||||||||||||
134 | __FILE__ | - | ||||||||||||||||||||||||
135 | , | - | ||||||||||||||||||||||||
136 | 124 | - | ||||||||||||||||||||||||
137 | ) | - | ||||||||||||||||||||||||
138 | ; | - | ||||||||||||||||||||||||
139 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||||||||
140 | } else { | - | ||||||||||||||||||||||||
141 | - | |||||||||||||||||||||||||
142 | - | |||||||||||||||||||||||||
143 | - | |||||||||||||||||||||||||
144 | EVP_CIPHER_CTX_reset(s->enc_read_ctx); | - | ||||||||||||||||||||||||
145 | } executed 2425 times by 1 test: end of block Executed by:
| 2425 | ||||||||||||||||||||||||
146 | dd = s->enc_read_ctx; | - | ||||||||||||||||||||||||
147 | mac_ctx = ssl_replace_hash(&s->read_hash, | - | ||||||||||||||||||||||||
148 | ((void *)0) | - | ||||||||||||||||||||||||
149 | ); | - | ||||||||||||||||||||||||
150 | if (mac_ctx ==
| 0-2469 | ||||||||||||||||||||||||
151 | ((void *)0)
| 0-2469 | ||||||||||||||||||||||||
152 | ) | - | ||||||||||||||||||||||||
153 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||||||||
154 | - | |||||||||||||||||||||||||
155 | COMP_CTX_free(s->expand); | - | ||||||||||||||||||||||||
156 | s->expand = | - | ||||||||||||||||||||||||
157 | ((void *)0) | - | ||||||||||||||||||||||||
158 | ; | - | ||||||||||||||||||||||||
159 | if (comp !=
| 0-2469 | ||||||||||||||||||||||||
160 | ((void *)0)
| 0-2469 | ||||||||||||||||||||||||
161 | ) { | - | ||||||||||||||||||||||||
162 | s->expand = COMP_CTX_new(comp->method); | - | ||||||||||||||||||||||||
163 | if (s->expand ==
| 0 | ||||||||||||||||||||||||
164 | ((void *)0)
| 0 | ||||||||||||||||||||||||
165 | ) { | - | ||||||||||||||||||||||||
166 | ossl_statem_fatal((s), (80), (209), (142), | - | ||||||||||||||||||||||||
167 | - | |||||||||||||||||||||||||
168 | __FILE__ | - | ||||||||||||||||||||||||
169 | , | - | ||||||||||||||||||||||||
170 | - | |||||||||||||||||||||||||
171 | 144 | - | ||||||||||||||||||||||||
172 | ) | - | ||||||||||||||||||||||||
173 | - | |||||||||||||||||||||||||
174 | ; | - | ||||||||||||||||||||||||
175 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||||||||
176 | } | - | ||||||||||||||||||||||||
177 | } never executed: end of block | 0 | ||||||||||||||||||||||||
178 | - | |||||||||||||||||||||||||
179 | - | |||||||||||||||||||||||||
180 | - | |||||||||||||||||||||||||
181 | - | |||||||||||||||||||||||||
182 | if (!(s->method->ssl3_enc->enc_flags & 0x8)
| 355-2114 | ||||||||||||||||||||||||
183 | RECORD_LAYER_reset_read_sequence(&s->rlayer); executed 2114 times by 1 test: RECORD_LAYER_reset_read_sequence(&s->rlayer); Executed by:
| 2114 | ||||||||||||||||||||||||
184 | mac_secret = &(s->s3->read_mac_secret[0]); | - | ||||||||||||||||||||||||
185 | mac_secret_size = &(s->s3->read_mac_secret_size); | - | ||||||||||||||||||||||||
186 | } executed 2469 times by 1 test: else {end of block Executed by:
| 2469 | ||||||||||||||||||||||||
187 | s->statem.enc_write_state = ENC_WRITE_STATE_INVALID; | - | ||||||||||||||||||||||||
188 | if (s->ext.use_etm
| 1137-1385 | ||||||||||||||||||||||||
189 | s->s3->flags |= 0x0400; executed 1137 times by 1 test: s->s3->flags |= 0x0400; Executed by:
| 1137 | ||||||||||||||||||||||||
190 | else | - | ||||||||||||||||||||||||
191 | s->s3->flags &= ~0x0400; executed 1385 times by 1 test: s->s3->flags &= ~0x0400; Executed by:
| 1385 | ||||||||||||||||||||||||
192 | - | |||||||||||||||||||||||||
193 | if (s->s3->tmp.new_cipher->algorithm2 & 0x10000
| 0-2522 | ||||||||||||||||||||||||
194 | s->mac_flags |= 2; never executed: s->mac_flags |= 2; | 0 | ||||||||||||||||||||||||
195 | else | - | ||||||||||||||||||||||||
196 | s->mac_flags &= ~2; executed 2522 times by 1 test: s->mac_flags &= ~2; Executed by:
| 2522 | ||||||||||||||||||||||||
197 | if (s->enc_write_ctx !=
| 44-2478 | ||||||||||||||||||||||||
198 | ((void *)0)
| 44-2478 | ||||||||||||||||||||||||
199 | && !(s->method->ssl3_enc->enc_flags & 0x8)
| 18-26 | ||||||||||||||||||||||||
200 | reuse_dd = 1; | - | ||||||||||||||||||||||||
201 | } executed 26 times by 1 test: else if ((end of block Executed by:
| 0-2496 | ||||||||||||||||||||||||
202 | ((void *)0)
| 0-2496 | ||||||||||||||||||||||||
203 | ) { | - | ||||||||||||||||||||||||
204 | ossl_statem_fatal((s), (80), (209), ((1|64)), | - | ||||||||||||||||||||||||
205 | __FILE__ | - | ||||||||||||||||||||||||
206 | , | - | ||||||||||||||||||||||||
207 | 171 | - | ||||||||||||||||||||||||
208 | ) | - | ||||||||||||||||||||||||
209 | ; | - | ||||||||||||||||||||||||
210 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||||||||
211 | } | - | ||||||||||||||||||||||||
212 | dd = s->enc_write_ctx; | - | ||||||||||||||||||||||||
213 | if ((
| 359-2163 | ||||||||||||||||||||||||
214 | mac_ctx = EVP_MD_CTX_new(); | - | ||||||||||||||||||||||||
215 | if (mac_ctx ==
| 0-359 | ||||||||||||||||||||||||
216 | ((void *)0)
| 0-359 | ||||||||||||||||||||||||
217 | ) { | - | ||||||||||||||||||||||||
218 | ossl_statem_fatal((s), (80), (209), ((1|64)), | - | ||||||||||||||||||||||||
219 | - | |||||||||||||||||||||||||
220 | __FILE__ | - | ||||||||||||||||||||||||
221 | , | - | ||||||||||||||||||||||||
222 | - | |||||||||||||||||||||||||
223 | 180 | - | ||||||||||||||||||||||||
224 | ) | - | ||||||||||||||||||||||||
225 | - | |||||||||||||||||||||||||
226 | ; | - | ||||||||||||||||||||||||
227 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||||||||
228 | } | - | ||||||||||||||||||||||||
229 | s->write_hash = mac_ctx; | - | ||||||||||||||||||||||||
230 | } executed 359 times by 1 test: else {end of block Executed by:
| 359 | ||||||||||||||||||||||||
231 | mac_ctx = ssl_replace_hash(&s->write_hash, | - | ||||||||||||||||||||||||
232 | ((void *)0) | - | ||||||||||||||||||||||||
233 | ); | - | ||||||||||||||||||||||||
234 | if (mac_ctx ==
| 0-2163 | ||||||||||||||||||||||||
235 | ((void *)0)
| 0-2163 | ||||||||||||||||||||||||
236 | ) { | - | ||||||||||||||||||||||||
237 | ossl_statem_fatal((s), (80), (209), ((1|64)), | - | ||||||||||||||||||||||||
238 | - | |||||||||||||||||||||||||
239 | __FILE__ | - | ||||||||||||||||||||||||
240 | , | - | ||||||||||||||||||||||||
241 | - | |||||||||||||||||||||||||
242 | 189 | - | ||||||||||||||||||||||||
243 | ) | - | ||||||||||||||||||||||||
244 | - | |||||||||||||||||||||||||
245 | ; | - | ||||||||||||||||||||||||
246 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||||||||
247 | } | - | ||||||||||||||||||||||||
248 | } executed 2163 times by 1 test: end of block Executed by:
| 2163 | ||||||||||||||||||||||||
249 | - | |||||||||||||||||||||||||
250 | COMP_CTX_free(s->compress); | - | ||||||||||||||||||||||||
251 | s->compress = | - | ||||||||||||||||||||||||
252 | ((void *)0) | - | ||||||||||||||||||||||||
253 | ; | - | ||||||||||||||||||||||||
254 | if (comp !=
| 0-2522 | ||||||||||||||||||||||||
255 | ((void *)0)
| 0-2522 | ||||||||||||||||||||||||
256 | ) { | - | ||||||||||||||||||||||||
257 | s->compress = COMP_CTX_new(comp->method); | - | ||||||||||||||||||||||||
258 | if (s->compress ==
| 0 | ||||||||||||||||||||||||
259 | ((void *)0)
| 0 | ||||||||||||||||||||||||
260 | ) { | - | ||||||||||||||||||||||||
261 | ossl_statem_fatal((s), (80), (209), (142), | - | ||||||||||||||||||||||||
262 | - | |||||||||||||||||||||||||
263 | __FILE__ | - | ||||||||||||||||||||||||
264 | , | - | ||||||||||||||||||||||||
265 | - | |||||||||||||||||||||||||
266 | 201 | - | ||||||||||||||||||||||||
267 | ) | - | ||||||||||||||||||||||||
268 | - | |||||||||||||||||||||||||
269 | ; | - | ||||||||||||||||||||||||
270 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||||||||
271 | } | - | ||||||||||||||||||||||||
272 | } never executed: end of block | 0 | ||||||||||||||||||||||||
273 | - | |||||||||||||||||||||||||
274 | - | |||||||||||||||||||||||||
275 | - | |||||||||||||||||||||||||
276 | - | |||||||||||||||||||||||||
277 | if (!(s->method->ssl3_enc->enc_flags & 0x8)
| 359-2163 | ||||||||||||||||||||||||
278 | RECORD_LAYER_reset_write_sequence(&s->rlayer); executed 2163 times by 1 test: RECORD_LAYER_reset_write_sequence(&s->rlayer); Executed by:
| 2163 | ||||||||||||||||||||||||
279 | mac_secret = &(s->s3->write_mac_secret[0]); | - | ||||||||||||||||||||||||
280 | mac_secret_size = &(s->s3->write_mac_secret_size); | - | ||||||||||||||||||||||||
281 | } executed 2522 times by 1 test: end of block Executed by:
| 2522 | ||||||||||||||||||||||||
282 | - | |||||||||||||||||||||||||
283 | if (reuse_dd
| 70-4921 | ||||||||||||||||||||||||
284 | EVP_CIPHER_CTX_reset(dd); executed 70 times by 1 test: EVP_CIPHER_CTX_reset(dd); Executed by:
| 70 | ||||||||||||||||||||||||
285 | - | |||||||||||||||||||||||||
286 | p = s->s3->tmp.key_block; | - | ||||||||||||||||||||||||
287 | i = *mac_secret_size = s->s3->tmp.new_mac_secret_size; | - | ||||||||||||||||||||||||
288 | - | |||||||||||||||||||||||||
289 | - | |||||||||||||||||||||||||
290 | cl = EVP_CIPHER_key_length(c); | - | ||||||||||||||||||||||||
291 | j = cl; | - | ||||||||||||||||||||||||
292 | - | |||||||||||||||||||||||||
293 | - | |||||||||||||||||||||||||
294 | if ((
| 2070-2921 | ||||||||||||||||||||||||
295 | k = 4; executed 2070 times by 1 test: k = 4; Executed by:
| 2070 | ||||||||||||||||||||||||
296 | else if ((
| 126-2795 | ||||||||||||||||||||||||
297 | k = 4; executed 126 times by 1 test: k = 4; Executed by:
| 126 | ||||||||||||||||||||||||
298 | else | - | ||||||||||||||||||||||||
299 | k = EVP_CIPHER_iv_length(c); executed 2795 times by 1 test: k = EVP_CIPHER_iv_length(c); Executed by:
| 2795 | ||||||||||||||||||||||||
300 | if ((
| 1456-3535 | ||||||||||||||||||||||||
301 | (
| 1217-2318 | ||||||||||||||||||||||||
302 | ms = &(p[0]); | - | ||||||||||||||||||||||||
303 | n = i + i; | - | ||||||||||||||||||||||||
304 | key = &(p[n]); | - | ||||||||||||||||||||||||
305 | n += j + j; | - | ||||||||||||||||||||||||
306 | iv = &(p[n]); | - | ||||||||||||||||||||||||
307 | n += k + k; | - | ||||||||||||||||||||||||
308 | } executed 2673 times by 1 test: else {end of block Executed by:
| 2673 | ||||||||||||||||||||||||
309 | n = i; | - | ||||||||||||||||||||||||
310 | ms = &(p[n]); | - | ||||||||||||||||||||||||
311 | n += i + j; | - | ||||||||||||||||||||||||
312 | key = &(p[n]); | - | ||||||||||||||||||||||||
313 | n += j + k; | - | ||||||||||||||||||||||||
314 | iv = &(p[n]); | - | ||||||||||||||||||||||||
315 | n += k; | - | ||||||||||||||||||||||||
316 | } executed 2318 times by 1 test: end of block Executed by:
| 2318 | ||||||||||||||||||||||||
317 | - | |||||||||||||||||||||||||
318 | if (n > s->s3->tmp.key_block_length
| 0-4991 | ||||||||||||||||||||||||
319 | ossl_statem_fatal((s), (80), (209), ((4|64)), | - | ||||||||||||||||||||||||
320 | __FILE__ | - | ||||||||||||||||||||||||
321 | , | - | ||||||||||||||||||||||||
322 | 252 | - | ||||||||||||||||||||||||
323 | ) | - | ||||||||||||||||||||||||
324 | ; | - | ||||||||||||||||||||||||
325 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||||||||
326 | } | - | ||||||||||||||||||||||||
327 | - | |||||||||||||||||||||||||
328 | memcpy(mac_secret, ms, i); | - | ||||||||||||||||||||||||
329 | - | |||||||||||||||||||||||||
330 | if (!(EVP_CIPHER_flags(c) & 0x200000)
| 2245-2746 | ||||||||||||||||||||||||
331 | - | |||||||||||||||||||||||||
332 | mac_key = EVP_PKEY_new_mac_key(mac_type, | - | ||||||||||||||||||||||||
333 | ((void *)0) | - | ||||||||||||||||||||||||
334 | , mac_secret, | - | ||||||||||||||||||||||||
335 | (int)*mac_secret_size); | - | ||||||||||||||||||||||||
336 | if (mac_key ==
| 0-2746 | ||||||||||||||||||||||||
337 | ((void *)0)
| 0-2746 | ||||||||||||||||||||||||
338 | - | |||||||||||||||||||||||||
339 | || EVP_DigestSignInit(mac_ctx,
| 0-2746 | ||||||||||||||||||||||||
340 | ((void *)0)
| 0-2746 | ||||||||||||||||||||||||
341 | , m,
| 0-2746 | ||||||||||||||||||||||||
342 | ((void *)0)
| 0-2746 | ||||||||||||||||||||||||
343 | , mac_key) <= 0
| 0-2746 | ||||||||||||||||||||||||
344 | EVP_PKEY_free(mac_key); | - | ||||||||||||||||||||||||
345 | ossl_statem_fatal((s), (80), (209), ((4|64)), | - | ||||||||||||||||||||||||
346 | __FILE__ | - | ||||||||||||||||||||||||
347 | , | - | ||||||||||||||||||||||||
348 | 266 | - | ||||||||||||||||||||||||
349 | ) | - | ||||||||||||||||||||||||
350 | ; | - | ||||||||||||||||||||||||
351 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||||||||
352 | } | - | ||||||||||||||||||||||||
353 | EVP_PKEY_free(mac_key); | - | ||||||||||||||||||||||||
354 | } executed 2746 times by 1 test: end of block Executed by:
| 2746 | ||||||||||||||||||||||||
355 | if ((
| 2070-2921 | ||||||||||||||||||||||||
356 | if (!EVP_CipherInit_ex(dd, c,
| 0-2070 | ||||||||||||||||||||||||
357 | ((void *)0)
| 0-2070 | ||||||||||||||||||||||||
358 | , key,
| 0-2070 | ||||||||||||||||||||||||
359 | ((void *)0)
| 0-2070 | ||||||||||||||||||||||||
360 | , (which & 0x002))
| 0-2070 | ||||||||||||||||||||||||
361 | || !EVP_CIPHER_CTX_ctrl(dd, 0x12, (int)k,
| 0-2070 | ||||||||||||||||||||||||
362 | iv)
| 0-2070 | ||||||||||||||||||||||||
363 | ossl_statem_fatal((s), (80), (209), ((4|64)), | - | ||||||||||||||||||||||||
364 | __FILE__ | - | ||||||||||||||||||||||||
365 | , | - | ||||||||||||||||||||||||
366 | 285 | - | ||||||||||||||||||||||||
367 | ) | - | ||||||||||||||||||||||||
368 | ; | - | ||||||||||||||||||||||||
369 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||||||||
370 | } | - | ||||||||||||||||||||||||
371 | } executed 2070 times by 1 test: else if ((end of block Executed by:
| 126-2795 | ||||||||||||||||||||||||
372 | int taglen; | - | ||||||||||||||||||||||||
373 | if (s->s3->tmp.
| 59-67 | ||||||||||||||||||||||||
374 | new_cipher->algorithm_enc & (0x00010000U | 0x00020000U)
| 59-67 | ||||||||||||||||||||||||
375 | taglen = 8; executed 59 times by 1 test: taglen = 8; Executed by:
| 59 | ||||||||||||||||||||||||
376 | else | - | ||||||||||||||||||||||||
377 | taglen = 16; executed 67 times by 1 test: taglen = 16; Executed by:
| 67 | ||||||||||||||||||||||||
378 | if (!EVP_CipherInit_ex(dd, c,
| 0-126 | ||||||||||||||||||||||||
379 | ((void *)0)
| 0-126 | ||||||||||||||||||||||||
380 | ,
| 0-126 | ||||||||||||||||||||||||
381 | ((void *)0)
| 0-126 | ||||||||||||||||||||||||
382 | ,
| 0-126 | ||||||||||||||||||||||||
383 | ((void *)0)
| 0-126 | ||||||||||||||||||||||||
384 | , (which & 0x002))
| 0-126 | ||||||||||||||||||||||||
385 | || !EVP_CIPHER_CTX_ctrl(dd, 0x9, 12,
| 0-126 | ||||||||||||||||||||||||
386 | ((void *)0)
| 0-126 | ||||||||||||||||||||||||
387 | )
| 0-126 | ||||||||||||||||||||||||
388 | || !EVP_CIPHER_CTX_ctrl(dd, 0x11, taglen,
| 0-126 | ||||||||||||||||||||||||
389 | ((void *)0)
| 0-126 | ||||||||||||||||||||||||
390 | )
| 0-126 | ||||||||||||||||||||||||
391 | || !EVP_CIPHER_CTX_ctrl(dd, 0x12, (int)k, iv)
| 0-126 | ||||||||||||||||||||||||
392 | || !EVP_CipherInit_ex(dd,
| 0-126 | ||||||||||||||||||||||||
393 | ((void *)0)
| 0-126 | ||||||||||||||||||||||||
394 | ,
| 0-126 | ||||||||||||||||||||||||
395 | ((void *)0)
| 0-126 | ||||||||||||||||||||||||
396 | , key,
| 0-126 | ||||||||||||||||||||||||
397 | ((void *)0)
| 0-126 | ||||||||||||||||||||||||
398 | , -1)
| 0-126 | ||||||||||||||||||||||||
399 | ossl_statem_fatal((s), (80), (209), ((4|64)), | - | ||||||||||||||||||||||||
400 | __FILE__ | - | ||||||||||||||||||||||||
401 | , | - | ||||||||||||||||||||||||
402 | 301 | - | ||||||||||||||||||||||||
403 | ) | - | ||||||||||||||||||||||||
404 | ; | - | ||||||||||||||||||||||||
405 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||||||||
406 | } | - | ||||||||||||||||||||||||
407 | } executed 126 times by 1 test: else {end of block Executed by:
| 126 | ||||||||||||||||||||||||
408 | if (!EVP_CipherInit_ex(dd, c,
| 0-2795 | ||||||||||||||||||||||||
409 | ((void *)0)
| 0-2795 | ||||||||||||||||||||||||
410 | , key, iv, (which & 0x002))
| 0-2795 | ||||||||||||||||||||||||
411 | ossl_statem_fatal((s), (80), (209), ((4|64)), | - | ||||||||||||||||||||||||
412 | __FILE__ | - | ||||||||||||||||||||||||
413 | , | - | ||||||||||||||||||||||||
414 | 307 | - | ||||||||||||||||||||||||
415 | ) | - | ||||||||||||||||||||||||
416 | ; | - | ||||||||||||||||||||||||
417 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||||||||
418 | } | - | ||||||||||||||||||||||||
419 | } executed 2795 times by 1 test: end of block Executed by:
| 2795 | ||||||||||||||||||||||||
420 | - | |||||||||||||||||||||||||
421 | if ((
| 0-2746 | ||||||||||||||||||||||||
422 | && !EVP_CIPHER_CTX_ctrl(dd, 0x17,
| 0 | ||||||||||||||||||||||||
423 | (int)*mac_secret_size, mac_secret)
| 0 | ||||||||||||||||||||||||
424 | ossl_statem_fatal((s), (80), (209), ((4|64)), | - | ||||||||||||||||||||||||
425 | __FILE__ | - | ||||||||||||||||||||||||
426 | , | - | ||||||||||||||||||||||||
427 | 316 | - | ||||||||||||||||||||||||
428 | ) | - | ||||||||||||||||||||||||
429 | ; | - | ||||||||||||||||||||||||
430 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||||||||
431 | } | - | ||||||||||||||||||||||||
432 | s->statem.enc_write_state = ENC_WRITE_STATE_VALID; | - | ||||||||||||||||||||||||
433 | OPENSSL_cleanse(tmp1, sizeof(tmp1)); | - | ||||||||||||||||||||||||
434 | OPENSSL_cleanse(tmp2, sizeof(tmp1)); | - | ||||||||||||||||||||||||
435 | OPENSSL_cleanse(iv1, sizeof(iv1)); | - | ||||||||||||||||||||||||
436 | OPENSSL_cleanse(iv2, sizeof(iv2)); | - | ||||||||||||||||||||||||
437 | return executed 4991 times by 1 test: 1;return 1; Executed by:
executed 4991 times by 1 test: return 1; Executed by:
| 4991 | ||||||||||||||||||||||||
438 | err: | - | ||||||||||||||||||||||||
439 | OPENSSL_cleanse(tmp1, sizeof(tmp1)); | - | ||||||||||||||||||||||||
440 | OPENSSL_cleanse(tmp2, sizeof(tmp1)); | - | ||||||||||||||||||||||||
441 | OPENSSL_cleanse(iv1, sizeof(iv1)); | - | ||||||||||||||||||||||||
442 | OPENSSL_cleanse(iv2, sizeof(iv2)); | - | ||||||||||||||||||||||||
443 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||
444 | } | - | ||||||||||||||||||||||||
445 | - | |||||||||||||||||||||||||
446 | int tls1_setup_key_block(SSL *s) | - | ||||||||||||||||||||||||
447 | { | - | ||||||||||||||||||||||||
448 | unsigned char *p; | - | ||||||||||||||||||||||||
449 | const EVP_CIPHER *c; | - | ||||||||||||||||||||||||
450 | const EVP_MD *hash; | - | ||||||||||||||||||||||||
451 | SSL_COMP *comp; | - | ||||||||||||||||||||||||
452 | int mac_type = 0; | - | ||||||||||||||||||||||||
453 | size_t num, mac_secret_size = 0; | - | ||||||||||||||||||||||||
454 | int ret = 0; | - | ||||||||||||||||||||||||
455 | - | |||||||||||||||||||||||||
456 | if (s->s3->tmp.key_block_length != 0
| 1047-2685 | ||||||||||||||||||||||||
457 | return executed 1047 times by 1 test: 1;return 1; Executed by:
executed 1047 times by 1 test: return 1; Executed by:
| 1047 | ||||||||||||||||||||||||
458 | - | |||||||||||||||||||||||||
459 | if (!ssl_cipher_get_evp(s->session, &c, &hash, &mac_type, &mac_secret_size,
| 0-2685 | ||||||||||||||||||||||||
460 | &comp, s->ext.use_etm)
| 0-2685 | ||||||||||||||||||||||||
461 | ossl_statem_fatal((s), (80), (211), (138), | - | ||||||||||||||||||||||||
462 | __FILE__ | - | ||||||||||||||||||||||||
463 | , | - | ||||||||||||||||||||||||
464 | 366 | - | ||||||||||||||||||||||||
465 | ) | - | ||||||||||||||||||||||||
466 | ; | - | ||||||||||||||||||||||||
467 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||
468 | } | - | ||||||||||||||||||||||||
469 | - | |||||||||||||||||||||||||
470 | s->s3->tmp.new_sym_enc = c; | - | ||||||||||||||||||||||||
471 | s->s3->tmp.new_hash = hash; | - | ||||||||||||||||||||||||
472 | s->s3->tmp.new_mac_pkey_type = mac_type; | - | ||||||||||||||||||||||||
473 | s->s3->tmp.new_mac_secret_size = mac_secret_size; | - | ||||||||||||||||||||||||
474 | num = EVP_CIPHER_key_length(c) + mac_secret_size + EVP_CIPHER_iv_length(c); | - | ||||||||||||||||||||||||
475 | num *= 2; | - | ||||||||||||||||||||||||
476 | - | |||||||||||||||||||||||||
477 | ssl3_cleanup_key_block(s); | - | ||||||||||||||||||||||||
478 | - | |||||||||||||||||||||||||
479 | if ((
| 0-2685 | ||||||||||||||||||||||||
480 | ((void *)0)
| 0-2685 | ||||||||||||||||||||||||
481 | ) { | - | ||||||||||||||||||||||||
482 | ossl_statem_fatal((s), (80), (211), ((1|64)), | - | ||||||||||||||||||||||||
483 | __FILE__ | - | ||||||||||||||||||||||||
484 | , | - | ||||||||||||||||||||||||
485 | 381 | - | ||||||||||||||||||||||||
486 | ) | - | ||||||||||||||||||||||||
487 | ; | - | ||||||||||||||||||||||||
488 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||||||||
489 | } | - | ||||||||||||||||||||||||
490 | - | |||||||||||||||||||||||||
491 | s->s3->tmp.key_block_length = num; | - | ||||||||||||||||||||||||
492 | s->s3->tmp.key_block = p; | - | ||||||||||||||||||||||||
493 | if (!tls1_generate_key_block(s, p, num)
| 0-2685 | ||||||||||||||||||||||||
494 | - | |||||||||||||||||||||||||
495 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||||||||
496 | } | - | ||||||||||||||||||||||||
497 | if (!(s->options & 0x00000800U)
| 0-2685 | ||||||||||||||||||||||||
498 | && s->method->version <= 0x0301
| 477-2208 | ||||||||||||||||||||||||
499 | - | |||||||||||||||||||||||||
500 | - | |||||||||||||||||||||||||
501 | - | |||||||||||||||||||||||||
502 | - | |||||||||||||||||||||||||
503 | s->s3->need_empty_fragments = 1; | - | ||||||||||||||||||||||||
504 | - | |||||||||||||||||||||||||
505 | if (s->session->cipher !=
| 0-477 | ||||||||||||||||||||||||
506 | ((void *)0)
| 0-477 | ||||||||||||||||||||||||
507 | ) { | - | ||||||||||||||||||||||||
508 | if (s->session->cipher->algorithm_enc == 0x00000020U
| 10-467 | ||||||||||||||||||||||||
509 | s->s3->need_empty_fragments = 0; executed 10 times by 1 test: s->s3->need_empty_fragments = 0; Executed by:
| 10 | ||||||||||||||||||||||||
510 | - | |||||||||||||||||||||||||
511 | - | |||||||||||||||||||||||||
512 | if (s->session->cipher->algorithm_enc == 0x00000004U
| 0-477 | ||||||||||||||||||||||||
513 | s->s3->need_empty_fragments = 0; never executed: s->s3->need_empty_fragments = 0; | 0 | ||||||||||||||||||||||||
514 | - | |||||||||||||||||||||||||
515 | } executed 477 times by 1 test: end of block Executed by:
| 477 | ||||||||||||||||||||||||
516 | } executed 477 times by 1 test: end of block Executed by:
| 477 | ||||||||||||||||||||||||
517 | - | |||||||||||||||||||||||||
518 | ret = 1; | - | ||||||||||||||||||||||||
519 | err: code before this statement executed 2685 times by 1 test: err: Executed by:
| 2685 | ||||||||||||||||||||||||
520 | return executed 2685 times by 1 test: ret;return ret; Executed by:
executed 2685 times by 1 test: return ret; Executed by:
| 2685 | ||||||||||||||||||||||||
521 | } | - | ||||||||||||||||||||||||
522 | - | |||||||||||||||||||||||||
523 | size_t tls1_final_finish_mac(SSL *s, const char *str, size_t slen, | - | ||||||||||||||||||||||||
524 | unsigned char *out) | - | ||||||||||||||||||||||||
525 | { | - | ||||||||||||||||||||||||
526 | size_t hashlen; | - | ||||||||||||||||||||||||
527 | unsigned char hash[64]; | - | ||||||||||||||||||||||||
528 | - | |||||||||||||||||||||||||
529 | if (!ssl3_digest_cached_records(s, 0)
| 0-4618 | ||||||||||||||||||||||||
530 | - | |||||||||||||||||||||||||
531 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||
532 | } | - | ||||||||||||||||||||||||
533 | - | |||||||||||||||||||||||||
534 | if (!ssl_handshake_hash(s, hash, sizeof(hash), &hashlen)
| 0-4618 | ||||||||||||||||||||||||
535 | - | |||||||||||||||||||||||||
536 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||
537 | } | - | ||||||||||||||||||||||||
538 | - | |||||||||||||||||||||||||
539 | if (!tls1_PRF(s, str, slen, hash, hashlen,
| 0-4618 | ||||||||||||||||||||||||
540 | ((void *)0)
| 0-4618 | ||||||||||||||||||||||||
541 | , 0,
| 0-4618 | ||||||||||||||||||||||||
542 | ((void *)0)
| 0-4618 | ||||||||||||||||||||||||
543 | , 0,
| 0-4618 | ||||||||||||||||||||||||
544 | ((void *)0)
| 0-4618 | ||||||||||||||||||||||||
545 | , 0,
| 0-4618 | ||||||||||||||||||||||||
546 | s->session->master_key, s->session->master_key_length,
| 0-4618 | ||||||||||||||||||||||||
547 | out, 12, 1)
| 0-4618 | ||||||||||||||||||||||||
548 | - | |||||||||||||||||||||||||
549 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||
550 | } | - | ||||||||||||||||||||||||
551 | OPENSSL_cleanse(hash, hashlen); | - | ||||||||||||||||||||||||
552 | return executed 4618 times by 1 test: 12;return 12; Executed by:
executed 4618 times by 1 test: return 12; Executed by:
| 4618 | ||||||||||||||||||||||||
553 | } | - | ||||||||||||||||||||||||
554 | - | |||||||||||||||||||||||||
555 | int tls1_generate_master_secret(SSL *s, unsigned char *out, unsigned char *p, | - | ||||||||||||||||||||||||
556 | size_t len, size_t *secret_size) | - | ||||||||||||||||||||||||
557 | { | - | ||||||||||||||||||||||||
558 | if (s->session->flags & 0x1
| 389-2193 | ||||||||||||||||||||||||
559 | unsigned char hash[64 * 2]; | - | ||||||||||||||||||||||||
560 | size_t hashlen; | - | ||||||||||||||||||||||||
561 | - | |||||||||||||||||||||||||
562 | - | |||||||||||||||||||||||||
563 | - | |||||||||||||||||||||||||
564 | - | |||||||||||||||||||||||||
565 | - | |||||||||||||||||||||||||
566 | if (!ssl3_digest_cached_records(s, 1)
| 0-2193 | ||||||||||||||||||||||||
567 | || !ssl_handshake_hash(s, hash, sizeof(hash), &hashlen)
| 0-2193 | ||||||||||||||||||||||||
568 | - | |||||||||||||||||||||||||
569 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||
570 | } | - | ||||||||||||||||||||||||
571 | - | |||||||||||||||||||||||||
572 | - | |||||||||||||||||||||||||
573 | - | |||||||||||||||||||||||||
574 | - | |||||||||||||||||||||||||
575 | if (!tls1_PRF(s,
| 0-2193 | ||||||||||||||||||||||||
576 | "extended master secret",
| 0-2193 | ||||||||||||||||||||||||
577 | 22,
| 0-2193 | ||||||||||||||||||||||||
578 | hash, hashlen,
| 0-2193 | ||||||||||||||||||||||||
579 |
| 0-2193 | ||||||||||||||||||||||||
580 | ((void *)0)
| 0-2193 | ||||||||||||||||||||||||
581 | , 0,
| 0-2193 | ||||||||||||||||||||||||
582 |
| 0-2193 | ||||||||||||||||||||||||
583 | ((void *)0)
| 0-2193 | ||||||||||||||||||||||||
584 | , 0,
| 0-2193 | ||||||||||||||||||||||||
585 |
| 0-2193 | ||||||||||||||||||||||||
586 | ((void *)0)
| 0-2193 | ||||||||||||||||||||||||
587 | , 0, p, len, out,
| 0-2193 | ||||||||||||||||||||||||
588 | 48, 1)
| 0-2193 | ||||||||||||||||||||||||
589 | - | |||||||||||||||||||||||||
590 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||
591 | } | - | ||||||||||||||||||||||||
592 | OPENSSL_cleanse(hash, hashlen); | - | ||||||||||||||||||||||||
593 | } executed 2193 times by 1 test: else {end of block Executed by:
| 2193 | ||||||||||||||||||||||||
594 | if (!tls1_PRF(s,
| 0-389 | ||||||||||||||||||||||||
595 | "master secret",
| 0-389 | ||||||||||||||||||||||||
596 | 13,
| 0-389 | ||||||||||||||||||||||||
597 | s->s3->client_random, 32,
| 0-389 | ||||||||||||||||||||||||
598 |
| 0-389 | ||||||||||||||||||||||||
599 | ((void *)0)
| 0-389 | ||||||||||||||||||||||||
600 | , 0,
| 0-389 | ||||||||||||||||||||||||
601 | s->s3->server_random, 32,
| 0-389 | ||||||||||||||||||||||||
602 |
| 0-389 | ||||||||||||||||||||||||
603 | ((void *)0)
| 0-389 | ||||||||||||||||||||||||
604 | , 0, p, len, out,
| 0-389 | ||||||||||||||||||||||||
605 | 48, 1)
| 0-389 | ||||||||||||||||||||||||
606 | - | |||||||||||||||||||||||||
607 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||
608 | } | - | ||||||||||||||||||||||||
609 | } executed 389 times by 1 test: end of block Executed by:
| 389 | ||||||||||||||||||||||||
610 | *secret_size = 48; | - | ||||||||||||||||||||||||
611 | return executed 2582 times by 1 test: 1;return 1; Executed by:
executed 2582 times by 1 test: return 1; Executed by:
| 2582 | ||||||||||||||||||||||||
612 | } | - | ||||||||||||||||||||||||
613 | - | |||||||||||||||||||||||||
614 | int tls1_export_keying_material(SSL *s, unsigned char *out, size_t olen, | - | ||||||||||||||||||||||||
615 | const char *label, size_t llen, | - | ||||||||||||||||||||||||
616 | const unsigned char *context, | - | ||||||||||||||||||||||||
617 | size_t contextlen, int use_context) | - | ||||||||||||||||||||||||
618 | { | - | ||||||||||||||||||||||||
619 | unsigned char *val = | - | ||||||||||||||||||||||||
620 | ((void *)0) | - | ||||||||||||||||||||||||
621 | ; | - | ||||||||||||||||||||||||
622 | size_t vallen = 0, currentvalpos; | - | ||||||||||||||||||||||||
623 | int rv; | - | ||||||||||||||||||||||||
624 | - | |||||||||||||||||||||||||
625 | - | |||||||||||||||||||||||||
626 | - | |||||||||||||||||||||||||
627 | - | |||||||||||||||||||||||||
628 | - | |||||||||||||||||||||||||
629 | - | |||||||||||||||||||||||||
630 | vallen = llen + 32 * 2; | - | ||||||||||||||||||||||||
631 | if (use_context
| 6-12 | ||||||||||||||||||||||||
632 | vallen += 2 + contextlen; | - | ||||||||||||||||||||||||
633 | } executed 12 times by 1 test: end of block Executed by:
| 12 | ||||||||||||||||||||||||
634 | - | |||||||||||||||||||||||||
635 | val = CRYPTO_malloc(vallen, __FILE__, 554); | - | ||||||||||||||||||||||||
636 | if (val ==
| 0-18 | ||||||||||||||||||||||||
637 | ((void *)0)
| 0-18 | ||||||||||||||||||||||||
638 | ) | - | ||||||||||||||||||||||||
639 | goto never executed: err2;goto err2; never executed: goto err2; | 0 | ||||||||||||||||||||||||
640 | currentvalpos = 0; | - | ||||||||||||||||||||||||
641 | memcpy(val + currentvalpos, (unsigned char *)label, llen); | - | ||||||||||||||||||||||||
642 | currentvalpos += llen; | - | ||||||||||||||||||||||||
643 | memcpy(val + currentvalpos, s->s3->client_random, 32); | - | ||||||||||||||||||||||||
644 | currentvalpos += 32; | - | ||||||||||||||||||||||||
645 | memcpy(val + currentvalpos, s->s3->server_random, 32); | - | ||||||||||||||||||||||||
646 | currentvalpos += 32; | - | ||||||||||||||||||||||||
647 | - | |||||||||||||||||||||||||
648 | if (use_context
| 6-12 | ||||||||||||||||||||||||
649 | val[currentvalpos] = (contextlen >> 8) & 0xff; | - | ||||||||||||||||||||||||
650 | currentvalpos++; | - | ||||||||||||||||||||||||
651 | val[currentvalpos] = contextlen & 0xff; | - | ||||||||||||||||||||||||
652 | currentvalpos++; | - | ||||||||||||||||||||||||
653 | if ((
| 0-6 | ||||||||||||||||||||||||
654 | ((void *)0)
| 0-6 | ||||||||||||||||||||||||
655 | )
| 0-6 | ||||||||||||||||||||||||
656 | memcpy(val + currentvalpos, context, contextlen); | - | ||||||||||||||||||||||||
657 | } executed 6 times by 1 test: end of block Executed by:
| 6 | ||||||||||||||||||||||||
658 | } executed 12 times by 1 test: end of block Executed by:
| 12 | ||||||||||||||||||||||||
659 | - | |||||||||||||||||||||||||
660 | - | |||||||||||||||||||||||||
661 | - | |||||||||||||||||||||||||
662 | - | |||||||||||||||||||||||||
663 | - | |||||||||||||||||||||||||
664 | - | |||||||||||||||||||||||||
665 | if (memcmp(val, "client finished",
| 0-18 | ||||||||||||||||||||||||
666 | 15) == 0
| 0-18 | ||||||||||||||||||||||||
667 | goto never executed: err1;goto err1; never executed: goto err1; | 0 | ||||||||||||||||||||||||
668 | if (memcmp(val, "server finished",
| 0-18 | ||||||||||||||||||||||||
669 | 15) == 0
| 0-18 | ||||||||||||||||||||||||
670 | goto never executed: err1;goto err1; never executed: goto err1; | 0 | ||||||||||||||||||||||||
671 | if (memcmp(val, "master secret",
| 0-18 | ||||||||||||||||||||||||
672 | 13) == 0
| 0-18 | ||||||||||||||||||||||||
673 | goto never executed: err1;goto err1; never executed: goto err1; | 0 | ||||||||||||||||||||||||
674 | if (memcmp(val, "extended master secret",
| 0-18 | ||||||||||||||||||||||||
675 | 22) == 0
| 0-18 | ||||||||||||||||||||||||
676 | goto never executed: err1;goto err1; never executed: goto err1; | 0 | ||||||||||||||||||||||||
677 | if (memcmp(val, "key expansion",
| 0-18 | ||||||||||||||||||||||||
678 | 13) == 0
| 0-18 | ||||||||||||||||||||||||
679 | goto never executed: err1;goto err1; never executed: goto err1; | 0 | ||||||||||||||||||||||||
680 | - | |||||||||||||||||||||||||
681 | rv = tls1_PRF(s, | - | ||||||||||||||||||||||||
682 | val, vallen, | - | ||||||||||||||||||||||||
683 | - | |||||||||||||||||||||||||
684 | ((void *)0) | - | ||||||||||||||||||||||||
685 | , 0, | - | ||||||||||||||||||||||||
686 | - | |||||||||||||||||||||||||
687 | ((void *)0) | - | ||||||||||||||||||||||||
688 | , 0, | - | ||||||||||||||||||||||||
689 | - | |||||||||||||||||||||||||
690 | ((void *)0) | - | ||||||||||||||||||||||||
691 | , 0, | - | ||||||||||||||||||||||||
692 | - | |||||||||||||||||||||||||
693 | ((void *)0) | - | ||||||||||||||||||||||||
694 | , 0, | - | ||||||||||||||||||||||||
695 | s->session->master_key, s->session->master_key_length, | - | ||||||||||||||||||||||||
696 | out, olen, 0); | - | ||||||||||||||||||||||||
697 | - | |||||||||||||||||||||||||
698 | goto executed 18 times by 1 test: ret;goto ret; Executed by:
executed 18 times by 1 test: goto ret; Executed by:
| 18 | ||||||||||||||||||||||||
699 | err1: | - | ||||||||||||||||||||||||
700 | ERR_put_error(20,(314),(367),__FILE__,607); | - | ||||||||||||||||||||||||
701 | rv = 0; | - | ||||||||||||||||||||||||
702 | goto never executed: ret;goto ret; never executed: goto ret; | 0 | ||||||||||||||||||||||||
703 | err2: | - | ||||||||||||||||||||||||
704 | ERR_put_error(20,(314),((1|64)),__FILE__,611); | - | ||||||||||||||||||||||||
705 | rv = 0; | - | ||||||||||||||||||||||||
706 | ret: code before this statement never executed: ret: | 0 | ||||||||||||||||||||||||
707 | CRYPTO_clear_free(val, vallen, __FILE__, 614); | - | ||||||||||||||||||||||||
708 | return executed 18 times by 1 test: rv;return rv; Executed by:
executed 18 times by 1 test: return rv; Executed by:
| 18 | ||||||||||||||||||||||||
709 | } | - | ||||||||||||||||||||||||
710 | - | |||||||||||||||||||||||||
711 | int tls1_alert_code(int code) | - | ||||||||||||||||||||||||
712 | { | - | ||||||||||||||||||||||||
713 | switch (code) { | - | ||||||||||||||||||||||||
714 | case executed 2587 times by 1 test: 0:case 0: Executed by:
executed 2587 times by 1 test: case 0: Executed by:
| 2587 | ||||||||||||||||||||||||
715 | return executed 2587 times by 1 test: 0;return 0; Executed by:
executed 2587 times by 1 test: return 0; Executed by:
| 2587 | ||||||||||||||||||||||||
716 | case executed 131 times by 1 test: 10:case 10: Executed by:
executed 131 times by 1 test: case 10: Executed by:
| 131 | ||||||||||||||||||||||||
717 | return executed 131 times by 1 test: 10;return 10; Executed by:
executed 131 times by 1 test: return 10; Executed by:
| 131 | ||||||||||||||||||||||||
718 | case executed 334 times by 1 test: 20:case 20: Executed by:
executed 334 times by 1 test: case 20: Executed by:
| 334 | ||||||||||||||||||||||||
719 | return executed 334 times by 1 test: 20;return 20; Executed by:
executed 334 times by 1 test: return 20; Executed by:
| 334 | ||||||||||||||||||||||||
720 | case executed 41 times by 1 test: 21:case 21: Executed by:
executed 41 times by 1 test: case 21: Executed by:
| 41 | ||||||||||||||||||||||||
721 | return executed 41 times by 1 test: 21;return 21; Executed by:
executed 41 times by 1 test: return 21; Executed by:
| 41 | ||||||||||||||||||||||||
722 | case executed 13 times by 1 test: 22:case 22: Executed by:
executed 13 times by 1 test: case 22: Executed by:
| 13 | ||||||||||||||||||||||||
723 | return executed 13 times by 1 test: 22;return 22; Executed by:
executed 13 times by 1 test: return 22; Executed by:
| 13 | ||||||||||||||||||||||||
724 | case never executed: 30:case 30: never executed: case 30: | 0 | ||||||||||||||||||||||||
725 | return never executed: 30;return 30; never executed: return 30; | 0 | ||||||||||||||||||||||||
726 | case executed 257 times by 1 test: 40:case 40: Executed by:
executed 257 times by 1 test: case 40: Executed by:
| 257 | ||||||||||||||||||||||||
727 | return executed 257 times by 1 test: 40;return 40; Executed by:
executed 257 times by 1 test: return 40; Executed by:
| 257 | ||||||||||||||||||||||||
728 | case never executed: 41:case 41: never executed: case 41: | 0 | ||||||||||||||||||||||||
729 | return never executed: -1;return -1; never executed: return -1; | 0 | ||||||||||||||||||||||||
730 | case executed 437 times by 1 test: 42:case 42: Executed by:
executed 437 times by 1 test: case 42: Executed by:
| 437 | ||||||||||||||||||||||||
731 | return executed 437 times by 1 test: 42;return 42; Executed by:
executed 437 times by 1 test: return 42; Executed by:
| 437 | ||||||||||||||||||||||||
732 | case never executed: 43:case 43: never executed: case 43: | 0 | ||||||||||||||||||||||||
733 | return never executed: 43;return 43; never executed: return 43; | 0 | ||||||||||||||||||||||||
734 | case never executed: 44:case 44: never executed: case 44: | 0 | ||||||||||||||||||||||||
735 | return never executed: 44;return 44; never executed: return 44; | 0 | ||||||||||||||||||||||||
736 | case never executed: 45:case 45: never executed: case 45: | 0 | ||||||||||||||||||||||||
737 | return never executed: 45;return 45; never executed: return 45; | 0 | ||||||||||||||||||||||||
738 | case never executed: 46:case 46: never executed: case 46: | 0 | ||||||||||||||||||||||||
739 | return never executed: 46;return 46; never executed: return 46; | 0 | ||||||||||||||||||||||||
740 | case executed 265 times by 1 test: 47:case 47: Executed by:
executed 265 times by 1 test: case 47: Executed by:
| 265 | ||||||||||||||||||||||||
741 | return executed 265 times by 1 test: 47;return 47; Executed by:
executed 265 times by 1 test: return 47; Executed by:
| 265 | ||||||||||||||||||||||||
742 | case executed 10 times by 1 test: 48:case 48: Executed by:
executed 10 times by 1 test: case 48: Executed by:
| 10 | ||||||||||||||||||||||||
743 | return executed 10 times by 1 test: 48;return 48; Executed by:
executed 10 times by 1 test: return 48; Executed by:
| 10 | ||||||||||||||||||||||||
744 | case never executed: 49:case 49: never executed: case 49: | 0 | ||||||||||||||||||||||||
745 | return never executed: 49;return 49; never executed: return 49; | 0 | ||||||||||||||||||||||||
746 | case executed 523 times by 1 test: 50:case 50: Executed by:
executed 523 times by 1 test: case 50: Executed by:
| 523 | ||||||||||||||||||||||||
747 | return executed 523 times by 1 test: 50;return 50; Executed by:
executed 523 times by 1 test: return 50; Executed by:
| 523 | ||||||||||||||||||||||||
748 | case executed 400 times by 1 test: 51:case 51: Executed by:
executed 400 times by 1 test: case 51: Executed by:
| 400 | ||||||||||||||||||||||||
749 | return executed 400 times by 1 test: 51;return 51; Executed by:
executed 400 times by 1 test: return 51; Executed by:
| 400 | ||||||||||||||||||||||||
750 | case never executed: 60:case 60: never executed: case 60: | 0 | ||||||||||||||||||||||||
751 | return never executed: 60;return 60; never executed: return 60; | 0 | ||||||||||||||||||||||||
752 | case executed 958 times by 1 test: 70:case 70: Executed by:
executed 958 times by 1 test: case 70: Executed by:
| 958 | ||||||||||||||||||||||||
753 | return executed 958 times by 1 test: 70;return 70; Executed by:
executed 958 times by 1 test: return 70; Executed by:
| 958 | ||||||||||||||||||||||||
754 | case never executed: 71:case 71: never executed: case 71: | 0 | ||||||||||||||||||||||||
755 | return never executed: 71;return 71; never executed: return 71; | 0 | ||||||||||||||||||||||||
756 | case executed 369 times by 1 test: 80:case 80: Executed by:
executed 369 times by 1 test: case 80: Executed by:
| 369 | ||||||||||||||||||||||||
757 | return executed 369 times by 1 test: 80;return 80; Executed by:
executed 369 times by 1 test: return 80; Executed by:
| 369 | ||||||||||||||||||||||||
758 | case never executed: 90:case 90: never executed: case 90: | 0 | ||||||||||||||||||||||||
759 | return never executed: 90;return 90; never executed: return 90; | 0 | ||||||||||||||||||||||||
760 | case executed 3 times by 1 test: 100:case 100: Executed by:
executed 3 times by 1 test: case 100: Executed by:
| 3 | ||||||||||||||||||||||||
761 | return executed 3 times by 1 test: 100;return 100; Executed by:
executed 3 times by 1 test: return 100; Executed by:
| 3 | ||||||||||||||||||||||||
762 | case executed 11 times by 1 test: 110:case 110: Executed by:
executed 11 times by 1 test: case 110: Executed by:
| 11 | ||||||||||||||||||||||||
763 | return executed 11 times by 1 test: 110;return 110; Executed by:
executed 11 times by 1 test: return 110; Executed by:
| 11 | ||||||||||||||||||||||||
764 | case never executed: 111:case 111: never executed: case 111: | 0 | ||||||||||||||||||||||||
765 | return never executed: 111;return 111; never executed: return 111; | 0 | ||||||||||||||||||||||||
766 | case executed 4 times by 1 test: 112:case 112: Executed by:
executed 4 times by 1 test: case 112: Executed by:
| 4 | ||||||||||||||||||||||||
767 | return executed 4 times by 1 test: 112;return 112; Executed by:
executed 4 times by 1 test: return 112; Executed by:
| 4 | ||||||||||||||||||||||||
768 | case executed 2 times by 1 test: 113:case 113: Executed by:
executed 2 times by 1 test: case 113: Executed by:
| 2 | ||||||||||||||||||||||||
769 | return executed 2 times by 1 test: 113;return 113; Executed by:
executed 2 times by 1 test: return 113; Executed by:
| 2 | ||||||||||||||||||||||||
770 | case never executed: 114:case 114: never executed: case 114: | 0 | ||||||||||||||||||||||||
771 | return never executed: 114;return 114; never executed: return 114; | 0 | ||||||||||||||||||||||||
772 | case never executed: 115:case 115: never executed: case 115: | 0 | ||||||||||||||||||||||||
773 | return never executed: 115;return 115; never executed: return 115; | 0 | ||||||||||||||||||||||||
774 | case executed 1 time by 1 test: 86:case 86: Executed by:
executed 1 time by 1 test: case 86: Executed by:
| 1 | ||||||||||||||||||||||||
775 | return executed 1 time by 1 test: 86;return 86; Executed by:
executed 1 time by 1 test: return 86; Executed by:
| 1 | ||||||||||||||||||||||||
776 | case executed 2 times by 1 test: 120:case 120: Executed by:
executed 2 times by 1 test: case 120: Executed by:
| 2 | ||||||||||||||||||||||||
777 | return executed 2 times by 1 test: 120;return 120; Executed by:
executed 2 times by 1 test: return 120; Executed by:
| 2 | ||||||||||||||||||||||||
778 | case executed 5 times by 1 test: 116:case 116: Executed by:
executed 5 times by 1 test: case 116: Executed by:
| 5 | ||||||||||||||||||||||||
779 | return executed 5 times by 1 test: 40;return 40; Executed by:
executed 5 times by 1 test: return 40; Executed by:
| 5 | ||||||||||||||||||||||||
780 | default never executed: :default: never executed: default: | 0 | ||||||||||||||||||||||||
781 | return never executed: -1;return -1; never executed: return -1; | 0 | ||||||||||||||||||||||||
782 | } | - | ||||||||||||||||||||||||
783 | } | - | ||||||||||||||||||||||||
Switch to Source code | Preprocessed file |