multof assert fix
[rofl0r-kripto.git] / test / pbkdf2.c
blobe49fa929f3d490a8faa4cc82d3fc3287750c63f9
1 /*
2 * Copyright (C) 2013 Gregor Pintar <grpintar@gmail.com>
4 * Permission is granted to deal in this work without any restriction,
5 * including unlimited rights to use, publicly perform, publish,
6 * reproduce, relicence, modify, merge, and/or distribute in any form,
7 * for any purpose, with or without fee, and by any means.
9 * This work is provided "AS IS" and WITHOUT WARRANTY of any kind,
10 * to the utmost extent permitted by applicable law. In no event
11 * shall a licensor, author or contributor be held liable for any
12 * issues arising in any way out of dealing in the work.
15 #include <stdint.h>
16 #include <stdio.h>
18 #include <kripto/mac/hmac.h>
19 #include <kripto/hash/sha1.h>
20 #include <kripto/pbkdf2.h>
22 int main(void)
24 const uint8_t out[20] =
26 0x4B, 0x00, 0x79, 0x01,
27 0xB7, 0x65, 0x48, 0x9A,
28 0xBE, 0xAD, 0x49, 0xD9,
29 0x26, 0xF7, 0x21, 0xD0,
30 0x65, 0xA4, 0x29, 0xC1
32 uint8_t buf[20];
33 unsigned int i;
35 if(kripto_pbkdf2
37 kripto_mac_hmac,
38 kripto_hash_sha1,
40 4096,
41 "password",
43 "salt",
45 buf,
49 perror("kripto_pbkdf2() returned error");
50 return -1;
53 for(i = 0; i < 20; i++) if(buf[i] != out[i])
55 fputs("kripto_pbkdf2: FAIL\n", stderr);
56 return -1;
59 puts("kripto_pbkdf2: OK");
60 return 0;