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