1 /* ssl/statem/statem.c */
3 * Written by Matt Caswell for the OpenSSL project.
5 /* ====================================================================
6 * Copyright (c) 1998-2015 The OpenSSL Project. All rights reserved.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in
17 * the documentation and/or other materials provided with the
20 * 3. All advertising materials mentioning features or use of this
21 * software must display the following acknowledgment:
22 * "This product includes software developed by the OpenSSL Project
23 * for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
25 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
26 * endorse or promote products derived from this software without
27 * prior written permission. For written permission, please contact
28 * openssl-core@openssl.org.
30 * 5. Products derived from this software may not be called "OpenSSL"
31 * nor may "OpenSSL" appear in their names without prior written
32 * permission of the OpenSSL Project.
34 * 6. Redistributions of any form whatsoever must retain the following
36 * "This product includes software developed by the OpenSSL Project
37 * for use in the OpenSSL Toolkit (http://www.openssl.org/)"
39 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
40 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
41 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
42 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
43 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
44 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
45 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
46 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
47 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
48 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
49 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
50 * OF THE POSSIBILITY OF SUCH DAMAGE.
51 * ====================================================================
53 * This product includes cryptographic software written by Eric Young
54 * (eay@cryptsoft.com). This product includes software written by Tim
55 * Hudson (tjh@cryptsoft.com).
59 #include <openssl/rand.h>
60 #include "../ssl_locl.h"
61 #include "statem_locl.h"
64 * This file implements the SSL/TLS/DTLS state machines.
66 * There are two primary state machines:
68 * 1) Message flow state machine
69 * 2) Handshake state machine
71 * The Message flow state machine controls the reading and sending of messages
72 * including handling of non-blocking IO events, flushing of the underlying
73 * write BIO, handling unexpected messages, etc. It is itself broken into two
74 * separate sub-state machines which control reading and writing respectively.
76 * The Handshake state machine keeps track of the current SSL/TLS handshake
77 * state. Transitions of the handshake state are the result of events that
78 * occur within the Message flow state machine.
80 * Overall it looks like this:
82 * --------------------------------------------- -------------------
84 * | Message flow state machine | | |
86 * | -------------------- -------------------- | Transition | Handshake state |
87 * | | MSG_FLOW_READING | | MSG_FLOW_WRITING | | Event | machine |
88 * | | sub-state | | sub-state | |----------->| |
89 * | | machine for | | machine for | | | |
90 * | | reading messages | | writing messages | | | |
91 * | -------------------- -------------------- | | |
93 * --------------------------------------------- -------------------
97 /* Sub state machine return values */
99 /* Something bad happened or NBIO */
101 /* Sub state finished go to the next sub state */
103 /* Sub state finished and handshake was completed */
104 SUB_STATE_END_HANDSHAKE
107 static int state_machine(SSL *s, int server);
108 static void init_read_state_machine(SSL *s);
109 static SUB_STATE_RETURN read_state_machine(SSL *s);
110 static void init_write_state_machine(SSL *s);
111 static SUB_STATE_RETURN write_state_machine(SSL *s);
113 OSSL_HANDSHAKE_STATE SSL_get_state(const SSL *ssl)
115 return ssl->statem.hand_state;
118 int SSL_in_init(SSL *s)
120 return s->statem.in_init;
123 int SSL_is_init_finished(SSL *s)
125 return !(s->statem.in_init) && (s->statem.hand_state == TLS_ST_OK);
128 int SSL_in_before(SSL *s)
131 * Historically being "in before" meant before anything had happened. In the
132 * current code though we remain in the "before" state for a while after we
133 * have started the handshake process (e.g. as a server waiting for the
134 * first message to arrive). There "in before" is taken to mean "in before"
135 * and not started any handshake process yet.
137 return (s->statem.hand_state == TLS_ST_BEFORE)
138 && (s->statem.state == MSG_FLOW_UNINITED);
142 * Clear the state machine state and reset back to MSG_FLOW_UNINITED
144 void ossl_statem_clear(SSL *s)
146 s->statem.state = MSG_FLOW_UNINITED;
147 s->statem.hand_state = TLS_ST_BEFORE;
148 s->statem.in_init = 1;
149 s->statem.no_cert_verify = 0;
153 * Set the state machine up ready for a renegotiation handshake
155 void ossl_statem_set_renegotiate(SSL *s)
157 s->statem.state = MSG_FLOW_RENEGOTIATE;
158 s->statem.in_init = 1;
162 * Put the state machine into an error state. This is a permanent error for
163 * the current connection.
165 void ossl_statem_set_error(SSL *s)
167 s->statem.state = MSG_FLOW_ERROR;
171 * Discover whether the current connection is in the error state.
173 * Valid return values are:
177 int ossl_statem_in_error(const SSL *s)
179 if (s->statem.state == MSG_FLOW_ERROR)
185 void ossl_statem_set_in_init(SSL *s, int init)
187 s->statem.in_init = init;
190 int ossl_statem_get_in_handshake(SSL *s)
192 return s->statem.in_handshake;
195 void ossl_statem_set_in_handshake(SSL *s, int inhand)
198 s->statem.in_handshake++;
200 s->statem.in_handshake--;
203 void ossl_statem_set_hello_verify_done(SSL *s)
205 s->statem.state = MSG_FLOW_UNINITED;
206 s->statem.in_init = 1;
208 * This will get reset (briefly) back to TLS_ST_BEFORE when we enter
209 * state_machine() because |state| is MSG_FLOW_UNINITED, but until then any
210 * calls to SSL_in_before() will return false. Also calls to
211 * SSL_state_string() and SSL_state_string_long() will return something
214 s->statem.hand_state = TLS_ST_SR_CLNT_HELLO;
217 int ossl_statem_connect(SSL *s) {
218 return state_machine(s, 0);
221 int ossl_statem_accept(SSL *s)
223 return state_machine(s, 1);
226 static void (*get_callback(SSL *s))(const SSL *, int, int)
228 if (s->info_callback != NULL)
229 return s->info_callback;
230 else if (s->ctx->info_callback != NULL)
231 return s->ctx->info_callback;
237 * The main message flow state machine. We start in the MSG_FLOW_UNINITED or
238 * MSG_FLOW_RENEGOTIATE state and finish in MSG_FLOW_FINISHED. Valid states and
239 * transitions are as follows:
241 * MSG_FLOW_UNINITED MSG_FLOW_RENEGOTIATE
243 * +-----------------------+
245 * MSG_FLOW_WRITING <---> MSG_FLOW_READING
253 * We may exit at any point due to an error or NBIO event. If an NBIO event
254 * occurs then we restart at the point we left off when we are recalled.
255 * MSG_FLOW_WRITING and MSG_FLOW_READING have sub-state machines associated with them.
257 * In addition to the above there is also the MSG_FLOW_ERROR state. We can move
258 * into that state at any point in the event that an irrecoverable error occurs.
260 * Valid return values are:
264 static int state_machine(SSL *s, int server)
267 unsigned long Time = (unsigned long)time(NULL);
268 void (*cb) (const SSL *ssl, int type, int val) = NULL;
269 OSSL_STATEM *st = &s->statem;
273 if (st->state == MSG_FLOW_ERROR) {
274 /* Shouldn't have been called if we're already in the error state */
278 RAND_add(&Time, sizeof(Time), 0);
282 cb = get_callback(s);
285 if (!SSL_in_init(s) || SSL_in_before(s)) {
290 #ifndef OPENSSL_NO_SCTP
291 if (SSL_IS_DTLS(s)) {
293 * Notify SCTP BIO socket to enter handshake mode and prevent stream
294 * identifier other than 0. Will be ignored if no SCTP is used.
296 BIO_ctrl(SSL_get_wbio(s), BIO_CTRL_DGRAM_SCTP_SET_IN_HANDSHAKE,
297 st->in_handshake, NULL);
301 #ifndef OPENSSL_NO_HEARTBEATS
303 * If we're awaiting a HeartbeatResponse, pretend we already got and
304 * don't await it anymore, because Heartbeats don't make sense during
307 if (s->tlsext_hb_pending) {
310 s->tlsext_hb_pending = 0;
315 /* Initialise state machine */
317 if (st->state == MSG_FLOW_RENEGOTIATE) {
320 s->ctx->stats.sess_connect_renegotiate++;
323 if (st->state == MSG_FLOW_UNINITED || st->state == MSG_FLOW_RENEGOTIATE) {
324 if (st->state == MSG_FLOW_UNINITED) {
325 st->hand_state = TLS_ST_BEFORE;
330 cb(s, SSL_CB_HANDSHAKE_START, 1);
332 if (SSL_IS_DTLS(s)) {
333 if ((s->version & 0xff00) != (DTLS1_VERSION & 0xff00) &&
335 || (s->version & 0xff00) != (DTLS1_BAD_VER & 0xff00))) {
336 SSLerr(SSL_F_STATE_MACHINE, ERR_R_INTERNAL_ERROR);
340 if ((s->version >> 8) != SSL3_VERSION_MAJOR) {
341 SSLerr(SSL_F_STATE_MACHINE, ERR_R_INTERNAL_ERROR);
346 if (!ssl_security(s, SSL_SECOP_VERSION, 0, s->version, NULL)) {
347 SSLerr(SSL_F_STATE_MACHINE, SSL_R_VERSION_TOO_LOW);
351 if (s->init_buf == NULL) {
352 if ((buf = BUF_MEM_new()) == NULL) {
355 if (!BUF_MEM_grow(buf, SSL3_RT_MAX_PLAIN_LENGTH)) {
362 if (!ssl3_setup_buffers(s)) {
368 * Should have been reset by tls_process_finished, too.
370 s->s3->change_cipher_spec = 0;
372 if (!server || st->state != MSG_FLOW_RENEGOTIATE) {
374 * Ok, we now need to push on a buffering BIO ...but not with
377 #ifndef OPENSSL_NO_SCTP
378 if (!SSL_IS_DTLS(s) || !BIO_dgram_is_sctp(SSL_get_wbio(s)))
380 if (!ssl_init_wbio_buffer(s, server ? 1 : 0)) {
384 ssl3_init_finished_mac(s);
388 if (st->state != MSG_FLOW_RENEGOTIATE) {
389 s->ctx->stats.sess_accept++;
390 } else if (!s->s3->send_connection_binding &&
392 SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION)) {
394 * Server attempting to renegotiate with client that doesn't
395 * support secure renegotiation.
397 SSLerr(SSL_F_STATE_MACHINE,
398 SSL_R_UNSAFE_LEGACY_RENEGOTIATION_DISABLED);
399 ssl3_send_alert(s, SSL3_AL_FATAL, SSL_AD_HANDSHAKE_FAILURE);
400 ossl_statem_set_error(s);
404 * st->state == MSG_FLOW_RENEGOTIATE, we will just send a
407 s->ctx->stats.sess_accept_renegotiate++;
410 s->ctx->stats.sess_connect++;
412 /* mark client_random uninitialized */
413 memset(s->s3->client_random, 0, sizeof(s->s3->client_random));
416 s->s3->tmp.cert_request = 0;
418 if (SSL_IS_DTLS(s)) {
423 st->state = MSG_FLOW_WRITING;
424 init_write_state_machine(s);
425 st->read_state_first_init = 1;
428 while(st->state != MSG_FLOW_FINISHED) {
429 if(st->state == MSG_FLOW_READING) {
430 ssret = read_state_machine(s);
431 if (ssret == SUB_STATE_FINISHED) {
432 st->state = MSG_FLOW_WRITING;
433 init_write_state_machine(s);
438 } else if (st->state == MSG_FLOW_WRITING) {
439 ssret = write_state_machine(s);
440 if (ssret == SUB_STATE_FINISHED) {
441 st->state = MSG_FLOW_READING;
442 init_read_state_machine(s);
443 } else if (ssret == SUB_STATE_END_HANDSHAKE) {
444 st->state = MSG_FLOW_FINISHED;
451 ossl_statem_set_error(s);
456 st->state = MSG_FLOW_UNINITED;
462 #ifndef OPENSSL_NO_SCTP
463 if (SSL_IS_DTLS(s)) {
465 * Notify SCTP BIO socket to leave handshake mode and allow stream
466 * identifier other than 0. Will be ignored if no SCTP is used.
468 BIO_ctrl(SSL_get_wbio(s), BIO_CTRL_DGRAM_SCTP_SET_IN_HANDSHAKE,
469 st->in_handshake, NULL);
476 cb(s, SSL_CB_ACCEPT_EXIT, ret);
478 cb(s, SSL_CB_CONNECT_EXIT, ret);
484 * Initialise the MSG_FLOW_READING sub-state machine
486 static void init_read_state_machine(SSL *s)
488 OSSL_STATEM *st = &s->statem;
490 st->read_state = READ_STATE_HEADER;
494 * This function implements the sub-state machine when the message flow is in
495 * MSG_FLOW_READING. The valid sub-states and transitions are:
497 * READ_STATE_HEADER <--+<-------------+
500 * READ_STATE_BODY -----+-->READ_STATE_POST_PROCESS
502 * +----------------------------+
504 * [SUB_STATE_FINISHED]
506 * READ_STATE_HEADER has the responsibility for reading in the message header
507 * and transitioning the state of the handshake state machine.
509 * READ_STATE_BODY reads in the rest of the message and then subsequently
512 * READ_STATE_POST_PROCESS is an optional step that may occur if some post
513 * processing activity performed on the message may block.
515 * Any of the above states could result in an NBIO event occuring in which case
516 * control returns to the calling application. When this function is recalled we
517 * will resume in the same state where we left off.
519 static SUB_STATE_RETURN read_state_machine(SSL *s) {
520 OSSL_STATEM *st = &s->statem;
522 unsigned long len = 0;
523 int (*transition)(SSL *s, int mt);
525 MSG_PROCESS_RETURN (*process_message)(SSL *s, PACKET *pkt);
526 WORK_STATE (*post_process_message)(SSL *s, WORK_STATE wst);
527 unsigned long (*max_message_size)(SSL *s);
528 void (*cb) (const SSL *ssl, int type, int val) = NULL;
530 cb = get_callback(s);
533 transition = ossl_statem_server_read_transition;
534 process_message = ossl_statem_server_process_message;
535 max_message_size = ossl_statem_server_max_message_size;
536 post_process_message = ossl_statem_server_post_process_message;
538 transition = ossl_statem_client_read_transition;
539 process_message = ossl_statem_client_process_message;
540 max_message_size = ossl_statem_client_max_message_size;
541 post_process_message = ossl_statem_client_post_process_message;
544 if (st->read_state_first_init) {
546 st->read_state_first_init = 0;
550 switch(st->read_state) {
551 case READ_STATE_HEADER:
553 /* Get the state the peer wants to move to */
554 if (SSL_IS_DTLS(s)) {
556 * In DTLS we get the whole message in one go - header and body
558 ret = dtls_get_message(s, &mt, &len);
560 ret = tls_get_message_header(s, &mt);
564 /* Could be non-blocking IO */
565 return SUB_STATE_ERROR;
569 /* Notify callback of an impending state change */
571 cb(s, SSL_CB_ACCEPT_LOOP, 1);
573 cb(s, SSL_CB_CONNECT_LOOP, 1);
576 * Validate that we are allowed to move to the new state and move
577 * to that state if so
579 if(!transition(s, mt)) {
580 ssl3_send_alert(s, SSL3_AL_FATAL, SSL3_AD_UNEXPECTED_MESSAGE);
581 SSLerr(SSL_F_READ_STATE_MACHINE, SSL_R_UNEXPECTED_MESSAGE);
582 return SUB_STATE_ERROR;
585 if (s->s3->tmp.message_size > max_message_size(s)) {
586 ssl3_send_alert(s, SSL3_AL_FATAL, SSL_AD_ILLEGAL_PARAMETER);
587 SSLerr(SSL_F_READ_STATE_MACHINE, SSL_R_EXCESSIVE_MESSAGE_SIZE);
588 return SUB_STATE_ERROR;
591 st->read_state = READ_STATE_BODY;
594 case READ_STATE_BODY:
595 if (!SSL_IS_DTLS(s)) {
596 /* We already got this above for DTLS */
597 ret = tls_get_message_body(s, &len);
599 /* Could be non-blocking IO */
600 return SUB_STATE_ERROR;
605 if (!PACKET_buf_init(&pkt, s->init_msg, len)) {
606 ssl3_send_alert(s, SSL3_AL_FATAL, SSL_AD_INTERNAL_ERROR);
607 SSLerr(SSL_F_READ_STATE_MACHINE, ERR_R_INTERNAL_ERROR);
608 return SUB_STATE_ERROR;
610 ret = process_message(s, &pkt);
611 if (ret == MSG_PROCESS_ERROR) {
612 return SUB_STATE_ERROR;
615 if (ret == MSG_PROCESS_FINISHED_READING) {
616 if (SSL_IS_DTLS(s)) {
619 return SUB_STATE_FINISHED;
622 if (ret == MSG_PROCESS_CONTINUE_PROCESSING) {
623 st->read_state = READ_STATE_POST_PROCESS;
624 st->read_state_work = WORK_MORE_A;
626 st->read_state = READ_STATE_HEADER;
630 case READ_STATE_POST_PROCESS:
631 st->read_state_work = post_process_message(s, st->read_state_work);
632 switch(st->read_state_work) {
634 return SUB_STATE_ERROR;
636 case WORK_FINISHED_CONTINUE:
637 st->read_state = READ_STATE_HEADER;
640 case WORK_FINISHED_STOP:
641 if (SSL_IS_DTLS(s)) {
644 return SUB_STATE_FINISHED;
649 /* Shouldn't happen */
650 ssl3_send_alert(s, SSL3_AL_FATAL, SSL_AD_INTERNAL_ERROR);
651 SSLerr(SSL_F_READ_STATE_MACHINE, ERR_R_INTERNAL_ERROR);
652 ossl_statem_set_error(s);
653 return SUB_STATE_ERROR;
659 * Send a previously constructed message to the peer.
661 static int statem_do_write(SSL *s)
663 OSSL_STATEM *st = &s->statem;
665 if (st->hand_state == TLS_ST_CW_CHANGE
666 || st->hand_state == TLS_ST_SW_CHANGE) {
668 return dtls1_do_write(s, SSL3_RT_CHANGE_CIPHER_SPEC);
670 return ssl3_do_write(s, SSL3_RT_CHANGE_CIPHER_SPEC);
672 return ssl_do_write(s);
677 * Initialise the MSG_FLOW_WRITING sub-state machine
679 static void init_write_state_machine(SSL *s)
681 OSSL_STATEM *st = &s->statem;
683 st->write_state = WRITE_STATE_TRANSITION;
687 * This function implements the sub-state machine when the message flow is in
688 * MSG_FLOW_WRITING. The valid sub-states and transitions are:
690 * +-> WRITE_STATE_TRANSITION ------> [SUB_STATE_FINISHED]
693 * | WRITE_STATE_PRE_WORK -----> [SUB_STATE_END_HANDSHAKE]
699 * | WRITE_STATE_POST_WORK
703 * WRITE_STATE_TRANSITION transitions the state of the handshake state machine
705 * WRITE_STATE_PRE_WORK performs any work necessary to prepare the later
706 * sending of the message. This could result in an NBIO event occuring in
707 * which case control returns to the calling application. When this function
708 * is recalled we will resume in the same state where we left off.
710 * WRITE_STATE_SEND sends the message and performs any work to be done after
713 * WRITE_STATE_POST_WORK performs any work necessary after the sending of the
714 * message has been completed. As for WRITE_STATE_PRE_WORK this could also
715 * result in an NBIO event.
717 static SUB_STATE_RETURN write_state_machine(SSL *s)
719 OSSL_STATEM *st = &s->statem;
721 WRITE_TRAN (*transition)(SSL *s);
722 WORK_STATE (*pre_work)(SSL *s, WORK_STATE wst);
723 WORK_STATE (*post_work)(SSL *s, WORK_STATE wst);
724 int (*construct_message)(SSL *s);
725 void (*cb) (const SSL *ssl, int type, int val) = NULL;
727 cb = get_callback(s);
730 transition = ossl_statem_server_write_transition;
731 pre_work = ossl_statem_server_pre_work;
732 post_work = ossl_statem_server_post_work;
733 construct_message = ossl_statem_server_construct_message;
735 transition = ossl_statem_client_write_transition;
736 pre_work = ossl_statem_client_pre_work;
737 post_work = ossl_statem_client_post_work;
738 construct_message = ossl_statem_client_construct_message;
742 switch(st->write_state) {
743 case WRITE_STATE_TRANSITION:
745 /* Notify callback of an impending state change */
747 cb(s, SSL_CB_ACCEPT_LOOP, 1);
749 cb(s, SSL_CB_CONNECT_LOOP, 1);
751 switch(transition(s)) {
752 case WRITE_TRAN_CONTINUE:
753 st->write_state = WRITE_STATE_PRE_WORK;
754 st->write_state_work = WORK_MORE_A;
757 case WRITE_TRAN_FINISHED:
758 return SUB_STATE_FINISHED;
762 return SUB_STATE_ERROR;
766 case WRITE_STATE_PRE_WORK:
767 switch(st->write_state_work = pre_work(s, st->write_state_work)) {
769 return SUB_STATE_ERROR;
771 case WORK_FINISHED_CONTINUE:
772 st->write_state = WRITE_STATE_SEND;
775 case WORK_FINISHED_STOP:
776 return SUB_STATE_END_HANDSHAKE;
778 if(construct_message(s) == 0)
779 return SUB_STATE_ERROR;
783 case WRITE_STATE_SEND:
784 if (SSL_IS_DTLS(s) && st->use_timer) {
785 dtls1_start_timer(s);
787 ret = statem_do_write(s);
789 return SUB_STATE_ERROR;
791 st->write_state = WRITE_STATE_POST_WORK;
792 st->write_state_work = WORK_MORE_A;
795 case WRITE_STATE_POST_WORK:
796 switch(st->write_state_work = post_work(s, st->write_state_work)) {
798 return SUB_STATE_ERROR;
800 case WORK_FINISHED_CONTINUE:
801 st->write_state = WRITE_STATE_TRANSITION;
804 case WORK_FINISHED_STOP:
805 return SUB_STATE_END_HANDSHAKE;
810 return SUB_STATE_ERROR;
816 * Flush the write BIO
818 int statem_flush(SSL *s)
820 s->rwstate = SSL_WRITING;
821 if (BIO_flush(s->wbio) <= 0) {
824 s->rwstate = SSL_NOTHING;
830 * Called by the record layer to determine whether application data is
831 * allowed to be sent in the current handshake state or not.
834 * 1: Yes (application data allowed)
835 * 0: No (application data not allowed)
837 int ossl_statem_app_data_allowed(SSL *s)
839 OSSL_STATEM *st = &s->statem;
841 if (st->state == MSG_FLOW_UNINITED || st->state == MSG_FLOW_RENEGOTIATE)
844 if (!s->s3->in_read_app_data || (s->s3->total_renegotiations == 0))
849 * If we're a server and we haven't got as far as writing our
850 * ServerHello yet then we allow app data
852 if (st->hand_state == TLS_ST_BEFORE
853 || st->hand_state == TLS_ST_SR_CLNT_HELLO)
857 * If we're a client and we haven't read the ServerHello yet then we
860 if (st->hand_state == TLS_ST_CW_CLNT_HELLO)
867 #ifndef OPENSSL_NO_SCTP
869 * Set flag used by SCTP to determine whether we are in the read sock state
871 void ossl_statem_set_sctp_read_sock(SSL *s, int read_sock)
873 s->statem.in_sctp_read_sock = read_sock;
877 * Called by the record layer to determine whether we are in the read sock
881 * 1: Yes (we are in the read sock state)
882 * 0: No (we are not in the read sock state)
884 int ossl_statem_in_sctp_read_sock(SSL *s)
886 return s->statem.in_sctp_read_sock;