OpenCoverage

statem.c

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/openssl/src/ssl/statem/statem.c
Source codeSwitch to Preprocessed file
LineSourceCount
1/*-
2 * Copyright 2015-2018 The OpenSSL Project Authors. All Rights Reserved.-
3 *-
4 * Licensed under the OpenSSL license (the "License"). You may not use-
5 * this file except in compliance with the License. You can obtain a copy-
6 * in the file LICENSE in the source distribution or at-
7 * https://www.openssl.org/source/license.html-
8 */-
9-
10#include "internal/cryptlib.h"-
11#include <openssl/rand.h>-
12#include "../ssl_locl.h"-
13#include "statem_locl.h"-
14#include <assert.h>-
15-
16/*-
17 * This file implements the SSL/TLS/DTLS state machines.-
18 *-
19 * There are two primary state machines:-
20 *-
21 * 1) Message flow state machine-
22 * 2) Handshake state machine-
23 *-
24 * The Message flow state machine controls the reading and sending of messages-
25 * including handling of non-blocking IO events, flushing of the underlying-
26 * write BIO, handling unexpected messages, etc. It is itself broken into two-
27 * separate sub-state machines which control reading and writing respectively.-
28 *-
29 * The Handshake state machine keeps track of the current SSL/TLS handshake-
30 * state. Transitions of the handshake state are the result of events that-
31 * occur within the Message flow state machine.-
32 *-
33 * Overall it looks like this:-
34 *-
35 * --------------------------------------------- --------------------
36 * | | | |-
37 * | Message flow state machine | | |-
38 * | | | |-
39 * | -------------------- -------------------- | Transition | Handshake state |-
40 * | | MSG_FLOW_READING | | MSG_FLOW_WRITING | | Event | machine |-
41 * | | sub-state | | sub-state | |----------->| |-
42 * | | machine for | | machine for | | | |-
43 * | | reading messages | | writing messages | | | |-
44 * | -------------------- -------------------- | | |-
45 * | | | |-
46 * --------------------------------------------- --------------------
47 *-
48 */-
49-
50/* Sub state machine return values */-
51typedef enum {-
52 /* Something bad happened or NBIO */-
53 SUB_STATE_ERROR,-
54 /* Sub state finished go to the next sub state */-
55 SUB_STATE_FINISHED,-
56 /* Sub state finished and handshake was completed */-
57 SUB_STATE_END_HANDSHAKE-
58} SUB_STATE_RETURN;-
59-
60static int state_machine(SSL *s, int server);-
61static void init_read_state_machine(SSL *s);-
62static SUB_STATE_RETURN read_state_machine(SSL *s);-
63static void init_write_state_machine(SSL *s);-
64static SUB_STATE_RETURN write_state_machine(SSL *s);-
65-
66OSSL_HANDSHAKE_STATE SSL_get_state(const SSL *ssl)-
67{-
68 return ssl->statem.hand_state;
executed 41174 times by 1 test: return ssl->statem.hand_state;
Executed by:
  • libssl.so.1.1
41174
69}-
70-
71int SSL_in_init(const SSL *s)-
72{-
73 return s->statem.in_init;
executed 180793 times by 1 test: return s->statem.in_init;
Executed by:
  • libssl.so.1.1
180793
74}-
75-
76int SSL_is_init_finished(const SSL *s)-
77{-
78 return !(s->statem.in_init) && (s->statem.hand_state == TLS_ST_OK);
executed 7657 times by 1 test: return !(s->statem.in_init) && (s->statem.hand_state == TLS_ST_OK);
Executed by:
  • libssl.so.1.1
!(s->statem.in_init)Description
TRUEevaluated 1152 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 6505 times by 1 test
Evaluated by:
  • libssl.so.1.1
(s->statem.han... == TLS_ST_OK)Description
TRUEevaluated 1152 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEnever evaluated
0-7657
79}-
80-
81int SSL_in_before(const SSL *s)-
82{-
83 /*-
84 * Historically being "in before" meant before anything had happened. In the-
85 * current code though we remain in the "before" state for a while after we-
86 * have started the handshake process (e.g. as a server waiting for the-
87 * first message to arrive). There "in before" is taken to mean "in before"-
88 * and not started any handshake process yet.-
89 */-
90 return (s->statem.hand_state == TLS_ST_BEFORE)
executed 44252 times by 1 test: return (s->statem.hand_state == TLS_ST_BEFORE) && (s->statem.state == MSG_FLOW_UNINITED);
Executed by:
  • libssl.so.1.1
(s->statem.han...TLS_ST_BEFORE)Description
TRUEevaluated 17447 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 26805 times by 1 test
Evaluated by:
  • libssl.so.1.1
17447-44252
91 && (s->statem.state == MSG_FLOW_UNINITED);
executed 44252 times by 1 test: return (s->statem.hand_state == TLS_ST_BEFORE) && (s->statem.state == MSG_FLOW_UNINITED);
Executed by:
  • libssl.so.1.1
(s->statem.sta...FLOW_UNINITED)Description
TRUEevaluated 16730 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 717 times by 1 test
Evaluated by:
  • libssl.so.1.1
717-44252
92}-
93-
94/*-
95 * Clear the state machine state and reset back to MSG_FLOW_UNINITED-
96 */-
97void ossl_statem_clear(SSL *s)-
98{-
99 s->statem.state = MSG_FLOW_UNINITED;-
100 s->statem.hand_state = TLS_ST_BEFORE;-
101 s->statem.in_init = 1;-
102 s->statem.no_cert_verify = 0;-
103}
executed 24376 times by 2 tests: end of block
Executed by:
  • libssl.so.1.1
  • tls13encryptiontest
24376
104-
105/*-
106 * Set the state machine up ready for a renegotiation handshake-
107 */-
108void ossl_statem_set_renegotiate(SSL *s)-
109{-
110 s->statem.in_init = 1;-
111 s->statem.request_state = TLS_ST_SW_HELLO_REQ;-
112}
executed 32 times by 1 test: end of block
Executed by:
  • libssl.so.1.1
32
113-
114/*-
115 * Put the state machine into an error state and send an alert if appropriate.-
116 * This is a permanent error for the current connection.-
117 */-
118void ossl_statem_fatal(SSL *s, int al, int func, int reason, const char *file,-
119 int line)-
120{-
121 ERR_put_error(ERR_LIB_SSL, func, reason, file, line);-
122 /* We shouldn't call SSLfatal() twice. Once is enough */-
123 if (s->statem.in_init && s->statem.state == MSG_FLOW_ERROR)
s->statem.in_initDescription
TRUEevaluated 4071 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 41 times by 1 test
Evaluated by:
  • libssl.so.1.1
s->statem.stat...MSG_FLOW_ERRORDescription
TRUEnever evaluated
FALSEevaluated 4071 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-4071
124 return;
never executed: return;
0
125 s->statem.in_init = 1;-
126 s->statem.state = MSG_FLOW_ERROR;-
127 if (al != SSL_AD_NO_ALERT
al != -1Description
TRUEevaluated 3787 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 325 times by 1 test
Evaluated by:
  • libssl.so.1.1
325-3787
128 && s->statem.enc_write_state != ENC_WRITE_STATE_INVALID)
s->statem.enc_..._STATE_INVALIDDescription
TRUEevaluated 3787 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEnever evaluated
0-3787
129 ssl3_send_alert(s, SSL3_AL_FATAL, al);
executed 3787 times by 1 test: ssl3_send_alert(s, 2, al);
Executed by:
  • libssl.so.1.1
3787
130}
executed 4112 times by 1 test: end of block
Executed by:
  • libssl.so.1.1
4112
131-
132/*-
133 * This macro should only be called if we are already expecting to be in-
134 * a fatal error state. We verify that we are, and set it if not (this would-
135 * indicate a bug).-
136 */-
137#define check_fatal(s, f) \-
138 do { \-
139 if (!ossl_assert((s)->statem.in_init \-
140 && (s)->statem.state == MSG_FLOW_ERROR)) \-
141 SSLfatal(s, SSL_AD_INTERNAL_ERROR, (f), \-
142 SSL_R_MISSING_FATAL); \-
143 } while (0)-
144-
145/*-
146 * Discover whether the current connection is in the error state.-
147 *-
148 * Valid return values are:-
149 * 1: Yes-
150 * 0: No-
151 */-
152int ossl_statem_in_error(const SSL *s)-
153{-
154 if (s->statem.state == MSG_FLOW_ERROR)
s->statem.stat...MSG_FLOW_ERRORDescription
TRUEevaluated 14 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 18043 times by 1 test
Evaluated by:
  • libssl.so.1.1
14-18043
155 return 1;
executed 14 times by 1 test: return 1;
Executed by:
  • libssl.so.1.1
14
156-
157 return 0;
executed 18043 times by 1 test: return 0;
Executed by:
  • libssl.so.1.1
18043
158}-
159-
160void ossl_statem_set_in_init(SSL *s, int init)-
161{-
162 s->statem.in_init = init;-
163}
executed 11815 times by 1 test: end of block
Executed by:
  • libssl.so.1.1
