status update, probably last commit
[rofl0r-kripto.git] / test / pbkdf2.c
blob5704211addef8f18a6b95823cff2302b9a8d3fac
1 /*
2 * Written in 2013 by Gregor Pintar <grpintar@gmail.com>
4 * To the extent possible under law, the author(s) have dedicated
5 * all copyright and related and neighboring rights to this software
6 * to the public domain worldwide.
7 *
8 * This software is distributed without any warranty.
10 * You should have received a copy of the CC0 Public Domain Dedication.
11 * If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
14 #include <stdint.h>
15 #include <stdio.h>
17 #include <kripto/mac/hmac.h>
18 #include <kripto/hash/sha1.h>
19 #include <kripto/pbkdf2.h>
21 int main(void)
23 const uint8_t out[20] =
25 0x4B, 0x00, 0x79, 0x01,
26 0xB7, 0x65, 0x48, 0x9A,
27 0xBE, 0xAD, 0x49, 0xD9,
28 0x26, 0xF7, 0x21, 0xD0,
29 0x65, 0xA4, 0x29, 0xC1
31 uint8_t buf[20];
32 unsigned int i;
34 if(kripto_pbkdf2
36 kripto_mac_hmac,
37 kripto_hash_sha1,
39 4096,
40 "password",
42 "salt",
44 buf,
48 perror("kripto_pbkdf2() returned error");
49 return -1;
52 for(i = 0; i < 20; i++) if(buf[i] != out[i])
54 fputs("kripto_pbkdf2: FAIL\n", stderr);
55 return -1;
58 puts("kripto_pbkdf2: OK");
59 return 0;