Move in_handshake into STATEM
[openssl.git] / ssl / statem / statem.c
index f681ab4f6dac22425a3d85fd3dada2b0bed03ed8..76e902c993cd710e3d6ffe6702a9e335f2da9cb5 100644 (file)
@@ -187,6 +187,33 @@ void ossl_statem_set_in_init(SSL *s, int init)
     s->statem.in_init = init;
 }
 
+int ossl_statem_get_in_handshake(SSL *s)
+{
+    return s->statem.in_handshake;
+}
+
+void ossl_statem_set_in_handshake(SSL *s, int inhand)
+{
+    if (inhand)
+        s->statem.in_handshake++;
+    else
+        s->statem.in_handshake--;
+}
+
+void ossl_statem_set_hello_verify_done(SSL *s)
+{
+    s->statem.state = MSG_FLOW_UNINITED;
+    s->statem.in_init = 1;
+    /*
+     * This will get reset (briefly) back to TLS_ST_BEFORE when we enter
+     * state_machine() because |state| is MSG_FLOW_UNINITED, but until then any
+     * calls to SSL_in_before() will return false. Also calls to
+     * SSL_state_string() and SSL_state_string_long() will return something
+     * sensible.
+     */
+    s->statem.hand_state = TLS_ST_SR_CLNT_HELLO;
+}
+
 int ossl_statem_connect(SSL *s) {
     return state_machine(s, 0);
 }
@@ -253,7 +280,7 @@ static int state_machine(SSL *s, int server) {
 
     cb = get_callback(s);
 
-    s->in_handshake++;
+    st->in_handshake++;
     if (!SSL_in_init(s) || SSL_in_before(s)) {
         if (!SSL_clear(s))
             return -1;
@@ -266,7 +293,7 @@ static int state_machine(SSL *s, int server) {
          * identifier other than 0. Will be ignored if no SCTP is used.
          */
         BIO_ctrl(SSL_get_wbio(s), BIO_CTRL_DGRAM_SCTP_SET_IN_HANDSHAKE,
-                 s->in_handshake, NULL);
+                 st->in_handshake, NULL);
     }
 #endif
 
@@ -433,7 +460,7 @@ static int state_machine(SSL *s, int server) {
     ret = 1;
 
  end:
-    s->in_handshake--;
+    st->in_handshake--;
 
 #ifndef OPENSSL_NO_SCTP
     if (SSL_IS_DTLS(s)) {
@@ -442,7 +469,7 @@ static int state_machine(SSL *s, int server) {
          * identifier other than 0. Will be ignored if no SCTP is used.
          */
         BIO_ctrl(SSL_get_wbio(s), BIO_CTRL_DGRAM_SCTP_SET_IN_HANDSHAKE,
-                 s->in_handshake, NULL);
+                 st->in_handshake, NULL);
     }
 #endif