Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/openssl/src/ssl/d1_lib.c |
Switch to Source code | Preprocessed file |
Line | Source | Count | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | - | |||||||||||||
2 | - | |||||||||||||
3 | static void get_current_time(struct timeval *t); | - | ||||||||||||
4 | static int dtls1_handshake_write(SSL *s); | - | ||||||||||||
5 | static size_t dtls1_link_min_mtu(void); | - | ||||||||||||
6 | - | |||||||||||||
7 | - | |||||||||||||
8 | static const size_t g_probable_mtu[] = { 1500, 512, 256 }; | - | ||||||||||||
9 | - | |||||||||||||
10 | const SSL3_ENC_METHOD DTLSv1_enc_data = { | - | ||||||||||||
11 | tls1_enc, | - | ||||||||||||
12 | tls1_mac, | - | ||||||||||||
13 | tls1_setup_key_block, | - | ||||||||||||
14 | tls1_generate_master_secret, | - | ||||||||||||
15 | tls1_change_cipher_state, | - | ||||||||||||
16 | tls1_final_finish_mac, | - | ||||||||||||
17 | "client finished", 15, | - | ||||||||||||
18 | "server finished", 15, | - | ||||||||||||
19 | tls1_alert_code, | - | ||||||||||||
20 | tls1_export_keying_material, | - | ||||||||||||
21 | 0x8 | 0x1, | - | ||||||||||||
22 | dtls1_set_handshake_header, | - | ||||||||||||
23 | dtls1_close_construct_packet, | - | ||||||||||||
24 | dtls1_handshake_write | - | ||||||||||||
25 | }; | - | ||||||||||||
26 | - | |||||||||||||
27 | const SSL3_ENC_METHOD DTLSv1_2_enc_data = { | - | ||||||||||||
28 | tls1_enc, | - | ||||||||||||
29 | tls1_mac, | - | ||||||||||||
30 | tls1_setup_key_block, | - | ||||||||||||
31 | tls1_generate_master_secret, | - | ||||||||||||
32 | tls1_change_cipher_state, | - | ||||||||||||
33 | tls1_final_finish_mac, | - | ||||||||||||
34 | "client finished", 15, | - | ||||||||||||
35 | "server finished", 15, | - | ||||||||||||
36 | tls1_alert_code, | - | ||||||||||||
37 | tls1_export_keying_material, | - | ||||||||||||
38 | 0x8 | 0x1 | 0x2 | - | ||||||||||||
39 | | 0x4 | 0x10, | - | ||||||||||||
40 | dtls1_set_handshake_header, | - | ||||||||||||
41 | dtls1_close_construct_packet, | - | ||||||||||||
42 | dtls1_handshake_write | - | ||||||||||||
43 | }; | - | ||||||||||||
44 | - | |||||||||||||
45 | long dtls1_default_timeout(void) | - | ||||||||||||
46 | { | - | ||||||||||||
47 | - | |||||||||||||
48 | - | |||||||||||||
49 | - | |||||||||||||
50 | - | |||||||||||||
51 | return executed 305 times by 1 test: (60 * 60 * 2);return (60 * 60 * 2); Executed by:
executed 305 times by 1 test: return (60 * 60 * 2); Executed by:
| 305 | ||||||||||||
52 | } | - | ||||||||||||
53 | - | |||||||||||||
54 | int dtls1_new(SSL *s) | - | ||||||||||||
55 | { | - | ||||||||||||
56 | DTLS1_STATE *d1; | - | ||||||||||||
57 | - | |||||||||||||
58 | if (!DTLS_RECORD_LAYER_new(&s->rlayer)
| 0-373 | ||||||||||||
59 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||
60 | } | - | ||||||||||||
61 | - | |||||||||||||
62 | if (!ssl3_new(s)
| 0-373 | ||||||||||||
63 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||
64 | if ((
| 0-373 | ||||||||||||
65 | ((void *)0)
| 0-373 | ||||||||||||
66 | ) { | - | ||||||||||||
67 | ssl3_free(s); | - | ||||||||||||
68 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||
69 | } | - | ||||||||||||
70 | - | |||||||||||||
71 | d1->buffered_messages = pqueue_new(); | - | ||||||||||||
72 | d1->sent_messages = pqueue_new(); | - | ||||||||||||
73 | - | |||||||||||||
74 | if (s->server
| 1-372 | ||||||||||||
75 | d1->cookie_len = sizeof(s->d1->cookie); | - | ||||||||||||
76 | } executed 1 time by 1 test: end of block Executed by:
| 1 | ||||||||||||
77 | - | |||||||||||||
78 | d1->link_mtu = 0; | - | ||||||||||||
79 | d1->mtu = 0; | - | ||||||||||||
80 | - | |||||||||||||
81 | if (d1->buffered_messages ==
| 0-373 | ||||||||||||
82 | ((void *)0)
| 0-373 | ||||||||||||
83 | || d1->sent_messages ==
| 0-373 | ||||||||||||
84 | ((void *)0)
| 0-373 | ||||||||||||
85 | ) { | - | ||||||||||||
86 | pqueue_free(d1->buffered_messages); | - | ||||||||||||
87 | pqueue_free(d1->sent_messages); | - | ||||||||||||
88 | CRYPTO_free(d1, __FILE__, 95); | - | ||||||||||||
89 | ssl3_free(s); | - | ||||||||||||
90 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||
91 | } | - | ||||||||||||
92 | - | |||||||||||||
93 | s->d1 = d1; | - | ||||||||||||
94 | - | |||||||||||||
95 | if (!s->method->ssl_clear(s)
| 0-373 | ||||||||||||
96 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||
97 | - | |||||||||||||
98 | return executed 373 times by 1 test: 1;return 1; Executed by:
executed 373 times by 1 test: return 1; Executed by:
| 373 | ||||||||||||
99 | } | - | ||||||||||||
100 | - | |||||||||||||
101 | static void dtls1_clear_queues(SSL *s) | - | ||||||||||||
102 | { | - | ||||||||||||
103 | dtls1_clear_received_buffer(s); | - | ||||||||||||
104 | dtls1_clear_sent_buffer(s); | - | ||||||||||||
105 | } executed 1490 times by 1 test: end of block Executed by:
| 1490 | ||||||||||||
106 | - | |||||||||||||
107 | void dtls1_clear_received_buffer(SSL *s) | - | ||||||||||||
108 | { | - | ||||||||||||
109 | pitem *item = | - | ||||||||||||
110 | ((void *)0) | - | ||||||||||||
111 | ; | - | ||||||||||||
112 | hm_fragment *frag = | - | ||||||||||||
113 | ((void *)0) | - | ||||||||||||
114 | ; | - | ||||||||||||
115 | - | |||||||||||||
116 | while ((
| 0-2200 | ||||||||||||
117 | ((void *)0)
| 0-2200 | ||||||||||||
118 | ) { | - | ||||||||||||
119 | frag = (hm_fragment *)item->data; | - | ||||||||||||
120 | dtls1_hm_fragment_free(frag); | - | ||||||||||||
121 | pitem_free(item); | - | ||||||||||||
122 | } never executed: end of block | 0 | ||||||||||||
123 | } executed 2200 times by 1 test: end of block Executed by:
| 2200 | ||||||||||||
124 | - | |||||||||||||
125 | void dtls1_clear_sent_buffer(SSL *s) | - | ||||||||||||
126 | { | - | ||||||||||||
127 | pitem *item = | - | ||||||||||||
128 | ((void *)0) | - | ||||||||||||
129 | ; | - | ||||||||||||
130 | hm_fragment *frag = | - | ||||||||||||
131 | ((void *)0) | - | ||||||||||||
132 | ; | - | ||||||||||||
133 | - | |||||||||||||
134 | while ((
| 1891-2319 | ||||||||||||
135 | ((void *)0)
| 1891-2319 | ||||||||||||
136 | ) { | - | ||||||||||||
137 | frag = (hm_fragment *)item->data; | - | ||||||||||||
138 | dtls1_hm_fragment_free(frag); | - | ||||||||||||
139 | pitem_free(item); | - | ||||||||||||
140 | } executed 1891 times by 1 test: end of block Executed by:
| 1891 | ||||||||||||
141 | } executed 2319 times by 1 test: end of block Executed by:
| 2319 | ||||||||||||
142 | - | |||||||||||||
143 | - | |||||||||||||
144 | void dtls1_free(SSL *s) | - | ||||||||||||
145 | { | - | ||||||||||||
146 | DTLS_RECORD_LAYER_free(&s->rlayer); | - | ||||||||||||
147 | - | |||||||||||||
148 | ssl3_free(s); | - | ||||||||||||
149 | - | |||||||||||||
150 | dtls1_clear_queues(s); | - | ||||||||||||
151 | - | |||||||||||||
152 | pqueue_free(s->d1->buffered_messages); | - | ||||||||||||
153 | pqueue_free(s->d1->sent_messages); | - | ||||||||||||
154 | - | |||||||||||||
155 | CRYPTO_free(s->d1, __FILE__, 150); | - | ||||||||||||
156 | s->d1 = | - | ||||||||||||
157 | ((void *)0) | - | ||||||||||||
158 | ; | - | ||||||||||||
159 | } executed 373 times by 1 test: end of block Executed by:
| 373 | ||||||||||||
160 | - | |||||||||||||
161 | int dtls1_clear(SSL *s) | - | ||||||||||||
162 | { | - | ||||||||||||
163 | pqueue *buffered_messages; | - | ||||||||||||
164 | pqueue *sent_messages; | - | ||||||||||||
165 | size_t mtu; | - | ||||||||||||
166 | size_t link_mtu; | - | ||||||||||||
167 | - | |||||||||||||
168 | DTLS_RECORD_LAYER_clear(&s->rlayer); | - | ||||||||||||
169 | - | |||||||||||||
170 | if (s->d1
| 373-1117 | ||||||||||||
171 | DTLS_timer_cb timer_cb = s->d1->timer_cb; | - | ||||||||||||
172 | - | |||||||||||||
173 | buffered_messages = s->d1->buffered_messages; | - | ||||||||||||
174 | sent_messages = s->d1->sent_messages; | - | ||||||||||||
175 | mtu = s->d1->mtu; | - | ||||||||||||
176 | link_mtu = s->d1->link_mtu; | - | ||||||||||||
177 | - | |||||||||||||
178 | dtls1_clear_queues(s); | - | ||||||||||||
179 | - | |||||||||||||
180 | memset(s->d1, 0, sizeof(*s->d1)); | - | ||||||||||||
181 | - | |||||||||||||
182 | - | |||||||||||||
183 | s->d1->timer_cb = timer_cb; | - | ||||||||||||
184 | - | |||||||||||||
185 | if (s->server
| 408-709 | ||||||||||||
186 | s->d1->cookie_len = sizeof(s->d1->cookie); | - | ||||||||||||
187 | } executed 408 times by 1 test: end of block Executed by:
| 408 | ||||||||||||
188 | - | |||||||||||||
189 | if (SSL_get_options(s) & 0x00001000U
| 0-1117 | ||||||||||||
190 | s->d1->mtu = mtu; | - | ||||||||||||
191 | s->d1->link_mtu = link_mtu; | - | ||||||||||||
192 | } never executed: end of block | 0 | ||||||||||||
193 | - | |||||||||||||
194 | s->d1->buffered_messages = buffered_messages; | - | ||||||||||||
195 | s->d1->sent_messages = sent_messages; | - | ||||||||||||
196 | } executed 1117 times by 1 test: end of block Executed by:
| 1117 | ||||||||||||
197 | - | |||||||||||||
198 | if (!ssl3_clear(s)
| 0-1490 | ||||||||||||
199 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||
200 | - | |||||||||||||
201 | if (s->method->version == 0x1FFFF
| 0-1490 | ||||||||||||
202 | s->version = 0xFEFD; executed 1490 times by 1 test: s->version = 0xFEFD; Executed by:
| 1490 | ||||||||||||
203 | - | |||||||||||||
204 | else if (s->options & 0x00008000U
| 0 | ||||||||||||
205 | s->client_version = s->version = 0x0100; never executed: s->client_version = s->version = 0x0100; | 0 | ||||||||||||
206 | - | |||||||||||||
207 | else | - | ||||||||||||
208 | s->version = s->method->version; never executed: s->version = s->method->version; | 0 | ||||||||||||
209 | - | |||||||||||||
210 | return executed 1490 times by 1 test: 1;return 1; Executed by:
executed 1490 times by 1 test: return 1; Executed by:
| 1490 | ||||||||||||
211 | } | - | ||||||||||||
212 | - | |||||||||||||
213 | long dtls1_ctrl(SSL *s, int cmd, long larg, void *parg) | - | ||||||||||||
214 | { | - | ||||||||||||
215 | int ret = 0; | - | ||||||||||||
216 | - | |||||||||||||
217 | switch (cmd) { | - | ||||||||||||
218 | case never executed: 73:case 73: never executed: case 73: | 0 | ||||||||||||
219 | if (dtls1_get_timeout(s, (struct timeval *)parg) !=
| 0 | ||||||||||||
220 | ((void *)0)
| 0 | ||||||||||||
221 | ) { | - | ||||||||||||
222 | ret = 1; | - | ||||||||||||
223 | } never executed: end of block | 0 | ||||||||||||
224 | break; never executed: break; | 0 | ||||||||||||
225 | case executed 102 times by 1 test: 74:case 74: Executed by:
executed 102 times by 1 test: case 74: Executed by:
| 102 | ||||||||||||
226 | ret = dtls1_handle_timeout(s); | - | ||||||||||||
227 | break; executed 102 times by 1 test: break; Executed by:
| 102 | ||||||||||||
228 | case never executed: 120:case 120: never executed: case 120: | 0 | ||||||||||||
229 | if (larg < (long)dtls1_link_min_mtu()
| 0 | ||||||||||||
230 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||
231 | s->d1->link_mtu = larg; | - | ||||||||||||
232 | return never executed: 1;return 1; never executed: return 1; | 0 | ||||||||||||
233 | case never executed: 121:case 121: never executed: case 121: | 0 | ||||||||||||
234 | return never executed: (long)dtls1_link_min_mtu();return (long)dtls1_link_min_mtu(); never executed: return (long)dtls1_link_min_mtu(); | 0 | ||||||||||||
235 | case executed 837 times by 1 test: 17:case 17: Executed by:
executed 837 times by 1 test: case 17: Executed by:
| 837 | ||||||||||||
236 | - | |||||||||||||
237 | - | |||||||||||||
238 | - | |||||||||||||
239 | - | |||||||||||||
240 | if (larg < (long)dtls1_link_min_mtu() - 48
| 0-837 | ||||||||||||
241 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||
242 | s->d1->mtu = larg; | - | ||||||||||||
243 | return executed 837 times by 1 test: larg;return larg; Executed by:
executed 837 times by 1 test: return larg; Executed by:
| 837 | ||||||||||||
244 | default executed 361 times by 1 test: :default: Executed by:
executed 361 times by 1 test: default: Executed by:
| 361 | ||||||||||||
245 | ret = ssl3_ctrl(s, cmd, larg, parg); | - | ||||||||||||
246 | break; executed 361 times by 1 test: break; Executed by:
| 361 | ||||||||||||
247 | } | - | ||||||||||||
248 | return executed 463 times by 1 test: ret;return ret; Executed by:
executed 463 times by 1 test: return ret; Executed by:
| 463 | ||||||||||||
249 | } | - | ||||||||||||
250 | - | |||||||||||||
251 | void dtls1_start_timer(SSL *s) | - | ||||||||||||
252 | { | - | ||||||||||||
253 | unsigned int sec, usec; | - | ||||||||||||
254 | if (s->d1->next_timeout.tv_sec == 0
| 0-858 | ||||||||||||
255 | - | |||||||||||||
256 | if (s->d1->timer_cb !=
| 93-628 | ||||||||||||
257 | ((void *)0)
| 93-628 | ||||||||||||
258 | ) | - | ||||||||||||
259 | s->d1->timeout_duration_us = s->d1->timer_cb(s, 0); executed 93 times by 1 test: s->d1->timeout_duration_us = s->d1->timer_cb(s, 0); Executed by:
| 93 | ||||||||||||
260 | else | - | ||||||||||||
261 | s->d1->timeout_duration_us = 1000000; executed 628 times by 1 test: s->d1->timeout_duration_us = 1000000; Executed by:
| 628 | ||||||||||||
262 | } | - | ||||||||||||
263 | - | |||||||||||||
264 | - | |||||||||||||
265 | get_current_time(&(s->d1->next_timeout)); | - | ||||||||||||
266 | - | |||||||||||||
267 | - | |||||||||||||
268 | - | |||||||||||||
269 | sec = s->d1->timeout_duration_us / 1000000; | - | ||||||||||||
270 | usec = s->d1->timeout_duration_us - (sec * 1000000); | - | ||||||||||||
271 | - | |||||||||||||
272 | s->d1->next_timeout.tv_sec += sec; | - | ||||||||||||
273 | s->d1->next_timeout.tv_usec += usec; | - | ||||||||||||
274 | - | |||||||||||||
275 | if (s->d1->next_timeout.tv_usec >= 1000000
| 8-1571 | ||||||||||||
276 | s->d1->next_timeout.tv_sec++; | - | ||||||||||||
277 | s->d1->next_timeout.tv_usec -= 1000000; | - | ||||||||||||
278 | } executed 8 times by 1 test: end of block Executed by:
| 8 | ||||||||||||
279 | - | |||||||||||||
280 | BIO_ctrl(SSL_get_rbio(s), 45, 0, | - | ||||||||||||
281 | &(s->d1->next_timeout)); | - | ||||||||||||
282 | } executed 1579 times by 1 test: end of block Executed by:
| 1579 | ||||||||||||
283 | - | |||||||||||||
284 | struct timeval *dtls1_get_timeout(SSL *s, struct timeval *timeleft) | - | ||||||||||||
285 | { | - | ||||||||||||
286 | struct timeval timenow; | - | ||||||||||||
287 | - | |||||||||||||
288 | - | |||||||||||||
289 | if (s->d1->next_timeout.tv_sec == 0
| 0-7067 | ||||||||||||
290 | return executed 1284 times by 1 test: return ((void *)0) ; Executed by:
executed 1284 times by 1 test: return ((void *)0) ; Executed by:
| 1284 | ||||||||||||
291 | ((void *)0) executed 1284 times by 1 test: return ((void *)0) ; Executed by:
| 1284 | ||||||||||||
292 | ; executed 1284 times by 1 test: return ((void *)0) ; Executed by:
| 1284 | ||||||||||||
293 | } | - | ||||||||||||
294 | - | |||||||||||||
295 | - | |||||||||||||
296 | get_current_time(&timenow); | - | ||||||||||||
297 | - | |||||||||||||
298 | - | |||||||||||||
299 | if (s->d1->next_timeout.tv_sec < timenow.tv_sec
| 0-7067 | ||||||||||||
300 | (s->d1->next_timeout.tv_sec == timenow.tv_sec
| 1813-5254 | ||||||||||||
301 | s->d1->next_timeout.tv_usec <= timenow.tv_usec
| 45-1768 | ||||||||||||
302 | memset(timeleft, 0, sizeof(*timeleft)); | - | ||||||||||||
303 | return executed 45 times by 1 test: timeleft;return timeleft; Executed by:
executed 45 times by 1 test: return timeleft; Executed by:
| 45 | ||||||||||||
304 | } | - | ||||||||||||
305 | - | |||||||||||||
306 | - | |||||||||||||
307 | memcpy(timeleft, &(s->d1->next_timeout), sizeof(struct timeval)); | - | ||||||||||||
308 | timeleft->tv_sec -= timenow.tv_sec; | - | ||||||||||||
309 | timeleft->tv_usec -= timenow.tv_usec; | - | ||||||||||||
310 | if (timeleft->tv_usec < 0
| 1768-5254 | ||||||||||||
311 | timeleft->tv_sec--; | - | ||||||||||||
312 | timeleft->tv_usec += 1000000; | - | ||||||||||||
313 | } executed 5254 times by 1 test: end of block Executed by:
| 5254 | ||||||||||||
314 | - | |||||||||||||
315 | - | |||||||||||||
316 | - | |||||||||||||
317 | - | |||||||||||||
318 | - | |||||||||||||
319 | if (timeleft->tv_sec == 0
| 0-7022 | ||||||||||||
320 | memset(timeleft, 0, sizeof(*timeleft)); | - | ||||||||||||
321 | } never executed: end of block | 0 | ||||||||||||
322 | - | |||||||||||||
323 | return executed 7022 times by 1 test: timeleft;return timeleft; Executed by:
executed 7022 times by 1 test: return timeleft; Executed by:
| 7022 | ||||||||||||
324 | } | - | ||||||||||||
325 | - | |||||||||||||
326 | int dtls1_is_timer_expired(SSL *s) | - | ||||||||||||
327 | { | - | ||||||||||||
328 | struct timeval timeleft; | - | ||||||||||||
329 | - | |||||||||||||
330 | - | |||||||||||||
331 | if (dtls1_get_timeout(s, &timeleft) ==
| 1284-7067 | ||||||||||||
332 | ((void *)0)
| 1284-7067 | ||||||||||||
333 | ) { | - | ||||||||||||
334 | return executed 1284 times by 1 test: 0;return 0; Executed by:
executed 1284 times by 1 test: return 0; Executed by:
| 1284 | ||||||||||||
335 | } | - | ||||||||||||
336 | - | |||||||||||||
337 | - | |||||||||||||
338 | if (timeleft.tv_sec > 0
| 0-7067 | ||||||||||||
339 | return executed 7022 times by 1 test: 0;return 0; Executed by:
executed 7022 times by 1 test: return 0; Executed by:
| 7022 | ||||||||||||
340 | } | - | ||||||||||||
341 | - | |||||||||||||
342 | - | |||||||||||||
343 | return executed 45 times by 1 test: 1;return 1; Executed by:
executed 45 times by 1 test: return 1; Executed by:
| 45 | ||||||||||||
344 | } | - | ||||||||||||
345 | - | |||||||||||||
346 | void dtls1_double_timeout(SSL *s) | - | ||||||||||||
347 | { | - | ||||||||||||
348 | s->d1->timeout_duration_us *= 2; | - | ||||||||||||
349 | if (s->d1->timeout_duration_us > 60000000
| 0 | ||||||||||||
350 | s->d1->timeout_duration_us = 60000000; never executed: s->d1->timeout_duration_us = 60000000; | 0 | ||||||||||||
351 | dtls1_start_timer(s); | - | ||||||||||||
352 | } never executed: end of block | 0 | ||||||||||||
353 | - | |||||||||||||
354 | void dtls1_stop_timer(SSL *s) | - | ||||||||||||
355 | { | - | ||||||||||||
356 | - | |||||||||||||
357 | memset(&s->d1->timeout, 0, sizeof(s->d1->timeout)); | - | ||||||||||||
358 | memset(&s->d1->next_timeout, 0, sizeof(s->d1->next_timeout)); | - | ||||||||||||
359 | s->d1->timeout_duration_us = 1000000; | - | ||||||||||||
360 | BIO_ctrl(SSL_get_rbio(s), 45, 0, | - | ||||||||||||
361 | &(s->d1->next_timeout)); | - | ||||||||||||
362 | - | |||||||||||||
363 | dtls1_clear_sent_buffer(s); | - | ||||||||||||
364 | } executed 826 times by 1 test: end of block Executed by:
| 826 | ||||||||||||
365 | - | |||||||||||||
366 | int dtls1_check_timeout_num(SSL *s) | - | ||||||||||||
367 | { | - | ||||||||||||
368 | size_t mtu; | - | ||||||||||||
369 | - | |||||||||||||
370 | s->d1->timeout.num_alerts++; | - | ||||||||||||
371 | - | |||||||||||||
372 | - | |||||||||||||
373 | if (s->d1->timeout.num_alerts > 2
| 0-51 | ||||||||||||
374 | && !(SSL_get_options(s) & 0x00001000U)
| 0 | ||||||||||||
375 | mtu = | - | ||||||||||||
376 | BIO_ctrl(SSL_get_wbio(s), 47, 0, | - | ||||||||||||
377 | ((void *)0) | - | ||||||||||||
378 | ); | - | ||||||||||||
379 | if (mtu < s->d1->mtu
| 0 | ||||||||||||
380 | s->d1->mtu = mtu; never executed: s->d1->mtu = mtu; | 0 | ||||||||||||
381 | } never executed: end of block | 0 | ||||||||||||
382 | - | |||||||||||||
383 | if (s->d1->timeout.num_alerts > 12
| 0-51 | ||||||||||||
384 | - | |||||||||||||
385 | ossl_statem_fatal((s), (-1), (318), (312), | - | ||||||||||||
386 | __FILE__ | - | ||||||||||||
387 | , | - | ||||||||||||
388 | 382 | - | ||||||||||||
389 | ) | - | ||||||||||||
390 | ; | - | ||||||||||||
391 | return never executed: -1;return -1; never executed: return -1; | 0 | ||||||||||||
392 | } | - | ||||||||||||
393 | - | |||||||||||||
394 | return executed 51 times by 1 test: 0;return 0; Executed by:
executed 51 times by 1 test: return 0; Executed by:
| 51 | ||||||||||||
395 | } | - | ||||||||||||
396 | - | |||||||||||||
397 | int dtls1_handle_timeout(SSL *s) | - | ||||||||||||
398 | { | - | ||||||||||||
399 | - | |||||||||||||
400 | if (!dtls1_is_timer_expired(s)
| 45-7102 | ||||||||||||
401 | return executed 7102 times by 1 test: 0;return 0; Executed by:
executed 7102 times by 1 test: return 0; Executed by:
| 7102 | ||||||||||||
402 | } | - | ||||||||||||
403 | - | |||||||||||||
404 | if (s->d1->timer_cb !=
| 0-45 | ||||||||||||
405 | ((void *)0)
| 0-45 | ||||||||||||
406 | ) | - | ||||||||||||
407 | s->d1->timeout_duration_us = s->d1->timer_cb(s, s->d1->timeout_duration_us); executed 45 times by 1 test: s->d1->timeout_duration_us = s->d1->timer_cb(s, s->d1->timeout_duration_us); Executed by:
| 45 | ||||||||||||
408 | else | - | ||||||||||||
409 | dtls1_double_timeout(s); never executed: dtls1_double_timeout(s); | 0 | ||||||||||||
410 | - | |||||||||||||
411 | if (dtls1_check_timeout_num(s) < 0
| 0-45 | ||||||||||||
412 | - | |||||||||||||
413 | return never executed: -1;return -1; never executed: return -1; | 0 | ||||||||||||
414 | } | - | ||||||||||||
415 | - | |||||||||||||
416 | s->d1->timeout.read_timeouts++; | - | ||||||||||||
417 | if (s->d1->timeout.read_timeouts > 2
| 0-45 | ||||||||||||
418 | s->d1->timeout.read_timeouts = 1; | - | ||||||||||||
419 | } never executed: end of block | 0 | ||||||||||||
420 | - | |||||||||||||
421 | dtls1_start_timer(s); | - | ||||||||||||
422 | - | |||||||||||||
423 | return executed 45 times by 1 test: dtls1_retransmit_buffered_messages(s);return dtls1_retransmit_buffered_messages(s); Executed by:
executed 45 times by 1 test: return dtls1_retransmit_buffered_messages(s); Executed by:
| 45 | ||||||||||||
424 | } | - | ||||||||||||
425 | - | |||||||||||||
426 | static void get_current_time(struct timeval *t) | - | ||||||||||||
427 | { | - | ||||||||||||
428 | gettimeofday(t, | - | ||||||||||||
429 | ((void *)0) | - | ||||||||||||
430 | ); | - | ||||||||||||
431 | - | |||||||||||||
432 | } executed 8646 times by 1 test: end of block Executed by:
| 8646 | ||||||||||||
433 | - | |||||||||||||
434 | - | |||||||||||||
435 | - | |||||||||||||
436 | - | |||||||||||||
437 | - | |||||||||||||
438 | int DTLSv1_listen(SSL *s, BIO_ADDR *client) | - | ||||||||||||
439 | { | - | ||||||||||||
440 | int next, n, ret = 0, clearpkt = 0; | - | ||||||||||||
441 | unsigned char cookie[256]; | - | ||||||||||||
442 | unsigned char seq[8]; | - | ||||||||||||
443 | const unsigned char *data; | - | ||||||||||||
444 | unsigned char *buf; | - | ||||||||||||
445 | size_t fragoff, fraglen, msglen; | - | ||||||||||||
446 | unsigned int rectype, versmajor, msgseq, msgtype, clientvers, cookielen; | - | ||||||||||||
447 | BIO *rbio, *wbio; | - | ||||||||||||
448 | BUF_MEM *bufm; | - | ||||||||||||
449 | BIO_ADDR *tmpclient = | - | ||||||||||||
450 | ((void *)0) | - | ||||||||||||
451 | ; | - | ||||||||||||
452 | PACKET pkt, msgpkt, msgpayload, session, cookiepkt; | - | ||||||||||||
453 | - | |||||||||||||
454 | if (s->handshake_func ==
| 0-9 | ||||||||||||
455 | ((void *)0)
| 0-9 | ||||||||||||
456 | ) { | - | ||||||||||||
457 | - | |||||||||||||
458 | SSL_set_accept_state(s); | - | ||||||||||||
459 | } executed 9 times by 1 test: end of block Executed by:
| 9 | ||||||||||||
460 | - | |||||||||||||
461 | - | |||||||||||||
462 | if (!SSL_clear(s)
| 0-9 | ||||||||||||
463 | return never executed: -1;return -1; never executed: return -1; | 0 | ||||||||||||
464 | - | |||||||||||||
465 | ERR_clear_error(); | - | ||||||||||||
466 | - | |||||||||||||
467 | rbio = SSL_get_rbio(s); | - | ||||||||||||
468 | wbio = SSL_get_wbio(s); | - | ||||||||||||
469 | - | |||||||||||||
470 | if (!rbio
| 0-9 | ||||||||||||
471 | ERR_put_error(20,(350),(128),__FILE__,475); | - | ||||||||||||
472 | return never executed: -1;return -1; never executed: return -1; | 0 | ||||||||||||
473 | } | - | ||||||||||||
474 | - | |||||||||||||
475 | - | |||||||||||||
476 | - | |||||||||||||
477 | - | |||||||||||||
478 | - | |||||||||||||
479 | - | |||||||||||||
480 | BIO_ctrl(SSL_get_rbio(s), 71, 1, | - | ||||||||||||
481 | ((void *)0) | - | ||||||||||||
482 | ); | - | ||||||||||||
483 | if ((
| 0-9 | ||||||||||||
484 | ERR_put_error(20,(350),(259),__FILE__,494); | - | ||||||||||||
485 | return never executed: -1;return -1; never executed: return -1; | 0 | ||||||||||||
486 | } | - | ||||||||||||
487 | - | |||||||||||||
488 | if (s->init_buf ==
| 0-9 | ||||||||||||
489 | ((void *)0)
| 0-9 | ||||||||||||
490 | ) { | - | ||||||||||||
491 | if ((
| 0-9 | ||||||||||||
492 | ((void *)0)
| 0-9 | ||||||||||||
493 | ) { | - | ||||||||||||
494 | ERR_put_error(20,(350),((1|64)),__FILE__,500); | - | ||||||||||||
495 | return never executed: -1;return -1; never executed: return -1; | 0 | ||||||||||||
496 | } | - | ||||||||||||
497 | - | |||||||||||||
498 | if (!BUF_MEM_grow(bufm, 16384)
| 0-9 | ||||||||||||
499 | BUF_MEM_free(bufm); | - | ||||||||||||
500 | ERR_put_error(20,(350),((1|64)),__FILE__,506); | - | ||||||||||||
501 | return never executed: -1;return -1; never executed: return -1; | 0 | ||||||||||||
502 | } | - | ||||||||||||
503 | s->init_buf = bufm; | - | ||||||||||||
504 | } executed 9 times by 1 test: end of block Executed by:
| 9 | ||||||||||||
505 | buf = (unsigned char *)s->init_buf->data; | - | ||||||||||||
506 | - | |||||||||||||
507 | do { | - | ||||||||||||
508 | - | |||||||||||||
509 | - | |||||||||||||
510 | - | |||||||||||||
511 | (*__errno_location ()) | - | ||||||||||||
512 | =0; | - | ||||||||||||
513 | n = BIO_read(rbio, buf, 16384); | - | ||||||||||||
514 | - | |||||||||||||
515 | if (n <= 0
| 3-9 | ||||||||||||
516 | if (BIO_test_flags(rbio, 0x08)
| 0-3 | ||||||||||||
517 | - | |||||||||||||
518 | goto executed 3 times by 1 test: end;goto end; Executed by:
executed 3 times by 1 test: goto end; Executed by:
| 3 | ||||||||||||
519 | } | - | ||||||||||||
520 | return never executed: -1;return -1; never executed: return -1; | 0 | ||||||||||||
521 | } | - | ||||||||||||
522 | - | |||||||||||||
523 | - | |||||||||||||
524 | clearpkt = 1; | - | ||||||||||||
525 | - | |||||||||||||
526 | if (!PACKET_buf_init(&pkt, buf, n)
| 0-9 | ||||||||||||
527 | ERR_put_error(20,(350),((4|64)),__FILE__,539); | - | ||||||||||||
528 | return never executed: -1;return -1; never executed: return -1; | 0 | ||||||||||||
529 | } | - | ||||||||||||
530 | if (n < 13
| 1-8 | ||||||||||||
531 | ERR_put_error(20,(350),(298),__FILE__,554); | - | ||||||||||||
532 | goto executed 1 time by 1 test: end;goto end; Executed by:
executed 1 time by 1 test: goto end; Executed by:
| 1 | ||||||||||||
533 | } | - | ||||||||||||
534 | - | |||||||||||||
535 | if (s->msg_callback
| 0-8 | ||||||||||||
536 | s->msg_callback(0, 0, 0x100, buf, never executed: s->msg_callback(0, 0, 0x100, buf, 13, s, s->msg_callback_arg); | 0 | ||||||||||||
537 | 13, s, s->msg_callback_arg); never executed: s->msg_callback(0, 0, 0x100, buf, 13, s, s->msg_callback_arg); | 0 | ||||||||||||
538 | - | |||||||||||||
539 | - | |||||||||||||
540 | if (!PACKET_get_1(&pkt, &rectype)
| 0-8 | ||||||||||||
541 | || !PACKET_get_1(&pkt, &versmajor)
| 0-8 | ||||||||||||
542 | ERR_put_error(20,(350),(159),__FILE__,565); | - | ||||||||||||
543 | goto never executed: end;goto end; never executed: goto end; | 0 | ||||||||||||
544 | } | - | ||||||||||||
545 | - | |||||||||||||
546 | if (rectype != 22
| 0-8 | ||||||||||||
547 | ERR_put_error(20,(350),(244),__FILE__,570); | - | ||||||||||||
548 | goto never executed: end;goto end; never executed: goto end; | 0 | ||||||||||||
549 | } | - | ||||||||||||
550 | - | |||||||||||||
551 | - | |||||||||||||
552 | - | |||||||||||||
553 | - | |||||||||||||
554 | - | |||||||||||||
555 | if (versmajor != 0xFE
| 0-8 | ||||||||||||
556 | ERR_put_error(20,(350),(116),__FILE__,579); | - | ||||||||||||
557 | goto never executed: end;goto end; never executed: goto end; | 0 | ||||||||||||
558 | } | - | ||||||||||||
559 | - | |||||||||||||
560 | if (!PACKET_forward(&pkt, 1)
| 0-8 | ||||||||||||
561 | - | |||||||||||||
562 | || !PACKET_copy_bytes(&pkt, seq, 8)
| 0-8 | ||||||||||||
563 | || !PACKET_get_length_prefixed_2(&pkt, &msgpkt)
| 0-8 | ||||||||||||
564 | ERR_put_error(20,(350),(159),__FILE__,587); | - | ||||||||||||
565 | goto never executed: end;goto end; never executed: goto end; | 0 | ||||||||||||
566 | } | - | ||||||||||||
567 | - | |||||||||||||
568 | - | |||||||||||||
569 | - | |||||||||||||
570 | - | |||||||||||||
571 | - | |||||||||||||
572 | - | |||||||||||||
573 | if (seq[0] != 0
| 0-8 | ||||||||||||
574 | ERR_put_error(20,(350),(244),__FILE__,597); | - | ||||||||||||
575 | goto never executed: end;goto end; never executed: goto end; | 0 | ||||||||||||
576 | } | - | ||||||||||||
577 | - | |||||||||||||
578 | - | |||||||||||||
579 | data = PACKET_data(&msgpkt); | - | ||||||||||||
580 | - | |||||||||||||
581 | - | |||||||||||||
582 | if (!PACKET_get_1(&msgpkt, &msgtype)
| 0-8 | ||||||||||||
583 | || !PACKET_get_net_3_len(&msgpkt, &msglen)
| 0-8 | ||||||||||||
584 | || !PACKET_get_net_2(&msgpkt, &msgseq)
| 0-8 | ||||||||||||
585 | || !PACKET_get_net_3_len(&msgpkt, &fragoff)
| 0-8 | ||||||||||||
586 | || !PACKET_get_net_3_len(&msgpkt, &fraglen)
| 0-8 | ||||||||||||
587 | || !PACKET_get_sub_packet(&msgpkt, &msgpayload, fraglen)
| 0-8 | ||||||||||||
588 | || PACKET_remaining(&msgpkt) != 0
| 0-8 | ||||||||||||
589 | ERR_put_error(20,(350),(159),__FILE__,612); | - | ||||||||||||
590 | goto never executed: end;goto end; never executed: goto end; | 0 | ||||||||||||
591 | } | - | ||||||||||||
592 | - | |||||||||||||
593 | if (msgtype != 1
| 0-8 | ||||||||||||
594 | ERR_put_error(20,(350),(244),__FILE__,617); | - | ||||||||||||
595 | goto never executed: end;goto end; never executed: goto end; | 0 | ||||||||||||
596 | } | - | ||||||||||||
597 | - | |||||||||||||
598 | - | |||||||||||||
599 | if (msgseq > 2
| 0-8 | ||||||||||||
600 | ERR_put_error(20,(350),(402),__FILE__,623); | - | ||||||||||||
601 | goto never executed: end;goto end; never executed: goto end; | 0 | ||||||||||||
602 | } | - | ||||||||||||
603 | if (fragoff != 0
| 0-7 | ||||||||||||
604 | - | |||||||||||||
605 | ERR_put_error(20,(350),(401),__FILE__,636); | - | ||||||||||||
606 | goto executed 1 time by 1 test: end;goto end; Executed by:
executed 1 time by 1 test: goto end; Executed by:
| 1 | ||||||||||||
607 | } | - | ||||||||||||
608 | - | |||||||||||||
609 | if (s->msg_callback
| 0-7 | ||||||||||||
610 | s->msg_callback(0, s->version, 22, data, never executed: s->msg_callback(0, s->version, 22, data, fraglen + 12, s, s->msg_callback_arg); | 0 | ||||||||||||
611 | fraglen + 12, s, never executed: s->msg_callback(0, s->version, 22, data, fraglen + 12, s, s->msg_callback_arg); | 0 | ||||||||||||
612 | s->msg_callback_arg); never executed: s->msg_callback(0, s->version, 22, data, fraglen + 12, s, s->msg_callback_arg); | 0 | ||||||||||||
613 | - | |||||||||||||
614 | if (!PACKET_get_net_2(&msgpayload, &clientvers)
| 0-7 | ||||||||||||
615 | ERR_put_error(20,(350),(159),__FILE__,646); | - | ||||||||||||
616 | goto never executed: end;goto end; never executed: goto end; | 0 | ||||||||||||
617 | } | - | ||||||||||||
618 | - | |||||||||||||
619 | - | |||||||||||||
620 | - | |||||||||||||
621 | - | |||||||||||||
622 | if (((((
| 0-7 | ||||||||||||
623 | s->method->version != 0x1FFFF
| 0 | ||||||||||||
624 | ERR_put_error(20,(350),(267),__FILE__,655); | - | ||||||||||||
625 | goto never executed: end;goto end; never executed: goto end; | 0 | ||||||||||||
626 | } | - | ||||||||||||
627 | - | |||||||||||||
628 | if (!PACKET_forward(&msgpayload, 32)
| 0-7 | ||||||||||||
629 | || !PACKET_get_length_prefixed_1(&msgpayload, &session)
| 0-7 | ||||||||||||
630 | || !PACKET_get_length_prefixed_1(&msgpayload, &cookiepkt)
| 2-5 | ||||||||||||
631 | - | |||||||||||||
632 | - | |||||||||||||
633 | - | |||||||||||||
634 | - | |||||||||||||
635 | ERR_put_error(20,(350),(159),__FILE__,666); | - | ||||||||||||
636 | goto executed 2 times by 1 test: end;goto end; Executed by:
executed 2 times by 1 test: goto end; Executed by:
| 2 | ||||||||||||
637 | } | - | ||||||||||||
638 | - | |||||||||||||
639 | - | |||||||||||||
640 | - | |||||||||||||
641 | - | |||||||||||||
642 | - | |||||||||||||
643 | if (PACKET_remaining(&cookiepkt) == 0
| 2-3 | ||||||||||||
644 | next = 1; | - | ||||||||||||
645 | } executed 2 times by 1 test: else {end of block Executed by:
| 2 | ||||||||||||
646 | - | |||||||||||||
647 | - | |||||||||||||
648 | - | |||||||||||||
649 | if (s->ctx->app_verify_cookie_cb ==
| 0-3 | ||||||||||||
650 | ((void *)0)
| 0-3 | ||||||||||||
651 | ) { | - | ||||||||||||
652 | ERR_put_error(20,(350),(403),__FILE__,681); | - | ||||||||||||
653 | - | |||||||||||||
654 | return never executed: -1;return -1; never executed: return -1; | 0 | ||||||||||||
655 | } | - | ||||||||||||
656 | if (s->ctx->app_verify_cookie_cb(s, PACKET_data(&cookiepkt),
| 1-2 | ||||||||||||
657 | (unsigned int)PACKET_remaining(&cookiepkt)) == 0
| 1-2 | ||||||||||||
658 | - | |||||||||||||
659 | - | |||||||||||||
660 | - | |||||||||||||
661 | - | |||||||||||||
662 | next = 1; | - | ||||||||||||
663 | } executed 1 time by 1 test: else {end of block Executed by:
| 1 | ||||||||||||
664 | - | |||||||||||||
665 | next = 2; | - | ||||||||||||
666 | } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||
667 | } | - | ||||||||||||
668 | - | |||||||||||||
669 | if (next == 1
| 2-3 | ||||||||||||
670 | WPACKET wpkt; | - | ||||||||||||
671 | unsigned int version; | - | ||||||||||||
672 | size_t wreclen; | - | ||||||||||||
673 | BIO_ctrl(SSL_get_rbio(s), 71, 0, | - | ||||||||||||
674 | ((void *)0) | - | ||||||||||||
675 | ); | - | ||||||||||||
676 | BIO_read(rbio, buf, 16384); | - | ||||||||||||
677 | BIO_ctrl(SSL_get_rbio(s), 71, 1, | - | ||||||||||||
678 | ((void *)0) | - | ||||||||||||
679 | ); | - | ||||||||||||
680 | - | |||||||||||||
681 | - | |||||||||||||
682 | if (s->ctx->app_gen_cookie_cb ==
| 0-3 | ||||||||||||
683 | ((void *)0)
| 0-3 | ||||||||||||
684 | || | - | ||||||||||||
685 | s->ctx->app_gen_cookie_cb(s, cookie, &cookielen) == 0
| 0-3 | ||||||||||||
686 | cookielen > 255
| 0-3 | ||||||||||||
687 | ERR_put_error(20,(350),(400),__FILE__,721); | - | ||||||||||||
688 | - | |||||||||||||
689 | return never executed: -1;return -1; never executed: return -1; | 0 | ||||||||||||
690 | } | - | ||||||||||||
691 | - | |||||||||||||
692 | - | |||||||||||||
693 | - | |||||||||||||
694 | - | |||||||||||||
695 | - | |||||||||||||
696 | - | |||||||||||||
697 | version = (
| 0-3 | ||||||||||||
698 | : s->version; | - | ||||||||||||
699 | - | |||||||||||||
700 | - | |||||||||||||
701 | if (!WPACKET_init(&wpkt, s->init_buf)
| 0-3 | ||||||||||||
702 | || !WPACKET_put_bytes__((&wpkt), (22), 1)
| 0-3 | ||||||||||||
703 | || !WPACKET_put_bytes__((&wpkt), (version), 2)
| 0-3 | ||||||||||||
704 | - | |||||||||||||
705 | - | |||||||||||||
706 | - | |||||||||||||
707 | - | |||||||||||||
708 | || !WPACKET_memcpy(&wpkt, seq, 8)
| 0-3 | ||||||||||||
709 | - | |||||||||||||
710 | || !WPACKET_start_sub_packet_len__((&wpkt), 2)
| 0-3 | ||||||||||||
711 | - | |||||||||||||
712 | || !WPACKET_put_bytes__((&wpkt), (3), 1)
| 0-3 | ||||||||||||
713 | - | |||||||||||||
714 | - | |||||||||||||
715 | - | |||||||||||||
716 | - | |||||||||||||
717 | - | |||||||||||||
718 | - | |||||||||||||
719 | - | |||||||||||||
720 | || !WPACKET_put_bytes__((&wpkt), (0), 3)
| 0-3 | ||||||||||||
721 | - | |||||||||||||
722 | - | |||||||||||||
723 | - | |||||||||||||
724 | - | |||||||||||||
725 | || !WPACKET_put_bytes__((&wpkt), (0), 2)
| 0-3 | ||||||||||||
726 | - | |||||||||||||
727 | - | |||||||||||||
728 | - | |||||||||||||
729 | - | |||||||||||||
730 | || !WPACKET_put_bytes__((&wpkt), (0), 3)
| 0-3 | ||||||||||||
731 | - | |||||||||||||
732 | - | |||||||||||||
733 | - | |||||||||||||
734 | - | |||||||||||||
735 | - | |||||||||||||
736 | - | |||||||||||||
737 | || !WPACKET_start_sub_packet_len__((&wpkt), 3)
| 0-3 | ||||||||||||
738 | - | |||||||||||||
739 | || !dtls_raw_hello_verify_request(&wpkt, cookie, cookielen)
| 0-3 | ||||||||||||
740 | - | |||||||||||||
741 | || !WPACKET_close(&wpkt)
| 0-3 | ||||||||||||
742 | - | |||||||||||||
743 | || !WPACKET_close(&wpkt)
| 0-3 | ||||||||||||
744 | || !WPACKET_get_total_written(&wpkt, &wreclen)
| 0-3 | ||||||||||||
745 | || !WPACKET_finish(&wpkt)
| 0-3 | ||||||||||||
746 | ERR_put_error(20,(350),((4|64)),__FILE__,780); | - | ||||||||||||
747 | WPACKET_cleanup(&wpkt); | - | ||||||||||||
748 | - | |||||||||||||
749 | return never executed: -1;return -1; never executed: return -1; | 0 | ||||||||||||
750 | } | - | ||||||||||||
751 | memcpy(&buf[13 + 1], | - | ||||||||||||
752 | &buf[13 + 12 - 3], | - | ||||||||||||
753 | 3); | - | ||||||||||||
754 | - | |||||||||||||
755 | if (s->msg_callback
| 0-3 | ||||||||||||
756 | s->msg_callback(1, 0, 0x100, buf, never executed: s->msg_callback(1, 0, 0x100, buf, 13, s, s->msg_callback_arg); | 0 | ||||||||||||
757 | 13, s, s->msg_callback_arg); never executed: s->msg_callback(1, 0, 0x100, buf, 13, s, s->msg_callback_arg); | 0 | ||||||||||||
758 | - | |||||||||||||
759 | if ((
| 0-3 | ||||||||||||
760 | ((void *)0)
| 0-3 | ||||||||||||
761 | ) { | - | ||||||||||||
762 | ERR_put_error(20,(350),((1|64)),__FILE__,802); | - | ||||||||||||
763 | goto never executed: end;goto end; never executed: goto end; | 0 | ||||||||||||
764 | } | - | ||||||||||||
765 | - | |||||||||||||
766 | - | |||||||||||||
767 | - | |||||||||||||
768 | - | |||||||||||||
769 | - | |||||||||||||
770 | - | |||||||||||||
771 | if ((
| 0-3 | ||||||||||||
772 | (void)(int)BIO_ctrl(wbio, 44, 0, (char *)(tmpclient)); | - | ||||||||||||
773 | } never executed: end of block | 0 | ||||||||||||
774 | BIO_ADDR_free(tmpclient); | - | ||||||||||||
775 | tmpclient = | - | ||||||||||||
776 | ((void *)0) | - | ||||||||||||
777 | ; | - | ||||||||||||
778 | - | |||||||||||||
779 | - | |||||||||||||
780 | if (BIO_write(wbio, buf, wreclen) < (int)wreclen
| 0-3 | ||||||||||||
781 | if (BIO_test_flags(wbio, 0x08)
| 0 | ||||||||||||
782 | - | |||||||||||||
783 | - | |||||||||||||
784 | - | |||||||||||||
785 | - | |||||||||||||
786 | goto never executed: end;goto end; never executed: goto end; | 0 | ||||||||||||
787 | } | - | ||||||||||||
788 | return never executed: -1;return -1; never executed: return -1; | 0 | ||||||||||||
789 | } | - | ||||||||||||
790 | - | |||||||||||||
791 | if ((
| 0-3 | ||||||||||||
792 | ((void *)0)
| 0-3 | ||||||||||||
793 | ) <= 0
| 0-3 | ||||||||||||
794 | if (BIO_test_flags(wbio, 0x08)
| 0 | ||||||||||||
795 | - | |||||||||||||
796 | - | |||||||||||||
797 | - | |||||||||||||
798 | - | |||||||||||||
799 | goto never executed: end;goto end; never executed: goto end; | 0 | ||||||||||||
800 | } | - | ||||||||||||
801 | return never executed: -1;return -1; never executed: return -1; | 0 | ||||||||||||
802 | } | - | ||||||||||||
803 | } executed 3 times by 1 test: end of block Executed by:
| 3 | ||||||||||||
804 | } executed 5 times by 1 test: while (next != 2end of block Executed by:
| 2-5 | ||||||||||||
805 | - | |||||||||||||
806 | - | |||||||||||||
807 | - | |||||||||||||
808 | - | |||||||||||||
809 | s->d1->handshake_read_seq = 1; | - | ||||||||||||
810 | s->d1->handshake_write_seq = 1; | - | ||||||||||||
811 | s->d1->next_handshake_write_seq = 1; | - | ||||||||||||
812 | DTLS_RECORD_LAYER_set_write_sequence(&s->rlayer, seq); | - | ||||||||||||
813 | - | |||||||||||||
814 | - | |||||||||||||
815 | - | |||||||||||||
816 | - | |||||||||||||
817 | - | |||||||||||||
818 | SSL_set_options(s, 0x00002000U); | - | ||||||||||||
819 | - | |||||||||||||
820 | - | |||||||||||||
821 | - | |||||||||||||
822 | - | |||||||||||||
823 | - | |||||||||||||
824 | ossl_statem_set_hello_verify_done(s); | - | ||||||||||||
825 | - | |||||||||||||
826 | - | |||||||||||||
827 | - | |||||||||||||
828 | - | |||||||||||||
829 | if ((
| 0-2 | ||||||||||||
830 | BIO_ADDR_clear(client); executed 2 times by 1 test: BIO_ADDR_clear(client); Executed by:
| 2 | ||||||||||||
831 | - | |||||||||||||
832 | ret = 1; | - | ||||||||||||
833 | clearpkt = 0; | - | ||||||||||||
834 | end: code before this statement executed 2 times by 1 test: end: Executed by:
| 2 | ||||||||||||
835 | BIO_ADDR_free(tmpclient); | - | ||||||||||||
836 | BIO_ctrl(SSL_get_rbio(s), 71, 0, | - | ||||||||||||
837 | ((void *)0) | - | ||||||||||||
838 | ); | - | ||||||||||||
839 | if (clearpkt
| 2-7 | ||||||||||||
840 | - | |||||||||||||
841 | BIO_read(rbio, buf, 16384); | - | ||||||||||||
842 | } executed 7 times by 1 test: end of block Executed by:
| 7 | ||||||||||||
843 | return executed 9 times by 1 test: ret;return ret; Executed by:
executed 9 times by 1 test: return ret; Executed by:
| 9 | ||||||||||||
844 | } | - | ||||||||||||
845 | - | |||||||||||||
846 | - | |||||||||||||
847 | static int dtls1_handshake_write(SSL *s) | - | ||||||||||||
848 | { | - | ||||||||||||
849 | return executed 1532 times by 1 test: dtls1_do_write(s, 22);return dtls1_do_write(s, 22); Executed by:
executed 1532 times by 1 test: return dtls1_do_write(s, 22); Executed by:
| 1532 | ||||||||||||
850 | } | - | ||||||||||||
851 | - | |||||||||||||
852 | int dtls1_shutdown(SSL *s) | - | ||||||||||||
853 | { | - | ||||||||||||
854 | int ret; | - | ||||||||||||
855 | ret = ssl3_shutdown(s); | - | ||||||||||||
856 | - | |||||||||||||
857 | - | |||||||||||||
858 | - | |||||||||||||
859 | return executed 438 times by 1 test: ret;return ret; Executed by:
executed 438 times by 1 test: return ret; Executed by:
| 438 | ||||||||||||
860 | } | - | ||||||||||||
861 | - | |||||||||||||
862 | int dtls1_query_mtu(SSL *s) | - | ||||||||||||
863 | { | - | ||||||||||||
864 | if (s->d1->link_mtu
| 0-2013 | ||||||||||||
865 | s->d1->mtu = | - | ||||||||||||
866 | s->d1->link_mtu - (unsigned int)BIO_ctrl((SSL_get_wbio(s)), 49, 0, | - | ||||||||||||
867 | ((void *)0) | - | ||||||||||||
868 | ); | - | ||||||||||||
869 | s->d1->link_mtu = 0; | - | ||||||||||||
870 | } never executed: end of block | 0 | ||||||||||||
871 | - | |||||||||||||
872 | - | |||||||||||||
873 | if (s->d1->mtu < dtls1_min_mtu(s)
| 359-1654 | ||||||||||||
874 | if (!(SSL_get_options(s) & 0x00001000U)
| 0-359 | ||||||||||||
875 | s->d1->mtu = | - | ||||||||||||
876 | BIO_ctrl(SSL_get_wbio(s), 40, 0, | - | ||||||||||||
877 | ((void *)0) | - | ||||||||||||
878 | ); | - | ||||||||||||
879 | - | |||||||||||||
880 | - | |||||||||||||
881 | - | |||||||||||||
882 | - | |||||||||||||
883 | - | |||||||||||||
884 | if (s->d1->mtu < dtls1_min_mtu(s)
| 0-359 | ||||||||||||
885 | - | |||||||||||||
886 | s->d1->mtu = dtls1_min_mtu(s); | - | ||||||||||||
887 | BIO_ctrl(SSL_get_wbio(s), 42, | - | ||||||||||||
888 | (long)s->d1->mtu, | - | ||||||||||||
889 | ((void *)0) | - | ||||||||||||
890 | ); | - | ||||||||||||
891 | } executed 359 times by 1 test: end of block Executed by:
| 359 | ||||||||||||
892 | } executed 359 times by 1 test: elseend of block Executed by:
| 359 | ||||||||||||
893 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||
894 | } | - | ||||||||||||
895 | return executed 2013 times by 1 test: 1;return 1; Executed by:
executed 2013 times by 1 test: return 1; Executed by:
| 2013 | ||||||||||||
896 | } | - | ||||||||||||
897 | - | |||||||||||||
898 | static size_t dtls1_link_min_mtu(void) | - | ||||||||||||
899 | { | - | ||||||||||||
900 | return executed 5581 times by 1 test: (g_probable_mtu[(sizeof(g_probable_mtu) /return (g_probable_mtu[(sizeof(g_probable_mtu) / sizeof(g_probable_mtu[0])) - 1]); Executed by:
executed 5581 times by 1 test: return (g_probable_mtu[(sizeof(g_probable_mtu) / sizeof(g_probable_mtu[0])) - 1]); Executed by:
| 5581 | ||||||||||||
901 | sizeof(g_probable_mtu[0])) - 1]); executed 5581 times by 1 test: return (g_probable_mtu[(sizeof(g_probable_mtu) / sizeof(g_probable_mtu[0])) - 1]); Executed by:
| 5581 | ||||||||||||
902 | } | - | ||||||||||||
903 | - | |||||||||||||
904 | size_t dtls1_min_mtu(SSL *s) | - | ||||||||||||
905 | { | - | ||||||||||||
906 | return executed 4744 times by 1 test: dtls1_link_min_mtu() - (unsigned int)BIO_ctrl((SSL_get_wbio(s)), 49, 0, return dtls1_link_min_mtu() - (unsigned int)BIO_ctrl((SSL_get_wbio(s)), 49, 0, ((void *)0) ); Executed by:
executed 4744 times by 1 test: return dtls1_link_min_mtu() - (unsigned int)BIO_ctrl((SSL_get_wbio(s)), 49, 0, ((void *)0) ); Executed by:
| 4744 | ||||||||||||
907 | ((void *)0) executed 4744 times by 1 test: return dtls1_link_min_mtu() - (unsigned int)BIO_ctrl((SSL_get_wbio(s)), 49, 0, ((void *)0) ); Executed by:
| 4744 | ||||||||||||
908 | ); executed 4744 times by 1 test: return dtls1_link_min_mtu() - (unsigned int)BIO_ctrl((SSL_get_wbio(s)), 49, 0, ((void *)0) ); Executed by:
| 4744 | ||||||||||||
909 | } | - | ||||||||||||
910 | - | |||||||||||||
911 | size_t DTLS_get_data_mtu(const SSL *s) | - | ||||||||||||
912 | { | - | ||||||||||||
913 | size_t mac_overhead, int_overhead, blocksize, ext_overhead; | - | ||||||||||||
914 | const SSL_CIPHER *ciph = SSL_get_current_cipher(s); | - | ||||||||||||
915 | size_t mtu = s->d1->mtu; | - | ||||||||||||
916 | - | |||||||||||||
917 | if (ciph ==
| 0-810 | ||||||||||||
918 | ((void *)0)
| 0-810 | ||||||||||||
919 | ) | - | ||||||||||||
920 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||
921 | - | |||||||||||||
922 | if (!ssl_cipher_get_overhead(ciph, &mac_overhead, &int_overhead,
| 0-810 | ||||||||||||
923 | &blocksize, &ext_overhead)
| 0-810 | ||||||||||||
924 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||
925 | - | |||||||||||||
926 | if ((
| 270-540 | ||||||||||||
927 | ext_overhead += mac_overhead; executed 270 times by 1 test: ext_overhead += mac_overhead; Executed by:
| 270 | ||||||||||||
928 | else | - | ||||||||||||
929 | int_overhead += mac_overhead; executed 540 times by 1 test: int_overhead += mac_overhead; Executed by:
| 540 | ||||||||||||
930 | - | |||||||||||||
931 | - | |||||||||||||
932 | if (ext_overhead + 13 >= mtu
| 0-810 | ||||||||||||
933 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||
934 | mtu -= ext_overhead + 13; | - | ||||||||||||
935 | - | |||||||||||||
936 | - | |||||||||||||
937 | - | |||||||||||||
938 | if (blocksize
| 360-450 | ||||||||||||
939 | mtu -= (mtu % blocksize); executed 360 times by 1 test: mtu -= (mtu % blocksize); Executed by:
| 360 | ||||||||||||
940 | - | |||||||||||||
941 | - | |||||||||||||
942 | if (int_overhead >= mtu
| 0-810 | ||||||||||||
943 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||
944 | mtu -= int_overhead; | - | ||||||||||||
945 | - | |||||||||||||
946 | return executed 810 times by 1 test: mtu;return mtu; Executed by:
executed 810 times by 1 test: return mtu; Executed by:
| 810 | ||||||||||||
947 | } | - | ||||||||||||
948 | - | |||||||||||||
949 | void DTLS_set_timer_cb(SSL *s, DTLS_timer_cb cb) | - | ||||||||||||
950 | { | - | ||||||||||||
951 | s->d1->timer_cb = cb; | - | ||||||||||||
952 | } executed 50 times by 1 test: end of block Executed by:
| 50 | ||||||||||||
Switch to Source code | Preprocessed file |