Cryptography Reference
In-Depth Information
printf( “Server refused to renegotiate, exiting.\n” );
return 7;
}
else
{
memcpy( parameters->master_secret, master_secret,
MASTER_SECRET_LENGTH );
calculate_keys( parameters );
}
}
First, it checks to see if the session ID returned by the server matches the
one offered by the client. If not, the server is unable to or is unwilling to rene-
gotiate this session. This code aborts if this is the case; normally you'd want
to just continue on with the handshake and negotiate new keys. However,
for experimental purposes, you should be more interested in ensuring that a
resumption succeeded. This way, if you mistype the session ID, for instance,
you get an immediate error.
Restoring the Previous Session's Master Secret
If the server is willing to resume, the client has to reproduce the master secret,
so it had better have it handy. If it does, it can just perform the calculate keys
routine. You could do this with the premaster secret, the master secret, or the
keying material itself, but it's easiest to work with the master secret. Notice that
the fi nished messages start over “from scratch” when a session resumes; neither
side needs to keep track of the digest from the original handshake.
None of the subordinate functions except send_client_hello and parse_
server_hello are aware that they are participating in a resumption instead of
an initial handshake. send_client_hello , of course, needs to send the ID of
the session it's trying to resume as shown in Listing 8-6.
Listing 8-6: “tls.c” send_client_hello with session resumption
static int send_client_hello( int connection, TLSParameters *parameters )
{
...
memcpy( package.random.random_bytes, parameters->client_random + 4, 28 );
if ( parameters->session_id_length > 0 )
{
package.session_id_length = parameters->session_id_length;
package.session_id = parameters->session_id;
}
else
{
package.session_id_length = 0;
package.session_id = NULL;
 
Search WWH ::




Custom Search