Cryptography Reference
In-Depth Information
char *verify_data )
{
unsigned char handshake_hash[ ( MD5_RESULT_SIZE * sizeof( int ) ) +
( SHA1_RESULT_SIZE * sizeof( int ) ) ];
finalize_digest( &parameters->md5_handshake_digest );
finalize_digest( &parameters->sha1_handshake_digest );
memcpy( handshake_hash, parameters->md5_handshake_digest.hash, MD5_BYTE_SIZE
);
memcpy( handshake_hash + MD5_BYTE_SIZE, parameters->sha1_handshake_digest.hash,
SHA1_BYTE_SIZE );
PRF( parameters->master_secret, MASTER_SECRET_LENGTH,
finished_label, strlen( finished_label ),
handshake_hash,
MD5_RESULT_SIZE * sizeof( int ) + SHA1_RESULT_SIZE * sizeof( int ),
verify_data, VERIFY_DATA_LEN );
}
The verify data is a PRF expansion of “client fi nished” with both hashes
concatenated next to one another. The result is 12 bytes, and both sides
end up computing the same value.
9. Of course, the client must wait for the server to send its finished message
as well. Update tls_connect to wait for the server_finished as shown
in Listing 6-54.
Listing 6-54: “tls.c” tls_connect with server fi nished support
parameters->server_finished = 0;
while ( !parameters->server_finished )
{
if ( receive_tls_msg( connection, parameters ) < 0 )
{
perror( “Unable to receive server finished” );
return 6;
}
}
NOTE This call will also be the fi rst time the client receives the change
cipher spec message.
10. This requires that you also add a server_finished fl ag, similar to the
server_hello_done fl ag, in TLSParameters , in Listing 6-55:
Listing 6-55: “tls.c” TLSParameters
typedef struct
{
 
Search WWH ::




Custom Search