1 /*
2 * $FreeBSD$
3 */
4
5 #include <sys/param.h>
6 #include <atf-c.h>
7
8 #include <geom/eli/pkcs5v2.h>
9
10 const struct {
11 char *salt;
12 size_t saltlen;
13 char *passwd;
14 int iterations;
15 char *hmacout;
16 size_t hmaclen;
17 } testdata[] = {
18 #include "testvect.h"
19 };
20
21 ATF_TC_WITHOUT_HEAD(hmactest);
ATF_TC_BODY(hmactest,tc)22 ATF_TC_BODY(hmactest, tc)
23 {
24 size_t i;
25 uint8_t hmacout[64];
26
27 for (i = 0; i < nitems(testdata); i++) {
28 pkcs5v2_genkey(hmacout, testdata[i].hmaclen,
29 (uint8_t *)testdata[i].salt, testdata[i].saltlen,
30 testdata[i].passwd, testdata[i].iterations);
31 ATF_REQUIRE(bcmp(hmacout, testdata[i].hmacout,
32 testdata[i].hmaclen) == 0);
33 }
34 }
35
ATF_TP_ADD_TCS(tp)36 ATF_TP_ADD_TCS(tp)
37 {
38 ATF_TP_ADD_TC(tp, hmactest);
39
40 return (atf_no_error());
41 }
42