Deleted Added
full compact
83,86c83,86
< SSL_METHOD *SSLv23_client_method(void)
< {
< static int init=1;
< static SSL_METHOD SSLv23_client_data;
---
> IMPLEMENT_ssl23_meth_func(SSLv23_client_method,
> ssl_undefined_function,
> ssl23_connect,
> ssl23_get_client_method)
88,105d87
< if (init)
< {
< CRYPTO_w_lock(CRYPTO_LOCK_SSL_METHOD);
<
< if (init)
< {
< memcpy((char *)&SSLv23_client_data,
< (char *)sslv23_base_method(),sizeof(SSL_METHOD));
< SSLv23_client_data.ssl_connect=ssl23_connect;
< SSLv23_client_data.get_ssl_method=ssl23_get_client_method;
< init=0;
< }
<
< CRYPTO_w_unlock(CRYPTO_LOCK_SSL_METHOD);
< }
< return(&SSLv23_client_data);
< }
<
109c91
< unsigned long Time=time(NULL);
---
> unsigned long Time=(unsigned long)time(NULL);
223c205,209
< int i,ch_len;
---
> int i,j,ch_len;
> unsigned long Time,l;
> int ssl2_compat;
> int version = 0, version_major, version_minor;
> SSL_COMP *comp;
225a212,226
> ssl2_compat = (s->options & SSL_OP_NO_SSLv2) ? 0 : 1;
>
> if (!(s->options & SSL_OP_NO_TLSv1))
> {
> version = TLS1_VERSION;
> }
> else if (!(s->options & SSL_OP_NO_SSLv3))
> {
> version = SSL3_VERSION;
> }
> else if (!(s->options & SSL_OP_NO_SSLv2))
> {
> version = SSL2_VERSION;
> }
>
238,239c239,242
< if(RAND_pseudo_bytes(p,SSL3_RANDOM_SIZE) <= 0)
< return -1;
---
> Time=(unsigned long)time(NULL); /* Time */
> l2n(Time,p);
> if (RAND_pseudo_bytes(p,SSL3_RANDOM_SIZE-4) <= 0)
> return -1;
241,246c244
< /* Do the message type and length last */
< d= &(buf[2]);
< p=d+9;
<
< *(d++)=SSL2_MT_CLIENT_HELLO;
< if (!(s->options & SSL_OP_NO_TLSv1))
---
> if (version == TLS1_VERSION)
248,250c246,247
< *(d++)=TLS1_VERSION_MAJOR;
< *(d++)=TLS1_VERSION_MINOR;
< s->client_version=TLS1_VERSION;
---
> version_major = TLS1_VERSION_MAJOR;
> version_minor = TLS1_VERSION_MINOR;
252c249
< else if (!(s->options & SSL_OP_NO_SSLv3))
---
> else if (version == SSL3_VERSION)
254,256c251,252
< *(d++)=SSL3_VERSION_MAJOR;
< *(d++)=SSL3_VERSION_MINOR;
< s->client_version=SSL3_VERSION;
---
> version_major = SSL3_VERSION_MAJOR;
> version_minor = SSL3_VERSION_MINOR;
258c254
< else if (!(s->options & SSL_OP_NO_SSLv2))
---
> else if (version == SSL2_VERSION)
260,262c256,257
< *(d++)=SSL2_VERSION_MAJOR;
< *(d++)=SSL2_VERSION_MINOR;
< s->client_version=SSL2_VERSION;
---
> version_major = SSL2_VERSION_MAJOR;
> version_minor = SSL2_VERSION_MINOR;
270,272c265,267
< /* Ciphers supported */
< i=ssl_cipher_list_to_bytes(s,SSL_get_ciphers(s),p);
< if (i == 0)
---
> s->client_version = version;
>
> if (ssl2_compat)
274,279c269
< /* no ciphers */
< SSLerr(SSL_F_SSL23_CLIENT_HELLO,SSL_R_NO_CIPHERS_AVAILABLE);
< return(-1);
< }
< s2n(i,d);
< p+=i;
---
> /* create SSL 2.0 compatible Client Hello */
281,282c271,290
< /* put in the session-id, zero since there is no
< * reuse. */
---
> /* two byte record header will be written last */
> d = &(buf[2]);
> p = d + 9; /* leave space for message type, version, individual length fields */
>
> *(d++) = SSL2_MT_CLIENT_HELLO;
> *(d++) = version_major;
> *(d++) = version_minor;
>
> /* Ciphers supported */
> i=ssl_cipher_list_to_bytes(s,SSL_get_ciphers(s),p,0);
> if (i == 0)
> {
> /* no ciphers */
> SSLerr(SSL_F_SSL23_CLIENT_HELLO,SSL_R_NO_CIPHERS_AVAILABLE);
> return -1;
> }
> s2n(i,d);
> p+=i;
>
> /* put in the session-id length (zero since there is no reuse) */
284c292
< s->session->session_id_length=0;
---
> s->session->session_id_length=0;
286c294
< s2n(0,d);
---
> s2n(0,d);
288,291c296,299
< if (s->options & SSL_OP_NETSCAPE_CHALLENGE_BUG)
< ch_len=SSL2_CHALLENGE_LENGTH;
< else
< ch_len=SSL2_MAX_CHALLENGE_LENGTH;
---
> if (s->options & SSL_OP_NETSCAPE_CHALLENGE_BUG)
> ch_len=SSL2_CHALLENGE_LENGTH;
> else
> ch_len=SSL2_MAX_CHALLENGE_LENGTH;
293,295c301,323
< /* write out sslv2 challenge */
< if (SSL3_RANDOM_SIZE < ch_len)
< i=SSL3_RANDOM_SIZE;
---
> /* write out sslv2 challenge */
> if (SSL3_RANDOM_SIZE < ch_len)
> i=SSL3_RANDOM_SIZE;
> else
> i=ch_len;
> s2n(i,d);
> memset(&(s->s3->client_random[0]),0,SSL3_RANDOM_SIZE);
> if (RAND_pseudo_bytes(&(s->s3->client_random[SSL3_RANDOM_SIZE-i]),i) <= 0)
> return -1;
>
> memcpy(p,&(s->s3->client_random[SSL3_RANDOM_SIZE-i]),i);
> p+=i;
>
> i= p- &(buf[2]);
> buf[0]=((i>>8)&0xff)|0x80;
> buf[1]=(i&0xff);
>
> /* number of bytes to write */
> s->init_num=i+2;
> s->init_off=0;
>
> ssl3_finish_mac(s,&(buf[2]),i);
> }
297,301c325,326
< i=ch_len;
< s2n(i,d);
< memset(&(s->s3->client_random[0]),0,SSL3_RANDOM_SIZE);
< if(RAND_pseudo_bytes(&(s->s3->client_random[SSL3_RANDOM_SIZE-i]),i) <= 0)
< return -1;
---
> {
> /* create Client Hello in SSL 3.0/TLS 1.0 format */
303,304c328,332
< memcpy(p,&(s->s3->client_random[SSL3_RANDOM_SIZE-i]),i);
< p+=i;
---
> /* do the record header (5 bytes) and handshake message header (4 bytes) last */
> d = p = &(buf[9]);
>
> *(p++) = version_major;
> *(p++) = version_minor;
306,308c334,336
< i= p- &(buf[2]);
< buf[0]=((i>>8)&0xff)|0x80;
< buf[1]=(i&0xff);
---
> /* Random stuff */
> memcpy(p, s->s3->client_random, SSL3_RANDOM_SIZE);
> p += SSL3_RANDOM_SIZE;
309a338,394
> /* Session ID (zero since there is no reuse) */
> *(p++) = 0;
>
> /* Ciphers supported (using SSL 3.0/TLS 1.0 format) */
> i=ssl_cipher_list_to_bytes(s,SSL_get_ciphers(s),&(p[2]),ssl3_put_cipher_by_char);
> if (i == 0)
> {
> SSLerr(SSL_F_SSL23_CLIENT_HELLO,SSL_R_NO_CIPHERS_AVAILABLE);
> return -1;
> }
> s2n(i,p);
> p+=i;
>
> /* COMPRESSION */
> if (s->ctx->comp_methods == NULL)
> j=0;
> else
> j=sk_SSL_COMP_num(s->ctx->comp_methods);
> *(p++)=1+j;
> for (i=0; i<j; i++)
> {
> comp=sk_SSL_COMP_value(s->ctx->comp_methods,i);
> *(p++)=comp->id;
> }
> *(p++)=0; /* Add the NULL method */
>
> l = p-d;
> *p = 42;
>
> /* fill in 4-byte handshake header */
> d=&(buf[5]);
> *(d++)=SSL3_MT_CLIENT_HELLO;
> l2n3(l,d);
>
> l += 4;
>
> if (l > SSL3_RT_MAX_PLAIN_LENGTH)
> {
> SSLerr(SSL_F_SSL23_CLIENT_HELLO,ERR_R_INTERNAL_ERROR);
> return -1;
> }
>
> /* fill in 5-byte record header */
> d=buf;
> *(d++) = SSL3_RT_HANDSHAKE;
> *(d++) = version_major;
> *(d++) = version_minor; /* arguably we should send the *lowest* suported version here
> * (indicating, e.g., TLS 1.0 in "SSL 3.0 format") */
> s2n((int)l,d);
>
> /* number of bytes to write */
> s->init_num=p-buf;
> s->init_off=0;
>
> ssl3_finish_mac(s,&(buf[5]), s->init_num - 5);
> }
>
311,312d395
< /* number of bytes to write */
< s->init_num=i+2;
314,315d396
<
< ssl3_finish_mac(s,&(buf[2]),i);
320,322c401,411
< if (ret >= 2)
< if (s->msg_callback)
< s->msg_callback(1, SSL2_VERSION, 0, s->init_buf->data+2, ret-2, s, s->msg_callback_arg); /* CLIENT-HELLO */
---
>
> if ((ret >= 2) && s->msg_callback)
> {
> /* Client Hello has been sent; tell msg_callback */
>
> if (ssl2_compat)
> s->msg_callback(1, SSL2_VERSION, 0, s->init_buf->data+2, ret-2, s, s->msg_callback_arg);
> else
> s->msg_callback(1, version, SSL3_RT_HANDSHAKE, s->init_buf->data+5, ret-5, s, s->msg_callback_arg);
> }
>