11815
164-
165int ossl_statem_get_in_handshake(SSL *s)-
166{-
167 return s->statem.in_handshake;
executed 123956 times by 1 test: return s->statem.in_handshake;
Executed by:
  • libssl.so.1.1
123956
168}-
169-
170void ossl_statem_set_in_handshake(SSL *s, int inhand)-
171{-
172 if (inhand)
inhandDescription
TRUEnever evaluated
FALSEnever evaluated
0
173 s->statem.in_handshake++;
never executed: s->statem.in_handshake++;
0
174 else-
175 s->statem.in_handshake--;
never executed: s->statem.in_handshake--;
0
176}-
177-
178/* Are we in a sensible state to skip over unreadable early data? */-
179int ossl_statem_skip_early_data(SSL *s)-
180{-
181 if (s->ext.early_data != SSL_EARLY_DATA_REJECTED)
s->ext.early_data != 1Description
TRUEevaluated 336 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 10796 times by 1 test
Evaluated by:
  • libssl.so.1.1
336-10796
182 return 0;
executed 336 times by 1 test: return 0;
Executed by:
  • libssl.so.1.1
336
183-
184 if (!s->server
!s->serverDescription
TRUEnever evaluated
FALSEevaluated 10796 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-10796
185 || s->statem.hand_state != TLS_ST_EARLY_DATA
s->statem.hand..._ST_EARLY_DATADescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 10795 times by 1 test
Evaluated by:
  • libssl.so.1.1
1-10795
186 || s->hello_retry_request == SSL_HRR_COMPLETE)
s->hello_retry...L_HRR_COMPLETEDescription
TRUEevaluated 4 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 10791 times by 1 test
Evaluated by:
  • libssl.so.1.1
4-10791
187 return 0;
executed 5 times by 1 test: return 0;
Executed by:
  • libssl.so.1.1
5
188-
189 return 1;
executed 10791 times by 1 test: return 1;
Executed by:
  • libssl.so.1.1
10791
190}-
191-
192/*-
193 * Called when we are in SSL_read*(), SSL_write*(), or SSL_accept()-
194 * /SSL_connect()/SSL_do_handshake(). Used to test whether we are in an early-
195 * data state and whether we should attempt to move the handshake on if so.-
196 * |sending| is 1 if we are attempting to send data (SSL_write*()), 0 if we are-
197 * attempting to read data (SSL_read*()), or -1 if we are in SSL_do_handshake()-
198 * or similar.-
199 */-
200void ossl_statem_check_finish_init(SSL *s, int sending)-
201{-
202 if (sending == -1) {
sending == -1Description
TRUEevaluated 24091 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 27951 times by 1 test
Evaluated by:
  • libssl.so.1.1
24091-27951
203 if (s->statem.hand_state == TLS_ST_PENDING_EARLY_DATA_END
s->statem.hand...EARLY_DATA_ENDDescription
TRUEnever evaluated
FALSEevaluated 24091 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-24091
204 || s->statem.hand_state == TLS_ST_EARLY_DATA) {
s->statem.hand..._ST_EARLY_DATADescription
TRUEevaluated 4530 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 19561 times by 1 test
Evaluated by:
  • libssl.so.1.1
4530-19561
205 ossl_statem_set_in_init(s, 1);-
206 if (s->early_data_state == SSL_EARLY_DATA_WRITE_RETRY) {
s->early_data_...TA_WRITE_RETRYDescription
TRUEevaluated 32 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 4498 times by 1 test
Evaluated by:
  • libssl.so.1.1
32-4498
207 /*-
208 * SSL_connect() or SSL_do_handshake() has been called directly.-
209 * We don't allow any more writing of early data.-
210 */-
211 s->early_data_state = SSL_EARLY_DATA_FINISHED_WRITING;-
212 }
executed 32 times by 1 test: end of block
Executed by:
  • libssl.so.1.1
32
213 }
executed 4530 times by 1 test: end of block
Executed by:
  • libssl.so.1.1
4530
214 } else if (!s->server) {
executed 24091 times by 1 test: end of block
Executed by:
  • libssl.so.1.1
!s->serverDescription
TRUEevaluated 17794 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 10157 times by 1 test
Evaluated by:
  • libssl.so.1.1
10157-24091
215 if ((sending && (s->statem.hand_state == TLS_ST_PENDING_EARLY_DATA_END
sendingDescription
TRUEevaluated 3146 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 14648 times by 1 test
Evaluated by:
  • libssl.so.1.1
s->statem.hand...EARLY_DATA_ENDDescription
TRUEevaluated 6 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 3140 times by 1 test
Evaluated by:
  • libssl.so.1.1
6-14648
216 || s->statem.hand_state == TLS_ST_EARLY_DATA)
s->statem.hand..._ST_EARLY_DATADescription
TRUEevaluated 59 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 3081 times by 1 test
Evaluated by:
  • libssl.so.1.1
59-3081
217 && s->early_data_state != SSL_EARLY_DATA_WRITING)
s->early_data_...Y_DATA_WRITINGDescription
TRUEevaluated 12 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 53 times by 1 test
Evaluated by:
  • libssl.so.1.1
12-53
218 || (!sending && s->statem.hand_state == TLS_ST_EARLY_DATA)) {
!sendingDescription
TRUEevaluated 14648 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 3134 times by 1 test
Evaluated by:
  • libssl.so.1.1
s->statem.hand..._ST_EARLY_DATADescription
TRUEevaluated 3 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 14645 times by 1 test
Evaluated by:
  • libssl.so.1.1
3-14648
219 ossl_statem_set_in_init(s, 1);-
220 /*-
221 * SSL_write() has been called directly. We don't allow any more-
222 * writing of early data.-
223 */-
224 if (sending && s->early_data_state == SSL_EARLY_DATA_WRITE_RETRY)
sendingDescription
TRUEevaluated 12 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 3 times by 1 test
Evaluated by:
  • libssl.so.1.1
s->early_data_...TA_WRITE_RETRYDescription
TRUEevaluated 12 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEnever evaluated
0-12
225 s->early_data_state = SSL_EARLY_DATA_FINISHED_WRITING;
executed 12 times by 1 test: s->early_data_state = SSL_EARLY_DATA_FINISHED_WRITING;
Executed by:
  • libssl.so.1.1
12
226 }
executed 15 times by 1 test: end of block
Executed by:
  • libssl.so.1.1
15
227 } else {
executed 17794 times by 1 test: end of block
Executed by:
  • libssl.so.1.1
17794
228 if (s->early_data_state == SSL_EARLY_DATA_FINISHED_READING
s->early_data_...NISHED_READINGDescription
TRUEevaluated 36 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 10121 times by 1 test
Evaluated by:
  • libssl.so.1.1
36-10121
229 && s->statem.hand_state == TLS_ST_EARLY_DATA)
s->statem.hand..._ST_EARLY_DATADescription
TRUEevaluated 18 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 18 times by 1 test
Evaluated by:
  • libssl.so.1.1
18
230 ossl_statem_set_in_init(s, 1);
executed 18 times by 1 test: ossl_statem_set_in_init(s, 1);
Executed by:
  • libssl.so.1.1
18
231 }
executed 10157 times by 1 test: end of block
Executed by:
  • libssl.so.1.1
10157
232}-
233-
234void ossl_statem_set_hello_verify_done(SSL *s)-
235{-
236 s->statem.state = MSG_FLOW_UNINITED;-
237 s->statem.in_init = 1;-
238 /*-
239 * This will get reset (briefly) back to TLS_ST_BEFORE when we enter-
240 * state_machine() because |state| is MSG_FLOW_UNINITED, but until then any-
241 * calls to SSL_in_before() will return false. Also calls to-
242 * SSL_state_string() and SSL_state_string_long() will return something-
243 * sensible.-
244 */-
245 s->statem.hand_state = TLS_ST_SR_CLNT_HELLO;-
246}
executed 2 times by 1 test: end of block
Executed by:
  • libssl.so.1.1
