Cryptography Reference
In-Depth Information
Listing 6-59: “tls.h” ProtectionParameters with seq_num
typedef struct
{
unsigned long seq_num;
}
ProtectionParameters;
Listing 6-60: “tls.c” init_protection_parameters with seq_num
void init_protection_parameters( ProtectionParameters *parameters )
{
parameters->MAC_secret = NULL;
parameters->key = NULL;
parameters->IV = NULL;
parameters->seq_num = 0;
parameters->suite = TLS_NULL_WITH_NULL_NULL;
}
static int send_change_cipher_spec( int connection, TLSParameters *parameters )
{
send_message( connection, content_change_cipher_spec, send_buffer, 1,
&parameters->active_send_parameters );
// Per 6.1: The sequence number must be set to zero whenever a connection
// state is made the active state... the first record which is transmitted
// under a particular connection state should use sequence number 0.
parameters->pending_send_parameters.seq_num = 0;
memcpy( &parameters->active_send_parameters,
&parameters->pending_send_parameters,
sizeof( ProtectionParameters ) );
static int receive_tls_msg( int connection,
TLSParameters *parameters )
{
else if ( message.type == content_change_cipher_spec )
{
if ( change_cipher_spec_type != 1 )
{
printf( “Error - received message of type ChangeCipherSpec, but type !=
1\n” );
exit( 0 );
}
else
{
parameters->pending_recv_parameters.seq_num = 0;
Search WWH ::




Custom Search