Cryptography Reference
In-Depth Information
TLS 1.2 Modifi cations to the Finished Messages
Verify Data
You may recall from Listing 6-53 that there was one other data value that depended
on the combination of an MD5 and an SHA-1 hash: the verify data in the fi n-
ished message. And yes, sure enough, this changes in TLS 1.2 as well. Rather
than tracking the MD5 and SHA-1 hashes of the handshake messages and then
running those hashes through the PRF to generate the fi nished message, TLS
1.2 instead tracks a single hash; the same one that the PRF uses (the one nego-
tiated in the client hello or the default SHA-256). It still hashes all handshake
messages, and does so in the same way as TLS 1.1.
To support the TLS 1.2 fi nished message, follow these steps:
1. Modify TLSParameters as shown in Listing 9-5 to keep track of an SHA-
256 digest.
Listing 9-5: “tls.h” TLSParameters
int got_certificate_request;
digest_ctx sha256_handshake_digest;
char *unread_buffer;
2. Of course, the two digest updates in send_handshake_message and receive_
tls_msg must be changed to update this digest as shown in Listing 9-6.
Listing 9-6: “tls.c” SHA-256 digest update
int send_handshake_message( int connection,
int msg_type,
const unsigned char *message,
int message_len,
TLSParameters *parameters )
{
memcpy( send_buffer + 1, &record.length, 3 );
memcpy( send_buffer + 4, message, message_len );
update_digest( &parameters->sha256_handshake_digest,
send_buffer, send_buffer_size );
response = send_message( connection, content_handshake, send_buffer,
send_buffer_size, &parameters->active_send_parameters );
static int receive_tls_msg( int connection,
char *buffer,
(Continued)
Search WWH ::




Custom Search