2
247-
248int ossl_statem_connect(SSL *s)-
249{-
250 return state_machine(s, 0);
executed 15708 times by 1 test: return state_machine(s, 0);
Executed by:
  • libssl.so.1.1
15708
251}-
252-
253int ossl_statem_accept(SSL *s)-
254{-
255 return state_machine(s, 1);
executed 13982 times by 1 test: return state_machine(s, 1);
Executed by:
  • libssl.so.1.1
13982
256}-
257-
258typedef void (*info_cb) (const SSL *, int, int);-
259-
260static info_cb get_callback(SSL *s)-
261{-
262 if (s->info_callback != NULL)
s->info_callba...!= ((void *)0)Description
TRUEevaluated 20410 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 60329 times by 1 test
Evaluated by:
  • libssl.so.1.1
20410-60329
263 return s->info_callback;
executed 20410 times by 1 test: return s->info_callback;
Executed by:
  • libssl.so.1.1
20410
264 else if (s->ctx->info_callback != NULL)
s->ctx->info_c...!= ((void *)0)Description
TRUEevaluated 72 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 60257 times by 1 test
Evaluated by:
  • libssl.so.1.1
72-60257
265 return s->ctx->info_callback;
executed 72 times by 1 test: return s->ctx->info_callback;
Executed by:
  • libssl.so.1.1
72
266-
267 return NULL;
executed 60257 times by 1 test: return ((void *)0) ;
Executed by:
  • libssl.so.1.1
60257
268}-
269-
270/*-
271 * The main message flow state machine. We start in the MSG_FLOW_UNINITED or-
272 * MSG_FLOW_FINISHED state and finish in MSG_FLOW_FINISHED. Valid states and-
273 * transitions are as follows:-
274 *-
275 * MSG_FLOW_UNINITED MSG_FLOW_FINISHED-
276 * | |-
277 * +-----------------------+-
278 * v-
279 * MSG_FLOW_WRITING <---> MSG_FLOW_READING-
280 * |-
281 * V-
282 * MSG_FLOW_FINISHED-
283 * |-
284 * V-
285 * [SUCCESS]-
286 *-
287 * We may exit at any point due to an error or NBIO event. If an NBIO event-
288 * occurs then we restart at the point we left off when we are recalled.-
289 * MSG_FLOW_WRITING and MSG_FLOW_READING have sub-state machines associated with them.-
290 *-
291 * In addition to the above there is also the MSG_FLOW_ERROR state. We can move-
292 * into that state at any point in the event that an irrecoverable error occurs.-
293 *-
294 * Valid return values are:-
295 * 1: Success-
296 * <=0: NBIO or error-
297 */-
298static int state_machine(SSL *s, int server)-
299{-
300 BUF_MEM *buf = NULL;-
301 void (*cb) (const SSL *ssl, int type, int val) = NULL;-
302 OSSL_STATEM *st = &s->statem;-
303 int ret = -1;-
304 int ssret;-
305-
306 if (st->state == MSG_FLOW_ERROR) {
st->state == MSG_FLOW_ERRORDescription
TRUEevaluated 454 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 29236 times by 1 test
Evaluated by:
  • libssl.so.1.1
454-29236
307 /* Shouldn't have been called if we're already in the error state */-
308 return -1;
executed 454 times by 1 test: return -1;
Executed by:
  • libssl.so.1.1
454
309 }-
310-
311 ERR_clear_error();-
312 clear_sys_error();-
313-
314 cb = get_callback(s);-
315-
316 st->in_handshake++;-
317 if (!SSL_in_init(s) || SSL_in_before(s)) {
!SSL_in_init(s)Description
TRUEnever evaluated
FALSEevaluated 29236 times by 1 test
Evaluated by:
  • libssl.so.1.1
SSL_in_before(s)Description
TRUEevaluated 8001 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 21235 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-29236
318 /*-
319 * If we are stateless then we already called SSL_clear() - don't do-
320 * it again and clear the STATELESS flag itself.-
321 */-
322 if ((s->s3->flags & TLS1_FLAGS_STATELESS) == 0 && !SSL_clear(s))
(s->s3->flags & 0x0800) == 0Description
TRUEevaluated 7997 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 4 times by 1 test
Evaluated by:
  • libssl.so.1.1
!SSL_clear(s)Description
TRUEnever evaluated
FALSEevaluated 7997 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-7997
323 return -1;
never executed: return -1;
0
324 }
executed 8001 times by 1 test: end of block
Executed by:
  • libssl.so.1.1
8001
325#ifndef OPENSSL_NO_SCTP-
326 if (SSL_IS_DTLS(s) && BIO_dgram_is_sctp(SSL_get_wbio(s))) {-
327 /*-
328 * Notify SCTP BIO socket to enter handshake mode and prevent stream-
329 * identifier other than 0.-
330 */-
331 BIO_ctrl(SSL_get_wbio(s), BIO_CTRL_DGRAM_SCTP_SET_IN_HANDSHAKE,-
332 st->in_handshake, NULL);-
333 }-
334#endif-
335-
336 /* Initialise state machine */-
337 if (st->state == MSG_FLOW_UNINITED
st->state == MSG_FLOW_UNINITEDDescription
TRUEevaluated 8001 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 21235 times by 1 test
Evaluated by:
  • libssl.so.1.1
8001-21235
338 || st->state == MSG_FLOW_FINISHED) {
st->state == MSG_FLOW_FINISHEDDescription
TRUEevaluated 1289 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 19946 times by 1 test
Evaluated by:
  • libssl.so.1.1
1289-19946
339 if (st->state == MSG_FLOW_UNINITED) {
st->state == MSG_FLOW_UNINITEDDescription
TRUEevaluated 8001 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 1289 times by 1 test
Evaluated by:
  • libssl.so.1.1
1289-8001
340 st->hand_state = TLS_ST_BEFORE;-
341 st->request_state = TLS_ST_BEFORE;-
342 }
executed 8001 times by 1 test: end of block
Executed by:
  • libssl.so.1.1
8001
343-
344 s->server = server;-
345 if (cb != NULL)
cb != ((void *)0)Description
TRUEevaluated 3005 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 6285 times by 1 test
Evaluated by:
  • libssl.so.1.1
3005-6285
346 cb(s, SSL_CB_HANDSHAKE_START, 1);
executed 3005 times by 1 test: cb(s, 0x10, 1);
Executed by:
  • libssl.so.1.1
3005
347-
348 /*-
349 * Fatal errors in this block don't send an alert because we have-
350 * failed to even initialise properly. Sending an alert is probably-
351 * doomed to failure.-
352 */-
353-
354 if (SSL_IS_DTLS(s)) {
(s->method->ss...c_flags & 0x8)Description
TRUEevaluated 384 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 8906 times by 1 test
Evaluated by:
  • libssl.so.1.1
384-8906
355 if ((s->version & 0xff00) != (DTLS1_VERSION & 0xff00) &&
(s->version & ...FEFF & 0xff00)Description
TRUEnever evaluated
FALSEevaluated 384 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-384
356 (server || (s->version & 0xff00) != (DTLS1_BAD_VER & 0xff00))) {
serverDescription
TRUEnever evaluated
FALSEnever evaluated
(s->version & ...0100 & 0xff00)Description
TRUEnever evaluated
FALSEnever evaluated
0
357 SSLfatal(s, SSL_AD_NO_ALERT, SSL_F_STATE_MACHINE,-
358 ERR_R_INTERNAL_ERROR);-
359 goto end;
never executed: goto end;
0
360 }-
361 } else {
executed 384 times by 1 test: end of block
Executed by:
  • libssl.so.1.1
384
362 if ((s->version >> 8) != SSL3_VERSION_MAJOR) {
(s->version >> 8) != 0x03Description
TRUEnever evaluated
FALSEevaluated 8906 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-8906
363 SSLfatal(s, SSL_AD_NO_ALERT, SSL_F_STATE_MACHINE,-
364 ERR_R_INTERNAL_ERROR);-
365 goto end;
never executed: goto end;
0
366 }-
367 }
executed 8906 times by 1 test: end of block
Executed by:
  • libssl.so.1.1
8906
368-
369 if (!ssl_security(s, SSL_SECOP_VERSION, 0, s->version, NULL)) {
!ssl_security(... ((void *)0) )Description
TRUEnever evaluated
FALSEevaluated 9290 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-9290
370 SSLfatal(s, SSL_AD_NO_ALERT, SSL_F_STATE_MACHINE,-
371 ERR_R_INTERNAL_ERROR);-
372 goto end;
never executed: goto end;
0
373 }-
374-
375 if (s->init_buf == NULL) {
s->init_buf == ((void *)0)Description
TRUEevaluated 9222 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 68 times by 1 test
Evaluated by:
  • libssl.so.1.1
68-9222
376 if ((buf = BUF_MEM_new()) == NULL) {
(buf = BUF_MEM...== ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 9222 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-9222
377 SSLfatal(s, SSL_AD_NO_ALERT, SSL_F_STATE_MACHINE,-
378 ERR_R_INTERNAL_ERROR);-
379 goto end;
never executed: goto end;
0
380 }-
381 if (!BUF_MEM_grow(buf, SSL3_RT_MAX_PLAIN_LENGTH)) {
!BUF_MEM_grow(buf, 16384)Description
TRUEnever evaluated
FALSEevaluated 9222 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-9222
382 SSLfatal(s, SSL_AD_NO_ALERT, SSL_F_STATE_MACHINE,-
383 ERR_R_INTERNAL_ERROR);-
384 goto end;
never executed: goto end;
0
385 }-
386 s->init_buf = buf;-
387 buf = NULL;-
388 }
executed 9222 times by 1 test: end of block
Executed by:
  • libssl.so.1.1
9222
389-
390 if (!ssl3_setup_buffers(s)) {
!ssl3_setup_buffers(s)Description
TRUEnever evaluated
FALSEevaluated 9290 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-9290
391 SSLfatal(s, SSL_AD_NO_ALERT, SSL_F_STATE_MACHINE,-
392 ERR_R_INTERNAL_ERROR);-
393 goto end;
never executed: goto end;
0
394 }-
395 s->init_num = 0;-
396-
397 /*-
398 * Should have been reset by tls_process_finished, too.-
399 */-
400 s->s3->change_cipher_spec = 0;-
401-
402 /*-
403 * Ok, we now need to push on a buffering BIO ...but not with-
404 * SCTP-
405 */-
406#ifndef OPENSSL_NO_SCTP-
407 if (!SSL_IS_DTLS(s) || !BIO_dgram_is_sctp(SSL_get_wbio(s)))-
408#endif-
409 if (!ssl_init_wbio_buffer(s)) {
!ssl_init_wbio_buffer(s)Description
TRUEnever evaluated
FALSEevaluated 9290 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-9290
410 SSLfatal(s, SSL_AD_NO_ALERT, SSL_F_STATE_MACHINE,-
411 ERR_R_INTERNAL_ERROR);-
412 goto end;
never executed: goto end;
0
413 }-
414-
415 if ((SSL_in_before(s))
(SSL_in_before(s))Description
TRUEevaluated 8001 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 1289 times by 1 test
Evaluated by:
  • libssl.so.1.1
1289-8001
416 || s->renegotiate) {
s->renegotiateDescription
TRUEevaluated 32 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 1257 times by 1 test
Evaluated by:
  • libssl.so.1.1
32-1257
417 if (!tls_setup_handshake(s)) {
!tls_setup_handshake(s)Description
TRUEevaluated 49 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 7984 times by 1 test
Evaluated by:
  • libssl.so.1.1
49-7984
418 /* SSLfatal() already called */-
419 goto end;
executed 49 times by 1 test: goto end;
Executed by:
  • libssl.so.1.1
49
420 }-
421-
422 if (SSL_IS_FIRST_HANDSHAKE(s))
(s)->s3->tmp.f...sh_md_len == 0Description
TRUEevaluated 7952 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 32 times by 1 test
Evaluated by:
  • libssl.so.1.1
(s)->s3->tmp.p...sh_md_len == 0Description
TRUEnever evaluated
FALSEevaluated 32 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-7952
423 st->read_state_first_init = 1;
executed 7952 times by 1 test: st->read_state_first_init = 1;
Executed by:
  • libssl.so.1.1
7952
424 }
executed 7984 times by 1 test: end of block
Executed by:
  • libssl.so.1.1
7984
425-
426 st->state = MSG_FLOW_WRITING;-
427 init_write_state_machine(s);-
428 }
executed 9241 times by 1 test: end of block
Executed by:
  • libssl.so.1.1
9241
429-
430 while (st->state != MSG_FLOW_FINISHED) {
st->state != MSG_FLOW_FINISHEDDescription
TRUEevaluated 51503 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 4486 times by 1 test
Evaluated by:
  • libssl.so.1.1
4486-51503
431 if (st->state == MSG_FLOW_READING) {
st->state == MSG_FLOW_READINGDescription
TRUEevaluated 32819 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 18684 times by 1 test
Evaluated by:
  • libssl.so.1.1
18684-32819
432 ssret = read_state_machine(s);-
433 if (ssret == SUB_STATE_FINISHED) {
ssret == SUB_STATE_FINISHEDDescription
TRUEevaluated 8827 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 23992 times by 1 test
Evaluated by:
  • libssl.so.1.1
8827-23992
434 st->state = MSG_FLOW_WRITING;-
435 init_write_state_machine(s);-
436 } else {
executed 8827 times by 1 test: end of block
Executed by:
  • libssl.so.1.1
8827
437 /* NBIO or error */-
438 goto end;
executed 23992 times by 1 test: goto end;
Executed by:
  • libssl.so.1.1
23992
439 }-
440 } else if (st->state == MSG_FLOW_WRITING) {
st->state == MSG_FLOW_WRITINGDescription
TRUEevaluated 18684 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEnever evaluated
0-18684
441 ssret = write_state_machine(s);-
442 if (ssret == SUB_STATE_FINISHED) {
ssret == SUB_STATE_FINISHEDDescription
TRUEevaluated 13489 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 5195 times by 1 test
Evaluated by:
  • libssl.so.1.1
5195-13489
443 st->state = MSG_FLOW_READING;-
444 init_read_state_machine(s);-
445 } else if (ssret == SUB_STATE_END_HANDSHAKE) {
executed 13489 times by 1 test: end of block
Executed by:
  • libssl.so.1.1
ssret == SUB_S..._END_HANDSHAKEDescription
TRUEevaluated 4486 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 709 times by 1 test
Evaluated by:
  • libssl.so.1.1
709-13489
446 st->state = MSG_FLOW_FINISHED;-
447 } else {
executed 4486 times by 1 test: end of block
Executed by:
  • libssl.so.1.1
4486
448 /* NBIO or error */-
449 goto end;
executed 709 times by 1 test: goto end;
Executed by:
  • libssl.so.1.1
709
450 }-
451 } else {-
452 /* Error */-
453 check_fatal(s, SSL_F_STATE_MACHINE);
never executed: ossl_statem_fatal((s), (80), ((353)), (256), __FILE__, 453);
!(((s)->statem...W_ERROR) != 0)Description
TRUEnever evaluated
FALSEnever evaluated
(s)->statem.in_initDescription
TRUEnever evaluated
FALSEnever evaluated
(s)->statem.st...MSG_FLOW_ERRORDescription
TRUEnever evaluated
FALSEnever evaluated
0
454 SSLerr(SSL_F_STATE_MACHINE, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);-
455 goto end;
never executed: goto end;
0
456 }-
457 }-
458-
459 ret = 1;-
460-
461 end:
code before this statement executed 4486 times by 1 test: end:
Executed by:
  • libssl.so.1.1
4486
462 st->in_handshake--;-
463-
464#ifndef OPENSSL_NO_SCTP-
465 if (SSL_IS_DTLS(s) && BIO_dgram_is_sctp(SSL_get_wbio(s))) {-
466 /*-
467 * Notify SCTP BIO socket to leave handshake mode and allow stream-
468 * identifier other than 0.-
469 */-
470 BIO_ctrl(SSL_get_wbio(s), BIO_CTRL_DGRAM_SCTP_SET_IN_HANDSHAKE,-
471 st->in_handshake, NULL);-
472 }-
473#endif-
474-
475 BUF_MEM_free(buf);-
476 if (cb != NULL) {
cb != ((void *)0)Description
TRUEevaluated 5872 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 23364 times by 1 test
Evaluated by:
  • libssl.so.1.1
5872-23364
477 if (server)
serverDescription
TRUEevaluated 2220 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 3652 times by 1 test
Evaluated by:
  • libssl.so.1.1
2220-3652
478 cb(s, SSL_CB_ACCEPT_EXIT, ret);
executed 2220 times by 1 test: cb(s, (0x2000|0x02), ret);
Executed by:
  • libssl.so.1.1
2220
479 else-
480 cb(s, SSL_CB_CONNECT_EXIT, ret);
executed 3652 times by 1 test: cb(s, (0x1000|0x02), ret);
Executed by:
  • libssl.so.1.1
3652
481 }-
482 return ret;
executed 29236 times by 1 test: return ret;
Executed by:
  • libssl.so.1.1
29236
483}-
484-
485/*-
486 * Initialise the MSG_FLOW_READING sub-state machine-
487 */-
488static void init_read_state_machine(SSL *s)-
489{-
490 OSSL_STATEM *st = &s->statem;-
491-
492 st->read_state = READ_STATE_HEADER;-
493}
executed 13489 times by 1 test: end of block
Executed by:
  • libssl.so.1.1
13489
494-
495static int grow_init_buf(SSL *s, size_t size) {-
496-
497 size_t msg_offset = (char *)s->init_msg - s->init_buf->data;-
498-
499 if (!BUF_MEM_grow_clean(s->init_buf, (int)size))
!BUF_MEM_grow_...uf, (int)size)Description
TRUEnever evaluated
FALSEevaluated 21276 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-21276
500 return 0;
never executed: return 0;
0
501-
502 if (size < msg_offset)
size < msg_offsetDescription
TRUEnever evaluated
FALSEevaluated 21276 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-21276
503 return 0;
never executed: return 0;
0
504-
505 s->init_msg = s->init_buf->data + msg_offset;-
506-
507 return 1;
executed 21276 times by 1 test: return 1;
Executed by:
  • libssl.so.1.1
21276
508}-
509-
510/*-
511 * This function implements the sub-state machine when the message flow is in-
512 * MSG_FLOW_READING. The valid sub-states and transitions are:-
513 *-
514 * READ_STATE_HEADER <--+<-------------+-
515 * | | |-
516 * v | |-
517 * READ_STATE_BODY -----+-->READ_STATE_POST_PROCESS-
518 * | |-
519 * +----------------------------+-
520 * v-
521 * [SUB_STATE_FINISHED]-
522 *-
523 * READ_STATE_HEADER has the responsibility for reading in the message header-
524 * and transitioning the state of the handshake state machine.-
525 *-
526 * READ_STATE_BODY reads in the rest of the message and then subsequently-
527 * processes it.-
528 *-
529 * READ_STATE_POST_PROCESS is an optional step that may occur if some post-
530 * processing activity performed on the message may block.-
531 *-
532 * Any of the above states could result in an NBIO event occurring in which case-
533 * control returns to the calling application. When this function is recalled we-
534 * will resume in the same state where we left off.-
535 */-
536static SUB_STATE_RETURN read_state_machine(SSL *s)-
537{-
538 OSSL_STATEM *st = &s->statem;-
539 int ret, mt;-
540 size_t len = 0;-
541 int (*transition) (SSL *s, int mt);-
542 PACKET pkt;-
543 MSG_PROCESS_RETURN(*process_message) (SSL *s, PACKET *pkt);-
544 WORK_STATE(*post_process_message) (SSL *s, WORK_STATE wst);-
545 size_t (*max_message_size) (SSL *s);-
546 void (*cb) (const SSL *ssl, int type, int val) = NULL;-
547-
548 cb = get_callback(s);-
549-
550 if (s->server) {
s->serverDescription
TRUEevaluated 15292 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 17527 times by 1 test
Evaluated by:
  • libssl.so.1.1
15292-17527
551 transition = ossl_statem_server_read_transition;-
552 process_message = ossl_statem_server_process_message;-
553 max_message_size = ossl_statem_server_max_message_size;-
554 post_process_message = ossl_statem_server_post_process_message;-
555 } else {
executed 15292 times by 1 test: end of block
Executed by:
  • libssl.so.1.1
15292
556 transition = ossl_statem_client_read_transition;-
557 process_message = ossl_statem_client_process_message;-
558 max_message_size = ossl_statem_client_max_message_size;-
559 post_process_message = ossl_statem_client_post_process_message;-
560 }
executed 17527 times by 1 test: end of block
Executed by:
  • libssl.so.1.1
17527
561-
562 if (st->read_state_first_init) {
st->read_state_first_initDescription
TRUEevaluated 7890 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 24929 times by 1 test
Evaluated by:
  • libssl.so.1.1
7890-24929
563 s->first_packet = 1;-
564 st->read_state_first_init = 0;-
565 }
executed 7890 times by 1 test: end of block
Executed by:
  • libssl.so.1.1
7890
566-
567 while (1) {-
568 switch (st->read_state) {-
569 case READ_STATE_HEADER:
executed 42983 times by 1 test: case READ_STATE_HEADER:
Executed by:
  • libssl.so.1.1
42983
570 /* Get the state the peer wants to move to */-
571 if (SSL_IS_DTLS(s)) {
(s->method->ss...c_flags & 0x8)Description
TRUEevaluated 2843 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 40140 times by 1 test
Evaluated by:
  • libssl.so.1.1
2843-40140
572 /*-
573 * In DTLS we get the whole message in one go - header and body-
574 */-
575 ret = dtls_get_message(s, &mt, &len);-
576 } else {
executed 2843 times by 1 test: end of block
Executed by:
  • libssl.so.1.1
2843
577 ret = tls_get_message_header(s, &mt);-
578 }
executed 40140 times by 1 test: end of block
Executed by:
  • libssl.so.1.1
40140
579-
580 if (ret == 0) {
ret == 0Description
TRUEevaluated 18463 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 24520 times by 1 test
Evaluated by:
  • libssl.so.1.1
18463-24520
581 /* Could be non-blocking IO */-
582 return SUB_STATE_ERROR;
executed 18463 times by 1 test: return SUB_STATE_ERROR;
Executed by:
  • libssl.so.1.1
18463
583 }-
584-
585 if (cb != NULL) {
cb != ((void *)0)Description
TRUEevaluated 10272 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 14248 times by 1 test
Evaluated by:
  • libssl.so.1.1
10272-14248
586 /* Notify callback of an impending state change */-
587 if (s->server)
s->serverDescription
TRUEevaluated 3573 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 6699 times by 1 test
Evaluated by:
  • libssl.so.1.1
3573-6699
588 cb(s, SSL_CB_ACCEPT_LOOP, 1);
executed 3573 times by 1 test: cb(s, (0x2000|0x01), 1);
Executed by:
  • libssl.so.1.1
3573
589 else-
590 cb(s, SSL_CB_CONNECT_LOOP, 1);
executed 6699 times by 1 test: cb(s, (0x1000|0x01), 1);
Executed by:
  • libssl.so.1.1
6699
591 }-
592 /*-
593 * Validate that we are allowed to move to the new state and move-
594 * to that state if so-
595 */-
596 if (!transition(s, mt))
!transition(s, mt)Description
TRUEevaluated 74 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 24446 times by 1 test
Evaluated by:
  • libssl.so.1.1
74-24446
597 return SUB_STATE_ERROR;
executed 74 times by 1 test: return SUB_STATE_ERROR;
Executed by:
  • libssl.so.1.1
74
598-
599 if (s->s3->tmp.message_size > max_message_size(s)) {
s->s3->tmp.mes...essage_size(s)Description
TRUEevaluated 11 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 24435 times by 1 test
Evaluated by:
  • libssl.so.1.1
11-24435
600 SSLfatal(s, SSL_AD_ILLEGAL_PARAMETER, SSL_F_READ_STATE_MACHINE,-
601 SSL_R_EXCESSIVE_MESSAGE_SIZE);-
602 return SUB_STATE_ERROR;
executed 11 times by 1 test: return SUB_STATE_ERROR;
Executed by:
  • libssl.so.1.1
11
603 }-
604-
605 /* dtls_get_message already did this */-
606 if (!SSL_IS_DTLS(s)
!(s->method->s...c_flags & 0x8)Description
TRUEevaluated 22570 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 1865 times by 1 test
Evaluated by:
  • libssl.so.1.1
1865-22570
607 && s->s3->tmp.message_size > 0
s->s3->tmp.message_size > 0Description
TRUEevaluated 21276 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 1294 times by 1 test
Evaluated by:
  • libssl.so.1.1
1294-21276
608 && !grow_init_buf(s, s->s3->tmp.message_size
!grow_init_buf...sage_size + 4)Description
TRUEnever evaluated
FALSEevaluated 21276 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-21276
609 + SSL3_HM_HEADER_LENGTH)) {
!grow_init_buf...sage_size + 4)Description
TRUEnever evaluated
FALSEevaluated 21276 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-21276
610 SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_READ_STATE_MACHINE,-
611 ERR_R_BUF_LIB);-
612 return SUB_STATE_ERROR;
never executed: return SUB_STATE_ERROR;
0
613 }-
614-
615 st->read_state = READ_STATE_BODY;-
616 /* Fall through */-
617-
618 case READ_STATE_BODY:
code before this statement executed 24435 times by 1 test: case READ_STATE_BODY:
Executed by:
  • libssl.so.1.1
