2 * Copyright 2015-2016 The OpenSSL Project Authors. All Rights Reserved.
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
10 /*****************************************************************************
12 * These enums should be considered PRIVATE to the state machine. No *
13 * non-state machine code should need to use these *
15 *****************************************************************************/
17 * Valid return codes used for functions performing work prior to or after
18 * sending or receiving a message
21 /* Something went wrong */
23 /* We're done working and there shouldn't be anything else to do after */
25 /* We're done working move onto the next thing */
26 WORK_FINISHED_CONTINUE,
27 /* We're working on phase A */
29 /* We're working on phase B */
33 /* Write transition return codes */
35 /* Something went wrong */
37 /* A transition was successfully completed and we should continue */
39 /* There is no more write work to be done */
43 /* Message flow states */
45 /* No handshake in progress */
47 /* A permanent error with this connection */
49 /* We are reading messages */
51 /* We are writing messages */
53 /* Handshake has finished */
61 READ_STATE_POST_PROCESS
66 WRITE_STATE_TRANSITION,
72 /*****************************************************************************
74 * This structure should be considered "opaque" to anything outside of the *
75 * state machine. No non-state machine code should be accessing the members *
76 * of this structure. *
78 *****************************************************************************/
80 struct ossl_statem_st {
82 WRITE_STATE write_state;
83 WORK_STATE write_state_work;
84 READ_STATE read_state;
85 WORK_STATE read_state_work;
86 OSSL_HANDSHAKE_STATE hand_state;
87 /* The handshake state requested by an API call (e.g. HelloRequest) */
88 OSSL_HANDSHAKE_STATE request_state;
90 int read_state_first_init;
91 /* true when we are actually in SSL_accept() or SSL_connect() */
94 * True when are processing a "real" handshake that needs cleaning up (not
95 * just a HelloRequest or similar).
98 /* Should we skip the CertificateVerify message? */
99 unsigned int no_cert_verify;
101 #ifndef OPENSSL_NO_SCTP
102 int in_sctp_read_sock;
105 typedef struct ossl_statem_st OSSL_STATEM;
107 /*****************************************************************************
109 * The following macros/functions represent the libssl internal API to the *
110 * state machine. Any libssl code may call these functions/macros *
112 *****************************************************************************/
114 __owur int ossl_statem_accept(SSL *s);
115 __owur int ossl_statem_connect(SSL *s);
116 void ossl_statem_clear(SSL *s);
117 void ossl_statem_set_renegotiate(SSL *s);
118 void ossl_statem_set_error(SSL *s);
119 int ossl_statem_in_error(const SSL *s);
120 void ossl_statem_set_in_init(SSL *s, int init);
121 int ossl_statem_get_in_handshake(SSL *s);
122 void ossl_statem_set_in_handshake(SSL *s, int inhand);
123 void ossl_statem_set_hello_verify_done(SSL *s);
124 __owur int ossl_statem_app_data_allowed(SSL *s);
125 #ifndef OPENSSL_NO_SCTP
126 void ossl_statem_set_sctp_read_sock(SSL *s, int read_sock);
127 __owur int ossl_statem_in_sctp_read_sock(SSL *s);