Cryptography Reference
In-Depth Information
read_pos = read_buffer( ( void * ) hello.random.random_bytes,
( void * ) read_pos, 28 );
read_pos = read_buffer( ( void * ) &hello.session_id_length,
( void * ) read_pos, 1 );
hello.session_id = NULL;
if ( hello.session_id_length > 0 )
{
hello.session_id = ( unsigned char * ) malloc( hello.session_id_length );
read_pos = read_buffer( ( void * ) hello.session_id, ( void * ) read_pos,
hello.session_id_length );
// TODO if this is non-empty, the client is trying to trigger a restart
}
read_pos = read_buffer( ( void * ) &hello.cipher_suites_length,
( void * ) read_pos, 2 );
hello.cipher_suites_length = ntohs( hello.cipher_suites_length );
hello.cipher_suites = ( unsigned short * ) malloc( hello.cipher_suites_length
);
read_pos = read_buffer( ( void * ) hello.cipher_suites,
( void * ) read_pos,
hello.cipher_suites_length );
read_pos = read_buffer( ( void * ) &hello.compression_methods_length,
( void * ) read_pos, 1 );
hello.compression_methods = ( unsigned char * ) malloc(
hello.compression_methods_length );
read_pos = read_buffer( ( void * ) hello.compression_methods,
( void * ) read_pos,
hello.compression_methods_length );
This reuses the read_buffer function from Listing 6-21 to fi ll in the ClientHello
structure.
After this structure is fi lled in, the server must select a cipher suite.
for ( i = 0; i < hello.cipher_suites_length; i++ )
{
hello.cipher_suites[ i ] = ntohs( hello.cipher_suites[ i ] );
if ( hello.cipher_suites[ i ] < MAX_SUPPORTED_CIPHER_SUITE &&
suites[ hello.cipher_suites[ i ] ].bulk_encrypt != NULL )
{
parameters->pending_recv_parameters.suite = hello.cipher_suites[ i ];
parameters->pending_send_parameters.suite = hello.cipher_suites[ i ];
break;
}
}
if ( i == MAX_SUPPORTED_CIPHER_SUITE )
{
return NULL;
}
parameters->got_client_hello = 1;
Search WWH ::




Custom Search