executed 2419 times by 1 test: case READ_STATE_BODY:
Executed by:
  • libssl.so.1.1
2419-24435
619 if (!SSL_IS_DTLS(s)) {
!(s->method->s...c_flags & 0x8)Description
TRUEevaluated 24989 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 1865 times by 1 test
Evaluated by:
  • libssl.so.1.1
1865-24989
620 /* We already got this above for DTLS */-
621 ret = tls_get_message_body(s, &len);-
622 if (ret == 0) {
ret == 0Description
TRUEevaluated 2478 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 22511 times by 1 test
Evaluated by:
  • libssl.so.1.1
2478-22511
623 /* Could be non-blocking IO */-
624 return SUB_STATE_ERROR;
executed 2478 times by 1 test: return SUB_STATE_ERROR;
Executed by:
  • libssl.so.1.1
2478
625 }-
626 }
executed 22511 times by 1 test: end of block
Executed by:
  • libssl.so.1.1
22511
627-
628 s->first_packet = 0;-
629 if (!PACKET_buf_init(&pkt, s->init_msg, len)) {
!PACKET_buf_in...init_msg, len)Description
TRUEnever evaluated
FALSEevaluated 24376 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-24376
630 SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_READ_STATE_MACHINE,-
631 ERR_R_INTERNAL_ERROR);-
632 return SUB_STATE_ERROR;
never executed: return SUB_STATE_ERROR;
0
633 }-
634 ret = process_message(s, &pkt);-
635-
636 /* Discard the packet data */-
637 s->init_num = 0;-
638-
639 switch (ret) {-
640 case MSG_PROCESS_ERROR:
executed 1787 times by 1 test: case MSG_PROCESS_ERROR:
Executed by:
  • libssl.so.1.1
1787
641 check_fatal(s, SSL_F_READ_STATE_MACHINE);
never executed: ossl_statem_fatal((s), (80), ((352)), (256), __FILE__, 641);
!(((s)->statem...W_ERROR) != 0)Description
TRUEnever evaluated
FALSEevaluated 1787 times by 1 test
Evaluated by:
  • libssl.so.1.1
(s)->statem.in_initDescription
TRUEevaluated 1787 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEnever evaluated
(s)->statem.st...MSG_FLOW_ERRORDescription
TRUEevaluated 1787 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEnever evaluated
0-1787
642 return SUB_STATE_ERROR;
executed 1787 times by 1 test: return SUB_STATE_ERROR;
Executed by:
  • libssl.so.1.1
1787
643-
644 case MSG_PROCESS_FINISHED_READING:
executed 6322 times by 1 test: case MSG_PROCESS_FINISHED_READING:
Executed by:
  • libssl.so.1.1
6322
645 if (SSL_IS_DTLS(s)) {
(s->method->ss...c_flags & 0x8)Description
TRUEevaluated 524 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 5798 times by 1 test
Evaluated by:
  • libssl.so.1.1
524-5798
646 dtls1_stop_timer(s);-
647 }
executed 524 times by 1 test: end of block
Executed by:
  • libssl.so.1.1
524
648 return SUB_STATE_FINISHED;
executed 6322 times by 1 test: return SUB_STATE_FINISHED;
Executed by:
  • libssl.so.1.1
6322
649-
650 case MSG_PROCESS_CONTINUE_PROCESSING:
executed 4929 times by 1 test: case MSG_PROCESS_CONTINUE_PROCESSING:
Executed by:
  • libssl.so.1.1
4929
651 st->read_state = READ_STATE_POST_PROCESS;-
652 st->read_state_work = WORK_MORE_A;-
653 break;
executed 4929 times by 1 test: break;
Executed by:
  • libssl.so.1.1
4929
654-
655 default:
executed 11338 times by 1 test: default:
Executed by:
  • libssl.so.1.1
11338
656 st->read_state = READ_STATE_HEADER;-
657 break;
executed 11338 times by 1 test: break;
Executed by:
  • libssl.so.1.1
11338
658 }-
659 break;
executed 16267 times by 1 test: break;
Executed by:
  • libssl.so.1.1
