Fix SSL handshake functions and SSL_clear() such that SSL_clear()
[openssl.git] / ssl / s2_clnt.c
index 3e062863755e971c0c10b3584c77c70746915a46..8cb7388ef957180c78eac513245bff5649d16de4 100644 (file)
@@ -57,7 +57,7 @@
  */
 
 #include "ssl_locl.h"
-#ifndef NO_SSL2
+#ifndef OPENSSL_NO_SSL2
 #include <stdio.h>
 #include <openssl/rand.h>
 #include <openssl/buffer.h>
@@ -118,8 +118,8 @@ int ssl2_connect(SSL *s)
                cb=s->ctx->info_callback;
 
        /* init things to blank */
-       if (!SSL_in_init(s) || SSL_in_before(s)) SSL_clear(s);
        s->in_handshake++;
+       if (!SSL_in_init(s) || SSL_in_before(s)) SSL_clear(s);
 
        for (;;)
                {
@@ -456,7 +456,7 @@ static int get_server_hello(SSL *s)
                if (s->session->peer != NULL) /* can't happen*/
                        {
                        ssl2_return_error(s, SSL2_PE_UNDEFINED_ERROR);
-                       SSLerr(SSL_F_GET_SERVER_HELLO, SSL_R_INTERNAL_ERROR);
+                       SSLerr(SSL_F_GET_SERVER_HELLO, ERR_R_INTERNAL_ERROR);
                        return(-1);
                        }
 
@@ -469,7 +469,7 @@ static int get_server_hello(SSL *s)
                /* can't happen */
                {
                ssl2_return_error(s, SSL2_PE_UNDEFINED_ERROR);
-               SSLerr(SSL_F_GET_SERVER_HELLO, SSL_R_INTERNAL_ERROR);
+               SSLerr(SSL_F_GET_SERVER_HELLO, ERR_R_INTERNAL_ERROR);
                return(-1);
                }
                
@@ -766,7 +766,8 @@ static int client_certificate(SSL *s)
                /* ok, now we calculate the checksum
                 * do it first so we can reuse buf :-) */
                p=buf;
-               EVP_SignInit(&ctx,s->ctx->rsa_md5);
+               EVP_MD_CTX_init(&ctx);
+               EVP_SignInit_ex(&ctx,s->ctx->rsa_md5, NULL);
                EVP_SignUpdate(&ctx,s->s2->key_material,
                        (unsigned int)s->s2->key_material_length);
                EVP_SignUpdate(&ctx,cert_ch,(unsigned int)cert_ch_len);
@@ -787,7 +788,7 @@ static int client_certificate(SSL *s)
                         * We will continue with a 0 length signature
                         */
                        }
-               memset(&ctx,0,sizeof(ctx));
+               EVP_MD_CTX_cleanup(&ctx);
                s2n(n,p);
                d+=n;
 
@@ -1001,7 +1002,7 @@ end:
        EVP_PKEY_free(pkey);
        return(i);
        }
-#else /* !NO_SSL2 */
+#else /* !OPENSSL_NO_SSL2 */
 
 # if PEDANTIC
 static void *dummy=&dummy;