Cryptography Reference
In-Depth Information
parameters->proposed_cipher_spec->key_size );
for ( i = 0; i < parameters->proposed_cipher_spec->key_size; i++ )
{
// XXX should be random
parameters->master_key[ i ] = i;
}
You need to store the master key because it is what is RSA encrypted and
sent on to the server. Before you send it, though, go ahead and compute the
keys themselves. The server needs to repeat the computation when it receives
the RSA-encrypted master key:
while ( key_material_len )
{
new_md5_digest( &md5_digest );
update_digest( &md5_digest, parameters->master_key,
parameters->proposed_cipher_spec->key_size );
if ( counter )
{
update_digest( &md5_digest, &counter, 1 );
counter++;
}
update_digest( &md5_digest, parameters->challenge, CHALLENGE_LEN );
update_digest( &md5_digest, parameters->connection_id,
parameters->connection_id_len );
finalize_digest( &md5_digest );
memcpy( key_material_ptr, md5_digest.hash, MD5_BYTE_SIZE );
key_material_ptr += MD5_BYTE_SIZE;
key_material_len -= MD5_BYTE_SIZE;
}
Depending on how much keying material you need, cycle through the loop
one to three times, creating a new digest, updating and fi nalizing it each time.
The key material is stored in the temporary buffer key_material .
Next, copy the key_material buffer's contents into the read/write keys:
parameters->read_key = malloc(
parameters->proposed_cipher_spec->key_size );
parameters->write_key = malloc(
parameters->proposed_cipher_spec->key_size );
memcpy( parameters->read_key, key_material,
parameters->proposed_cipher_spec->key_size );
memcpy( parameters->write_key, key_material +
parameters->proposed_cipher_spec->key_size,
parameters->proposed_cipher_spec->key_size );
Search WWH ::




Custom Search