16267
660-
661 case READ_STATE_POST_PROCESS:
executed 4932 times by 1 test: case READ_STATE_POST_PROCESS:
Executed by:
  • libssl.so.1.1
4932
662 st->read_state_work = post_process_message(s, st->read_state_work);-
663 switch (st->read_state_work) {-
664 case WORK_ERROR:
executed 1176 times by 1 test: case WORK_ERROR:
Executed by:
  • libssl.so.1.1
1176
665 check_fatal(s, SSL_F_READ_STATE_MACHINE);
never executed: ossl_statem_fatal((s), (80), ((352)), (256), __FILE__, 665);
!(((s)->statem...W_ERROR) != 0)Description
TRUEnever evaluated
FALSEevaluated 1176 times by 1 test
Evaluated by:
  • libssl.so.1.1
(s)->statem.in_initDescription
TRUEevaluated 1176 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEnever evaluated
(s)->statem.st...MSG_FLOW_ERRORDescription
TRUEevaluated 1176 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEnever evaluated
0-1176
666 /* Fall through */-
667 case WORK_MORE_A:
code before this statement executed 1176 times by 1 test: case WORK_MORE_A:
Executed by:
  • libssl.so.1.1
executed 1 time by 1 test: case WORK_MORE_A:
Executed by:
  • libssl.so.1.1
1-1176
668 case WORK_MORE_B:
executed 2 times by 1 test: case WORK_MORE_B:
Executed by:
  • libssl.so.1.1
2
669 case WORK_MORE_C:
never executed: case WORK_MORE_C:
0
670 return SUB_STATE_ERROR;
executed 1179 times by 1 test: return SUB_STATE_ERROR;
Executed by:
  • libssl.so.1.1
1179
671-
672 case WORK_FINISHED_CONTINUE:
executed 1248 times by 1 test: case WORK_FINISHED_CONTINUE:
Executed by:
  • libssl.so.1.1
1248
673 st->read_state = READ_STATE_HEADER;-
674 break;
executed 1248 times by 1 test: break;
Executed by:
  • libssl.so.1.1
1248
675-
676 case WORK_FINISHED_STOP:
executed 2505 times by 1 test: case WORK_FINISHED_STOP:
Executed by:
  • libssl.so.1.1
2505
677 if (SSL_IS_DTLS(s)) {
(s->method->ss...c_flags & 0x8)Description
TRUEevaluated 186 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 2319 times by 1 test
Evaluated by:
  • libssl.so.1.1
186-2319
678 dtls1_stop_timer(s);-
679 }
executed 186 times by 1 test: end of block
Executed by:
  • libssl.so.1.1
186
680 return SUB_STATE_FINISHED;
executed 2505 times by 1 test: return SUB_STATE_FINISHED;
Executed by:
  • libssl.so.1.1
2505
681 }-
682 break;
executed 1248 times by 1 test: break;
Executed by:
  • libssl.so.1.1
