]> granicus.if.org Git - openssl/commitdiff
Fix DTLSv1_listen following state machine changes
authorMatt Caswell <matt@openssl.org>
Thu, 22 Oct 2015 11:18:45 +0000 (12:18 +0100)
committerMatt Caswell <matt@openssl.org>
Fri, 30 Oct 2015 08:39:47 +0000 (08:39 +0000)
Adding the new state machine broke the DTLSv1_listen code because
calling SSL_in_before() was erroneously returning true after DTLSv1_listen
had successfully completed. This change ensures that SSL_in_before returns
false.

Reviewed-by: Tim Hudson <tjh@openssl.org>
Reviewed-by: Richard Levitte <levitte@openssl.org>
ssl/d1_lib.c
ssl/statem/statem.c
ssl/statem/statem.h

index 087d6d26679c28632cfa668ef2243ac2a5faa92d..a6f06329a2d4506f7b2c4add82411ae2902e8ee6 100644 (file)
@@ -872,8 +872,11 @@ int dtls1_listen(SSL *s, struct sockaddr *client)
      */
     SSL_set_options(s, SSL_OP_COOKIE_EXCHANGE);
 
-    /* Put us into the "init" state so that we don't get our state cleared */
-    ossl_statem_set_in_init(s, 1);
+    /*
+     * Tell the state machine that we've done the initial hello verify
+     * exchange
+     */
+    ossl_statem_set_hello_verify_done(s);
 
     if(BIO_dgram_get_peer(rbio, client) <= 0) {
         SSLerr(SSL_F_DTLS1_LISTEN, ERR_R_INTERNAL_ERROR);
index f681ab4f6dac22425a3d85fd3dada2b0bed03ed8..f22801987a85b8065ef72eb22d6f4157ba6f3592 100644 (file)
@@ -187,6 +187,20 @@ void ossl_statem_set_in_init(SSL *s, int init)
     s->statem.in_init = init;
 }
 
+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);
 }
index 4c090dc1cb89f91e74e6006fa5122bdf1641bf6d..2dc603ac054caabc725f77da8ddaf33d2eb90ef8 100644 (file)
@@ -161,6 +161,7 @@ void ossl_statem_set_renegotiate(SSL *s);
 void ossl_statem_set_error(SSL *s);
 int ossl_statem_in_error(const SSL *s);
 void ossl_statem_set_in_init(SSL *s, int init);
+void ossl_statem_set_hello_verify_done(SSL *s);
 __owur int ossl_statem_app_data_allowed(SSL *s);
 #ifndef OPENSSL_NO_SCTP
 void ossl_statem_set_sctp_read_sock(SSL *s, int read_sock);