SEC: add implementations for PBKDF1 and PBKDF2.
[bertos.git] / bertos / sec / kdf / pbkdf1_test.c
1 #include <string.h>
2 #include <cpu/detect.h>
3 #include <cfg/test.h>
4 #include <cfg/debug.h>
5 #include <sec/mac/hmac.h>
6 #include <sec/hash/sha1.h>
7 #include <sec/kdf/PBKDF1.h>
8
9 int PBKDF1_testSetup(void)
10 {
11         kdbg_init();
12         return 0;
13 }
14
15 int PBKDF1_testTearDown(void)
16 {
17         return 0;
18 }
19
20 int PBKDF1_testRun(void)
21 {
22         Kdf *kdf = PBKDF1_stackinit(SHA1_stackinit());
23
24         uint8_t res[16];
25         
26         PBKDF1_set_iterations(kdf, 1000);
27         kdf_begin(kdf, "password", 8, (const uint8_t*)"\x78\x57\x8E\x5A\x5D\x63\xCB\x06", 8);
28         kdf_read(kdf, res, 16);
29         ASSERT(memcmp(res, "\xDC\x19\x84\x7E\x05\xC6\x4D\x2F\xAF\x10\xEB\xFB\x4A\x3D\x2A\x20", 16) == 0);
30         
31         return 0;
32 }
33
34 TEST_MAIN(PBKDF1);