From 026469ffa1e4bad4d90229d66d2f38603a9da55e Mon Sep 17 00:00:00 2001 From: Narrat Date: Sun, 28 Jul 2024 21:09:24 +0200 Subject: [PATCH] extras/tests: add test for argon2 functionality rename original kdf test accordingly to be pbkdf2 related. --- extras/test/30_kdf-pbkdf2.sh | 31 +++++++++++++++++++ extras/test/30_kdf.sh | 58 ------------------------------------ extras/test/31_kdf-argon2.sh | 31 +++++++++++++++++++ extras/test/setup | 1 + 4 files changed, 63 insertions(+), 58 deletions(-) create mode 100644 extras/test/30_kdf-pbkdf2.sh delete mode 100644 extras/test/30_kdf.sh create mode 100644 extras/test/31_kdf-argon2.sh diff --git a/extras/test/30_kdf-pbkdf2.sh b/extras/test/30_kdf-pbkdf2.sh new file mode 100644 index 00000000..a97f4a52 --- /dev/null +++ b/extras/test/30_kdf-pbkdf2.sh @@ -0,0 +1,31 @@ +#!/usr/bin/env zsh + +export test_description="Testing tomb with pbkdf2 KDF key" + +source ./setup + +if test_have_prereq KDF; then + test_export "kdf" + test_expect_success 'Testing pbkdf2 KDF: tomb creation' ' + tt_dig -s 20 && + tt_forge --tomb-pwd $DUMMYPASS --kdf && + print $DUMMYPASS \ + | gpg --batch --passphrase-fd 0 --no-tty --no-options -d $tomb_key \ + | xxd && + tt_lock --tomb-pwd $DUMMYPASS + ' + + test_expect_success 'Testing pbkdf2 KDF: tomb passwd' ' + tt passwd -k $tomb_key \ + --unsafe --tomb-old-pwd $DUMMYPASS --tomb-pwd $DUMMYPASSNEW && + tt passwd -k $tomb_key \ + --unsafe --tomb-old-pwd $DUMMYPASSNEW --tomb-pwd $DUMMYPASS + ' + + test_expect_success 'Testing pbkdf2 KDF: tomb open & close' ' + tt_open --tomb-pwd $DUMMYPASS && + tt_close + ' +fi + +test_done diff --git a/extras/test/30_kdf.sh b/extras/test/30_kdf.sh deleted file mode 100644 index 86a585ff..00000000 --- a/extras/test/30_kdf.sh +++ /dev/null @@ -1,58 +0,0 @@ -#!/usr/bin/env zsh - -export test_description="Testing tomb with KDF keys" - -source ./setup - -if test_have_prereq KDF; then - test_export "kdf" - test_expect_success 'Testing KDF: tomb creation' ' - tt_dig -s 20 && - tt_forge --tomb-pwd $DUMMYPASS --kdf && - print $DUMMYPASS \ - | gpg --batch --passphrase-fd 0 --no-tty --no-options -d $tomb_key \ - | xxd && - tt_lock --tomb-pwd $DUMMYPASS - ' - - test_expect_success 'Testing KDF: tomb passwd' ' - tt passwd -k $tomb_key \ - --unsafe --tomb-old-pwd $DUMMYPASS --tomb-pwd $DUMMYPASSNEW && - tt passwd -k $tomb_key \ - --unsafe --tomb-old-pwd $DUMMYPASSNEW --tomb-pwd $DUMMYPASS - ' - - test_expect_success 'Testing KDF: tomb open & close' ' - tt_open --tomb-pwd $DUMMYPASS && - tt_close - ' -fi - -# clean to avoid overwrite errors -# rm -f "$tomb_key" "$tomb" - -if test_have_prereq ARGON2; then - test_export "argon2" - test_expect_success 'Testing KDF ARGON2: tomb creation' ' - tt_dig -s 20 && - tt_forge --tomb-pwd $DUMMYPASS --kdftype argon2 --kdfmem 18 --kdf 1 && - print $DUMMYPASS \ - | gpg --batch --passphrase-fd 0 --no-tty --no-options -d $tomb_key \ - | xxd && - tt_lock --tomb-pwd $DUMMYPASS - ' - - test_expect_success 'Testing KDF ARGON2: tomb passwd' ' - tt passwd -k $tomb_key \ - --unsafe --tomb-old-pwd $DUMMYPASS --tomb-pwd $DUMMYPASSNEW && - tt passwd -k $tomb_key \ - --unsafe --tomb-old-pwd $DUMMYPASSNEW --tomb-pwd $DUMMYPASS - ' - - test_expect_success 'Testing KDF ARGON2: tomb open & close' ' - tt_open --tomb-pwd $DUMMYPASS && - tt_close - ' -fi - -test_done diff --git a/extras/test/31_kdf-argon2.sh b/extras/test/31_kdf-argon2.sh new file mode 100644 index 00000000..9aa71577 --- /dev/null +++ b/extras/test/31_kdf-argon2.sh @@ -0,0 +1,31 @@ +#!/usr/bin/env zsh + +export test_description="Testing tomb with argon2 KDF key" + +source ./setup + +if test_have_prereq ARGON; then + test_export "argon" + test_expect_success 'Testing argon2 KDF: tomb creation' ' + tt_dig -s 20 && + tt_forge --tomb-pwd $DUMMYPASS --kdf argon2 && + print $DUMMYPASS \ + | gpg --batch --passphrase-fd 0 --no-tty --no-options -d $tomb_key \ + | xxd && + tt_lock --tomb-pwd $DUMMYPASS + ' + + test_expect_success 'Testing argon2 KDF: tomb passwd' ' + tt passwd -k $tomb_key --kdf argon2 \ + --unsafe --tomb-old-pwd $DUMMYPASS --tomb-pwd $DUMMYPASSNEW && + tt passwd -k $tomb_key --kdf argon2 \ + --unsafe --tomb-old-pwd $DUMMYPASSNEW --tomb-pwd $DUMMYPASS + ' + + test_expect_success 'Testing argon2 KDF: tomb open & close' ' + tt_open --tomb-pwd $DUMMYPASS && + tt_close + ' +fi + +test_done diff --git a/extras/test/setup b/extras/test/setup index 91b5f5b7..d9390198 100755 --- a/extras/test/setup +++ b/extras/test/setup @@ -50,6 +50,7 @@ MEDIA="/media" command -v steghide > /dev/null && test_set_prereq STEGHIDE command -v e2fsck resize2fs > /dev/null && test_set_prereq RESIZER command -v tomb-kdb-pbkdf2 > /dev/null && test_set_prereq KDF +command -v argon2 > /dev/null && test_set_prereq ARGON command -v qrencode > /dev/null && test_set_prereq QRENCODE command -v lsof > /dev/null && test_set_prereq LSOF command -v python3 > /dev/null && test_set_prereq PYTHON3