Remove tag files.
[bertos.git] / bertos / sec / hash / sha1_test.c
1
2 #include <cfg/test.h>
3 #include <cfg/debug.h>
4
5 #include "sha1.h"
6 #include <string.h>
7
8 int SHA1_testSetup(void)
9 {
10         kdbg_init();
11         return 0;
12 }
13
14 int SHA1_testTearDown(void)
15 {
16         return 0;
17 }
18
19 int SHA1_testRun(void)
20 {
21         int i;
22         SHA1_Context context;
23         SHA1_init(&context);
24
25         hash_begin(&context.h);
26         hash_update(&context.h, "abc", 3);
27         ASSERT(memcmp(hash_final(&context.h), "\xA9\x99\x3E\x36\x47\x06\x81\x6A\xBA\x3E\x25\x71\x78\x50\xC2\x6C\x9C\xD0\xD8\x9D", 20) == 0);
28
29         hash_begin(&context.h);
30         hash_update(&context.h, "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq", 56);
31         ASSERT(memcmp(hash_final(&context.h), "\x84\x98\x3E\x44\x1C\x3B\xD2\x6E\xBA\xAE\x4A\xA1\xF9\x51\x29\xE5\xE5\x46\x70\xF1", 20) == 0);
32
33         hash_begin(&context.h);
34         for (i = 0; i < 1000000; i++)
35                 hash_update(&context.h, "a", 1);
36         ASSERT(memcmp(hash_final(&context.h), "\x34\xAA\x97\x3C\xD4\xC4\xDA\xA4\xF6\x1E\xEB\x2B\xDB\xAD\x27\x31\x65\x34\x01\x6F", 20) == 0);
37         
38         return 0;
39 }
40
41 TEST_MAIN(SHA1);