tests: use crypto check tool in tests

This commit is contained in:
Milan Broz
2024-07-09 21:23:57 +02:00
parent a9617c7c4a
commit 7fa19da140
3 changed files with 17 additions and 11 deletions

View File

@@ -6,6 +6,8 @@ TST_DIR=luks1-images
MAP=luks1tst MAP=luks1tst
KEYFILE=keyfile1 KEYFILE=keyfile1
CRYPTOCHECK=./crypto-check
if [ -n "$CRYPTSETUP_TESTS_RUN_IN_MESON" ]; then if [ -n "$CRYPTSETUP_TESTS_RUN_IN_MESON" ]; then
CRYPTSETUP_VALGRIND=$CRYPTSETUP CRYPTSETUP_VALGRIND=$CRYPTSETUP
else else
@@ -61,26 +63,25 @@ function remove_imgs()
function test_one() function test_one()
{ {
$CRYPTSETUP benchmark -c "$1" -s "$2" | grep -v "#" || remove_imgs $1 $CRYPTOCHECK cipher $1 $2 $3 || remove_imgs "$1-$2"
} }
function test_required() function test_required()
{ {
echo "REQUIRED KDF TEST" echo "REQUIRED KDF TEST"
$CRYPTSETUP benchmark -h whirlpool | grep "N/A" && remove_imgs whirlpool $CRYPTOCHECK hash whirlpool || remove_imgs whirlpool
echo "REQUIRED CIPHERS TEST" echo "REQUIRED CIPHERS TEST"
echo "# Algorithm | Key | Encryption | Decryption" test_one aes xts 256
test_one twofish xts 256
test_one aes-xts 256 test_one serpent xts 256
test_one twofish-xts 256 test_one aes cbc 256
test_one serpent-xts 256 test_one aes lrw 256
test_one aes-cbc 256
test_one aes-lrw 256
} }
export LANG=C export LANG=C
[ ! -x "$CRYPTSETUP" ] && skip "Cannot find $CRYPTSETUP, test skipped." [ ! -x "$CRYPTSETUP" ] && skip "Cannot find $CRYPTSETUP, test skipped."
[ ! -x "$CRYPTOCHECK" ] && skip "Cannot find $CRYPTOCHECK, test skipped."
command -v blkid >/dev/null || skip "blkid tool required, test skipped." command -v blkid >/dev/null || skip "blkid tool required, test skipped."
[ -n "$VALG" ] && valgrind_setup && CRYPTSETUP=valgrind_run [ -n "$VALG" ] && valgrind_setup && CRYPTSETUP=valgrind_run
[ ! -d $TST_DIR ] && tar xJf $srcdir/luks1-images.tar.xz --no-same-owner [ ! -d $TST_DIR ] && tar xJf $srcdir/luks1-images.tar.xz --no-same-owner

View File

@@ -365,6 +365,7 @@ if get_option('cryptsetup')
is_parallel: false, is_parallel: false,
depends: [ depends: [
cryptsetup, cryptsetup,
crypto_check,
]) ])
test('luks1-compat-test', test('luks1-compat-test',
find_program('./luks1-compat-test'), find_program('./luks1-compat-test'),
@@ -373,6 +374,7 @@ if get_option('cryptsetup')
is_parallel: false, is_parallel: false,
depends: [ depends: [
cryptsetup, cryptsetup,
crypto_check,
]) ])
test('device-test', test('device-test',
find_program('./device-test'), find_program('./device-test'),

View File

@@ -13,6 +13,8 @@ PIM=1234
LOOP_SYS="" LOOP_SYS=""
PART_IMG=tctst-part-img PART_IMG=tctst-part-img
CRYPTOCHECK=./crypto-check
if [ -n "$CRYPTSETUP_TESTS_RUN_IN_MESON" ]; then if [ -n "$CRYPTSETUP_TESTS_RUN_IN_MESON" ]; then
CRYPTSETUP_VALGRIND=$CRYPTSETUP CRYPTSETUP_VALGRIND=$CRYPTSETUP
else else
@@ -50,7 +52,7 @@ function skip()
function test_one() # cipher mode keysize rm_pattern function test_one() # cipher mode keysize rm_pattern
{ {
$CRYPTSETUP benchmark -c "$1-$2" -s "$3" >/dev/null 2>&1 $CRYPTOCHECK cipher $1 $2 $3
if [ $? -ne 0 ] ; then if [ $? -ne 0 ] ; then
echo "$1-$2 [N/A]" echo "$1-$2 [N/A]"
IMGS=$(ls $TST_DIR/[tv]c* | grep "$4") IMGS=$(ls $TST_DIR/[tv]c* | grep "$4")
@@ -62,7 +64,7 @@ function test_one() # cipher mode keysize rm_pattern
function test_kdf() # hash img_hash function test_kdf() # hash img_hash
{ {
$CRYPTSETUP benchmark -h "$1" >/dev/null 2>&1 $CRYPTOCHECK hash $1
if [ $? -ne 0 ] ; then if [ $? -ne 0 ] ; then
echo "pbkdf2-$1 [N/A]" echo "pbkdf2-$1 [N/A]"
IMGS=$(ls $TST_DIR/[tv]c* | grep "$2") IMGS=$(ls $TST_DIR/[tv]c* | grep "$2")
@@ -82,6 +84,7 @@ function get_HASH_CIPHER() # filename
function test_required() function test_required()
{ {
command -v blkid >/dev/null || skip "blkid tool required, test skipped." command -v blkid >/dev/null || skip "blkid tool required, test skipped."
[ ! -x "$CRYPTOCHECK" ] && skip "Cannot find $CRYPTOCHECK, test skipped."
echo "REQUIRED KDF TEST" echo "REQUIRED KDF TEST"
test_kdf sha256 sha256 test_kdf sha256 sha256