blob: 62046d72332730448c277d650bc16d829e05d1eb [file] [log] [blame]
Paul Bakker367dae42009-06-28 21:50:27 +00001BEGIN_HEADER
2#include <polarssl/md2.h>
3#include <polarssl/md4.h>
4#include <polarssl/md5.h>
5END_HEADER
6
7BEGIN_CASE
8md2_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}
25END_CASE
26
27BEGIN_CASE
28md4_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}
45END_CASE
46
47BEGIN_CASE
48md5_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}
65END_CASE