return(ssl23_write_bytes(s));
ret = ssl23_write_bytes(s); 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);  return ret;
static int ssl23_client_hello(SSL *s)	{	unsigned char *buf;	unsigned char *p,*d;	int i,ch_len;	buf=(unsigned char *)s->init_buf->data;	if (s->state == SSL23_ST_CW_CLNT_HELLO_A)		{#if 0		/* don't reuse session-id's */		if (!ssl_get_new_session(s,0))			{			return(-1);			}#endif		p=s->s3->client_random;		RAND_pseudo_bytes(p,SSL3_RANDOM_SIZE);		/* 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))			{			*(d++)=TLS1_VERSION_MAJOR;			*(d++)=TLS1_VERSION_MINOR;			s->client_version=TLS1_VERSION;			}		else if (!(s->options & SSL_OP_NO_SSLv3))			{			*(d++)=SSL3_VERSION_MAJOR;			*(d++)=SSL3_VERSION_MINOR;			s->client_version=SSL3_VERSION;			}		else if (!(s->options & SSL_OP_NO_SSLv2))			{			*(d++)=SSL2_VERSION_MAJOR;			*(d++)=SSL2_VERSION_MINOR;			s->client_version=SSL2_VERSION;			}		else			{			SSLerr(SSL_F_SSL23_CLIENT_HELLO,SSL_R_NO_PROTOCOLS_AVAILABLE);			return(-1);			}		/* Ciphers supported */		i=ssl_cipher_list_to_bytes(s,SSL_get_ciphers(s),p);		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, zero since there is no		 * reuse. */#if 0		s->session->session_id_length=0;#endif		s2n(0,d);		if (s->options & SSL_OP_NETSCAPE_CHALLENGE_BUG)			ch_len=SSL2_CHALLENGE_LENGTH;		else			ch_len=SSL2_MAX_CHALLENGE_LENGTH;		/* 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);		RAND_pseudo_bytes(&(s->s3->client_random[SSL3_RANDOM_SIZE-i]),i);		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);		s->state=SSL23_ST_CW_CLNT_HELLO_B;		/* number of bytes to write */		s->init_num=i+2;		s->init_off=0;		ssl3_finish_mac(s,&(buf[2]),i);		}	/* SSL3_ST_CW_CLNT_HELLO_B */	return(ssl23_write_bytes(s));	}