Initial incomplete TLS v1.2 support. New ciphersuites added, new version
[openssl.git] / ssl / s23_clnt.c
index 47f938981790d6959f7cc13ca01e765dd641e938..f49a95ba99aa3dd3fcf311c70ebdf3006ae47cf0 100644 (file)
@@ -131,6 +131,8 @@ static const SSL_METHOD *ssl23_get_client_method(int ver)
                return(TLSv1_client_method());
        else if (ver == TLS1_1_VERSION)
                return(TLSv1_1_client_method());
+       else if (ver == TLS1_2_VERSION)
+               return(TLSv1_2_client_method());
        else
                return(NULL);
        }
@@ -286,7 +288,11 @@ static int ssl23_client_hello(SSL *s)
        if (ssl2_compat && ssl23_no_ssl2_ciphers(s))
                ssl2_compat = 0;
 
-       if (!(s->options & SSL_OP_NO_TLSv1_1))
+       if (!(s->options & SSL_OP_NO_TLSv1_2))
+               {
+               version = TLS1_2_VERSION;
+               }
+       else if (!(s->options & SSL_OP_NO_TLSv1_1))
                {
                version = TLS1_1_VERSION;
                }
@@ -335,7 +341,12 @@ static int ssl23_client_hello(SSL *s)
                if (RAND_pseudo_bytes(p,SSL3_RANDOM_SIZE-4) <= 0)
                        return -1;
 
-               if (version == TLS1_1_VERSION)
+               if (version == TLS1_2_VERSION)
+                       {
+                       version_major = TLS1_2_VERSION_MAJOR;
+                       version_minor = TLS1_2_VERSION_MINOR;
+                       }
+               else if (version == TLS1_1_VERSION)
                        {
                        version_major = TLS1_1_VERSION_MAJOR;
                        version_minor = TLS1_1_VERSION_MINOR;
@@ -619,7 +630,7 @@ static int ssl23_get_server_hello(SSL *s)
 #endif
                }
        else if (p[1] == SSL3_VERSION_MAJOR &&
-                p[2] <= TLS1_1_VERSION_MINOR &&
+                p[2] <= TLS1_2_VERSION_MINOR &&
                 ((p[0] == SSL3_RT_HANDSHAKE && p[5] == SSL3_MT_SERVER_HELLO) ||
                  (p[0] == SSL3_RT_ALERT && p[3] == 0 && p[4] == 2)))
                {
@@ -643,6 +654,12 @@ static int ssl23_get_server_hello(SSL *s)
                        s->version=TLS1_1_VERSION;
                        s->method=TLSv1_1_client_method();
                        }
+               else if ((p[2] == TLS1_2_VERSION_MINOR) &&
+                       !(s->options & SSL_OP_NO_TLSv1_2))
+                       {
+                       s->version=TLS1_2_VERSION;
+                       s->method=TLSv1_2_client_method();
+                       }
                else
                        {
                        SSLerr(SSL_F_SSL23_GET_SERVER_HELLO,SSL_R_UNSUPPORTED_PROTOCOL);