123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206 |
- BEGIN_HEADER
- #include <polarssl/md2.h>
- #include <polarssl/md4.h>
- #include <polarssl/md5.h>
- END_HEADER
- BEGIN_CASE
- md2_text:text_src_string:hex_hash_string
- {
- unsigned char src_str[1000];
- unsigned char hash_str[1000];
- unsigned char output[33];
- memset(src_str, 0x00, 1000);
- memset(hash_str, 0x00, 1000);
- memset(output, 0x00, 33);
- strcpy( (char *) src_str, {text_src_string} );
- md2( src_str, strlen( (char *) src_str ), output );
- hexify( hash_str, output, 16 );
- TEST_ASSERT( strcmp( (char *) hash_str, {hex_hash_string} ) == 0 );
- }
- END_CASE
- BEGIN_CASE
- md4_text:text_src_string:hex_hash_string
- {
- unsigned char src_str[1000];
- unsigned char hash_str[1000];
- unsigned char output[33];
- memset(src_str, 0x00, 1000);
- memset(hash_str, 0x00, 1000);
- memset(output, 0x00, 33);
- strcpy( (char *) src_str, {text_src_string} );
- md4( src_str, strlen( (char *) src_str ), output );
- hexify( hash_str, output, 16 );
- TEST_ASSERT( strcmp( (char *) hash_str, {hex_hash_string} ) == 0 );
- }
- END_CASE
- BEGIN_CASE
- md5_text:text_src_string:hex_hash_string
- {
- unsigned char src_str[1000];
- unsigned char hash_str[1000];
- unsigned char output[33];
- memset(src_str, 0x00, 1000);
- memset(hash_str, 0x00, 1000);
- memset(output, 0x00, 33);
- strcpy( (char *) src_str, {text_src_string} );
- md5( src_str, strlen( (char *) src_str ), output );
- hexify( hash_str, output, 16 );
- TEST_ASSERT( strcmp( (char *) hash_str, {hex_hash_string} ) == 0 );
- }
- END_CASE
- BEGIN_CASE
- md2_hmac:trunc_size:hex_key_string:hex_src_string:hex_hash_string
- {
- unsigned char src_str[10000];
- unsigned char key_str[10000];
- unsigned char hash_str[10000];
- unsigned char output[33];
- int key_len, src_len;
- memset(src_str, 0x00, 10000);
- memset(key_str, 0x00, 10000);
- memset(hash_str, 0x00, 10000);
- memset(output, 0x00, 33);
- key_len = unhexify( key_str, {hex_key_string} );
- src_len = unhexify( src_str, {hex_src_string} );
- md2_hmac( key_str, key_len, src_str, src_len, output );
- hexify( hash_str, output, 16 );
- TEST_ASSERT( strncmp( (char *) hash_str, {hex_hash_string}, {trunc_size} * 2 ) == 0 );
- }
- END_CASE
- BEGIN_CASE
- md4_hmac:trunc_size:hex_key_string:hex_src_string:hex_hash_string
- {
- unsigned char src_str[10000];
- unsigned char key_str[10000];
- unsigned char hash_str[10000];
- unsigned char output[33];
- int key_len, src_len;
- memset(src_str, 0x00, 10000);
- memset(key_str, 0x00, 10000);
- memset(hash_str, 0x00, 10000);
- memset(output, 0x00, 33);
- key_len = unhexify( key_str, {hex_key_string} );
- src_len = unhexify( src_str, {hex_src_string} );
- md4_hmac( key_str, key_len, src_str, src_len, output );
- hexify( hash_str, output, 16 );
- TEST_ASSERT( strncmp( (char *) hash_str, {hex_hash_string}, {trunc_size} * 2 ) == 0 );
- }
- END_CASE
- BEGIN_CASE
- md5_hmac:trunc_size:hex_key_string:hex_src_string:hex_hash_string
- {
- unsigned char src_str[10000];
- unsigned char key_str[10000];
- unsigned char hash_str[10000];
- unsigned char output[33];
- int key_len, src_len;
- memset(src_str, 0x00, 10000);
- memset(key_str, 0x00, 10000);
- memset(hash_str, 0x00, 10000);
- memset(output, 0x00, 33);
- key_len = unhexify( key_str, {hex_key_string} );
- src_len = unhexify( src_str, {hex_src_string} );
- md5_hmac( key_str, key_len, src_str, src_len, output );
- hexify( hash_str, output, 16 );
- TEST_ASSERT( strncmp( (char *) hash_str, {hex_hash_string}, {trunc_size} * 2 ) == 0 );
- }
- END_CASE
- BEGIN_CASE
- md2_file:filename:hex_hash_string
- {
- unsigned char hash_str[65];
- unsigned char output[33];
- memset(hash_str, 0x00, 65);
- memset(output, 0x00, 33);
- md2_file( {filename}, output);
- hexify( hash_str, output, 16 );
- TEST_ASSERT( strcmp( (char *) hash_str, {hex_hash_string} ) == 0 );
- }
- END_CASE
- BEGIN_CASE
- md4_file:filename:hex_hash_string
- {
- unsigned char hash_str[65];
- unsigned char output[33];
- memset(hash_str, 0x00, 65);
- memset(output, 0x00, 33);
- md4_file( {filename}, output);
- hexify( hash_str, output, 16 );
- TEST_ASSERT( strcmp( (char *) hash_str, {hex_hash_string} ) == 0 );
- }
- END_CASE
- BEGIN_CASE
- md5_file:filename:hex_hash_string
- {
- unsigned char hash_str[65];
- unsigned char output[33];
- memset(hash_str, 0x00, 65);
- memset(output, 0x00, 33);
- md5_file( {filename}, output);
- hexify( hash_str, output, 16 );
- TEST_ASSERT( strcmp( (char *) hash_str, {hex_hash_string} ) == 0 );
- }
- END_CASE
- BEGIN_CASE
- md2_selftest:
- {
- TEST_ASSERT( md2_self_test( 0 ) == 0 );
- }
- END_CASE
- BEGIN_CASE
- md4_selftest:
- {
- TEST_ASSERT( md4_self_test( 0 ) == 0 );
- }
- END_CASE
- BEGIN_CASE
- md5_selftest:
- {
- TEST_ASSERT( md5_self_test( 0 ) == 0 );
- }
- END_CASE
|