Fix LUKS2 encryption initialization with non-zero keyslot.

Positive keyslot number was interpreted as a failure.
This commit is contained in:
Ondrej Kozina
2019-11-08 12:58:28 +01:00
parent ba0ecc54df
commit 0a9e7028ae
2 changed files with 2 additions and 2 deletions

View File

@@ -1324,7 +1324,7 @@ static int _luksFormat(struct crypt_device **r_cd, char **r_password, size_t *r_
if (opt_integrity && !opt_integrity_no_wipe) if (opt_integrity && !opt_integrity_no_wipe)
r = _wipe_data_device(cd); r = _wipe_data_device(cd);
out: out:
if (r == 0 && r_cd && r_password && r_passwordLen) { if (r >= 0 && r_cd && r_password && r_passwordLen) {
*r_cd = cd; *r_cd = cd;
*r_password = password; *r_password = password;
*r_passwordLen = passwordLen; *r_passwordLen = passwordLen;

View File

@@ -816,7 +816,7 @@ check_hash $PWD1 $HASH6
# Device activation after encryption initialization # Device activation after encryption initialization
wipe_dev $DEV wipe_dev $DEV
echo $PWD1 | $CRYPTSETUP reencrypt $DEV --encrypt --init-only -c aes-cbc-essiv:sha256 -s 128 --reduce-device-size 8M -q $FAST_PBKDF_ARGON $DEV_NAME >/dev/null || fail echo $PWD1 | $CRYPTSETUP reencrypt $DEV --encrypt --init-only -c aes-cbc-essiv:sha256 -s 128 -S11 --reduce-device-size 8M -q $FAST_PBKDF_ARGON $DEV_NAME >/dev/null || fail
$CRYPTSETUP status $DEV_NAME >/dev/null 2>&1 || fail $CRYPTSETUP status $DEV_NAME >/dev/null 2>&1 || fail
check_hash_dev /dev/mapper/$DEV_NAME $HASH5 check_hash_dev /dev/mapper/$DEV_NAME $HASH5
echo $PWD1 | $CRYPTSETUP reencrypt --resume-only $DEV -q || fail echo $PWD1 | $CRYPTSETUP reencrypt --resume-only $DEV -q || fail