Adapt programs / test suites to _init() and _free()

This commit is contained in:
Paul Bakker 2014-06-18 11:16:11 +02:00
parent c7ea99af4f
commit 8cfd9d8c59
9 changed files with 113 additions and 2 deletions

View file

@ -22,6 +22,7 @@ void aes_encrypt_ecb( char *hex_key_string, char *hex_src_string,
memset(src_str, 0x00, 100);
memset(dst_str, 0x00, 100);
memset(output, 0x00, 100);
aes_init( &ctx );
key_len = unhexify( key_str, hex_key_string );
unhexify( src_str, hex_src_string );
@ -34,6 +35,8 @@ void aes_encrypt_ecb( char *hex_key_string, char *hex_src_string,
TEST_ASSERT( strcmp( (char *) dst_str, hex_dst_string ) == 0 );
}
aes_free( &ctx );
}
/* END_CASE */
@ -52,6 +55,7 @@ void aes_decrypt_ecb( char *hex_key_string, char *hex_src_string,
memset(src_str, 0x00, 100);
memset(dst_str, 0x00, 100);
memset(output, 0x00, 100);
aes_init( &ctx );
key_len = unhexify( key_str, hex_key_string );
unhexify( src_str, hex_src_string );
@ -64,6 +68,8 @@ void aes_decrypt_ecb( char *hex_key_string, char *hex_src_string,
TEST_ASSERT( strcmp( (char *) dst_str, hex_dst_string ) == 0 );
}
aes_free( &ctx );
}
/* END_CASE */
@ -85,6 +91,7 @@ void aes_encrypt_cbc( char *hex_key_string, char *hex_iv_string,
memset(src_str, 0x00, 100);
memset(dst_str, 0x00, 100);
memset(output, 0x00, 100);
aes_init( &ctx );
key_len = unhexify( key_str, hex_key_string );
unhexify( iv_str, hex_iv_string );
@ -98,6 +105,8 @@ void aes_encrypt_cbc( char *hex_key_string, char *hex_iv_string,
TEST_ASSERT( strcmp( (char *) dst_str, hex_dst_string ) == 0 );
}
aes_free( &ctx );
}
/* END_CASE */
@ -119,6 +128,7 @@ void aes_decrypt_cbc( char *hex_key_string, char *hex_iv_string,
memset(src_str, 0x00, 100);
memset(dst_str, 0x00, 100);
memset(output, 0x00, 100);
aes_init( &ctx );
key_len = unhexify( key_str, hex_key_string );
unhexify( iv_str, hex_iv_string );
@ -132,6 +142,8 @@ void aes_decrypt_cbc( char *hex_key_string, char *hex_iv_string,
TEST_ASSERT( strcmp( (char *) dst_str, hex_dst_string ) == 0 );
}
aes_free( &ctx );
}
/* END_CASE */
@ -153,6 +165,7 @@ void aes_encrypt_cfb128( char *hex_key_string, char *hex_iv_string,
memset(src_str, 0x00, 100);
memset(dst_str, 0x00, 100);
memset(output, 0x00, 100);
aes_init( &ctx );
key_len = unhexify( key_str, hex_key_string );
unhexify( iv_str, hex_iv_string );
@ -163,6 +176,8 @@ void aes_encrypt_cfb128( char *hex_key_string, char *hex_iv_string,
hexify( dst_str, output, 16 );
TEST_ASSERT( strcmp( (char *) dst_str, hex_dst_string ) == 0 );
aes_free( &ctx );
}
/* END_CASE */
@ -184,6 +199,7 @@ void aes_decrypt_cfb128( char *hex_key_string, char *hex_iv_string,
memset(src_str, 0x00, 100);
memset(dst_str, 0x00, 100);
memset(output, 0x00, 100);
aes_init( &ctx );
key_len = unhexify( key_str, hex_key_string );
unhexify( iv_str, hex_iv_string );
@ -194,6 +210,8 @@ void aes_decrypt_cfb128( char *hex_key_string, char *hex_iv_string,
hexify( dst_str, output, 16 );
TEST_ASSERT( strcmp( (char *) dst_str, hex_dst_string ) == 0 );
aes_free( &ctx );
}
/* END_CASE */
@ -214,6 +232,7 @@ void aes_encrypt_cfb8( char *hex_key_string, char *hex_iv_string,
memset(src_str, 0x00, 100);
memset(dst_str, 0x00, 100);
memset(output, 0x00, 100);
aes_init( &ctx );
key_len = unhexify( key_str, hex_key_string );
unhexify( iv_str, hex_iv_string );
@ -224,6 +243,8 @@ void aes_encrypt_cfb8( char *hex_key_string, char *hex_iv_string,
hexify( dst_str, output, src_len );
TEST_ASSERT( strcmp( (char *) dst_str, hex_dst_string ) == 0 );
aes_free( &ctx );
}
/* END_CASE */
@ -244,6 +265,7 @@ void aes_decrypt_cfb8( char *hex_key_string, char *hex_iv_string,
memset(src_str, 0x00, 100);
memset(dst_str, 0x00, 100);
memset(output, 0x00, 100);
aes_init( &ctx );
key_len = unhexify( key_str, hex_key_string );
unhexify( iv_str, hex_iv_string );
@ -254,6 +276,8 @@ void aes_decrypt_cfb8( char *hex_key_string, char *hex_iv_string,
hexify( dst_str, output, src_len );
TEST_ASSERT( strcmp( (char *) dst_str, hex_dst_string ) == 0 );
aes_free( &ctx );
}
/* END_CASE */

View file

@ -22,6 +22,7 @@ void arc4_crypt( char *hex_src_string, char *hex_key_string,
memset(key_str, 0x00, 1000);
memset(dst_str, 0x00, 1000);
memset(dst_hexstr, 0x00, 2000);
arc4_init( &ctx );
src_len = unhexify( src_str, hex_src_string );
key_len = unhexify( key_str, hex_key_string );
@ -31,6 +32,8 @@ void arc4_crypt( char *hex_src_string, char *hex_key_string,
hexify( dst_hexstr, dst_str, src_len );
TEST_ASSERT( strcmp( (char *) dst_hexstr, hex_dst_string ) == 0 );
arc4_free( &ctx );
}
/* END_CASE */

View file

@ -22,6 +22,7 @@ void blowfish_encrypt_ecb( char *hex_key_string, char *hex_src_string,
memset(src_str, 0x00, 100);
memset(dst_str, 0x00, 100);
memset(output, 0x00, 100);
blowfish_init( &ctx );
key_len = unhexify( key_str, hex_key_string );
unhexify( src_str, hex_src_string );
@ -34,6 +35,8 @@ void blowfish_encrypt_ecb( char *hex_key_string, char *hex_src_string,
TEST_ASSERT( strcmp( (char *) dst_str, hex_dst_string ) == 0 );
}
blowfish_free( &ctx );
}
/* END_CASE */
@ -52,6 +55,7 @@ void blowfish_decrypt_ecb( char *hex_key_string, char *hex_src_string,
memset(src_str, 0x00, 100);
memset(dst_str, 0x00, 100);
memset(output, 0x00, 100);
blowfish_init( &ctx );
key_len = unhexify( key_str, hex_key_string );
unhexify( src_str, hex_src_string );
@ -64,6 +68,8 @@ void blowfish_decrypt_ecb( char *hex_key_string, char *hex_src_string,
TEST_ASSERT( strcmp( (char *) dst_str, hex_dst_string ) == 0 );
}
blowfish_free( &ctx );
}
/* END_CASE */
@ -85,6 +91,7 @@ void blowfish_encrypt_cbc( char *hex_key_string, char *hex_iv_string,
memset(src_str, 0x00, 100);
memset(dst_str, 0x00, 100);
memset(output, 0x00, 100);
blowfish_init( &ctx );
key_len = unhexify( key_str, hex_key_string );
unhexify( iv_str, hex_iv_string );
@ -99,6 +106,8 @@ void blowfish_encrypt_cbc( char *hex_key_string, char *hex_iv_string,
TEST_ASSERT( strcmp( (char *) dst_str, hex_dst_string ) == 0 );
}
blowfish_free( &ctx );
}
/* END_CASE */
@ -120,6 +129,7 @@ void blowfish_decrypt_cbc( char *hex_key_string, char *hex_iv_string,
memset(src_str, 0x00, 100);
memset(dst_str, 0x00, 100);
memset(output, 0x00, 100);
blowfish_init( &ctx );
key_len = unhexify( key_str, hex_key_string );
unhexify( iv_str, hex_iv_string );
@ -133,6 +143,8 @@ void blowfish_decrypt_cbc( char *hex_key_string, char *hex_iv_string,
TEST_ASSERT( strcmp( (char *) dst_str, hex_dst_string ) == 0 );
}
blowfish_free( &ctx );
}
/* END_CASE */
@ -154,6 +166,7 @@ void blowfish_encrypt_cfb64( char *hex_key_string, char *hex_iv_string,
memset(src_str, 0x00, 100);
memset(dst_str, 0x00, 100);
memset(output, 0x00, 100);
blowfish_init( &ctx );
key_len = unhexify( key_str, hex_key_string );
unhexify( iv_str, hex_iv_string );
@ -164,6 +177,8 @@ void blowfish_encrypt_cfb64( char *hex_key_string, char *hex_iv_string,
hexify( dst_str, output, src_len );
TEST_ASSERT( strcmp( (char *) dst_str, hex_dst_string ) == 0 );
blowfish_free( &ctx );
}
/* END_CASE */
@ -185,6 +200,7 @@ void blowfish_decrypt_cfb64( char *hex_key_string, char *hex_iv_string,
memset(src_str, 0x00, 100);
memset(dst_str, 0x00, 100);
memset(output, 0x00, 100);
blowfish_init( &ctx );
key_len = unhexify( key_str, hex_key_string );
unhexify( iv_str, hex_iv_string );
@ -195,6 +211,8 @@ void blowfish_decrypt_cfb64( char *hex_key_string, char *hex_iv_string,
hexify( dst_str, output, src_len );
TEST_ASSERT( strcmp( (char *) dst_str, hex_dst_string ) == 0 );
blowfish_free( &ctx );
}
/* END_CASE */
@ -218,6 +236,7 @@ void blowfish_encrypt_ctr( char *hex_key_string, char *hex_iv_string,
memset(src_str, 0x00, 100);
memset(dst_str, 0x00, 100);
memset(output, 0x00, 100);
blowfish_init( &ctx );
key_len = unhexify( key_str, hex_key_string );
unhexify( iv_str, hex_iv_string );
@ -228,5 +247,7 @@ void blowfish_encrypt_ctr( char *hex_key_string, char *hex_iv_string,
hexify( dst_str, output, src_len );
TEST_ASSERT( strcmp( (char *) dst_str, hex_dst_string ) == 0 );
blowfish_free( &ctx );
}
/* END_CASE */

View file

@ -22,6 +22,7 @@ void camellia_encrypt_ecb( char *hex_key_string, char *hex_src_string,
memset(src_str, 0x00, 100);
memset(dst_str, 0x00, 100);
memset(output, 0x00, 100);
camellia_init( &ctx );
key_len = unhexify( key_str, hex_key_string );
unhexify( src_str, hex_src_string );
@ -34,6 +35,8 @@ void camellia_encrypt_ecb( char *hex_key_string, char *hex_src_string,
TEST_ASSERT( strcasecmp( (char *) dst_str, hex_dst_string ) == 0 );
}
camellia_free( &ctx );
}
/* END_CASE */
@ -52,6 +55,7 @@ void camellia_decrypt_ecb( char *hex_key_string, char *hex_src_string,
memset(src_str, 0x00, 100);
memset(dst_str, 0x00, 100);
memset(output, 0x00, 100);
camellia_init( &ctx );
key_len = unhexify( key_str, hex_key_string );
unhexify( src_str, hex_src_string );
@ -64,6 +68,8 @@ void camellia_decrypt_ecb( char *hex_key_string, char *hex_src_string,
TEST_ASSERT( strcasecmp( (char *) dst_str, hex_dst_string ) == 0 );
}
camellia_free( &ctx );
}
/* END_CASE */
@ -85,6 +91,7 @@ void camellia_encrypt_cbc( char *hex_key_string, char *hex_iv_string,
memset(src_str, 0x00, 100);
memset(dst_str, 0x00, 100);
memset(output, 0x00, 100);
camellia_init( &ctx );
key_len = unhexify( key_str, hex_key_string );
unhexify( iv_str, hex_iv_string );
@ -98,6 +105,8 @@ void camellia_encrypt_cbc( char *hex_key_string, char *hex_iv_string,
TEST_ASSERT( strcasecmp( (char *) dst_str, hex_dst_string ) == 0 );
}
camellia_free( &ctx );
}
/* END_CASE */
@ -119,6 +128,7 @@ void camellia_decrypt_cbc( char *hex_key_string, char *hex_iv_string,
memset(src_str, 0x00, 100);
memset(dst_str, 0x00, 100);
memset(output, 0x00, 100);
camellia_init( &ctx );
key_len = unhexify( key_str, hex_key_string );
unhexify( iv_str, hex_iv_string );
@ -132,6 +142,8 @@ void camellia_decrypt_cbc( char *hex_key_string, char *hex_iv_string,
TEST_ASSERT( strcasecmp( (char *) dst_str, hex_dst_string ) == 0 );
}
camellia_free( &ctx );
}
/* END_CASE */
@ -153,6 +165,7 @@ void camellia_encrypt_cfb128( char *hex_key_string, char *hex_iv_string,
memset(src_str, 0x00, 100);
memset(dst_str, 0x00, 100);
memset(output, 0x00, 100);
camellia_init( &ctx );
key_len = unhexify( key_str, hex_key_string );
unhexify( iv_str, hex_iv_string );
@ -163,6 +176,8 @@ void camellia_encrypt_cfb128( char *hex_key_string, char *hex_iv_string,
hexify( dst_str, output, 16 );
TEST_ASSERT( strcasecmp( (char *) dst_str, hex_dst_string ) == 0 );
camellia_free( &ctx );
}
/* END_CASE */
@ -184,6 +199,7 @@ void camellia_decrypt_cfb128( char *hex_key_string, char *hex_iv_string,
memset(src_str, 0x00, 100);
memset(dst_str, 0x00, 100);
memset(output, 0x00, 100);
camellia_init( &ctx );
key_len = unhexify( key_str, hex_key_string );
unhexify( iv_str, hex_iv_string );
@ -194,6 +210,8 @@ void camellia_decrypt_cfb128( char *hex_key_string, char *hex_iv_string,
hexify( dst_str, output, 16 );
TEST_ASSERT( strcasecmp( (char *) dst_str, hex_dst_string ) == 0 );
camellia_free( &ctx );
}
/* END_CASE */

View file

@ -34,6 +34,7 @@ void des_encrypt_ecb( char *hex_key_string, char *hex_src_string,
memset(src_str, 0x00, 100);
memset(dst_str, 0x00, 100);
memset(output, 0x00, 100);
des_init( &ctx );
unhexify( key_str, hex_key_string );
unhexify( src_str, hex_src_string );
@ -43,6 +44,8 @@ void des_encrypt_ecb( char *hex_key_string, char *hex_src_string,
hexify( dst_str, output, 8 );
TEST_ASSERT( strcasecmp( (char *) dst_str, hex_dst_string ) == 0 );
des_free( &ctx );
}
/* END_CASE */
@ -60,6 +63,7 @@ void des_decrypt_ecb( char *hex_key_string, char *hex_src_string,
memset(src_str, 0x00, 100);
memset(dst_str, 0x00, 100);
memset(output, 0x00, 100);
des_init( &ctx );
unhexify( key_str, hex_key_string );
unhexify( src_str, hex_src_string );
@ -69,6 +73,8 @@ void des_decrypt_ecb( char *hex_key_string, char *hex_src_string,
hexify( dst_str, output, 8 );
TEST_ASSERT( strcasecmp( (char *) dst_str, hex_dst_string ) == 0 );
des_free( &ctx );
}
/* END_CASE */
@ -89,6 +95,7 @@ void des_encrypt_cbc( char *hex_key_string, char *hex_iv_string,
memset(src_str, 0x00, 100);
memset(dst_str, 0x00, 100);
memset(output, 0x00, 100);
des_init( &ctx );
unhexify( key_str, hex_key_string );
unhexify( iv_str, hex_iv_string );
@ -102,6 +109,8 @@ void des_encrypt_cbc( char *hex_key_string, char *hex_iv_string,
TEST_ASSERT( strcasecmp( (char *) dst_str, hex_dst_string ) == 0 );
}
des_free( &ctx );
}
/* END_CASE */
@ -122,6 +131,7 @@ void des_decrypt_cbc( char *hex_key_string, char *hex_iv_string,
memset(src_str, 0x00, 100);
memset(dst_str, 0x00, 100);
memset(output, 0x00, 100);
des_init( &ctx );
unhexify( key_str, hex_key_string );
unhexify( iv_str, hex_iv_string );
@ -135,6 +145,8 @@ void des_decrypt_cbc( char *hex_key_string, char *hex_iv_string,
TEST_ASSERT( strcasecmp( (char *) dst_str, hex_dst_string ) == 0 );
}
des_free( &ctx );
}
/* END_CASE */
@ -152,6 +164,7 @@ void des3_encrypt_ecb( int key_count, char *hex_key_string,
memset(src_str, 0x00, 100);
memset(dst_str, 0x00, 100);
memset(output, 0x00, 100);
des3_init( &ctx );
unhexify( key_str, hex_key_string );
unhexify( src_str, hex_src_string );
@ -167,6 +180,8 @@ void des3_encrypt_ecb( int key_count, char *hex_key_string,
hexify( dst_str, output, 8 );
TEST_ASSERT( strcasecmp( (char *) dst_str, hex_dst_string ) == 0 );
des3_free( &ctx );
}
/* END_CASE */
@ -184,6 +199,7 @@ void des3_decrypt_ecb( int key_count, char *hex_key_string,
memset(src_str, 0x00, 100);
memset(dst_str, 0x00, 100);
memset(output, 0x00, 100);
des3_init( &ctx );
unhexify( key_str, hex_key_string );
unhexify( src_str, hex_src_string );
@ -199,6 +215,8 @@ void des3_decrypt_ecb( int key_count, char *hex_key_string,
hexify( dst_str, output, 8 );
TEST_ASSERT( strcasecmp( (char *) dst_str, hex_dst_string ) == 0 );
des3_free( &ctx );
}
/* END_CASE */
@ -220,6 +238,7 @@ void des3_encrypt_cbc( int key_count, char *hex_key_string,
memset(src_str, 0x00, 100);
memset(dst_str, 0x00, 100);
memset(output, 0x00, 100);
des3_init( &ctx );
unhexify( key_str, hex_key_string );
unhexify( iv_str, hex_iv_string );
@ -240,6 +259,8 @@ void des3_encrypt_cbc( int key_count, char *hex_key_string,
TEST_ASSERT( strcasecmp( (char *) dst_str, hex_dst_string ) == 0 );
}
des3_free( &ctx );
}
/* END_CASE */
@ -261,6 +282,7 @@ void des3_decrypt_cbc( int key_count, char *hex_key_string,
memset(src_str, 0x00, 100);
memset(dst_str, 0x00, 100);
memset(output, 0x00, 100);
des3_init( &ctx );
unhexify( key_str, hex_key_string );
unhexify( iv_str, hex_iv_string );
@ -281,6 +303,8 @@ void des3_decrypt_cbc( int key_count, char *hex_key_string,
TEST_ASSERT( strcasecmp( (char *) dst_str, hex_dst_string ) == 0 );
}
des3_free( &ctx );
}
/* END_CASE */