Cryptography Reference
In-Depth Information
else if ( key_len == 32 )
{
aes_256_encrypt( input, input_len, ciphertext, iv, key );
}
else
{
fprintf( stderr, “Unsupported key length: %d\n”, key_len );
exit( 0 );
}
show_hex( ciphertext, input_len );
free( ciphertext );
}
else if ( !strcmp( argv[ 1 ], “-d” ) )
{
unsigned char *plaintext = ( unsigned char * ) malloc( input_len );
if ( key_len == 16 )
{
aes_128_decrypt( input, input_len, plaintext, iv, key );
}
else if ( key_len == 32 )
{
aes_256_decrypt( input, input_len, plaintext, iv, key );
}
else
{
fprintf( stderr, “Unsupported key length %d\n”, key_len );
exit( 0 );
}
show_hex( plaintext, input_len );
free( plaintext );
}
else
{
fprintf( stderr, “Usage: %s [-e|-d] <key> <iv> <input>\n”, argv[ 0 ] );
}
free( iv );
free( key );
free( input );
}
#endif
This checks the length of the key and invokes aes_128_decrypt or aes_256_
decrypt . Its operation is identical to the operation of the DES tester routine
described earlier.
Search WWH ::




Custom Search