Some fix to compile run test check.
[bertos.git] / bertos / sec / hash / ripemd_test.c
1
2 #include "ripemd.h"
3
4 #include <cfg/test.h>
5 #include <cfg/debug.h>
6
7 #include <string.h>
8
9 int RIPEMD_testSetup(void)
10 {
11         kdbg_init();
12         return 0;
13 }
14
15 int RIPEMD_testTearDown(void)
16 {
17         return 0;
18 }
19
20 int RIPEMD_testRun(void)
21 {
22         Hash *h = RIPEMD_stackinit();
23
24         hash_begin(h);
25         ASSERT(memcmp(hash_final(h), "\x9c\x11\x85\xa5\xc5\xe9\xfc\x54\x61\x28\x08\x97\x7e\xe8\xf5\x48\xb2\x25\x8d\x31", 20) == 0);
26
27         hash_begin(h);
28         hash_update(h, "a", 1);
29         ASSERT(memcmp(hash_final(h), "\x0b\xdc\x9d\x2d\x25\x6b\x3e\xe9\xda\xae\x34\x7b\xe6\xf4\xdc\x83\x5a\x46\x7f\xfe", 20) == 0);
30         
31         hash_begin(h);
32         hash_update(h, "abc", 3);
33         ASSERT(memcmp(hash_final(h), "\x8e\xb2\x08\xf7\xe0\x5d\x98\x7a\x9b\x04\x4a\x8e\x98\xc6\xb0\x87\xf1\x5a\x0b\xfc", 20) == 0);
34
35         hash_begin(h);
36         hash_update(h, "message digest", 14);
37         ASSERT(memcmp(hash_final(h), "\x5d\x06\x89\xef\x49\xd2\xfa\xe5\x72\xb8\x81\xb1\x23\xa8\x5f\xfa\x21\x59\x5f\x36", 20) == 0);
38
39         hash_begin(h);
40         hash_update(h, "abcdefghijklmnopqrstuvwxyz", 26);
41         ASSERT(memcmp(hash_final(h), "\xf7\x1c\x27\x10\x9c\x69\x2c\x1b\x56\xbb\xdc\xeb\x5b\x9d\x28\x65\xb3\x70\x8d\xbc", 20) == 0);
42
43         hash_begin(h);
44         hash_update(h, "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq", 56);
45         ASSERT(memcmp(hash_final(h), "\x12\xa0\x53\x38\x4a\x9c\x0c\x88\xe4\x05\xa0\x6c\x27\xdc\xf4\x9a\xda\x62\xeb\x2b", 20) == 0);
46
47         hash_begin(h);
48         hash_update(h, "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", 62);
49         ASSERT(memcmp(hash_final(h), "\xb0\xe2\x0b\x6e\x31\x16\x64\x02\x86\xed\x3a\x87\xa5\x71\x30\x79\xb2\x1f\x51\x89", 20) == 0);
50
51         hash_begin(h);
52         for (int i=0;i<8;++i)
53                 hash_update(h, "1234567890", 10);
54         ASSERT(memcmp(hash_final(h), "\x9b\x75\x2e\x45\x57\x3d\x4b\x39\xf4\xdb\xd3\x32\x3c\xab\x82\xbf\x63\x32\x6b\xfb", 20) == 0);
55
56         hash_begin(h);
57         for (int i=0;i<1000000;++i)
58                 hash_update(h, "a", 1);
59         ASSERT(memcmp(hash_final(h), "\x52\x78\x32\x43\xc1\x69\x7b\xdb\xe1\x6d\x37\xf9\x7f\x68\xf0\x83\x25\xdc\x15\x28", 20) == 0);
60
61         return 0;
62 }
63
64 TEST_MAIN(RIPEMD);