SSL_R_UNSUPPORTED_PROTOCOL (as in s23_clnt.c) for SSL 2 when
[openssl.git] / ssl / s23_srvr.c
index a9fefef3543a3c4ce98ef1796cc0e67223a53a55..7fe8027daa1833a5cc803bac4977c0d02f9c349f 100644 (file)
@@ -67,8 +67,10 @@ static SSL_METHOD *ssl23_get_server_method(int ver);
 int ssl23_get_client_hello(SSL *s);
 static SSL_METHOD *ssl23_get_server_method(int ver)
        {
+#ifndef NO_SSL2
        if (ver == SSL2_VERSION)
                return(SSLv2_server_method());
+#endif
        if (ver == SSL3_VERSION)
                return(SSLv3_server_method());
        else if (ver == TLS1_VERSION)
@@ -101,7 +103,7 @@ int ssl23_accept(SSL *s)
        int ret= -1;
        int new_state,state;
 
-       RAND_seed(&Time,sizeof(Time));
+       RAND_add(&Time,sizeof(Time),0);
        ERR_clear_error();
        clear_sys_error();
 
@@ -186,7 +188,18 @@ end:
 
 int ssl23_get_client_hello(SSL *s)
        {
-       char buf_space[11]; /* request this many bytes in initial read */
+       char buf_space[11]; /* Request this many bytes in initial read.
+                            * We can detect SSL 3.0/TLS 1.0 Client Hellos only
+                            * when the following is in a single record
+                            * (not guaranteed by protocol specs):
+                            * Byte  Content
+                            *  0     type            \
+                            *  1/2   version          > record header
+                            *  3/4   length          /
+                            *  5     msg_type        \
+                            *  6-8   length           > Client Hello message
+                            *  9/10  client_version  /
+                            */
        char *buf= &(buf_space[0]);
        unsigned char *p,*d,*dd;
        unsigned int i;
@@ -439,6 +452,10 @@ next_bit:
 
        if (type == 1)
                {
+#ifdef NO_SSL2
+               SSLerr(SSL_F_SSL23_GET_CLIENT_HELLO,SSL_R_UNSUPPORTED_PROTOCOL);
+               goto err;
+#else
                /* we are talking sslv2 */
                /* we need to clean up the SSLv3/TLSv1 setup and put in the
                 * sslv2 stuff. */
@@ -477,6 +494,7 @@ next_bit:
 
                s->method=SSLv2_server_method();
                s->handshake_func=s->method->ssl_accept;
+#endif
                }
 
        if ((type == 2) || (type == 3))