Cryptography Reference
In-Depth Information
typedef struct
{
unsigned int gmt_unix_time;
unsigned char random_bytes[ 28 ];
}
Random;
/**
* Section 7.4.1.2
*/
typedef struct
{
ProtocolVersion client_version;
Random random;
unsigned char session_id_length;
unsigned char *session_id;
unsigned short cipher_suites_length;
unsigned short *cipher_suites;
unsigned char compression_methods_length;
unsigned char *compression_methods;
}
ClientHello;
Listing 6-9 shows the fi rst part of the send_client_hello function, which is
responsible for fi lling out a ClientHello structure and sending it on to the server.
Listing 6-9: “tls.c” send_client_hello
/**
* Build and submit a TLS client hello handshake on the active
* connection. It is up to the caller of this function to wait
* for the server reply.
*/
static int send_client_hello( int connection, TLSParameters *parameters )
{
ClientHello package;
unsigned short supported_suites[ 1 ];
unsigned char supported_compression_methods[ 1 ];
int send_buffer_size;
char *send_buffer;
void *write_buffer;
time_t local_time;
int status = 1;
package.client_version.major = TLS_VERSION_MAJOR;
package.client_version.minor = TLS_VERSION_MINOR;
time( &local_time );
package.random.gmt_unix_time = htonl( local_time );
// TODO - actually make this random.
// This is 28 bytes, but client random is 32 - the first four bytes of
(Continued)
 
Search WWH ::




Custom Search