Rename STATEM to OSSL_STATEM
[openssl.git] / ssl / statem / statem.c
index f0b326082931a1da3832252c9ac53ede7bda0739..062329fc00c48fede03a7fc709d0638bdd4532a6 100644 (file)
@@ -110,20 +110,11 @@ static enum SUB_STATE_RETURN read_state_machine(SSL *s);
 static void init_write_state_machine(SSL *s);
 static enum SUB_STATE_RETURN write_state_machine(SSL *s);
 
 static void init_write_state_machine(SSL *s);
 static enum SUB_STATE_RETURN write_state_machine(SSL *s);
 
-enum HANDSHAKE_STATE SSL_state(const SSL *ssl)
+OSSL_HANDSHAKE_STATE SSL_get_state(const SSL *ssl)
 {
     return ssl->statem.hand_state;
 }
 
 {
     return ssl->statem.hand_state;
 }
 
-void SSL_set_state(SSL *ssl, enum HANDSHAKE_STATE state)
-{
-    /*
-     * This function seems like a really bad idea. Should we remove it
-     * completely?
-     */
-    ssl->statem.hand_state = state;
-}
-
 int SSL_in_init(SSL *s)
 {
     return s->statem.in_init;
 int SSL_in_init(SSL *s)
 {
     return s->statem.in_init;
@@ -150,17 +141,18 @@ int SSL_in_before(SSL *s)
 /*
  * Clear the state machine state and reset back to MSG_FLOW_UNINITED
  */
 /*
  * Clear the state machine state and reset back to MSG_FLOW_UNINITED
  */
-void statem_clear(SSL *s)
+void ossl_statem_clear(SSL *s)
 {
     s->statem.state = MSG_FLOW_UNINITED;
     s->statem.hand_state = TLS_ST_BEFORE;
     s->statem.in_init = 1;
 {
     s->statem.state = MSG_FLOW_UNINITED;
     s->statem.hand_state = TLS_ST_BEFORE;
     s->statem.in_init = 1;
+    s->statem.no_cert_verify = 0;
 }
 
 /*
  * Set the state machine up ready for a renegotiation handshake
  */
 }
 
 /*
  * Set the state machine up ready for a renegotiation handshake
  */
-void statem_set_renegotiate(SSL *s)
+void ossl_statem_set_renegotiate(SSL *s)
 {
     s->statem.state = MSG_FLOW_RENEGOTIATE;
     s->statem.in_init = 1;
 {
     s->statem.state = MSG_FLOW_RENEGOTIATE;
     s->statem.in_init = 1;
@@ -170,7 +162,7 @@ void statem_set_renegotiate(SSL *s)
  * Put the state machine into an error state. This is a permanent error for
  * the current connection.
  */
  * Put the state machine into an error state. This is a permanent error for
  * the current connection.
  */
-void statem_set_error(SSL *s)
+void ossl_statem_set_error(SSL *s)
 {
     s->statem.state = MSG_FLOW_ERROR;
 }
 {
     s->statem.state = MSG_FLOW_ERROR;
 }
@@ -182,7 +174,7 @@ void statem_set_error(SSL *s)
  *   1: Yes
  *   0: No
  */
  *   1: Yes
  *   0: No
  */
-int statem_in_error(const SSL *s)
+int ossl_statem_in_error(const SSL *s)
 {
     if (s->statem.state == MSG_FLOW_ERROR)
         return 1;
 {
     if (s->statem.state == MSG_FLOW_ERROR)
         return 1;
@@ -190,16 +182,16 @@ int statem_in_error(const SSL *s)
     return 0;
 }
 
     return 0;
 }
 
-void statem_set_in_init(SSL *s, int init)
+void ossl_statem_set_in_init(SSL *s, int init)
 {
     s->statem.in_init = init;
 }
 
 {
     s->statem.in_init = init;
 }
 
-int statem_connect(SSL *s) {
+int ossl_statem_connect(SSL *s) {
     return state_machine(s, 0);
 }
 
     return state_machine(s, 0);
 }
 
-int statem_accept(SSL *s)
+int ossl_statem_accept(SSL *s)
 {
     return state_machine(s, 1);
 }
 {
     return state_machine(s, 1);
 }
@@ -236,7 +228,7 @@ static int state_machine(SSL *s, int server) {
     BUF_MEM *buf = NULL;
     unsigned long Time = (unsigned long)time(NULL);
     void (*cb) (const SSL *ssl, int type, int val) = NULL;
     BUF_MEM *buf = NULL;
     unsigned long Time = (unsigned long)time(NULL);
     void (*cb) (const SSL *ssl, int type, int val) = NULL;
-    STATEM *st = &s->statem;
+    OSSL_STATEM *st = &s->statem;
     int ret = -1;
     int ssret;
 
     int ret = -1;
     int ssret;
 
@@ -374,11 +366,11 @@ static int state_machine(SSL *s, int server) {
                 SSLerr(SSL_F_STATE_MACHINE,
                        SSL_R_UNSAFE_LEGACY_RENEGOTIATION_DISABLED);
                 ssl3_send_alert(s, SSL3_AL_FATAL, SSL_AD_HANDSHAKE_FAILURE);
                 SSLerr(SSL_F_STATE_MACHINE,
                        SSL_R_UNSAFE_LEGACY_RENEGOTIATION_DISABLED);
                 ssl3_send_alert(s, SSL3_AL_FATAL, SSL_AD_HANDSHAKE_FAILURE);
-                statem_set_error(s);
+                ossl_statem_set_error(s);
                 goto end;
             } else {
                 /*
                 goto end;
             } else {
                 /*
-                 * s->state == SSL_ST_RENEGOTIATE, we will just send a
+                 * st->state == MSG_FLOW_RENEGOTIATE, we will just send a
                  * HelloRequest
                  */
                 s->ctx->stats.sess_accept_renegotiate++;
                  * HelloRequest
                  */
                 s->ctx->stats.sess_accept_renegotiate++;
@@ -425,7 +417,7 @@ static int state_machine(SSL *s, int server) {
             }
         } else {
             /* Error */
             }
         } else {
             /* Error */
-            statem_set_error(s);
+            ossl_statem_set_error(s);
             goto end;
         }
     }
             goto end;
         }
     }
@@ -462,7 +454,7 @@ static int state_machine(SSL *s, int server) {
  */
 static void init_read_state_machine(SSL *s)
 {
  */
 static void init_read_state_machine(SSL *s)
 {
-    STATEM *st = &s->statem;
+    OSSL_STATEM *st = &s->statem;
 
     st->read_state = READ_STATE_HEADER;
 }
 
     st->read_state = READ_STATE_HEADER;
 }
@@ -494,7 +486,7 @@ static void init_read_state_machine(SSL *s)
  * will resume in the same state where we left off.
  */
 static enum SUB_STATE_RETURN read_state_machine(SSL *s) {
  * will resume in the same state where we left off.
  */
 static enum SUB_STATE_RETURN read_state_machine(SSL *s) {
-    STATEM *st = &s->statem;
+    OSSL_STATEM *st = &s->statem;
     int ret, mt;
     unsigned long len;
     int (*transition)(SSL *s, int mt);
     int ret, mt;
     unsigned long len;
     int (*transition)(SSL *s, int mt);
@@ -629,7 +621,7 @@ static enum SUB_STATE_RETURN read_state_machine(SSL *s) {
             /* Shouldn't happen */
             ssl3_send_alert(s, SSL3_AL_FATAL, SSL_AD_INTERNAL_ERROR);
             SSLerr(SSL_F_READ_STATE_MACHINE, ERR_R_INTERNAL_ERROR);
             /* Shouldn't happen */
             ssl3_send_alert(s, SSL3_AL_FATAL, SSL_AD_INTERNAL_ERROR);
             SSLerr(SSL_F_READ_STATE_MACHINE, ERR_R_INTERNAL_ERROR);
-            statem_set_error(s);
+            ossl_statem_set_error(s);
             return SUB_STATE_ERROR;
         }
     }
             return SUB_STATE_ERROR;
         }
     }
@@ -640,7 +632,7 @@ static enum SUB_STATE_RETURN read_state_machine(SSL *s) {
  */
 static int statem_do_write(SSL *s)
 {
  */
 static int statem_do_write(SSL *s)
 {
-    STATEM *st = &s->statem;
+    OSSL_STATEM *st = &s->statem;
 
     if (st->hand_state == TLS_ST_CW_CHANGE
             || st->hand_state == TLS_ST_SW_CHANGE) {
 
     if (st->hand_state == TLS_ST_CW_CHANGE
             || st->hand_state == TLS_ST_SW_CHANGE) {
@@ -658,7 +650,7 @@ static int statem_do_write(SSL *s)
  */
 static void init_write_state_machine(SSL *s)
 {
  */
 static void init_write_state_machine(SSL *s)
 {
-    STATEM *st = &s->statem;
+    OSSL_STATEM *st = &s->statem;
 
     st->write_state = WRITE_STATE_TRANSITION;
 }
 
     st->write_state = WRITE_STATE_TRANSITION;
 }
@@ -696,7 +688,7 @@ static void init_write_state_machine(SSL *s)
  */
 static enum SUB_STATE_RETURN write_state_machine(SSL *s)
 {
  */
 static enum SUB_STATE_RETURN write_state_machine(SSL *s)
 {
-    STATEM *st = &s->statem;
+    OSSL_STATEM *st = &s->statem;
     int ret;
     enum WRITE_TRAN (*transition)(SSL *s);
     enum WORK_STATE (*pre_work)(SSL *s, enum WORK_STATE wst);
     int ret;
     enum WRITE_TRAN (*transition)(SSL *s);
     enum WORK_STATE (*pre_work)(SSL *s, enum WORK_STATE wst);
@@ -817,9 +809,9 @@ int statem_flush(SSL *s)
  *   1: Yes (application data allowed)
  *   0: No (application data not allowed)
  */
  *   1: Yes (application data allowed)
  *   0: No (application data not allowed)
  */
-int statem_app_data_allowed(SSL *s)
+int ossl_statem_app_data_allowed(SSL *s)
 {
 {
-    STATEM *st = &s->statem;
+    OSSL_STATEM *st = &s->statem;
 
     if (st->state == MSG_FLOW_UNINITED || st->state == MSG_FLOW_RENEGOTIATE)
         return 0;
 
     if (st->state == MSG_FLOW_UNINITED || st->state == MSG_FLOW_RENEGOTIATE)
         return 0;
@@ -851,7 +843,7 @@ int statem_app_data_allowed(SSL *s)
 /*
  * Set flag used by SCTP to determine whether we are in the read sock state
  */
 /*
  * Set flag used by SCTP to determine whether we are in the read sock state
  */
-void statem_set_sctp_read_sock(SSL *s, int read_sock)
+void ossl_statem_set_sctp_read_sock(SSL *s, int read_sock)
 {
     s->statem.in_sctp_read_sock = read_sock;
 }
 {
     s->statem.in_sctp_read_sock = read_sock;
 }