Ensure the dtls1_get_*_methods work with DTLS_ANY_VERSION
authorMatt Caswell <matt@openssl.org>
Wed, 4 Nov 2015 14:46:03 +0000 (14:46 +0000)
committerMatt Caswell <matt@openssl.org>
Wed, 4 Nov 2015 14:46:03 +0000 (14:46 +0000)
The various dtls1_get*_methods did not handle the DTLS_ANY_VERSION case,
so this needed to be added.

Reviewed-by: Tim Hudson <tjh@openssl.org>
ssl/d1_clnt.c
ssl/d1_meth.c
ssl/d1_srvr.c

index feeaf6d0656f5d0868121852d42b5037b8823111..3a2038c371612bef39b1e162e544383be17257fc 100644 (file)
@@ -133,12 +133,14 @@ static int dtls1_get_hello_verify(SSL *s);
 
 static const SSL_METHOD *dtls1_get_client_method(int ver)
 {
 
 static const SSL_METHOD *dtls1_get_client_method(int ver)
 {
-    if (ver == DTLS1_VERSION || ver == DTLS1_BAD_VER)
-        return (DTLSv1_client_method());
+    if (ver == DTLS_ANY_VERSION)
+        return DTLS_client_method();
+    else if (ver == DTLS1_VERSION || ver == DTLS1_BAD_VER)
+        return DTLSv1_client_method();
     else if (ver == DTLS1_2_VERSION)
     else if (ver == DTLS1_2_VERSION)
-        return (DTLSv1_2_client_method());
+        return DTLSv1_2_client_method();
     else
     else
-        return (NULL);
+        return NULL;
 }
 
 IMPLEMENT_dtls1_meth_func(DTLS1_VERSION,
 }
 
 IMPLEMENT_dtls1_meth_func(DTLS1_VERSION,
@@ -147,13 +149,13 @@ IMPLEMENT_dtls1_meth_func(DTLS1_VERSION,
                           dtls1_connect,
                           dtls1_get_client_method, DTLSv1_enc_data)
 
                           dtls1_connect,
                           dtls1_get_client_method, DTLSv1_enc_data)
 
-    IMPLEMENT_dtls1_meth_func(DTLS1_2_VERSION,
+IMPLEMENT_dtls1_meth_func(DTLS1_2_VERSION,
                           DTLSv1_2_client_method,
                           ssl_undefined_function,
                           dtls1_connect,
                           dtls1_get_client_method, DTLSv1_2_enc_data)
 
                           DTLSv1_2_client_method,
                           ssl_undefined_function,
                           dtls1_connect,
                           dtls1_get_client_method, DTLSv1_2_enc_data)
 
-    IMPLEMENT_dtls1_meth_func(DTLS_ANY_VERSION,
+IMPLEMENT_dtls1_meth_func(DTLS_ANY_VERSION,
                           DTLS_client_method,
                           ssl_undefined_function,
                           dtls1_connect,
                           DTLS_client_method,
                           ssl_undefined_function,
                           dtls1_connect,
index 734077493f843b96be9316f7f40fcee674f5e883..899010e9851ce356efe3c7ca7163b1517a8066eb 100644 (file)
 static const SSL_METHOD *dtls1_get_method(int ver);
 static const SSL_METHOD *dtls1_get_method(int ver)
 {
 static const SSL_METHOD *dtls1_get_method(int ver);
 static const SSL_METHOD *dtls1_get_method(int ver)
 {
-    if (ver == DTLS1_VERSION)
-        return (DTLSv1_method());
+    if (ver == DTLS_ANY_VERSION)
+        return DTLS_method();
+    else if (ver == DTLS1_VERSION)
+        return DTLSv1_method();
     else if (ver == DTLS1_2_VERSION)
     else if (ver == DTLS1_2_VERSION)
-        return (DTLSv1_2_method());
+        return DTLSv1_2_method();
     else
     else
-        return (NULL);
+        return NULL;
 }
 
 IMPLEMENT_dtls1_meth_func(DTLS1_VERSION,
 }
 
 IMPLEMENT_dtls1_meth_func(DTLS1_VERSION,
@@ -77,12 +79,12 @@ IMPLEMENT_dtls1_meth_func(DTLS1_VERSION,
                           dtls1_accept,
                           dtls1_connect, dtls1_get_method, DTLSv1_enc_data)
 
                           dtls1_accept,
                           dtls1_connect, dtls1_get_method, DTLSv1_enc_data)
 
-    IMPLEMENT_dtls1_meth_func(DTLS1_2_VERSION,
+IMPLEMENT_dtls1_meth_func(DTLS1_2_VERSION,
                           DTLSv1_2_method,
                           dtls1_accept,
                           dtls1_connect, dtls1_get_method, DTLSv1_2_enc_data)
 
                           DTLSv1_2_method,
                           dtls1_accept,
                           dtls1_connect, dtls1_get_method, DTLSv1_2_enc_data)
 
-    IMPLEMENT_dtls1_meth_func(DTLS_ANY_VERSION,
+IMPLEMENT_dtls1_meth_func(DTLS_ANY_VERSION,
                           DTLS_method,
                           dtls1_accept,
                           dtls1_connect, dtls1_get_method, DTLSv1_2_enc_data)
                           DTLS_method,
                           dtls1_accept,
                           dtls1_connect, dtls1_get_method, DTLSv1_2_enc_data)
index 6c3bfb830b667f6ab9f7947acfed965318dbd865..25c30a6a346a3c57653d0308c056bf2f4161046d 100644 (file)
@@ -131,12 +131,14 @@ static int dtls1_send_hello_verify_request(SSL *s);
 
 static const SSL_METHOD *dtls1_get_server_method(int ver)
 {
 
 static const SSL_METHOD *dtls1_get_server_method(int ver)
 {
-    if (ver == DTLS1_VERSION)
-        return (DTLSv1_server_method());
+    if (ver == DTLS_ANY_VERSION)
+        return DTLS_server_method();
+    else if (ver == DTLS1_VERSION)
+        return DTLSv1_server_method();
     else if (ver == DTLS1_2_VERSION)
     else if (ver == DTLS1_2_VERSION)
-        return (DTLSv1_2_server_method());
+        return DTLSv1_2_server_method();
     else
     else
-        return (NULL);
+        return NULL;
 }
 
 IMPLEMENT_dtls1_meth_func(DTLS1_VERSION,
 }
 
 IMPLEMENT_dtls1_meth_func(DTLS1_VERSION,
@@ -145,13 +147,13 @@ IMPLEMENT_dtls1_meth_func(DTLS1_VERSION,
                           ssl_undefined_function,
                           dtls1_get_server_method, DTLSv1_enc_data)
 
                           ssl_undefined_function,
                           dtls1_get_server_method, DTLSv1_enc_data)
 
-    IMPLEMENT_dtls1_meth_func(DTLS1_2_VERSION,
+IMPLEMENT_dtls1_meth_func(DTLS1_2_VERSION,
                           DTLSv1_2_server_method,
                           dtls1_accept,
                           ssl_undefined_function,
                           dtls1_get_server_method, DTLSv1_2_enc_data)
 
                           DTLSv1_2_server_method,
                           dtls1_accept,
                           ssl_undefined_function,
                           dtls1_get_server_method, DTLSv1_2_enc_data)
 
-    IMPLEMENT_dtls1_meth_func(DTLS_ANY_VERSION,
+IMPLEMENT_dtls1_meth_func(DTLS_ANY_VERSION,
                           DTLS_server_method,
                           dtls1_accept,
                           ssl_undefined_function,
                           DTLS_server_method,
                           dtls1_accept,
                           ssl_undefined_function,