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