1248
683-
684 default:
never executed: default:
0
685 /* Shouldn't happen */-
686 SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_READ_STATE_MACHINE,-
687 ERR_R_INTERNAL_ERROR);-
688 return SUB_STATE_ERROR;
never executed: return SUB_STATE_ERROR;
0
689 }-
690 }-
691}
never executed: end of block
0
692-
693/*-
694 * Send a previously constructed message to the peer.-
695 */-
696static int statem_do_write(SSL *s)-
697{-
698 OSSL_STATEM *st = &s->statem;-
699-
700 if (st->hand_state == TLS_ST_CW_CHANGE
st->hand_state...S_ST_CW_CHANGEDescription
TRUEevaluated 2682 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 23243 times by 1 test
Evaluated by:
  • libssl.so.1.1
2682-23243
701 || st->hand_state == TLS_ST_SW_CHANGE) {
st->hand_state...S_ST_SW_CHANGEDescription
TRUEevaluated 1993 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 21250 times by 1 test
Evaluated by:
  • libssl.so.1.1
1993-21250
702 if (SSL_IS_DTLS(s))
(s->method->ss...c_flags & 0x8)Description
TRUEevaluated 359 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 4316 times by 1 test
Evaluated by:
  • libssl.so.1.1
359-4316
703 return dtls1_do_write(s, SSL3_RT_CHANGE_CIPHER_SPEC);
executed 359 times by 1 test: return dtls1_do_write(s, 20);
Executed by:
  • libssl.so.1.1
359
704 else-
705 return ssl3_do_write(s, SSL3_RT_CHANGE_CIPHER_SPEC);
executed 4316 times by 1 test: return ssl3_do_write(s, 20);
Executed by:
  • libssl.so.1.1
4316
706 } else {-
707 return ssl_do_write(s);
executed 21250 times by 1 test: return s->method->ssl3_enc->do_write(s);
Executed by:
  • libssl.so.1.1
21250
708 }-
709}-
710-
711/*-
712 * Initialise the MSG_FLOW_WRITING sub-state machine-
713 */-
714static void init_write_state_machine(SSL *s)-
715{-
716 OSSL_STATEM *st = &s->statem;-
717-
718 st->write_state = WRITE_STATE_TRANSITION;-
719}
executed 18068 times by 1 test: end of block
Executed by:
  • libssl.so.1.1
