X-Git-Url: https://git.openssl.org/gitweb/?p=openssl.git;a=blobdiff_plain;f=ssl%2Fs2_lib.c;h=39ab1b6c753220627d7a6eaafd56bbf29ea804a9;hp=fb91582217047e256584b0b88cee711be67ed3f8;hb=ca8e5b9b8ad3c199943ad7850bf66bc03279c0b9;hpb=b7896b3cb86d80206af14a14d69b0717786f2729 diff --git a/ssl/s2_lib.c b/ssl/s2_lib.c index fb91582217..39ab1b6c75 100644 --- a/ssl/s2_lib.c +++ b/ssl/s2_lib.c @@ -1,5 +1,5 @@ /* ssl/s2_lib.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 @@ -56,20 +56,15 @@ * [including the GNU Public Licence.] */ +#ifndef NO_RSA #include -#include "rsa.h" -#include "objects.h" +#include +#include +#include #include "ssl_locl.h" -#ifndef NOPROTO -static int ssl2_ok(SSL *s); static long ssl2_default_timeout(void ); -#else -static int ssl2_ok(); -static long ssl2_default_timeout(); -#endif - -char *ssl2_version_str="SSLv2 part of SSLeay 0.8.1b 29-Jun-1998"; +const char *ssl2_version_str="SSLv2" OPENSSL_VERSION_PTEXT; #define SSL2_NUM_CIPHERS (sizeof(ssl2_ciphers)/sizeof(SSL_CIPHER)) @@ -80,7 +75,7 @@ SSL_CIPHER ssl2_ciphers[]={ 1, SSL2_TXT_NULL_WITH_MD5, SSL2_CK_NULL_WITH_MD5, - SSL_kRSA|SSL_aRSA|SSL_eNULL|SSL_MD5|SSL_EXP|SSL_SSLV2, + SSL_kRSA|SSL_aRSA|SSL_eNULL|SSL_MD5|SSL_EXP40|SSL_SSLV2, 0, SSL_ALL_CIPHERS, }, @@ -90,7 +85,7 @@ SSL_CIPHER ssl2_ciphers[]={ 1, SSL2_TXT_RC4_128_EXPORT40_WITH_MD5, SSL2_CK_RC4_128_EXPORT40_WITH_MD5, - SSL_kRSA|SSL_aRSA|SSL_RC4|SSL_MD5|SSL_EXP|SSL_SSLV2, + SSL_kRSA|SSL_aRSA|SSL_RC4|SSL_MD5|SSL_EXP40|SSL_SSLV2, SSL2_CF_5_BYTE_ENC, SSL_ALL_CIPHERS, }, @@ -108,7 +103,7 @@ SSL_CIPHER ssl2_ciphers[]={ 1, SSL2_TXT_RC2_128_CBC_EXPORT40_WITH_MD5, SSL2_CK_RC2_128_CBC_EXPORT40_WITH_MD5, - SSL_kRSA|SSL_aRSA|SSL_RC2|SSL_MD5|SSL_EXP|SSL_SSLV2, + SSL_kRSA|SSL_aRSA|SSL_RC2|SSL_MD5|SSL_EXP40|SSL_SSLV2, SSL2_CF_5_BYTE_ENC, SSL_ALL_CIPHERS, }, @@ -139,17 +134,6 @@ SSL_CIPHER ssl2_ciphers[]={ 0, SSL_ALL_CIPHERS, }, -/* DES_64_CBC_WITH_SHA */ -#if 0 - { - 1, - SSL2_TXT_DES_64_CBC_WITH_SHA, - SSL2_CK_DES_64_CBC_WITH_SHA, - SSL_kRSA|SSL_aRSA|SSL_DES|SSL_SHA0|SSL_NOT_EXP|SSL_SSLV2|SSL_LOW, - 0, - SSL_ALL_CIPHERS, - }, -#endif /* DES_192_EDE3_CBC_WITH_MD5 */ { 1, @@ -159,17 +143,6 @@ SSL_CIPHER ssl2_ciphers[]={ 0, SSL_ALL_CIPHERS, }, -/* DES_192_EDE3_CBC_WITH_SHA */ -#if 0 - { - 1, - SSL2_TXT_DES_192_EDE3_CBC_WITH_SHA, - SSL2_CK_DES_192_EDE3_CBC_WITH_SHA, - SSL_kRSA|SSL_aRSA|SSL_3DES|SSL_SHA0|SSL_NOT_EXP|SSL_SSLV2|SSL_HIGH, - 0, - SSL_ALL_CIPHERS, - }, -#endif /* RC4_64_WITH_MD5 */ #if 1 { @@ -196,7 +169,7 @@ SSL_CIPHER ssl2_ciphers[]={ }; static SSL_METHOD SSLv2_data= { - 2, + SSL2_VERSION, ssl2_new, /* local */ ssl2_clear, /* local */ ssl2_free, /* local */ @@ -206,7 +179,8 @@ static SSL_METHOD SSLv2_data= { ssl2_peek, ssl2_write, ssl2_shutdown, - ssl2_ok, + ssl_ok, /* NULL - renegotiate */ + ssl_ok, /* NULL - check renegotiate */ ssl2_ctrl, /* local */ ssl2_ctx_ctrl, /* local */ ssl2_get_cipher_by_char, @@ -216,25 +190,25 @@ static SSL_METHOD SSLv2_data= { ssl2_get_cipher, ssl_bad_method, ssl2_default_timeout, + &ssl3_undef_enc_method, }; -static long ssl2_default_timeout() +static long ssl2_default_timeout(void) { return(300); } -SSL_METHOD *sslv2_base_method() +SSL_METHOD *sslv2_base_method(void) { return(&SSLv2_data); } -int ssl2_num_ciphers() +int ssl2_num_ciphers(void) { return(SSL2_NUM_CIPHERS); } -SSL_CIPHER *ssl2_get_cipher(u) -unsigned int u; +SSL_CIPHER *ssl2_get_cipher(unsigned int u) { if (u < SSL2_NUM_CIPHERS) return(&(ssl2_ciphers[SSL2_NUM_CIPHERS-1-u])); @@ -242,18 +216,17 @@ unsigned int u; return(NULL); } -int ssl2_pending(s) -SSL *s; +int ssl2_pending(SSL *s) { return(s->s2->ract_data_length); } -int ssl2_new(s) -SSL *s; +int ssl2_new(SSL *s) { SSL2_CTX *s2; if ((s2=(SSL2_CTX *)Malloc(sizeof(SSL2_CTX))) == NULL) goto err; + memset(s2,0,sizeof(SSL2_CTX)); if ((s2->rbuf=(unsigned char *)Malloc( SSL2_MAX_RECORD_LENGTH_2_BYTE_HEADER+2)) == NULL) goto err; @@ -273,11 +246,13 @@ err: return(0); } -void ssl2_free(s) -SSL *s; +void ssl2_free(SSL *s) { SSL2_CTX *s2; + if(s == NULL) + return; + s2=s->s2; if (s2->rbuf != NULL) Free(s2->rbuf); if (s2->wbuf != NULL) Free(s2->wbuf); @@ -286,8 +261,7 @@ SSL *s; s->s2=NULL; } -void ssl2_clear(s) -SSL *s; +void ssl2_clear(SSL *s) { SSL2_CTX *s2; unsigned char *rbuf,*wbuf; @@ -302,34 +276,34 @@ SSL *s; s2->rbuf=rbuf; s2->wbuf=wbuf; s2->clear_text=1; - s2->first_packet=0; s->packet=s2->rbuf; - s->version=2; + s->version=SSL2_VERSION; s->packet_length=0; } -long ssl2_ctrl(s,cmd,larg,parg) -SSL *s; -int cmd; -long larg; -char *parg; +long ssl2_ctrl(SSL *s, int cmd, long larg, char *parg) { - return(0); + int ret=0; + + switch(cmd) + { + case SSL_CTRL_GET_SESSION_REUSED: + ret=s->hit; + break; + default: + break; + } + return(ret); } -long ssl2_ctx_ctrl(ctx,cmd,larg,parg) -SSL_CTX *ctx; -int cmd; -long larg; -char *parg; +long ssl2_ctx_ctrl(SSL_CTX *ctx, int cmd, long larg, char *parg) { return(0); } /* This function needs to check if the ciphers required are actually * available */ -SSL_CIPHER *ssl2_get_cipher_by_char(p) -unsigned char *p; +SSL_CIPHER *ssl2_get_cipher_by_char(const unsigned char *p) { static int init=1; static SSL_CIPHER *sorted[SSL2_NUM_CIPHERS]; @@ -339,7 +313,7 @@ unsigned char *p; if (init) { - init=0; + CRYPTO_w_lock(CRYPTO_LOCK_SSL); for (i=0; ierror) { @@ -416,10 +388,9 @@ int err; } -void ssl2_write_error(s) -SSL *s; +void ssl2_write_error(SSL *s) { - char buf[3]; + unsigned char buf[3]; int i,error; buf[0]=SSL2_MT_ERROR; @@ -440,16 +411,9 @@ SSL *s; s->error=0; */ } -static int ssl2_ok(s) -SSL *s; - { - return(1); - } - -int ssl2_shutdown(s) -SSL *s; +int ssl2_shutdown(SSL *s) { s->shutdown=(SSL_SENT_SHUTDOWN|SSL_RECEIVED_SHUTDOWN); return(1); } - +#endif