Add encrypt_keyfile and master_keyfile parameters to FsHelper and the image setup functions. This allows creating encrypted test images using: - A key file instead of a passphrase (encrypt_keyfile) - A specific master key for pre-derived unlock testing (master_keyfile) The keyfile takes precedence over passphrase when both are provided. Also reduce Argon2 memory parameters to values suitable for U-Boot testing. These new features will allow use of a real TKey for trying out this feature locally, as well as the emulated TKey for automated testing. Co-developed-by: Claude <noreply@anthropic.com> Signed-off-by: Simon Glass <simon.glass@canonical.com>
64 lines
2.3 KiB
Python
64 lines
2.3 KiB
Python
# SPDX-License-Identifier: GPL-2.0+
|
|
# Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved.
|
|
|
|
"""Create Ubuntu test disk images"""
|
|
|
|
from img.common import setup_extlinux_image
|
|
|
|
|
|
def setup_ubuntu_image(config, log, devnum, basename, version='24.04.1 LTS',
|
|
use_fde=0, luks_kdf='pbkdf2', encrypt_keyfile=None,
|
|
master_keyfile=None):
|
|
"""Create a Ubuntu disk image with a FAT partition and ext4 partition
|
|
|
|
This creates a FAT partition containing extlinux files, kernel, etc. and a
|
|
separate ext4 partition containing the root disk
|
|
|
|
Args:
|
|
config (ArbitraryAttributeContainer): Configuration
|
|
log (multiplexed_log.Logfile): Log to write to
|
|
devnum (int): Device number to use, e.g. 1
|
|
basename (str): Base name to use in the filename, e.g. 'mmc'
|
|
use_fde (int): LUKS version for full-disk encryption (0=none, 1=LUKS1, 2=LUKS2)
|
|
luks_kdf (str): Key derivation function for LUKS2: 'pbkdf2' or 'argon2id'.
|
|
Defaults to 'pbkdf2'. Ignored for LUKS1.
|
|
encrypt_keyfile (str, optional): Path to key file for LUKS encryption.
|
|
If provided, takes precedence over passphrase.
|
|
master_keyfile (str, optional): Path to file containing the raw master
|
|
key. If provided, this exact key is used as the LUKS master key,
|
|
enabling pre_derived unlock mode.
|
|
"""
|
|
vmlinux = 'vmlinuz-6.8.0-53-generic'
|
|
initrd = 'initrd.img-6.8.0-53-generic'
|
|
dtbdir = None
|
|
script = '''## /boot/extlinux/extlinux.conf
|
|
##
|
|
## IMPORTANT WARNING
|
|
##
|
|
## The configuration of this file is generated automatically.
|
|
## Do not edit this file manually, use: u-boot-update
|
|
|
|
default l0
|
|
menu title U-Boot menu
|
|
prompt 1
|
|
timeout 50
|
|
|
|
|
|
label l0
|
|
menu label Ubuntu %s 6.8.0-53-generic
|
|
linux /boot/%s
|
|
initrd /boot/%s
|
|
|
|
append root=/dev/disk/by-uuid/bcfdda4a-8249-4f40-9f0f-7c1a76b6cbe8 ro earlycon
|
|
|
|
label l0r
|
|
menu label Ubuntu %s 6.8.0-53-generic (rescue target)
|
|
linux /boot/%s
|
|
initrd /boot/%s
|
|
''' % ((version, vmlinux, initrd) * 2)
|
|
setup_extlinux_image(config, log, devnum, basename, vmlinux, initrd, dtbdir,
|
|
script, part2_size=60 if use_fde else 1,
|
|
use_fde=use_fde, luks_kdf=luks_kdf,
|
|
encrypt_keyfile=encrypt_keyfile,
|
|
master_keyfile=master_keyfile)
|