18068
720-
721/*-
722 * This function implements the sub-state machine when the message flow is in-
723 * MSG_FLOW_WRITING. The valid sub-states and transitions are:-
724 *-
725 * +-> WRITE_STATE_TRANSITION ------> [SUB_STATE_FINISHED]-
726 * | |-
727 * | v-
728 * | WRITE_STATE_PRE_WORK -----> [SUB_STATE_END_HANDSHAKE]-
729 * | |-
730 * | v-
731 * | WRITE_STATE_SEND-
732 * | |-
733 * | v-
734 * | WRITE_STATE_POST_WORK-
735 * | |-
736 * +-------------+-
737 *-
738 * WRITE_STATE_TRANSITION transitions the state of the handshake state machine-
739-
740 * WRITE_STATE_PRE_WORK performs any work necessary to prepare the later-
741 * sending of the message. This could result in an NBIO event occurring in-
742 * which case control returns to the calling application. When this function-
743 * is recalled we will resume in the same state where we left off.-
744 *-
745 * WRITE_STATE_SEND sends the message and performs any work to be done after-
746 * sending.-
747 *-
748 * WRITE_STATE_POST_WORK performs any work necessary after the sending of the-
749 * message has been completed. As for WRITE_STATE_PRE_WORK this could also-
750 * result in an NBIO event.-
751 */-
752static SUB_STATE_RETURN write_state_machine(SSL *s)-
753{-
754 OSSL_STATEM *st = &s->statem;-
755 int ret;-
756 WRITE_TRAN(*transition) (SSL *s);-
757 WORK_STATE(*pre_work) (SSL *s, WORK_STATE wst);-
758 WORK_STATE(*post_work) (SSL *s, WORK_STATE wst);-
759 int (*get_construct_message_f) (SSL *s, WPACKET *pkt,-
760 int (**confunc) (SSL *s, WPACKET *pkt),-
761 int *mt);-
762 void (*cb) (const SSL *ssl, int type, int val) = NULL;-
763 int (*confunc) (SSL *s, WPACKET *pkt);-
764 int mt;-
765 WPACKET pkt;-
766-
767 cb = get_callback(s);-
768-
769 if (s->server) {
s->serverDescription
TRUEevaluated 8486 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 10198 times by 1 test
Evaluated by:
  • libssl.so.1.1
8486-10198
770 transition = ossl_statem_server_write_transition;-
771 pre_work = ossl_statem_server_pre_work;-
772 post_work = ossl_statem_server_post_work;-
773 get_construct_message_f = ossl_statem_server_construct_message;-
774 } else {
executed 8486 times by 1 test: end of block
Executed by:
  • libssl.so.1.1
8486
775 transition = ossl_statem_client_write_transition;-
776 pre_work = ossl_statem_client_pre_work;-
777 post_work = ossl_statem_client_post_work;-
778 get_construct_message_f = ossl_statem_client_construct_message;-
779 }
executed 10198 times by 1 test: end of block
Executed by:
  • libssl.so.1.1
10198
780-
781 while (1) {-
782 switch (st->write_state) {-
783 case WRITE_STATE_TRANSITION:
executed 44838 times by 1 test: case WRITE_STATE_TRANSITION:
Executed by:
  • libssl.so.1.1
44838
784 if (cb != NULL) {
cb != ((void *)0)Description
TRUEevaluated 18455 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 26383 times by 1 test
Evaluated by:
  • libssl.so.1.1
18455-26383
785 /* Notify callback of an impending state change */-
786 if (s->server)
s->serverDescription
TRUEevaluated 10491 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 7964 times by 1 test
Evaluated by:
  • libssl.so.1.1
7964-10491
787 cb(s, SSL_CB_ACCEPT_LOOP, 1);
executed 10491 times by 1 test: cb(s, (0x2000|0x01), 1);
Executed by:
  • libssl.so.1.1
10491
788 else-
789 cb(s, SSL_CB_CONNECT_LOOP, 1);
executed 7964 times by 1 test: cb(s, (0x1000|0x01), 1);
Executed by:
  • libssl.so.1.1
7964
790 }-
791 switch (transition(s)) {-
792 case WRITE_TRAN_CONTINUE:
executed 31349 times by 1 test: case WRITE_TRAN_CONTINUE:
Executed by:
  • libssl.so.1.1
31349
793 st->write_state = WRITE_STATE_PRE_WORK;-
794 st->write_state_work = WORK_MORE_A;-
795 break;
executed 31349 times by 1 test: break;
Executed by:
  • libssl.so.1.1
31349
796-
797 case WRITE_TRAN_FINISHED:
executed 13489 times by 1 test: case WRITE_TRAN_FINISHED:
Executed by:
  • libssl.so.1.1
13489
798 return SUB_STATE_FINISHED;
executed 13489 times by 1 test: return SUB_STATE_FINISHED;
Executed by:
  • libssl.so.1.1
13489
799 break;
dead code: break;
-
800-
801 case WRITE_TRAN_ERROR:
never executed: case WRITE_TRAN_ERROR:
0
802 check_fatal(s, SSL_F_WRITE_STATE_MACHINE);
never executed: ossl_statem_fatal((s), (80), ((586)), (256), __FILE__, 802);
!(((s)->statem...W_ERROR) != 0)Description
TRUEnever evaluated
FALSEnever evaluated
(s)->statem.in_initDescription
TRUEnever evaluated
FALSEnever evaluated
(s)->statem.st...MSG_FLOW_ERRORDescription
TRUEnever evaluated
FALSEnever evaluated
0
803 return SUB_STATE_ERROR;
never executed: return SUB_STATE_ERROR;
0
804 }-
805 break;
executed 31349 times by 1 test: break;
Executed by:
  • libssl.so.1.1
31349
806-
807 case WRITE_STATE_PRE_WORK:
executed 31349 times by 1 test: case WRITE_STATE_PRE_WORK:
Executed by:
  • libssl.so.1.1
31349
808 switch (st->write_state_work = pre_work(s, st->write_state_work)) {-
809 case WORK_ERROR:
never executed: case WORK_ERROR:
0
810 check_fatal(s, SSL_F_WRITE_STATE_MACHINE);
never executed: ossl_statem_fatal((s), (80), ((586)), (256), __FILE__, 810);
!(((s)->statem...W_ERROR) != 0)Description
TRUEnever evaluated
FALSEnever evaluated
(s)->statem.in_initDescription
TRUEnever evaluated
FALSEnever evaluated
(s)->statem.st...MSG_FLOW_ERRORDescription
TRUEnever evaluated
FALSEnever evaluated
0
811 /* Fall through */-
812 case WORK_MORE_A:
code before this statement never executed: case WORK_MORE_A:
never executed: case WORK_MORE_A:
0
813 case WORK_MORE_B:
never executed: case WORK_MORE_B:
0
814 case WORK_MORE_C:
never executed: case WORK_MORE_C:
0
815 return SUB_STATE_ERROR;
never executed: return SUB_STATE_ERROR;
0
816-
817 case WORK_FINISHED_CONTINUE:
executed 26863 times by 1 test: case WORK_FINISHED_CONTINUE:
Executed by:
  • libssl.so.1.1
26863
818 st->write_state = WRITE_STATE_SEND;-
819 break;
executed 26863 times by 1 test: break;
Executed by:
  • libssl.so.1.1
26863
820-
821 case WORK_FINISHED_STOP:
executed 4486 times by 1 test: case WORK_FINISHED_STOP:
Executed by:
  • libssl.so.1.1
4486
822 return SUB_STATE_END_HANDSHAKE;
executed 4486 times by 1 test: return SUB_STATE_END_HANDSHAKE;
Executed by:
  • libssl.so.1.1
4486
823 }-
824 if (!get_construct_message_f(s, &pkt, &confunc, &mt)) {
!get_construct...&confunc, &mt)Description
TRUEnever evaluated
FALSEevaluated 26863 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-26863
825 /* SSLfatal() already called */-
826 return SUB_STATE_ERROR;
never executed: return SUB_STATE_ERROR;
0
827 }-
828 if (mt == SSL3_MT_DUMMY) {
mt == -1Description
TRUEevaluated 845 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 26018 times by 1 test
Evaluated by:
  • libssl.so.1.1
845-26018
829 /* Skip construction and sending. This isn't a "real" state */-
830 st->write_state = WRITE_STATE_POST_WORK;-
831 st->write_state_work = WORK_MORE_A;-
832 break;
executed 845 times by 1 test: break;
Executed by:
  • libssl.so.1.1
845
833 }-
834 if (!WPACKET_init(&pkt, s->init_buf)
!WPACKET_init(..., s->init_buf)Description
TRUEnever evaluated
FALSEevaluated 26018 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-26018
835 || !ssl_set_handshake_header(s, &pkt, mt)) {
!s->method->ss... (&pkt), (mt))Description
TRUEnever evaluated
FALSEevaluated 26018 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-26018
836 WPACKET_cleanup(&pkt);-
837 SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_WRITE_STATE_MACHINE,-
838 ERR_R_INTERNAL_ERROR);-
839 return SUB_STATE_ERROR;
never executed: return SUB_STATE_ERROR;
0
840 }-
841 if (confunc != NULL && !confunc(s, &pkt)) {
confunc != ((void *)0)Description
TRUEevaluated 26010 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 8 times by 1 test
Evaluated by:
  • libssl.so.1.1
!confunc(s, &pkt)Description
TRUEevaluated 93 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 25917 times by 1 test
Evaluated by:
  • libssl.so.1.1
8-26010
842 WPACKET_cleanup(&pkt);-
843 check_fatal(s, SSL_F_WRITE_STATE_MACHINE);
never executed: ossl_statem_fatal((s), (80), ((586)), (256), __FILE__, 843);
!(((s)->statem...W_ERROR) != 0)Description
TRUEnever evaluated
FALSEevaluated 93 times by 1 test
Evaluated by:
  • libssl.so.1.1
(s)->statem.in_initDescription
TRUEevaluated 93 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEnever evaluated
(s)->statem.st...MSG_FLOW_ERRORDescription
TRUEevaluated 93 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEnever evaluated
0-93
844 return SUB_STATE_ERROR;
executed 93 times by 1 test: return SUB_STATE_ERROR;
Executed by:
  • libssl.so.1.1
93
845 }-
846 if (!ssl_close_construct_packet(s, &pkt, mt)
!s->method->ss... (&pkt), (mt))Description
TRUEnever evaluated
FALSEevaluated 25925 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-25925
847 || !WPACKET_finish(&pkt)) {
!WPACKET_finish(&pkt)Description
TRUEnever evaluated
FALSEevaluated 25925 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-25925
848 WPACKET_cleanup(&pkt);-
849 SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_WRITE_STATE_MACHINE,-
850 ERR_R_INTERNAL_ERROR);-
851 return SUB_STATE_ERROR;
never executed: return SUB_STATE_ERROR;
0
852 }-
853-
854 /* Fall through */-
855-
856 case WRITE_STATE_SEND:
code before this statement executed 25925 times by 1 test: case WRITE_STATE_SEND:
Executed by:
  • libssl.so.1.1
