Cryptography Reference
In-Depth Information
package.cipher_specs_length = ntohs( package.cipher_specs_length );
buffer = read_buffer( ( void * ) &package.connection_id_length,
buffer, 2 );
package.connection_id_length = ntohs( package.connection_id_length );
// Only one of these was ever defined
if ( package.certificate_type == SSL_CT_X509_CERTIFICATE )
{
init_x509_certificate( &package.certificate );
if ( status = parse_x509_certificate( buffer,
package.certificate_length, &package.certificate ) )
{
// Abort immediately if there's a problem reading the certificate
return status;
}
}
else
{
printf( “Error - unrecognized certificate type %d\n”,
package.certificate_type );
status = -1;
return status;
}
buffer += package.certificate_length;
package.cipher_specs = malloc( package.cipher_specs_length );
buffer = read_buffer( package.cipher_specs, buffer,
package.cipher_specs_length );
package.connection_id = malloc( package.connection_id_length );
buffer = read_buffer( package.connection_id, buffer,
package.connection_id_length );
parameters->got_server_hello = 1;
// Copy connection ID into parameter state; this is needed for key
// computation, next
parameters->connection_id_len = package.connection_id_length;
parameters->connection_id = malloc( parameters->connection_id_len );
memcpy( parameters->connection_id, package.connection_id,
parameters->connection_id_len );
// cycle through the list of cipher specs until one is found that
// matches
// XXX this will match the last one on the list
for ( i = 0; i < NUM_CIPHER_SPECS; i++ )
{
for ( j = 0; j < package.cipher_specs_length; j++ )
{
if ( !memcmp( package.cipher_specs + ( j * 3 ),
&specs[ i ].cipher_spec_code, 3 ) )
{
parameters->proposed_cipher_spec = &specs[ i ];
Search WWH ::




Custom Search