adding argon2 tests

This commit is contained in:
jhigh 2019-10-14 03:47:19 +00:00
parent 85f5895969
commit 499c4e53b1
4 changed files with 91 additions and 1 deletions

View File

@ -1,4 +1,4 @@
# $NetBSD: Makefile,v 1.28 2019/10/05 18:06:16 jhigh Exp $
# $NetBSD: Makefile,v 1.29 2019/10/14 03:47:19 jhigh Exp $
#
.include <bsd.own.mk>
@ -15,4 +15,9 @@ TESTS_SUBDIRS= awk basename bzip2 cc cmp config cut \
TESTS_SUBDIRS+= c++
.endif
.if (defined(MKARGON2) && ${MKARGON2} != "no")
TESTS_SUBDIRS+= argon2
.endif
.include <bsd.test.mk>

View File

@ -0,0 +1,7 @@
Content-Type: application/X-atf-atffile; version="1"
# Automatically generated by bsd.test.mk.
prop: test-suite = "NetBSD"
tp: t_argon2

View File

@ -0,0 +1,8 @@
# $NetBSD: Makefile,v 1.1 2019/10/14 03:47:20 jhigh Exp $
.include <bsd.own.mk>
TESTSDIR= ${TESTSBASE}/usr.bin/argon2
TESTS_SH= t_argon2
.include <bsd.test.mk>

View File

@ -0,0 +1,70 @@
atf_test_case argon2_argon2id
argon2_argon2id_head() {
atf_set "descr" "ATF test for argon2 argon2id variant"
}
argon2_argon2id_body() {
atf_check -s exit:0 -o match:"^\\\$argon2id\\\$" -x \
'echo -n 'password' | argon2 somesalt -e -id'
}
atf_test_case argon2_argon2i
argon2_argon2i_head() {
atf_set "descr" "ATF test for argon2 argon2i variant"
}
argon2_argon2i_body() {
atf_check -s exit:0 -o match:"^\\\$argon2i\\\$" -x \
'echo -n 'password' | argon2 somesalt -e -i'
}
atf_test_case argon2_argon2d
argon2_argon2d_head() {
atf_set "descr" "ATF test for argon2 argon2d variant"
}
argon2_argon2d_body() {
atf_check -s exit:0 -o match:"^\\\$argon2d\\\$" -x \
'echo -n 'password' | argon2 somesalt -e -d'
}
atf_test_case argon2_argon2id_k2096_p2_t3
argon2_argon2id_k2096_p2_head() {
atf_set "descr" "ATF test for argon2 argon2id,k=2096,p=2,t=3 "
}
argon2_argon2id_k2096_p2_t3_body() {
atf_check -s exit:0 -o match:"^\\\$argon2id\\\$v=19\\\$m=2096,t=3,p=2" -x \
'echo -n 'password' | argon2 somesalt -e -id -k 2096 -p 2 -t 3'
}
atf_test_case argon2_argon2i_k2096_p1_t4
argon2_argon2i_k2096_p1_t4_head() {
atf_set "descr" "ATF test for argon2 argon2i,k=2096,p=1,t=4 "
}
argon2_argon2i_k2096_p1_t4_body() {
atf_check -s exit:0 -o match:"^\\\$argon2i\\\$v=19\\\$m=2096,t=4,p=1" -x \
'echo -n 'password' | argon2 somesalt -e -i -k 2096 -p 1 -t 4'
}
atf_test_case argon2_argon2d_k2096_p2_t4
argon2_argon2d_k2096_p2_t4_head() {
atf_set "descr" "ATF test for argon2 argon2d,k=2096,p=2,t=4"
}
argon2_argon2d_k2096_p2_t4_body() {
atf_check -s exit:0 -o match:"^\\\$argon2d\\\$v=19\\\$m=2096,t=4,p=2" -x \
'echo -n 'password' | argon2 somesalt -e -d -k 2096 -p 2 -t 4'
}
atf_init_test_cases()
{
atf_add_test_case argon2_argon2id
atf_add_test_case argon2_argon2i
atf_add_test_case argon2_argon2d
atf_add_test_case argon2_argon2id_k2096_p2_t3
atf_add_test_case argon2_argon2i_k2096_p1_t4
atf_add_test_case argon2_argon2d_k2096_p2_t4
}