1
0
mirror of https://github.com/Mbed-TLS/mbedtls.git synced 2025-08-08 17:42:09 +03:00

Remove tests for xxx_hmac()

This commit is contained in:
Manuel Pégourié-Gonnard
2015-03-24 16:59:49 +01:00
parent 8379a82a76
commit ec4a339c2a
6 changed files with 1 additions and 763 deletions

View File

@@ -85,242 +85,6 @@ void ripemd160_text( char *text_src_string, char *hex_hash_string )
}
/* END_CASE */
/* BEGIN_CASE depends_on:POLARSSL_MD2_C */
void md2_hmac( int trunc_size, char *hex_key_string, char *hex_src_string,
char *hex_hash_string )
{
unsigned char src_str[200];
unsigned char key_str[200];
unsigned char hash_str[33];
unsigned char output[16];
int key_len, src_len;
md2_context ctx;
memset( src_str, 0x00, sizeof src_str );
memset( key_str, 0x00, sizeof key_str );
md2_init( &ctx );
key_len = unhexify( key_str, hex_key_string );
src_len = unhexify( src_str, hex_src_string );
/* Test the all-in-one interface */
memset( hash_str, 0x00, sizeof hash_str );
memset( output, 0x00, sizeof output );
md2_hmac( key_str, key_len, src_str, src_len, output );
hexify( hash_str, output, sizeof output );
TEST_ASSERT( strncmp( (char *) hash_str, hex_hash_string, trunc_size * 2 ) == 0 );
/* Also test the "streaming" interface */
memset( hash_str, 0x00, sizeof hash_str );
memset( output, 0x00, sizeof output );
memset( &ctx, 0x00, sizeof ctx );
md2_hmac_starts( &ctx, key_str, key_len );
md2_hmac_update( &ctx, src_str, 0 );
md2_hmac_update( &ctx, src_str, src_len / 2 );
md2_hmac_update( &ctx, src_str + src_len / 2, src_len - src_len / 2 );
md2_hmac_update( &ctx, src_str + src_len, 0 );
md2_hmac_finish( &ctx, output );
hexify( hash_str, output, sizeof output );
TEST_ASSERT( strncmp( (char *) hash_str, hex_hash_string, trunc_size * 2 ) == 0 );
/* Again, to test hmac_reset() */
memset( hash_str, 0x00, sizeof hash_str );
memset( output, 0x00, sizeof output );
md2_hmac_reset( &ctx );
md2_hmac_update( &ctx, src_str, src_len / 2 );
md2_hmac_update( &ctx, src_str + src_len / 2, src_len - src_len / 2 );
md2_hmac_finish( &ctx, output );
hexify( hash_str, output, sizeof output );
TEST_ASSERT( strncmp( (char *) hash_str, hex_hash_string, trunc_size * 2 ) == 0 );
exit:
md2_free( &ctx );
}
/* END_CASE */
/* BEGIN_CASE depends_on:POLARSSL_MD4_C */
void md4_hmac( int trunc_size, char *hex_key_string, char *hex_src_string,
char *hex_hash_string )
{
unsigned char src_str[200];
unsigned char key_str[200];
unsigned char hash_str[33];
unsigned char output[16];
int key_len, src_len;
md4_context ctx;
memset( src_str, 0x00, sizeof src_str );
memset( key_str, 0x00, sizeof key_str );
md4_init( &ctx );
key_len = unhexify( key_str, hex_key_string );
src_len = unhexify( src_str, hex_src_string );
/* Test the all-in-one interface */
memset( hash_str, 0x00, sizeof hash_str );
memset( output, 0x00, sizeof output );
md4_hmac( key_str, key_len, src_str, src_len, output );
hexify( hash_str, output, sizeof output );
TEST_ASSERT( strncmp( (char *) hash_str, hex_hash_string, trunc_size * 2 ) == 0 );
/* Also test the "streaming" interface */
memset( hash_str, 0x00, sizeof hash_str );
memset( output, 0x00, sizeof output );
memset( &ctx, 0x00, sizeof ctx );
md4_hmac_starts( &ctx, key_str, key_len );
md4_hmac_update( &ctx, src_str, 0 );
md4_hmac_update( &ctx, src_str, src_len / 2 );
md4_hmac_update( &ctx, src_str + src_len / 2, src_len - src_len / 2 );
md4_hmac_update( &ctx, src_str + src_len, 0 );
md4_hmac_finish( &ctx, output );
hexify( hash_str, output, sizeof output );
TEST_ASSERT( strncmp( (char *) hash_str, hex_hash_string, trunc_size * 2 ) == 0 );
/* Again, to test hmac_reset() */
memset( hash_str, 0x00, sizeof hash_str );
memset( output, 0x00, sizeof output );
md4_hmac_reset( &ctx );
md4_hmac_update( &ctx, src_str, src_len / 2 );
md4_hmac_update( &ctx, src_str + src_len / 2, src_len - src_len / 2 );
md4_hmac_finish( &ctx, output );
hexify( hash_str, output, sizeof output );
TEST_ASSERT( strncmp( (char *) hash_str, hex_hash_string, trunc_size * 2 ) == 0 );
exit:
md4_free( &ctx );
}
/* END_CASE */
/* BEGIN_CASE depends_on:POLARSSL_MD5_C */
void md5_hmac( int trunc_size, char *hex_key_string, char *hex_src_string,
char *hex_hash_string )
{
unsigned char src_str[200];
unsigned char key_str[200];
unsigned char hash_str[33];
unsigned char output[16];
int key_len, src_len;
md5_context ctx;
memset( src_str, 0x00, sizeof src_str );
memset( key_str, 0x00, sizeof key_str );
md5_init( &ctx );
key_len = unhexify( key_str, hex_key_string );
src_len = unhexify( src_str, hex_src_string );
/* Test the all-in-one interface */
memset( hash_str, 0x00, sizeof hash_str );
memset( output, 0x00, sizeof output );
md5_hmac( key_str, key_len, src_str, src_len, output );
hexify( hash_str, output, sizeof output );
TEST_ASSERT( strncmp( (char *) hash_str, hex_hash_string, trunc_size * 2 ) == 0 );
/* Also test the "streaming" interface */
memset( hash_str, 0x00, sizeof hash_str );
memset( output, 0x00, sizeof output );
memset( &ctx, 0x00, sizeof ctx );
md5_hmac_starts( &ctx, key_str, key_len );
md5_hmac_update( &ctx, src_str, 0 );
md5_hmac_update( &ctx, src_str, src_len / 2 );
md5_hmac_update( &ctx, src_str + src_len / 2, src_len - src_len / 2 );
md5_hmac_update( &ctx, src_str + src_len, 0 );
md5_hmac_finish( &ctx, output );
hexify( hash_str, output, sizeof output );
TEST_ASSERT( strncmp( (char *) hash_str, hex_hash_string, trunc_size * 2 ) == 0 );
/* Again, to test hmac_reset() */
memset( hash_str, 0x00, sizeof hash_str );
memset( output, 0x00, sizeof output );
md5_hmac_reset( &ctx );
md5_hmac_update( &ctx, src_str, src_len / 2 );
md5_hmac_update( &ctx, src_str + src_len / 2, src_len - src_len / 2 );
md5_hmac_finish( &ctx, output );
hexify( hash_str, output, sizeof output );
TEST_ASSERT( strncmp( (char *) hash_str, hex_hash_string, trunc_size * 2 ) == 0 );
exit:
md5_free( &ctx );
}
/* END_CASE */
/* BEGIN_CASE depends_on:POLARSSL_RIPEMD160_C */
void ripemd160_hmac( int trunc_size, char *hex_key_string, char *hex_src_string,
char *hex_hash_string )
{
unsigned char src_str[200];
unsigned char key_str[200];
unsigned char hash_str[41];
unsigned char output[20];
int key_len, src_len;
ripemd160_context ctx;
memset( src_str, 0x00, sizeof src_str );
memset( key_str, 0x00, sizeof key_str );
ripemd160_init( &ctx );
key_len = unhexify( key_str, hex_key_string );
src_len = unhexify( src_str, hex_src_string );
/* Test the all-in-one interface */
memset( hash_str, 0x00, sizeof hash_str );
memset( output, 0x00, sizeof output );
ripemd160_hmac( key_str, key_len, src_str, src_len, output );
hexify( hash_str, output, sizeof output );
TEST_ASSERT( strncmp( (char *) hash_str, hex_hash_string, trunc_size * 2 ) == 0 );
/* Also test the "streaming" interface */
memset( hash_str, 0x00, sizeof hash_str );
memset( output, 0x00, sizeof output );
memset( &ctx, 0x00, sizeof ctx );
ripemd160_hmac_starts( &ctx, key_str, key_len );
ripemd160_hmac_update( &ctx, src_str, 0 );
ripemd160_hmac_update( &ctx, src_str, src_len / 2 );
ripemd160_hmac_update( &ctx, src_str + src_len / 2, src_len - src_len / 2 );
ripemd160_hmac_update( &ctx, src_str + src_len, 0 );
ripemd160_hmac_finish( &ctx, output );
hexify( hash_str, output, sizeof output );
TEST_ASSERT( strncmp( (char *) hash_str, hex_hash_string, trunc_size * 2 ) == 0 );
/* Again, to test hmac_reset() */
memset( hash_str, 0x00, sizeof hash_str );
memset( output, 0x00, sizeof output );
ripemd160_hmac_reset( &ctx );
ripemd160_hmac_update( &ctx, src_str, src_len / 2 );
ripemd160_hmac_update( &ctx, src_str + src_len / 2, src_len - src_len / 2 );
ripemd160_hmac_finish( &ctx, output );
hexify( hash_str, output, sizeof output );
TEST_ASSERT( strncmp( (char *) hash_str, hex_hash_string, trunc_size * 2 ) == 0 );
exit:
ripemd160_free( &ctx );
}
/* END_CASE */
/* BEGIN_CASE depends_on:POLARSSL_MD2_C:POLARSSL_FS_IO */
void md2_file( char *filename, char *hex_hash_string )
{