Use same name in the definition as in the header file declaration :-/
[openssl.git] / ssl / s3_lib.c
index 4e58bcd632814a9cfcc7ee01f4775de2da6f64b8..aeff6b5c5bc6d7319ffe52345dc39b24f54c8dac 100644 (file)
  */
 
 #include <stdio.h>
-#include "objects.h"
+#include <openssl/md5.h>
+#include <openssl/sha.h>
+#include <openssl/objects.h>
 #include "ssl_locl.h"
 
 const char *ssl3_version_str="SSLv3" OPENSSL_VERSION_PTEXT;
 
 #define SSL3_NUM_CIPHERS       (sizeof(ssl3_ciphers)/sizeof(SSL_CIPHER))
 
-#ifndef NOPROTO
 static long ssl3_default_timeout(void );
-#else
-static long ssl3_default_timeout();
-#endif
 
-SSL_CIPHER ssl3_ciphers[]={
+OPENSSL_GLOBAL SSL_CIPHER ssl3_ciphers[]={
 /* The RSA ciphers */
 /* Cipher 01 */
        {
@@ -587,7 +585,7 @@ long ssl3_ctrl(SSL *s, int cmd, long larg, char *parg)
 #endif
                0)
                {
-               if (!ssl_cert_instantiate(&s->cert, s->ctx->default_cert)) 
+               if (!ssl_cert_inst(&s->cert))
                        {
                        SSLerr(SSL_F_SSL3_CTRL, ERR_R_MALLOC_FAILURE);
                        return(0);
@@ -640,11 +638,7 @@ long ssl3_ctrl(SSL *s, int cmd, long larg, char *parg)
                }
                break;
        case SSL_CTRL_SET_TMP_RSA_CB:
-#ifndef NOPROTO
                s->cert->rsa_tmp_cb = (RSA *(*)(SSL *, int, int))parg;
-#else
-               s->cert->rsa_tmp_cb = (RSA *(*)())parg;
-#endif
                break;
 #endif
 #ifndef NO_DH
@@ -671,11 +665,7 @@ long ssl3_ctrl(SSL *s, int cmd, long larg, char *parg)
                }
                break;
        case SSL_CTRL_SET_TMP_DH_CB:
-#ifndef NOPROTO
                s->cert->dh_tmp_cb = (DH *(*)(SSL *, int, int))parg;
-#else
-               s->cert->dh_tmp_cb = (DH *(*)())parg;
-#endif
                break;
 #endif
        default:
@@ -688,7 +678,7 @@ long ssl3_ctx_ctrl(SSL_CTX *ctx, int cmd, long larg, char *parg)
        {
        CERT *cert;
 
-       cert=ctx->default_cert;
+       cert=ctx->cert;
 
        switch (cmd)
                {
@@ -731,11 +721,7 @@ long ssl3_ctx_ctrl(SSL_CTX *ctx, int cmd, long larg, char *parg)
                }
                /* break; */
        case SSL_CTRL_SET_TMP_RSA_CB:
-#ifndef NOPROTO
                cert->rsa_tmp_cb=(RSA *(*)(SSL *, int, int))parg;
-#else
-               cert->rsa_tmp_cb=(RSA *(*)())parg;
-#endif
                break;
 #endif
 #ifndef NO_DH
@@ -762,11 +748,7 @@ long ssl3_ctx_ctrl(SSL_CTX *ctx, int cmd, long larg, char *parg)
                }
                /*break; */
        case SSL_CTRL_SET_TMP_DH_CB:
-#ifndef NOPROTO
                cert->dh_tmp_cb=(DH *(*)(SSL *, int, int))parg;
-#else
-               cert->dh_tmp_cb=(DH *(*)())parg;
-#endif
                break;
 #endif
        /* A Thawte special :-) */
@@ -797,7 +779,7 @@ SSL_CIPHER *ssl3_get_cipher_by_char(const unsigned char *p)
 
        if (init)
                {
-               init=0;
+               CRYPTO_w_lock(CRYPTO_LOCK_SSL);
 
                for (i=0; i<SSL3_NUM_CIPHERS; i++)
                        sorted[i]= &(ssl3_ciphers[i]);
@@ -805,6 +787,10 @@ SSL_CIPHER *ssl3_get_cipher_by_char(const unsigned char *p)
                qsort(  (char *)sorted,
                        SSL3_NUM_CIPHERS,sizeof(SSL_CIPHER *),
                        FP_ICC ssl_cipher_ptr_id_cmp);
+
+               CRYPTO_w_unlock(CRYPTO_LOCK_SSL);
+
+               init=0;
                }
 
        id=0x03000000L|((unsigned long)p[0]<<8L)|(unsigned long)p[1];
@@ -856,11 +842,8 @@ SSL_CIPHER *ssl3_choose_cipher(SSL *s, STACK_OF(SSL_CIPHER) *have,
        CERT *cert;
        unsigned long alg,mask,emask;
 
-       /* Lets see which ciphers we can supported */
-       if (s->cert != NULL)
-               cert=s->cert;
-       else
-               cert=s->ctx->default_cert;
+       /* Let's see which ciphers we can support */
+       cert=s->cert;
 
        sk_SSL_CIPHER_set_cmp_func(pref,ssl_cipher_ptr_id_cmp);
 
@@ -877,7 +860,7 @@ SSL_CIPHER *ssl3_choose_cipher(SSL *s, STACK_OF(SSL_CIPHER) *have,
                {
                c=sk_SSL_CIPHER_value(have,i);
 
-               ssl_set_cert_masks(cert,s->ctx->default_cert,c);
+               ssl_set_cert_masks(cert,c);
                mask=cert->mask;
                emask=cert->export_mask;
                        
@@ -988,7 +971,7 @@ int ssl3_shutdown(SSL *s)
                return(0);
        }
 
-int ssl3_write(SSL *s, const char *buf, int len)
+int ssl3_write(SSL *s, const void *buf, int len)
        {
        int ret,n;
 
@@ -1041,7 +1024,7 @@ int ssl3_write(SSL *s, const char *buf, int len)
        return(ret);
        }
 
-int ssl3_read(SSL *s, char *buf, int len)
+int ssl3_read(SSL *s, void *buf, int len)
        {
        int ret;