Allow code which calls RSA temp key callback to cope
[openssl.git] / ssl / s2_enc.c
index b915f099e55a73b4e94d106697b5dec03059d126..a9458e7fa7208f59bff980971a46c3fd4846457e 100644 (file)
@@ -1,5 +1,5 @@
 /* ssl/s2_enc.c */
-/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
+/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
  * All rights reserved.
  *
  * This package is an SSL implementation written
  * [including the GNU Public Licence.]
  */
 
-#include <stdio.h>
 #include "ssl_locl.h"
+#ifndef NO_SSL2
+#include <stdio.h>
 
-#define RS     0
-#define WS     1
-
-int ssl2_enc_init(s, client)
-SSL *s;
-int client;
+int ssl2_enc_init(SSL *s, int client)
        {
        /* Max number of bytes needed */
        EVP_CIPHER_CTX *rs,*ws;
-       EVP_CIPHER *c;
-       EVP_MD *md;
+       const EVP_CIPHER *c;
+       const EVP_MD *md;
        int num;
 
-       if (!ssl_cipher_get_evp(s->session->cipher,&c,&md))
+       if (!ssl_cipher_get_evp(s->session,&c,&md,NULL))
                {
                ssl2_return_error(s,SSL2_PE_NO_CIPHER);
                SSLerr(SSL_F_SSL2_ENC_INIT,SSL_R_PROBLEMS_MAPPING_CIPHER_FUNCTIONS);
@@ -94,6 +90,9 @@ int client;
        rs= s->enc_read_ctx;
        ws= s->enc_write_ctx;
 
+       EVP_CIPHER_CTX_init(rs);
+       EVP_CIPHER_CTX_init(ws);
+
        num=c->key_len;
        s->s2->key_material_length=num*2;
 
@@ -114,9 +113,7 @@ err:
 /* read/writes from s->s2->mac_data using length for encrypt and 
  * decrypt.  It sets the s->s2->padding, s->[rw]length and
  * s->s2->pad_data ptr if we are encrypting */
-void ssl2_enc(s,send)
-SSL *s;
-int send;
+void ssl2_enc(SSL *s, int send)
        {
        EVP_CIPHER_CTX *ds;
        unsigned long l;
@@ -146,10 +143,7 @@ int send;
        EVP_Cipher(ds,s->s2->mac_data,s->s2->mac_data,l);
        }
 
-void ssl2_mac(s, md,send)
-SSL *s;
-unsigned char *md;
-int send;
+void ssl2_mac(SSL *s, unsigned char *md, int send)
        {
        EVP_MD_CTX c;
        unsigned char sequence[4],*p,*sec,*act;
@@ -184,4 +178,10 @@ int send;
        EVP_DigestFinal(&c,md,NULL);
        /* some would say I should zero the md context */
        }
+#else /* !NO_SSL2 */
+
+# if PEDANTIC
+static void *dummy=&dummy;
+# endif
 
+#endif