Skip to content

Commit e1cbd4e

Browse files
committed
tests: add simple verification test for --serialize-memory-hard-pbkdf
1 parent 9ea9af1 commit e1cbd4e

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

tests/compat-test2

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,14 @@ KEY_FILE1=test-key-file1
4545

4646
FAST_PBKDF_OPT="--pbkdf pbkdf2 --pbkdf-force-iterations 1000"
4747

48+
# 32 MiB + 1KiB to bypass minimal memory check (hardocoded)
49+
FAST_PBKDF_ARGON_OPT="--pbkdf argon2id --pbkdf-force-iterations 4 --pbkdf-memory 32769 --pbkdf-parallel 1"
50+
51+
# TODO: this is configurable
52+
LUKS2_LOCKING_DIR=/run/cryptsetup
53+
# hardcoded value
54+
MEMORY_HARD_LOCK_FILE=LN_memory-hard-access
55+
4856
TEST_UUID="12345678-1234-1234-1234-123456789abc"
4957

5058
LOOPDEV=$(losetup -f 2>/dev/null)
@@ -1698,5 +1706,14 @@ echo $PWD1 | $CRYPTSETUP luksFormat -q $FAST_PBKDF_OPT --type luks2 $LOOPDEV ||
16981706
echo $PWD1 | $CRYPTSETUP luksOpen $LOOPDEV $DM_BAD_NAME 2>/dev/null && fail
16991707
echo $PWD1 | $CRYPTSETUP luksOpen $LOOPDEV $DM_LONG_NAME 2>/dev/null && fail
17001708

1709+
if ! fips_mode -a -d $LUKS2_LOCKING_DIR; then
1710+
touch $LUKS2_LOCKING_DIR/$MEMORY_HARD_LOCK_FILE
1711+
prepare "[52] Test pbkdf serialization flag." wipe
1712+
echo $PWD1 | $CRYPTSETUP luksFormat -q $FAST_PBKDF_ARGON_OPT --type luks2 $LOOPDEV || fail
1713+
test -f $LUKS2_LOCKING_DIR/$MEMORY_HARD_LOCK_FILE || fail "The locking file disappeared unexpectedly"
1714+
echo $PWD1 | $CRYPTSETUP open --serialize-memory-hard-pbkdf --test-passphrase $LOOPDEV || fail
1715+
test -f $LUKS2_LOCKING_DIR/$MEMORY_HARD_LOCK_FILE && fail "The --serialize-memory-hard-pbkdf option did not remove the locking file (did not use the file)."
1716+
fi
1717+
17011718
remove_mapping
17021719
exit 0

0 commit comments

Comments
 (0)