diff options
Diffstat (limited to 'tests/sys/geom/class/eli/hmac_test.c')
-rw-r--r-- | tests/sys/geom/class/eli/hmac_test.c | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/tests/sys/geom/class/eli/hmac_test.c b/tests/sys/geom/class/eli/hmac_test.c new file mode 100644 index 000000000000..6e22c23fb41b --- /dev/null +++ b/tests/sys/geom/class/eli/hmac_test.c @@ -0,0 +1,40 @@ +/* + */ + +#include <sys/param.h> +#include <atf-c.h> + +#include <geom/eli/pkcs5v2.h> + +const struct { + char *salt; + size_t saltlen; + char *passwd; + int iterations; + char *hmacout; + size_t hmaclen; +} testdata[] = { +#include "testvect.h" +}; + +ATF_TC_WITHOUT_HEAD(hmactest); +ATF_TC_BODY(hmactest, tc) +{ + size_t i; + uint8_t hmacout[64]; + + for (i = 0; i < nitems(testdata); i++) { + pkcs5v2_genkey(hmacout, testdata[i].hmaclen, + (uint8_t *)testdata[i].salt, testdata[i].saltlen, + testdata[i].passwd, testdata[i].iterations); + ATF_REQUIRE(bcmp(hmacout, testdata[i].hmacout, + testdata[i].hmaclen) == 0); + } +} + +ATF_TP_ADD_TCS(tp) +{ + ATF_TP_ADD_TC(tp, hmactest); + + return (atf_no_error()); +} |