Paul Bakker | 367dae4 | 2009-06-28 21:50:27 +0000 | [diff] [blame] | 1 | BEGIN_HEADER |
| 2 | #include <polarssl/md2.h> |
| 3 | #include <polarssl/md4.h> |
| 4 | #include <polarssl/md5.h> |
| 5 | END_HEADER |
| 6 | |
| 7 | BEGIN_CASE |
| 8 | md2_text:text_src_string:hex_hash_string |
| 9 | { |
| 10 | unsigned char src_str[1000]; |
| 11 | unsigned char hash_str[1000]; |
| 12 | unsigned char output[33]; |
| 13 | |
| 14 | memset(src_str, 0x00, 1000); |
| 15 | memset(hash_str, 0x00, 1000); |
| 16 | memset(output, 0x00, 33); |
| 17 | |
| 18 | strcpy( (char *) src_str, {text_src_string} ); |
| 19 | |
| 20 | md2( src_str, strlen( (char *) src_str ), output ); |
| 21 | hexify( hash_str, output, 16 ); |
| 22 | |
| 23 | TEST_ASSERT( strcmp( (char *) hash_str, {hex_hash_string} ) == 0 ); |
| 24 | } |
| 25 | END_CASE |
| 26 | |
| 27 | BEGIN_CASE |
| 28 | md4_text:text_src_string:hex_hash_string |
| 29 | { |
| 30 | unsigned char src_str[1000]; |
| 31 | unsigned char hash_str[1000]; |
| 32 | unsigned char output[33]; |
| 33 | |
| 34 | memset(src_str, 0x00, 1000); |
| 35 | memset(hash_str, 0x00, 1000); |
| 36 | memset(output, 0x00, 33); |
| 37 | |
| 38 | strcpy( (char *) src_str, {text_src_string} ); |
| 39 | |
| 40 | md4( src_str, strlen( (char *) src_str ), output ); |
| 41 | hexify( hash_str, output, 16 ); |
| 42 | |
| 43 | TEST_ASSERT( strcmp( (char *) hash_str, {hex_hash_string} ) == 0 ); |
| 44 | } |
| 45 | END_CASE |
| 46 | |
| 47 | BEGIN_CASE |
| 48 | md5_text:text_src_string:hex_hash_string |
| 49 | { |
| 50 | unsigned char src_str[1000]; |
| 51 | unsigned char hash_str[1000]; |
| 52 | unsigned char output[33]; |
| 53 | |
| 54 | memset(src_str, 0x00, 1000); |
| 55 | memset(hash_str, 0x00, 1000); |
| 56 | memset(output, 0x00, 33); |
| 57 | |
| 58 | strcpy( (char *) src_str, {text_src_string} ); |
| 59 | |
| 60 | md5( src_str, strlen( (char *) src_str ), output ); |
| 61 | hexify( hash_str, output, 16 ); |
| 62 | |
| 63 | TEST_ASSERT( strcmp( (char *) hash_str, {hex_hash_string} ) == 0 ); |
| 64 | } |
| 65 | END_CASE |