summaryrefslogtreecommitdiffstats
path: root/tests/luks2-integrity-test
diff options
context:
space:
mode:
Diffstat (limited to 'tests/luks2-integrity-test')
-rwxr-xr-xtests/luks2-integrity-test30
1 files changed, 27 insertions, 3 deletions
diff --git a/tests/luks2-integrity-test b/tests/luks2-integrity-test
index a8082f8..ff41ebf 100755
--- a/tests/luks2-integrity-test
+++ b/tests/luks2-integrity-test
@@ -11,8 +11,12 @@ PWD1=nHjJHjI23JK
KEY_FILE=key.img
FAST_PBKDF_OPT="--pbkdf pbkdf2 --pbkdf-force-iterations 1000"
-CRYPTSETUP_VALGRIND=../.libs/cryptsetup
-CRYPTSETUP_LIB_VALGRIND=../.libs
+if [ -n "$CRYPTSETUP_TESTS_RUN_IN_MESON" ]; then
+ CRYPTSETUP_VALGRIND=$CRYPTSETUP
+else
+ CRYPTSETUP_VALGRIND=../.libs/cryptsetup
+ CRYPTSETUP_LIB_VALGRIND=../.libs
+fi
dmremove() { # device
udevadm settle >/dev/null 2>&1
@@ -45,7 +49,10 @@ function valgrind_setup()
{
command -v valgrind >/dev/null || fail "Cannot find valgrind."
[ ! -f $CRYPTSETUP_VALGRIND ] && fail "Unable to get location of cryptsetup executable."
- export LD_LIBRARY_PATH="$CRYPTSETUP_LIB_VALGRIND:$LD_LIBRARY_PATH"
+ [ ! -f valg.sh ] && fail "Unable to get location of valg runner script."
+ if [ -z "$CRYPTSETUP_TESTS_RUN_IN_MESON" ]; then
+ export LD_LIBRARY_PATH="$CRYPTSETUP_LIB_VALGRIND:$LD_LIBRARY_PATH"
+ fi
}
function valgrind_run()
@@ -60,6 +67,11 @@ add_device() {
sync
}
+set_LO_DEV() { # file
+ # support both /dev/loopX and /dev/loop/X
+ LO_DEV=$(losetup -l -O NAME -n -j $1 2>/dev/null | sed -e 's/loop\//loop/')
+}
+
status_check() # name value [detached]
{
if [ -n "$3" ]; then
@@ -122,10 +134,12 @@ intformat() # alg integrity integrity_out key_size int_key_size sector_size csum
dump_check "Key:" $(($4 + $5))
echo -n "[ACTIVATE]"
$CRYPTSETUP open -d $KEY_FILE $DEV $DEV_NAME || fail "Cannot activate device."
+ set_LO_DEV $DEV
status_check "cipher" $1
status_check "sector size" $6
status_check "integrity:" $3
status_check "keysize:" $(($4 + $5))
+ [ -n "$LO_DEV" ] && status_check "device:" $LO_DEV
[ $5 -gt 0 ] && status_check "integrity keysize:" $5
int_check_sum $1 $7
echo -n "[REMOVE]"
@@ -137,12 +151,21 @@ intformat() # alg integrity integrity_out key_size int_key_size sector_size csum
$CRYPTSETUP luksHeaderBackup -q --header-backup-file $HEADER_IMG $DEV || fail
wipefs -a $DEV >/dev/null 2>&1 || fail
$CRYPTSETUP open --header $HEADER_IMG -d $KEY_FILE $DEV $DEV_NAME || fail "Cannot activate device."
+ set_LO_DEV $DEV
status_check "cipher" $1 1
status_check "sector size" $6 1
status_check "integrity:" $3 1
status_check "keysize:" $(($4 + $5)) 1
+ [ -n "$LO_DEV" ] && status_check "device:" $LO_DEV 1
[ $5 -gt 0 ] && status_check "integrity keysize:" $5 1
int_check_sum $1 $7
+ # check status returns values even if no --header is set
+ status_check "cipher" $1
+ status_check "sector size" $6
+ status_check "integrity:" $3
+ status_check "keysize:" $(($4 + $5))
+ [ -n "$LO_DEV" ] && status_check "device:" $LO_DEV
+ [ $5 -gt 0 ] && status_check "integrity keysize:" $5
$CRYPTSETUP close $DEV_NAME || fail "Cannot deactivate device."
$CRYPTSETUP luksHeaderRestore -q --header-backup-file $HEADER_IMG $DEV || fail
rm -f $HEADER_IMG
@@ -169,6 +192,7 @@ intformat aes-xts-plain64 hmac-sha256 hmac\(sha256\) 512 256 512 ee501705a
intformat aes-xts-random hmac-sha256 hmac\(sha256\) 512 256 512 492c2d1cc9e222a850c399bfef4ed5a86bf5afc59e54f0f0c7ba8e2a64548323
intformat aes-cbc-essiv:sha256 hmac-sha256 hmac\(sha256\) 128 256 4096 358d6beceddf593aff6b22c31684e0df9c226330aff5812e060950215217d21b
intformat aes-xts-plain64 hmac-sha256 hmac\(sha256\) 256 256 4096 358d6beceddf593aff6b22c31684e0df9c226330aff5812e060950215217d21b
+intformat aes-xts-plain64 hmac-sha256 hmac\(sha256\) 256 256 4096 358d6beceddf593aff6b22c31684e0df9c226330aff5812e060950215217d21b 1
intformat aes-xts-random hmac-sha256 hmac\(sha256\) 256 256 4096 8c0463f5ac09613674bdf40b0ff6f985edbc3de04e51fdc688873cb333ef3cda
intformat aes-cbc-essiv:sha256 hmac-sha256 hmac\(sha256\) 256 256 4096 358d6beceddf593aff6b22c31684e0df9c226330aff5812e060950215217d21b
intformat aes-xts-plain64 hmac-sha256 hmac\(sha256\) 512 256 4096 358d6beceddf593aff6b22c31684e0df9c226330aff5812e060950215217d21b