Make GCM tests accept any cipher, not just AES

This commit is contained in:
Manuel Pégourié-Gonnard 2013-10-24 12:06:54 +02:00
parent 94dd5b4dd4
commit 083d66821e
7 changed files with 2028 additions and 2026 deletions

View file

@ -8,7 +8,8 @@
*/
/* BEGIN_CASE */
void gcm_encrypt_and_tag( char *hex_key_string, char *hex_src_string,
void gcm_encrypt_and_tag( int cipher_id,
char *hex_key_string, char *hex_src_string,
char *hex_iv_string, char *hex_add_string,
char *hex_dst_string, int tag_len_bits,
char *hex_tag_string, int init_result )
@ -39,7 +40,7 @@ void gcm_encrypt_and_tag( char *hex_key_string, char *hex_src_string,
iv_len = unhexify( iv_str, hex_iv_string );
add_len = unhexify( add_str, hex_add_string );
TEST_ASSERT( gcm_init( &ctx, POLARSSL_CIPHER_ID_AES, key_str, key_len * 8 ) == init_result );
TEST_ASSERT( gcm_init( &ctx, cipher_id, key_str, key_len * 8 ) == init_result );
if( init_result == 0 )
{
TEST_ASSERT( gcm_crypt_and_tag( &ctx, GCM_ENCRYPT, pt_len, iv_str, iv_len, add_str, add_len, src_str, output, tag_len, tag_output ) == 0 );
@ -55,7 +56,8 @@ void gcm_encrypt_and_tag( char *hex_key_string, char *hex_src_string,
/* END_CASE */
/* BEGIN_CASE */
void gcm_decrypt_and_verify( char *hex_key_string, char *hex_src_string,
void gcm_decrypt_and_verify( int cipher_id,
char *hex_key_string, char *hex_src_string,
char *hex_iv_string, char *hex_add_string,
int tag_len_bits, char *hex_tag_string,
char *pt_result, int init_result )
@ -86,7 +88,7 @@ void gcm_decrypt_and_verify( char *hex_key_string, char *hex_src_string,
add_len = unhexify( add_str, hex_add_string );
unhexify( tag_str, hex_tag_string );
TEST_ASSERT( gcm_init( &ctx, POLARSSL_CIPHER_ID_AES, key_str, key_len * 8 ) == init_result );
TEST_ASSERT( gcm_init( &ctx, cipher_id, key_str, key_len * 8 ) == init_result );
if( init_result == 0 )
{
ret = gcm_auth_decrypt( &ctx, pt_len, iv_str, iv_len, add_str, add_len, tag_str, tag_len, src_str, output );