2013-08-20 11:48:36 +02:00
|
|
|
/* BEGIN_HEADER */
|
2009-06-28 23:50:27 +02:00
|
|
|
#include <polarssl/md2.h>
|
|
|
|
#include <polarssl/md4.h>
|
|
|
|
#include <polarssl/md5.h>
|
2014-01-22 13:35:29 +01:00
|
|
|
#include <polarssl/ripemd160.h>
|
2013-08-20 11:48:36 +02:00
|
|
|
/* END_HEADER */
|
2009-06-28 23:50:27 +02:00
|
|
|
|
2013-08-20 11:48:36 +02:00
|
|
|
/* BEGIN_CASE depends_on:POLARSSL_MD2_C */
|
|
|
|
void md2_text( char *text_src_string, char *hex_hash_string )
|
2009-06-28 23:50:27 +02:00
|
|
|
{
|
2014-01-17 14:23:48 +01:00
|
|
|
unsigned char src_str[100];
|
|
|
|
unsigned char hash_str[33];
|
|
|
|
unsigned char output[16];
|
2009-06-28 23:50:27 +02:00
|
|
|
|
2014-01-17 14:23:48 +01:00
|
|
|
memset( src_str, 0x00, sizeof src_str );
|
|
|
|
memset( hash_str, 0x00, sizeof hash_str );
|
|
|
|
memset( output, 0x00, sizeof output );
|
2009-06-28 23:50:27 +02:00
|
|
|
|
2014-04-17 16:06:37 +02:00
|
|
|
strncpy( (char *) src_str, text_src_string, sizeof(src_str) - 1 );
|
2009-06-28 23:50:27 +02:00
|
|
|
|
|
|
|
md2( src_str, strlen( (char *) src_str ), output );
|
2014-01-17 14:23:48 +01:00
|
|
|
hexify( hash_str, output, sizeof output );
|
2009-06-28 23:50:27 +02:00
|
|
|
|
2013-08-20 11:48:36 +02:00
|
|
|
TEST_ASSERT( strcmp( (char *) hash_str, hex_hash_string ) == 0 );
|
2009-06-28 23:50:27 +02:00
|
|
|
}
|
2013-08-20 11:48:36 +02:00
|
|
|
/* END_CASE */
|
2009-06-28 23:50:27 +02:00
|
|
|
|
2013-08-20 11:48:36 +02:00
|
|
|
/* BEGIN_CASE depends_on:POLARSSL_MD4_C */
|
|
|
|
void md4_text( char *text_src_string, char *hex_hash_string )
|
2009-06-28 23:50:27 +02:00
|
|
|
{
|
2014-01-17 14:23:48 +01:00
|
|
|
unsigned char src_str[100];
|
|
|
|
unsigned char hash_str[33];
|
|
|
|
unsigned char output[16];
|
2009-06-28 23:50:27 +02:00
|
|
|
|
2014-01-17 14:23:48 +01:00
|
|
|
memset( src_str, 0x00, sizeof src_str );
|
|
|
|
memset( hash_str, 0x00, sizeof hash_str );
|
|
|
|
memset( output, 0x00, sizeof output );
|
2009-06-28 23:50:27 +02:00
|
|
|
|
2014-04-17 16:06:37 +02:00
|
|
|
strncpy( (char *) src_str, text_src_string, sizeof(src_str) - 1 );
|
2009-06-28 23:50:27 +02:00
|
|
|
|
|
|
|
md4( src_str, strlen( (char *) src_str ), output );
|
2014-01-17 14:23:48 +01:00
|
|
|
hexify( hash_str, output, sizeof output );
|
2009-06-28 23:50:27 +02:00
|
|
|
|
2013-08-20 11:48:36 +02:00
|
|
|
TEST_ASSERT( strcmp( (char *) hash_str, hex_hash_string ) == 0 );
|
2009-06-28 23:50:27 +02:00
|
|
|
}
|
2013-08-20 11:48:36 +02:00
|
|
|
/* END_CASE */
|
2009-06-28 23:50:27 +02:00
|
|
|
|
2013-08-20 11:48:36 +02:00
|
|
|
/* BEGIN_CASE depends_on:POLARSSL_MD5_C */
|
|
|
|
void md5_text( char *text_src_string, char *hex_hash_string )
|
2009-06-28 23:50:27 +02:00
|
|
|
{
|
2014-01-17 14:23:48 +01:00
|
|
|
unsigned char src_str[100];
|
|
|
|
unsigned char hash_str[33];
|
|
|
|
unsigned char output[16];
|
2009-06-28 23:50:27 +02:00
|
|
|
|
2014-01-17 14:23:48 +01:00
|
|
|
memset( src_str, 0x00, sizeof src_str );
|
|
|
|
memset( hash_str, 0x00, sizeof hash_str );
|
|
|
|
memset( output, 0x00, sizeof output );
|
2009-06-28 23:50:27 +02:00
|
|
|
|
2014-04-17 16:06:37 +02:00
|
|
|
strncpy( (char *) src_str, text_src_string, sizeof(src_str) - 1 );
|
2009-06-28 23:50:27 +02:00
|
|
|
|
|
|
|
md5( src_str, strlen( (char *) src_str ), output );
|
2014-01-17 14:23:48 +01:00
|
|
|
hexify( hash_str, output, sizeof output );
|
2009-06-28 23:50:27 +02:00
|
|
|
|
2013-08-20 11:48:36 +02:00
|
|
|
TEST_ASSERT( strcmp( (char *) hash_str, hex_hash_string ) == 0 );
|
2009-06-28 23:50:27 +02:00
|
|
|
}
|
2013-08-20 11:48:36 +02:00
|
|
|
/* END_CASE */
|
2009-07-06 08:40:23 +02:00
|
|
|
|
2014-01-22 13:35:29 +01:00
|
|
|
/* BEGIN_CASE depends_on:POLARSSL_RIPEMD160_C */
|
|
|
|
void ripemd160_text( char *text_src_string, char *hex_hash_string )
|
2014-01-17 12:42:35 +01:00
|
|
|
{
|
2014-01-17 14:23:48 +01:00
|
|
|
unsigned char src_str[100];
|
2014-01-17 12:42:35 +01:00
|
|
|
unsigned char hash_str[41];
|
|
|
|
unsigned char output[20];
|
|
|
|
|
|
|
|
memset(src_str, 0x00, sizeof src_str);
|
|
|
|
memset(hash_str, 0x00, sizeof hash_str);
|
|
|
|
memset(output, 0x00, sizeof output);
|
|
|
|
|
2014-04-17 16:06:37 +02:00
|
|
|
strncpy( (char *) src_str, text_src_string, sizeof(src_str) - 1 );
|
2014-01-17 12:42:35 +01:00
|
|
|
|
2014-01-22 13:35:29 +01:00
|
|
|
ripemd160( src_str, strlen( (char *) src_str ), output );
|
2014-01-17 12:42:35 +01:00
|
|
|
hexify( hash_str, output, sizeof output );
|
|
|
|
|
|
|
|
TEST_ASSERT( strcmp( (char *) hash_str, hex_hash_string ) == 0 );
|
|
|
|
}
|
|
|
|
/* END_CASE */
|
|
|
|
|
2013-08-20 11:48:36 +02:00
|
|
|
/* 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 )
|
2009-07-06 08:40:23 +02:00
|
|
|
{
|
2014-01-17 14:23:48 +01:00
|
|
|
unsigned char src_str[200];
|
|
|
|
unsigned char key_str[200];
|
|
|
|
unsigned char hash_str[33];
|
|
|
|
unsigned char output[16];
|
2009-07-11 21:15:20 +02:00
|
|
|
int key_len, src_len;
|
2014-03-29 14:05:06 +01:00
|
|
|
md2_context ctx;
|
2009-07-06 08:40:23 +02:00
|
|
|
|
2014-01-17 14:23:48 +01:00
|
|
|
memset( src_str, 0x00, sizeof src_str );
|
|
|
|
memset( key_str, 0x00, sizeof key_str );
|
2014-06-26 12:25:06 +02:00
|
|
|
md2_init( &ctx );
|
2009-07-06 08:40:23 +02:00
|
|
|
|
2013-08-20 11:48:36 +02:00
|
|
|
key_len = unhexify( key_str, hex_key_string );
|
|
|
|
src_len = unhexify( src_str, hex_src_string );
|
2009-07-06 08:40:23 +02:00
|
|
|
|
2014-03-29 14:05:06 +01:00
|
|
|
/* Test the all-in-one interface */
|
|
|
|
memset( hash_str, 0x00, sizeof hash_str );
|
|
|
|
memset( output, 0x00, sizeof output );
|
|
|
|
|
2009-07-06 08:40:23 +02:00
|
|
|
md2_hmac( key_str, key_len, src_str, src_len, output );
|
2014-03-29 14:05:06 +01:00
|
|
|
|
2014-01-17 14:23:48 +01:00
|
|
|
hexify( hash_str, output, sizeof output );
|
2014-03-29 14:05:06 +01:00
|
|
|
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 );
|
2009-07-06 08:40:23 +02:00
|
|
|
|
2014-03-29 14:05:06 +01:00
|
|
|
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 );
|
2013-08-20 11:48:36 +02:00
|
|
|
TEST_ASSERT( strncmp( (char *) hash_str, hex_hash_string, trunc_size * 2 ) == 0 );
|
2014-06-26 12:25:06 +02:00
|
|
|
|
|
|
|
md2_free( &ctx );
|
2009-07-06 08:40:23 +02:00
|
|
|
}
|
2013-08-20 11:48:36 +02:00
|
|
|
/* END_CASE */
|
2009-07-06 08:40:23 +02:00
|
|
|
|
2013-08-20 11:48:36 +02:00
|
|
|
/* 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 )
|
2009-07-06 08:40:23 +02:00
|
|
|
{
|
2014-01-17 14:23:48 +01:00
|
|
|
unsigned char src_str[200];
|
|
|
|
unsigned char key_str[200];
|
|
|
|
unsigned char hash_str[33];
|
|
|
|
unsigned char output[16];
|
2009-07-11 21:15:20 +02:00
|
|
|
int key_len, src_len;
|
2014-03-29 14:05:06 +01:00
|
|
|
md4_context ctx;
|
2009-07-06 08:40:23 +02:00
|
|
|
|
2014-01-17 14:23:48 +01:00
|
|
|
memset( src_str, 0x00, sizeof src_str );
|
|
|
|
memset( key_str, 0x00, sizeof key_str );
|
2014-06-26 12:25:06 +02:00
|
|
|
md4_init( &ctx );
|
2009-07-06 08:40:23 +02:00
|
|
|
|
2013-08-20 11:48:36 +02:00
|
|
|
key_len = unhexify( key_str, hex_key_string );
|
|
|
|
src_len = unhexify( src_str, hex_src_string );
|
2009-07-06 08:40:23 +02:00
|
|
|
|
2014-03-29 14:05:06 +01:00
|
|
|
/* Test the all-in-one interface */
|
|
|
|
memset( hash_str, 0x00, sizeof hash_str );
|
|
|
|
memset( output, 0x00, sizeof output );
|
|
|
|
|
2009-07-06 08:40:23 +02:00
|
|
|
md4_hmac( key_str, key_len, src_str, src_len, output );
|
2014-03-29 14:05:06 +01:00
|
|
|
|
2014-01-17 14:23:48 +01:00
|
|
|
hexify( hash_str, output, sizeof output );
|
2014-03-29 14:05:06 +01:00
|
|
|
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 );
|
2009-07-06 08:40:23 +02:00
|
|
|
|
2014-03-29 14:05:06 +01:00
|
|
|
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 );
|
2013-08-20 11:48:36 +02:00
|
|
|
TEST_ASSERT( strncmp( (char *) hash_str, hex_hash_string, trunc_size * 2 ) == 0 );
|
2014-06-26 12:25:06 +02:00
|
|
|
|
|
|
|
md4_free( &ctx );
|
2009-07-06 08:40:23 +02:00
|
|
|
}
|
2013-08-20 11:48:36 +02:00
|
|
|
/* END_CASE */
|
2009-07-06 08:40:23 +02:00
|
|
|
|
2013-08-20 11:48:36 +02:00
|
|
|
/* 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 )
|
2009-07-06 08:40:23 +02:00
|
|
|
{
|
2014-01-17 14:23:48 +01:00
|
|
|
unsigned char src_str[200];
|
|
|
|
unsigned char key_str[200];
|
|
|
|
unsigned char hash_str[33];
|
|
|
|
unsigned char output[16];
|
2009-07-11 21:15:20 +02:00
|
|
|
int key_len, src_len;
|
2014-03-29 14:05:06 +01:00
|
|
|
md5_context ctx;
|
2009-07-06 08:40:23 +02:00
|
|
|
|
2014-01-17 14:23:48 +01:00
|
|
|
memset( src_str, 0x00, sizeof src_str );
|
|
|
|
memset( key_str, 0x00, sizeof key_str );
|
2014-06-26 12:25:06 +02:00
|
|
|
md5_init( &ctx );
|
2009-07-06 08:40:23 +02:00
|
|
|
|
2013-08-20 11:48:36 +02:00
|
|
|
key_len = unhexify( key_str, hex_key_string );
|
|
|
|
src_len = unhexify( src_str, hex_src_string );
|
2009-07-06 08:40:23 +02:00
|
|
|
|
2014-03-29 14:05:06 +01:00
|
|
|
/* Test the all-in-one interface */
|
|
|
|
memset( hash_str, 0x00, sizeof hash_str );
|
|
|
|
memset( output, 0x00, sizeof output );
|
|
|
|
|
2009-07-06 08:40:23 +02:00
|
|
|
md5_hmac( key_str, key_len, src_str, src_len, output );
|
2014-03-29 14:05:06 +01:00
|
|
|
|
2014-01-17 14:23:48 +01:00
|
|
|
hexify( hash_str, output, sizeof output );
|
2014-03-29 14:05:06 +01:00
|
|
|
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 );
|
2009-07-06 08:40:23 +02:00
|
|
|
|
2014-03-29 14:05:06 +01:00
|
|
|
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 );
|
2013-08-20 11:48:36 +02:00
|
|
|
TEST_ASSERT( strncmp( (char *) hash_str, hex_hash_string, trunc_size * 2 ) == 0 );
|
2014-06-26 12:25:06 +02:00
|
|
|
|
|
|
|
md5_free( &ctx );
|
2009-07-06 08:40:23 +02:00
|
|
|
}
|
2013-08-20 11:48:36 +02:00
|
|
|
/* END_CASE */
|
2009-07-06 08:40:23 +02:00
|
|
|
|
2014-01-22 13:35:29 +01:00
|
|
|
/* 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 )
|
2014-01-17 19:49:15 +01:00
|
|
|
{
|
|
|
|
unsigned char src_str[200];
|
|
|
|
unsigned char key_str[200];
|
|
|
|
unsigned char hash_str[41];
|
|
|
|
unsigned char output[20];
|
|
|
|
int key_len, src_len;
|
2014-03-29 14:05:06 +01:00
|
|
|
ripemd160_context ctx;
|
2014-01-17 19:49:15 +01:00
|
|
|
|
|
|
|
memset( src_str, 0x00, sizeof src_str );
|
|
|
|
memset( key_str, 0x00, sizeof key_str );
|
2014-06-26 12:25:06 +02:00
|
|
|
ripemd160_init( &ctx );
|
2014-01-17 19:49:15 +01:00
|
|
|
|
|
|
|
key_len = unhexify( key_str, hex_key_string );
|
|
|
|
src_len = unhexify( src_str, hex_src_string );
|
|
|
|
|
2014-03-29 14:05:06 +01:00
|
|
|
/* Test the all-in-one interface */
|
|
|
|
memset( hash_str, 0x00, sizeof hash_str );
|
|
|
|
memset( output, 0x00, sizeof output );
|
|
|
|
|
2014-01-22 13:35:29 +01:00
|
|
|
ripemd160_hmac( key_str, key_len, src_str, src_len, output );
|
2014-03-29 14:05:06 +01:00
|
|
|
|
2014-01-17 19:49:15 +01:00
|
|
|
hexify( hash_str, output, sizeof output );
|
2014-03-29 14:05:06 +01:00
|
|
|
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 );
|
2014-01-17 19:49:15 +01:00
|
|
|
|
2014-03-29 14:05:06 +01:00
|
|
|
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 );
|
2014-01-17 19:49:15 +01:00
|
|
|
TEST_ASSERT( strncmp( (char *) hash_str, hex_hash_string, trunc_size * 2 ) == 0 );
|
2014-06-26 12:25:06 +02:00
|
|
|
|
|
|
|
ripemd160_free( &ctx );
|
2014-01-17 19:49:15 +01:00
|
|
|
}
|
|
|
|
/* END_CASE */
|
|
|
|
|
2013-09-15 15:20:37 +02:00
|
|
|
/* BEGIN_CASE depends_on:POLARSSL_MD2_C:POLARSSL_FS_IO */
|
2013-08-20 11:48:36 +02:00
|
|
|
void md2_file( char *filename, char *hex_hash_string )
|
2009-07-06 08:40:23 +02:00
|
|
|
{
|
2014-01-17 14:23:48 +01:00
|
|
|
unsigned char hash_str[33];
|
|
|
|
unsigned char output[16];
|
2009-07-06 08:40:23 +02:00
|
|
|
|
2014-01-17 14:23:48 +01:00
|
|
|
memset( hash_str, 0x00, sizeof hash_str );
|
|
|
|
memset( output, 0x00, sizeof output );
|
2009-07-06 08:40:23 +02:00
|
|
|
|
2013-08-20 11:48:36 +02:00
|
|
|
md2_file( filename, output);
|
2014-01-17 14:23:48 +01:00
|
|
|
hexify( hash_str, output, sizeof output );
|
2009-07-06 08:40:23 +02:00
|
|
|
|
2013-08-20 11:48:36 +02:00
|
|
|
TEST_ASSERT( strcmp( (char *) hash_str, hex_hash_string ) == 0 );
|
2009-07-06 08:40:23 +02:00
|
|
|
}
|
2013-08-20 11:48:36 +02:00
|
|
|
/* END_CASE */
|
2009-07-06 08:40:23 +02:00
|
|
|
|
2013-09-15 15:20:37 +02:00
|
|
|
/* BEGIN_CASE depends_on:POLARSSL_MD4_C:POLARSSL_FS_IO */
|
2013-08-20 11:48:36 +02:00
|
|
|
void md4_file( char *filename, char *hex_hash_string )
|
2009-07-06 08:40:23 +02:00
|
|
|
{
|
2014-01-17 14:23:48 +01:00
|
|
|
unsigned char hash_str[33];
|
|
|
|
unsigned char output[16];
|
2009-07-06 08:40:23 +02:00
|
|
|
|
2014-01-17 14:23:48 +01:00
|
|
|
memset( hash_str, 0x00, sizeof hash_str );
|
|
|
|
memset( output, 0x00, sizeof output );
|
2009-07-06 08:40:23 +02:00
|
|
|
|
2013-08-20 11:48:36 +02:00
|
|
|
md4_file( filename, output);
|
2014-01-17 14:23:48 +01:00
|
|
|
hexify( hash_str, output, sizeof output );
|
2009-07-06 08:40:23 +02:00
|
|
|
|
2013-08-20 11:48:36 +02:00
|
|
|
TEST_ASSERT( strcmp( (char *) hash_str, hex_hash_string ) == 0 );
|
2009-07-06 08:40:23 +02:00
|
|
|
}
|
2013-08-20 11:48:36 +02:00
|
|
|
/* END_CASE */
|
2009-07-06 08:40:23 +02:00
|
|
|
|
2013-09-15 15:20:37 +02:00
|
|
|
/* BEGIN_CASE depends_on:POLARSSL_MD5_C:POLARSSL_FS_IO */
|
2013-08-20 11:48:36 +02:00
|
|
|
void md5_file( char *filename, char *hex_hash_string )
|
2009-07-06 08:40:23 +02:00
|
|
|
{
|
2014-01-17 14:23:48 +01:00
|
|
|
unsigned char hash_str[33];
|
|
|
|
unsigned char output[16];
|
2009-07-06 08:40:23 +02:00
|
|
|
|
2014-01-17 14:23:48 +01:00
|
|
|
memset( hash_str, 0x00, sizeof hash_str );
|
|
|
|
memset( output, 0x00, sizeof output );
|
2009-07-06 08:40:23 +02:00
|
|
|
|
2013-08-20 11:48:36 +02:00
|
|
|
md5_file( filename, output);
|
2014-01-17 14:23:48 +01:00
|
|
|
hexify( hash_str, output, sizeof output );
|
2009-07-06 08:40:23 +02:00
|
|
|
|
2013-08-20 11:48:36 +02:00
|
|
|
TEST_ASSERT( strcmp( (char *) hash_str, hex_hash_string ) == 0 );
|
2009-07-06 08:40:23 +02:00
|
|
|
}
|
2013-08-20 11:48:36 +02:00
|
|
|
/* END_CASE */
|
2009-07-06 08:40:23 +02:00
|
|
|
|
2014-01-22 13:35:29 +01:00
|
|
|
/* BEGIN_CASE depends_on:POLARSSL_RIPEMD160_C:POLARSSL_FS_IO */
|
|
|
|
void ripemd160_file( char *filename, char *hex_hash_string )
|
2014-01-17 12:42:35 +01:00
|
|
|
{
|
|
|
|
unsigned char hash_str[41];
|
|
|
|
unsigned char output[20];
|
|
|
|
|
|
|
|
memset(hash_str, 0x00, sizeof hash_str );
|
|
|
|
memset(output, 0x00, sizeof output );
|
|
|
|
|
2014-01-22 13:35:29 +01:00
|
|
|
ripemd160_file( filename, output);
|
2014-01-17 14:23:48 +01:00
|
|
|
hexify( hash_str, output, sizeof output );
|
2014-01-17 12:42:35 +01:00
|
|
|
|
|
|
|
TEST_ASSERT( strcmp( (char *) hash_str, hex_hash_string ) == 0 );
|
|
|
|
}
|
|
|
|
/* END_CASE */
|
|
|
|
|
2013-10-10 12:48:03 +02:00
|
|
|
/* BEGIN_CASE depends_on:POLARSSL_MD2_C:POLARSSL_SELF_TEST */
|
2013-08-20 11:48:36 +02:00
|
|
|
void md2_selftest()
|
2009-07-06 08:40:23 +02:00
|
|
|
{
|
|
|
|
TEST_ASSERT( md2_self_test( 0 ) == 0 );
|
|
|
|
}
|
2013-08-20 11:48:36 +02:00
|
|
|
/* END_CASE */
|
2009-07-06 08:40:23 +02:00
|
|
|
|
2013-10-10 12:48:03 +02:00
|
|
|
/* BEGIN_CASE depends_on:POLARSSL_MD4_C:POLARSSL_SELF_TEST */
|
2013-08-20 11:48:36 +02:00
|
|
|
void md4_selftest()
|
2009-07-06 08:40:23 +02:00
|
|
|
{
|
|
|
|
TEST_ASSERT( md4_self_test( 0 ) == 0 );
|
|
|
|
}
|
2013-08-20 11:48:36 +02:00
|
|
|
/* END_CASE */
|
2009-07-06 08:40:23 +02:00
|
|
|
|
2013-10-10 12:48:03 +02:00
|
|
|
/* BEGIN_CASE depends_on:POLARSSL_MD5_C:POLARSSL_SELF_TEST */
|
2013-08-20 11:48:36 +02:00
|
|
|
void md5_selftest()
|
2009-07-06 08:40:23 +02:00
|
|
|
{
|
|
|
|
TEST_ASSERT( md5_self_test( 0 ) == 0 );
|
|
|
|
}
|
2013-08-20 11:48:36 +02:00
|
|
|
/* END_CASE */
|
2014-01-17 12:42:35 +01:00
|
|
|
|
2014-01-22 13:35:29 +01:00
|
|
|
/* BEGIN_CASE depends_on:POLARSSL_RIPEMD160_C:POLARSSL_SELF_TEST */
|
|
|
|
void ripemd160_selftest()
|
2014-01-17 12:42:35 +01:00
|
|
|
{
|
2014-01-22 13:35:29 +01:00
|
|
|
TEST_ASSERT( ripemd160_self_test( 0 ) == 0 );
|
2014-01-17 12:42:35 +01:00
|
|
|
}
|
|
|
|
/* END_CASE */
|