Cryptography Reference
In-Depth Information
int server_hello_done;
int server_finished;
}
TLSParameters;
11. Update tls_receive_message to process the server_finished message
in Listing 6-56.
Listing 6-56: “tls.c” tls_receive_message with server fi nished support
switch ( handshake.msg_type )
{
case finished:
{
read_pos = parse_finished( read_pos, handshake.length, parameters );
if ( read_pos == NULL )
{
send_alert_message( connection, illegal_parameter );
return -1;
}
}
break;
12. Now you can parse the fi nished message, in Listing 6-57.
Listing 6-57: “tls.c” parse_fi nished
static unsigned char *parse_finished( unsigned char *read_pos,
int pdu_length,
TLSParameters *parameters )
{
unsigned char verify_data[ VERIFY_DATA_LEN ];
parameters->server_finished = 1;
compute_verify_data( “server finished”, parameters, verify_data );
if ( memcmp( read_pos, verify_data, VERIFY_DATA_LEN ) )
{
return NULL;
}
return read_pos + pdu_length;
}
Here, compute_verify_data is called again to recompute the verifi cation data,
and the received data is compared with the computed data.
Search WWH ::




Custom Search