refactor(disk): address review feedback on cipher selection
- always serialize iter_time and cipher in DiskEncryption.json - simplify select_encryption_cipher using MenuItemGroup.from_enum - add cipher to _prev_disk_encryption preview in disk_menu.py - drop unnecessary inline comments from EncryptionCipher enum
This commit is contained in:
parent
e1fec5f816
commit
55a24b8e1a
|
|
@ -283,6 +283,7 @@ class DiskLayoutConfigurationMenu(AbstractSubMenu[DiskMenuConfig]):
|
|||
|
||||
if enc_type != EncryptionType.NO_ENCRYPTION:
|
||||
output += tr('Iteration time') + f': {enc_config.iter_time or DEFAULT_ITER_TIME}ms\n'
|
||||
output += tr('Cipher') + f': {enc_config.cipher.value}\n'
|
||||
|
||||
if enc_config.partitions:
|
||||
output += f'Partitions: {len(enc_config.partitions)} selected\n'
|
||||
|
|
|
|||
|
|
@ -431,14 +431,8 @@ async def select_iteration_time(preset: int | None = None) -> int | None:
|
|||
|
||||
|
||||
async def select_encryption_cipher(preset: EncryptionCipher | None = None) -> EncryptionCipher | None:
|
||||
options = list(EncryptionCipher)
|
||||
|
||||
if not preset:
|
||||
preset = DEFAULT_CIPHER
|
||||
|
||||
items = [MenuItem(o.value, value=o) for o in options]
|
||||
group = MenuItemGroup(items)
|
||||
group.set_focus_by_value(preset)
|
||||
group = MenuItemGroup.from_enum(EncryptionCipher)
|
||||
group.set_focus_by_value(preset or DEFAULT_CIPHER)
|
||||
|
||||
result = await Selection[EncryptionCipher](
|
||||
group,
|
||||
|
|
|
|||
|
|
@ -150,9 +150,7 @@ class Luks2:
|
|||
try:
|
||||
SysCommand(f'cryptsetup close {self.mapper_name}')
|
||||
except SysCallError as close_err:
|
||||
raise DiskError(
|
||||
f'Could not close existing mapper "{self.mapper_name}" before unlock: {close_err}'
|
||||
)
|
||||
raise DiskError(f'Could not close existing mapper "{self.mapper_name}" before unlock: {close_err}')
|
||||
|
||||
key_file_arg, passphrase = self._get_passphrase_args(key_file)
|
||||
|
||||
|
|
@ -179,6 +177,7 @@ class Luks2:
|
|||
|
||||
def lock(self) -> None:
|
||||
import time
|
||||
|
||||
umount(self.luks_dev_path)
|
||||
|
||||
# Get crypt-information about the device by doing a reverse lookup starting with the partition path
|
||||
|
|
@ -217,9 +216,7 @@ class Luks2:
|
|||
SysCommand(f'cryptsetup close --deferred {child.name}')
|
||||
debug(f'cryptsetup close --deferred issued for {child.name}')
|
||||
except SysCallError as deferred_err:
|
||||
raise DiskError(
|
||||
f'Could not close luks2 device "{child.name}": {deferred_err}'
|
||||
) from deferred_err
|
||||
raise DiskError(f'Could not close luks2 device "{child.name}": {deferred_err}') from deferred_err
|
||||
|
||||
# Wait until the mapper device node actually disappears before returning.
|
||||
# Subsequent commands (wipefs, mkfs, etc.) will fail with "Device busy"
|
||||
|
|
|
|||
|
|
@ -1523,11 +1523,8 @@ class DiskEncryption:
|
|||
if self.hsm_device:
|
||||
obj['hsm_device'] = self.hsm_device.json()
|
||||
|
||||
if self.iter_time != DEFAULT_ITER_TIME: # Only include if not default
|
||||
obj['iter_time'] = self.iter_time
|
||||
|
||||
if self.cipher != DEFAULT_CIPHER: # Only include if not default
|
||||
obj['cipher'] = self.cipher.value
|
||||
obj['iter_time'] = self.iter_time
|
||||
obj['cipher'] = self.cipher.value
|
||||
|
||||
return obj
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue