Skip to content

Commit ba685e2

Browse files
committed
luks-functions: remove key-slots being hardcoded for DRK handling since DUK code is now dynamic
TODO: multi LUKS volumes (Q4.2.1 non-default BRTFS deployment) not supported still with reencryption. Not a regression, just not yet handled since no OEM known to ship such setup. Signed-off-by: Thierry Laurion <insurgo@riseup.net>
1 parent 8e066fd commit ba685e2

1 file changed

Lines changed: 3 additions & 21 deletions

File tree

‎initrd/etc/luks-functions‎

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -363,29 +363,11 @@ luks_reencrypt() {
363363
warn "DO NOT POWER DOWN MACHINE, UNPLUG AC OR REMOVE BATTERY DURING REENCRYPTION PROCESS"
364364
cryptsetup reencrypt --resilience=none --force-offline-reencrypt --disable-locks \
365365
--perf-no_read_workqueue --perf-no_write_workqueue \
366-
"$LUKS" --key-slot 0 --key-file /tmp/luks_current_Disk_Recovery_Key_passphrase
366+
"$LUKS" --key-file /tmp/luks_current_Disk_Recovery_Key_passphrase
367367
#--perf-no_read_workqueue and/or --perf-no_write_workqueue improve encryption/reencrypton performance on kernel 5.10.9+
368368
# bypassing dm-crypt queues.
369369
#Ref https://github.com/cloudflare/linux/issues/1#issuecomment-729695518
370-
#
371-
#TODO: cryptsetup nows use specified --key-slot to test passphrase but moves keyslot to next available keyslot...
372-
# therefore, we cannot take for granted that DRK is under slot 0.
373-
# We could:
374-
# - not rely on keyslot anymore so that all keyslot are tested until DRK matches;
375-
# - Move DUK to slot 8?
376-
# This way
377-
# - luksChangeKey would change passphrase on same slot found
378-
# - reencrypt would rotate keyslot with next keyslot found
379-
# But then what to do with previous DUK.
380-
# We could:
381-
# - If 2+ keyslot, iterate through slot numbers to test passphrase.
382-
# - When passphrase matching keyslot is found, keep trace of it (expected 0, might be 1)
383-
# - If DRK is 1, DUK must be 2 if we have 2 keyslots used
384-
# - We don't touch passphrase matched DRK slot
385-
# - We wipe the others
386-
# - We move DUK keyslot to 8.
387-
# Bad approach?
388-
370+
389371
#Validate past cryptsetup reencrypt attempts
390372
if [ $? -ne 0 ]; then
391373
whiptail --title 'Invalid Actual LUKS Disk Recovery Key passphrase?' --msgbox \
@@ -444,7 +426,7 @@ luks_change_passphrase()
444426

445427
#output and do cryptsetup luksChangeKey op
446428
echo -e "\nChanging "$LUKS" LUKS encrypted disk passphrase to the new LUKS Disk Recovery Key passphrase..."
447-
cryptsetup luksChangeKey "$LUKS" --key-slot 0 --key-file=/tmp/luks_current_Disk_Recovery_Key_passphrase /tmp/luks_new_Disk_Recovery_Key_passphrase
429+
cryptsetup luksChangeKey "$LUKS" --key-file=/tmp/luks_current_Disk_Recovery_Key_passphrase /tmp/luks_new_Disk_Recovery_Key_passphrase
448430

449431
#Validate past cryptsetup attempts
450432
if [ $? -ne 0 ]; then

0 commit comments

Comments
 (0)