Cryptography Reference
In-Depth Information
All six of these handshake messages are sent in the ssl_connect function.
After the server_finished message has been received, the higher-level protocol
begins.
The code for ssl_connect is shown in Listing C-8.
Listing C-8: “ssl.c” ssl_connect
int ssl_connect( int connection,
SSLParameters *parameters )
{
init_parameters( parameters );
if ( send_client_hello( connection, parameters ) == -1 )
{
return -1;
}
while ( !parameters->got_server_hello )
{
// set proposed_cipher_spec from server hello
if ( receive_ssl_message( connection, NULL, 0, parameters ) == -1 )
{
return -1;
}
}
// If proposed_cipher_spec is not set at this point, no cipher could
// be negotiated
if ( parameters->proposed_cipher_spec == NULL )
{
send_error( connection, SSL_PE_NO_CIPHER, parameters );
return -1;
}
compute_keys( parameters );
if ( send_client_master_key( connection, parameters ) == -1 )
{
return -1;
}
// From this point forward, everything is encrypted
parameters->active_cipher_spec = parameters->proposed_cipher_spec;
parameters->proposed_cipher_spec = NULL;
if ( send_client_finished( connection, parameters ) == -1 )
{
return -1;
}
 
Search WWH ::




Custom Search