never executed: case WRITE_STATE_SEND:
0-25925
857 if (SSL_IS_DTLS(s) && st->use_timer) {
(s->method->ss...c_flags & 0x8)Description
TRUEevaluated 1891 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 24034 times by 1 test
Evaluated by:
  • libssl.so.1.1
st->use_timerDescription
TRUEevaluated 1356 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 535 times by 1 test
Evaluated by:
  • libssl.so.1.1
535-24034
858 dtls1_start_timer(s);-
859 }
executed 1356 times by 1 test: end of block
Executed by:
  • libssl.so.1.1
1356
860 ret = statem_do_write(s);-
861 if (ret <= 0) {
ret <= 0Description
TRUEnever evaluated
FALSEevaluated 25925 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-25925
862 return SUB_STATE_ERROR;
never executed: return SUB_STATE_ERROR;
0
863 }-
864 st->write_state = WRITE_STATE_POST_WORK;-
865 st->write_state_work = WORK_MORE_A;-
866 /* Fall through */-
867-
868 case WRITE_STATE_POST_WORK:
code before this statement executed 25925 times by 1 test: case WRITE_STATE_POST_WORK:
Executed by:
  • libssl.so.1.1
executed 1461 times by 1 test: case WRITE_STATE_POST_WORK:
Executed by:
  • libssl.so.1.1
1461-25925
869 switch (st->write_state_work = post_work(s, st->write_state_work)) {-
870 case WORK_ERROR:
never executed: case WORK_ERROR:
0
871 check_fatal(s, SSL_F_WRITE_STATE_MACHINE);
never executed: ossl_statem_fatal((s), (80), ((586)), (256), __FILE__, 871);
!(((s)->statem...W_ERROR) != 0)Description
TRUEnever evaluated
FALSEnever evaluated
(s)->statem.in_initDescription
TRUEnever evaluated
FALSEnever evaluated
(s)->statem.st...MSG_FLOW_ERRORDescription
TRUEnever evaluated
FALSEnever evaluated
0
872 /* Fall through */-
873 case WORK_MORE_A:
code before this statement never executed: case WORK_MORE_A:
executed 512 times by 1 test: case WORK_MORE_A:
Executed by:
  • libssl.so.1.1
0-512
874 case WORK_MORE_B:
executed 104 times by 1 test: case WORK_MORE_B:
Executed by:
  • libssl.so.1.1
104
875 case WORK_MORE_C:
never executed: case WORK_MORE_C:
0
876 return SUB_STATE_ERROR;
executed 616 times by 1 test: return SUB_STATE_ERROR;
Executed by:
  • libssl.so.1.1
616
877-
878 case WORK_FINISHED_CONTINUE:
executed 26770 times by 1 test: case WORK_FINISHED_CONTINUE:
Executed by:
  • libssl.so.1.1
26770
879 st->write_state = WRITE_STATE_TRANSITION;-
880 break;
executed 26770 times by 1 test: break;
Executed by:
  • libssl.so.1.1
26770
881-
882 case WORK_FINISHED_STOP:
never executed: case WORK_FINISHED_STOP:
0
883 return SUB_STATE_END_HANDSHAKE;
never executed: return SUB_STATE_END_HANDSHAKE;
0
884 }-
885 break;
executed 26770 times by 1 test: break;
Executed by:
  • libssl.so.1.1
26770
886-
887 default:
never executed: default:
0
888 SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_WRITE_STATE_MACHINE,-
889 ERR_R_INTERNAL_ERROR);-
890 return SUB_STATE_ERROR;
never executed: return SUB_STATE_ERROR;
0
891 }-
892 }-
893}
never executed: end of block
0
894-
895/*-
896 * Flush the write BIO-
897 */-
898int statem_flush(SSL *s)-
899{-
900 s->rwstate = SSL_WRITING;-
901 if (BIO_flush(s->wbio) <= 0) {
(int)BIO_ctrl(...id *)0) ) <= 0Description
TRUEevaluated 616 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 11529 times by 1 test
Evaluated by:
  • libssl.so.1.1
616-11529
902 return 0;
executed 616 times by 1 test: return 0;
Executed by:
  • libssl.so.1.1
616
903 }-
904 s->rwstate = SSL_NOTHING;-
905-
906 return 1;
executed 11529 times by 1 test: return 1;
Executed by:
  • libssl.so.1.1
11529
907}-
908-
909/*-
910 * Called by the record layer to determine whether application data is-
911 * allowed to be received in the current handshake state or not.-
912 *-
913 * Return values are:-
914 * 1: Yes (application data allowed)-
915 * 0: No (application data not allowed)-
916 */-
917int ossl_statem_app_data_allowed(SSL *s)-
918{-
919 OSSL_STATEM *st = &s->statem;-
920-
921 if (st->state == MSG_FLOW_UNINITED)
st->state == MSG_FLOW_UNINITEDDescription
TRUEnever evaluated
FALSEevaluated 219 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-219
922 return 0;
never executed: return 0;
0
923-
924 if (!s->s3->in_read_app_data || (s->s3->total_renegotiations == 0))
!s->s3->in_read_app_dataDescription
TRUEevaluated 213 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 6 times by 1 test
Evaluated by:
  • libssl.so.1.1
(s->s3->total_...tiations == 0)Description
TRUEevaluated 6 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEnever evaluated
0-213
925 return 0;
executed 219 times by 1 test: return 0;
Executed by:
  • libssl.so.1.1
219
926-
927 if (s->server) {
s->serverDescription
TRUEnever evaluated
FALSEnever evaluated
0
928 /*-
929 * If we're a server and we haven't got as far as writing our-
930 * ServerHello yet then we allow app data-
931 */-
932 if (st->hand_state == TLS_ST_BEFORE
st->hand_state... TLS_ST_BEFOREDescription
TRUEnever evaluated
FALSEnever evaluated
0
933 || st->hand_state == TLS_ST_SR_CLNT_HELLO)
st->hand_state..._SR_CLNT_HELLODescription
TRUEnever evaluated
FALSEnever evaluated
0
934 return 1;
never executed: return 1;
0
935 } else {
never executed: end of block
0
936 /*-
937 * If we're a client and we haven't read the ServerHello yet then we-
938 * allow app data-
939 */-
940 if (st->hand_state == TLS_ST_CW_CLNT_HELLO)
st->hand_state..._CW_CLNT_HELLODescription
TRUEnever evaluated
FALSEnever evaluated
0
941 return 1;
never executed: return 1;
0
942 }
never executed: end of block
0
943-
944 return 0;
never executed: return 0;
0
945}-
946-
947/*-
948 * This function returns 1 if TLS exporter is ready to export keying-
949 * material, or 0 if otherwise.-
950 */-
951int ossl_statem_export_allowed(SSL *s)-
952{-
953 return s->s3->previous_server_finished_len != 0
executed 6 times by 1 test: return s->s3->previous_server_finished_len != 0 && s->statem.hand_state != TLS_ST_SW_FINISHED;
Executed by:
  • libssl.so.1.1
s->s3->previou...ished_len != 0Description
TRUEevaluated 6 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEnever evaluated
0-6
954 && s->statem.hand_state != TLS_ST_SW_FINISHED;
executed 6 times by 1 test: return s->s3->previous_server_finished_len != 0 && s->statem.hand_state != TLS_ST_SW_FINISHED;
Executed by:
  • libssl.so.1.1
s->statem.hand...ST_SW_FINISHEDDescription
TRUEevaluated 6 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEnever evaluated
0-6
955}-
956-
957/*-
958 * Return 1 if early TLS exporter is ready to export keying material,-
959 * or 0 if otherwise.-
960 */-
961int ossl_statem_export_early_allowed(SSL *s)-
962{-
963 /*-
964 * The early exporter secret is only present on the server if we-
965 * have accepted early_data. It is present on the client as long-
966 * as we have sent early_data.-
967 */-
968 return s->ext.early_data == SSL_EARLY_DATA_ACCEPTED
executed 12 times by 1 test: return s->ext.early_data == 2 || (!s->server && s->ext.early_data != 0);
Executed by:
  • libssl.so.1.1
s->ext.early_data == 2Description
TRUEevaluated 6 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 6 times by 1 test
Evaluated by:
  • libssl.so.1.1
6-12
969 || (!s->server && s->ext.early_data != SSL_EARLY_DATA_NOT_SENT);
executed 12 times by 1 test: return s->ext.early_data == 2 || (!s->server && s->ext.early_data != 0);
Executed by:
  • libssl.so.1.1
!s->serverDescription
TRUEevaluated 6 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEnever evaluated
s->ext.early_data != 0Description
TRUEevaluated 6 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEnever evaluated
0-12
970}-
Source codeSwitch to Preprocessed file

Generated by Squish Coco 4.2.2