I'm reversing this change, as it seems the error is somewhere else.
[openssl.git] / ssl / s23_lib.c
index 822a3958372d0335ef4eef33625056b95e63c54e..2c5129831a3516b906e4ae748f5f52de62584ba9 100644 (file)
 static int ssl23_num_ciphers(void );
 static SSL_CIPHER *ssl23_get_cipher(unsigned int u);
 static int ssl23_read(SSL *s, void *buf, int len);
+static int ssl23_peek(SSL *s, void *buf, int len);
 static int ssl23_write(SSL *s, const void *buf, int len);
 static long ssl23_default_timeout(void );
 static int ssl23_put_cipher_by_char(const SSL_CIPHER *c, unsigned char *p);
 static SSL_CIPHER *ssl23_get_cipher_by_char(const unsigned char *p);
-char *SSL23_version_str="SSLv2/3 compatibility" OPENSSL_VERSION_PTEXT;
+const char *SSL23_version_str="SSLv2/3 compatibility" OPENSSL_VERSION_PTEXT;
 
 static SSL_METHOD SSLv23_data= {
        TLS1_VERSION,
@@ -77,21 +78,28 @@ static SSL_METHOD SSLv23_data= {
        ssl_undefined_function,
        ssl_undefined_function,
        ssl23_read,
-       (int (*)(struct ssl_st *, char *, int))ssl_undefined_function,
+       ssl23_peek,
        ssl23_write,
        ssl_undefined_function,
        ssl_undefined_function,
        ssl_ok,
+       ssl3_get_message,
+       ssl3_read_bytes,
+       ssl3_write_bytes,
+       ssl3_dispatch_alert,
        ssl3_ctrl,
        ssl3_ctx_ctrl,
        ssl23_get_cipher_by_char,
        ssl23_put_cipher_by_char,
-       ssl_undefined_function,
+       ssl_undefined_const_function,
        ssl23_num_ciphers,
        ssl23_get_cipher,
        ssl_bad_method,
        ssl23_default_timeout,
        &ssl3_undef_enc_method,
+       ssl_undefined_void_function,
+       ssl3_callback_ctrl,
+       ssl3_ctx_callback_ctrl,
        };
 
 static long ssl23_default_timeout(void)
@@ -106,7 +114,11 @@ SSL_METHOD *sslv23_base_method(void)
 
 static int ssl23_num_ciphers(void)
        {
-       return(ssl3_num_ciphers()+ssl2_num_ciphers());
+       return(ssl3_num_ciphers()
+#ifndef OPENSSL_NO_SSL2
+              + ssl2_num_ciphers()
+#endif
+           );
        }
 
 static SSL_CIPHER *ssl23_get_cipher(unsigned int u)
@@ -116,7 +128,11 @@ static SSL_CIPHER *ssl23_get_cipher(unsigned int u)
        if (u < uu)
                return(ssl3_get_cipher(u));
        else
+#ifndef OPENSSL_NO_SSL2
                return(ssl2_get_cipher(u-uu));
+#else
+               return(NULL);
+#endif
        }
 
 /* This function needs to check if the ciphers required are actually
@@ -132,8 +148,10 @@ static SSL_CIPHER *ssl23_get_cipher_by_char(const unsigned char *p)
                ((unsigned long)p[1]<<8L)|(unsigned long)p[2];
        c.id=id;
        cp=ssl3_get_cipher_by_char(p);
+#ifndef OPENSSL_NO_SSL2
        if (cp == NULL)
                cp=ssl2_get_cipher_by_char(p);
+#endif
        return(cp);
        }
 
@@ -156,13 +174,6 @@ static int ssl23_read(SSL *s, void *buf, int len)
        {
        int n;
 
-#if 0
-       if (s->shutdown & SSL_RECEIVED_SHUTDOWN)
-               {
-               s->rwstate=SSL_NOTHING;
-               return(0);
-               }
-#endif
        clear_sys_error();
        if (SSL_in_init(s) && (!s->in_handshake))
                {
@@ -182,17 +193,33 @@ static int ssl23_read(SSL *s, void *buf, int len)
                }
        }
 
-static int ssl23_write(SSL *s, const void *buf, int len)
+static int ssl23_peek(SSL *s, void *buf, int len)
        {
        int n;
 
-#if 0
-       if (s->shutdown & SSL_SENT_SHUTDOWN)
+       clear_sys_error();
+       if (SSL_in_init(s) && (!s->in_handshake))
+               {
+               n=s->handshake_func(s);
+               if (n < 0) return(n);
+               if (n == 0)
+                       {
+                       SSLerr(SSL_F_SSL23_PEEK,SSL_R_SSL_HANDSHAKE_FAILURE);
+                       return(-1);
+                       }
+               return(SSL_peek(s,buf,len));
+               }
+       else
                {
-               s->rwstate=SSL_NOTHING;
-               return(0);
+               ssl_undefined_function(s);
+               return(-1);
                }
-#endif
+       }
+
+static int ssl23_write(SSL *s, const void *buf, int len)
+       {
+       int n;
+
        clear_sys_error();
        if (SSL_in_init(s) && (!s->in_handshake))
                {