Commit Graph

99475 Commits

Author SHA1 Message Date
Simon Glass
dfb03773ca luks: Add detection of LUKS partition
Provide a function which can detect a LUKS partition. Add a test, using
mmc11

Series-to: concept
Cover-letter:
luks: Provide basic support for unlocking a LUKS1 partition
With full-disk encryption (FDE) it is traditional to unlock a LUKS
partition within userspace as part of the initial ramdisk passed to
Linux. The user is prompted for a passphrase and then the disk is
unlocked.

This works well but does have some drawbacks:
- firmware has no way of knowing whether the boot will success
- the 'passphrase' prompt comes quite late in the boot, which can be
  confusing for the user
- specifically it is not possible to provide an integrated 'boot' UI in
  firmware where the user can enter the passphrase
- in a VM environment, the key may be known in advance, but there is no
  way to take advantage of this
- it is not possible to use an encryted disk unless also using a ramdisk

This series makes a small step towards improving U-Boot in this area. It
allows a passphrase to be checked against a LUKS1-encrypted partition.
It also provides read-only access to the unencrypted data, so that files
can be read.
END

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
2025-10-24 21:02:11 +01:00
Simon Glass
fb5cd8627a luks: Add a subcommand to unlock an encrypted partition
Provide a new 'luks unlock' command which can unlock a LUKS1 partition,
given a passphrase.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
2025-10-24 21:02:11 +01:00
Simon Glass
0cbfb2d490 luks: Provide a way to unlock and map encrypted partitions
Add the logic to unlock a partition and set up a blkmap for use with it.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
2025-10-24 21:02:11 +01:00
Simon Glass
1f29c19082 luks: Enhance blkmap to support LUKSv1
Enhance blkmap to support decrypting a partition encrypted with LUKS
version 1. This will allow filesystems to access files on the parition.

This will be tested once filesystems support is plumbed in.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
2025-10-24 21:02:11 +01:00
Simon Glass
22826bf21f luks: Show the JSON information for LUKSv2
Extract the full information for version 2, which is JSON format. Show
this with the 'luks info' command.

Use the mmc12 disk to check this.

Require the JSON for LUKS.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
2025-10-24 21:02:11 +01:00
Simon Glass
eb2ae89f55 luks: Create a disk image with LUKS2 encryption
Add a new mmc12 image which has a LUKS2-encrypted ext4 partition.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
2025-10-24 21:02:11 +01:00
Simon Glass
2737bf15bf luks: Create a very simple JSON library
LUKS version 2 uses JSON as a means of communicating the key
information. Add a simple library which can print JSON in a
human-readable format.

Note that it does not fully parse the JSON fragment. That may be
considered later, if needed.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
2025-10-24 21:02:10 +01:00
Simon Glass
414baddf37 luks: Add a simple command
Add a 'luks' command which allows querying a partition to see if it is
encrypted using LUKS, as well as showing information about a LUKS
partition.

Provide some documentation and a test.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
2025-10-24 20:12:40 +01:00
Simon Glass
8410d62604 luks: Add the beginning of LUKS support
Linux Unified Key Setup (LUKS) provides a way to encryption a disk
partition with a a key an later unlock it. There are two versions (1 and
2).

Add a definition of the main structures and the ability to detect a LUKS
partition.

Enable this for the sandbox board.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
2025-10-24 20:12:40 +01:00
Simon Glass
838f9ce777 luks: Encrypt the mmc11 test image
Encrypt the ext4 partition in this image so that we can use it for
tests.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-10-24 20:12:40 +01:00
Simon Glass
444dd0a4fd luks: Add a way to create an encrypted partition
If requested, use cryptsetup to encrypt a partition with the provided
passphrase.

This requires use of sudo since there doesn't seem to be any other way
to write files into a filesystem on an encrypted disk.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
2025-10-24 20:12:25 +01:00
Simon Glass
0153d365b1 CI: Update Docker image to including luks tools
Update the GitLab CI Docker image to use the new build with cryptsetup
support for LUKS testing.

This appears to require use of sudo, so add a comment about that.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
2025-10-24 20:11:29 +01:00
Simon Glass
561a7efe58 docker: Add cryptsetup package for LUKS testing
Add cryptsetup to the CI Docker image to enable LUKS encryption tests.
This is needed to create test images.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-10-24 10:06:04 +01:00
Simon Glass
8863215954 test/py: Set up an Ubuntu image with space for FDE
Update one of the Ubuntu images to provide space for using full-disk
encryption.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-10-24 08:47:38 +01:00
Simon Glass
31fd3d283e test/py: Support FDE with the extlinux image
Add a parameter to indicate the size of the root partition so that it
can have space for the LUTS metadata.

Move the import of gzip to the top of the file while we are here.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-10-24 08:47:38 +01:00
Simon Glass
79cabfeb63 test/py: Support creating space after a filesystem
At present the partition size is always the same as the filesystem
within it. Add a way to specify a larger size, to make space for LUTS
tables needed for full-disk encryption.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-10-24 08:47:38 +01:00
Simon Glass
26569e4eb8 mbedtls: Allow use of PKCS#5 functions
Add a few Kconfig options to allow PKCS#5 (PBKDF2) to be used within
U-Boot

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
2025-10-24 08:47:38 +01:00
Simon Glass
83ae9fa20f mbedtls: hash: Provide the mbedtls hash type in the hash interface
The mbedtls hashing has not been integrated into U-Boot's hash API. As a
first step, add the mbedtls hash type into struct hash_algo and provide
the values. This allows looking up the type by its name.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-10-24 08:47:38 +01:00
Simon Glass
71cea84cc3 sandbox: Add devon and devoff subcommands to sb command
There are quite a few media devices in test.dts which are not enabled by
default, so are not bound on startup. Sometimes it is useful to be able
to use these from the command line.

Add 'sb devon' and 'sb devoff' subcommands to enable and disable devices
from the device tree. For example, running sandbox with -T, then
'sb devon mmc11' enables the mmc11 device mentioned in test.dts

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
2025-10-24 08:47:38 +01:00
Simon Glass
5e142ebaa0 sandbox: Enable CONFIG_PANIC_POWEROFF
Enable this option so that sandbox exits when a panic occurs, rather
than resetting in a loop.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-10-24 08:47:38 +01:00
Simon Glass
5cd0879c3e panic: Provide a way to poweroff on panic
For sandbox it normally doesn't make sense to reset when a panic occurs,
since presumably it will just happen again. Add an option to power off
instead.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
2025-10-24 08:47:38 +01:00
Simon Glass
1e45f11514 log: Provide a macro to log a hex string
Add a new log_debug_hex() macro which can log a a buffer as a hex
string, e.g. for showing a hash value.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
2025-10-24 08:47:38 +01:00
Simon Glass
98425bf676 doc: Provide documentation for the blkmap command
This command lacks documentation in the normal place. Add it.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
2025-10-24 08:47:38 +01:00
Simon Glass
431c711c7f aes: Fix key size handling for AES-192 and AES-256
At present the aes_get_rounds() and aes_get_keycols() functions compare
the key_len parameter (in bits) directly against AES*_KEY_LENGTH
constants (in bytes), causing incorrect round and column counts for
non-128-bit keys.

Additionally, aes_expand_key() uses key_len as a byte count in memcpy(),
copying far more data than intended and causing buffer overflows.

Specifically, for AES-256 (256-bit key) it comparies 256 (bits) against
32 (bytes), failing the comparison. This causes AES-256 to use AES-128
parameters (10 rounds instead of 14) and the memcpy() to copy 256 bytes
instead of 32.

Fix by converting key_len from bits to bytes before comparisons and in
memcpy. With this we get:
- AES-128 (128 bits / 16 bytes): 10 rounds, 4 key columns
- AES-192 (192 bits / 24 bytes): 12 rounds, 6 key columns
- AES-256 (256 bits / 32 bytes): 14 rounds, 8 key columns

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
Fixes: 8302d1708a ("aes: add support of aes192 and aes256")
2025-10-24 08:47:38 +01:00
Simon Glass
2ee77c0b8c Merge branch 'secb2' into 'master'
Bootstage and script enhancements

See merge request u-boot/u-boot!201
2025-10-24 06:10:42 +00:00
Simon Glass
6f8131d1a4 scripts: build-qemu: Allow enabling TKey access
Provide a -T/--tkey option to enable access to a USB-attached Tillitis
TKey.

Series-to: concept
Series-cc: heinrich
Series-links: 1:54
Series-version: 2
Cover-letter:
Bootstage and script enhancements
This series collects together a few improvements to the bootstage
subsystem, principally some new tests.

It also adds support for ACPI FPDT which is a way of passing timing
information to the OS.

A bug fix is provided for mouse clicks with expo.

Finally the series includes some new options for the build-efi script
for networking, spice, etc.
END

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-10-23 19:36:32 +01:00
Simon Glass
357418fc47 scripts: build-efi: Flush output before running QEMU
Complete writing of any output before running QEMU, since otherwise it
does not always appear until QEMU exits (e.g. with 'tee')

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-10-23 19:36:32 +01:00
Simon Glass
b6d52a75b8 scripts: build-efi: Allow enabling networking
Provide a -N/--net flag to enable networking for the guest.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-10-23 19:36:32 +01:00
Simon Glass
ab855a1aa4 scripts: build-efi: Support spice integration
Add a -c/--spice flag to enable spice, so that copy/paste works between
the guest and host.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-10-23 19:36:32 +01:00
Simon Glass
bfcb0a6dd6 bootm: Update FPDT boot times before handing off to OS
Update the FPDT boot performance record's ebs_entry and ebs_exit
fields in bootm_final() to record the time when we're about to
hand off to the operating system.

The timing is recorded just before we start the kernel, after all
device cleanup and before interrupts are disabled, which corresponds
to the ExitBootServices phase in UEFI.

If EFI is used to boot, a further update could be made, but that is
left for later.

Avoid including asm/acpi_table.h on platforms without ACPI. Ad a special
case for the QEMU RISC-V ACPI board.

Series-changes: 2
- Depend on ACPIGEN instead of GENERATE_ACPI_TABLE
- Avoid including asm/acpi_table.h on platforms without ACPI

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
2025-10-23 19:36:12 +01:00
Simon Glass
d9b81fa614 acpi: fpdt: Generate the table
Add an ACPI writer to automatically generate the FPDT table with boot
timing information when ACPI tables are created.

This allows the OS to read firmware boot-timing metrics from the FPDT
table.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
2025-10-23 19:34:49 +01:00
Simon Glass
958e2ecf55 acpi: Add support for Firmware Performance Data Table
Add ACPI FPDT support to report firmware boot timing information to
the OS. The FPDT table contains timing data for firmware phases from
reset through OS handoff.

Add some functions to enable generation of this table.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
2025-10-23 10:00:31 +01:00
Simon Glass
d26f3fe96a bootstage: Add a way to read the time from a record
Add a function which returns the time given a record ID.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-10-23 10:00:31 +01:00
Simon Glass
5094bffc50 bootstage: Add some more tests
There is already a Python test. Add a few C tests as well, for bootstage
itself and for the 'bootstage' command.

Add helpers to access the internal state. Be careful to zero records
when removing them, since if the record is later reused, bootstage
expects the time to be zero.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
2025-10-23 10:00:06 +01:00
Simon Glass
dbdd6fda44 bootstage: Move the bootstage record to the header file
Move struct bootstage_record to the header file so it can be used from
tests.

Add some more comments for the struct, while we are here.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-10-23 09:21:08 +01:00
Simon Glass
f56c1b0238 expo: Correct handling of mouse clicks
Due to a missing return in bootflow_menu_poll() a click on any object is
handled as if it were a click on the settings object. Fix this by
returning the correct error code for unrecognised clicks.

Signed-off-by: Simon Glass <sjg@chromium.org>
Fixes: e94de63e6c ("expo: Add a way to select settings")
2025-10-23 09:20:35 +01:00
Simon Glass
7c50fc5afa Merge branch 'seca' into 'master'
tkey: Provide basic support for Tillitis TKey

See merge request u-boot/u-boot!200
2025-10-19 15:31:37 +00:00
Simon Glass
797a952213 tkey: Add a sandbox driver for real TKey hardware
Add a sandbox TKey driver that enables communication with physical TKey
devices via serial port (/dev/ttyACM0). This allows testing TKey
functionality in sandbox with real hardware.

The driver:
  - Opens the configured device path from device tree
  - Configures TTY parameters using os_tty_set_params()
  - Implements read/write operations for TKey protocol
  - Supports both read() and read_all() operations

Device tree configuration:

  tkey-test {
    compatible = "sandbox,tkey";
    sandbox,device-path = "/dev/ttyACM0";
  };

Series-to: concept
Cover-letter:
tkey: Provide basic support for Tillitis TKey
This device provides a way to sign data using an internal, unique key.
It can be useful for features such as unlocking an encrypted disk.

This series provides basic support for the Tkey, with a uclass, two
sandbox drivers (emulator and serial), a simple command some tests.
END

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
2025-10-19 12:27:49 +01:00
Simon Glass
db0f44ec8e sandbox: Add TTY configuration for TKey serial communication
Add os_tty_set_params() function to configure terminal devices for
serial communication with TKey devices:

  - Custom baud rate of 62500 using termios2
  - 8n1 configuration (8 data bits, no parity, 1 stop bit)
  - Raw mode for binary communication
  - Appropriate timeouts for frame-based protocols

This is needed for serial-based TKey communication on sandbox, allowing
U-Boot to communicate with TKey security tokens via a serial port.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
2025-10-19 12:27:49 +01:00
Simon Glass
b7d758612a tkey: Add a command
Add a new 'tkey' command that provides an interface to interact with
Tillitis TKey security tokens. Subcommands include:

   - info: Display device information (UDI, name, version, mode)
   - load: Load and run applications on the TKey
   - pubkey: Get the public key from a signer app
   - getkey: Derive disk encryption keys with password and USS

This command enables U-Boot to use TKey devices for secure key
derivation for full-disk encryption.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
2025-10-19 12:27:49 +01:00
Simon Glass
c34b52c8a1 tkey: Add emulator and test
Provide a simple emulator which can handle the TKey operations. Add a
test which uses it.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
2025-10-19 12:27:49 +01:00
Simon Glass
6b7d989d9f tkey: Add the signer firmware
Add a binary for the TKey signer, so that it can be downloaded to the
key when needed.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-10-19 12:27:49 +01:00
Simon Glass
4277dd164a tkey: Provide a uclass for the Tillitis TKey
The TKey is a USB device which can run ephemeral firmware and perform
cyrptographic operations.

Add a uclass for the communication layer.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
2025-10-19 12:27:49 +01:00
Simon Glass
5a869f9523 lib: Add blake2s support for TKey USS derivation
The TKey User-Supplied Secret (USS) feature requires blake2s hashing
to derive app-specific secrets. Add blake2s implementation alongside
the existing blake2b support.

The blake2s implementation is ported from the reference BLAKE2
implementation at https://github.com/BLAKE2/BLAKE2

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
2025-10-19 12:27:49 +01:00
Simon Glass
ec753ac734 serial: ns16550: Add skip-init devicetree property
Add support for a 'skip-init' property in the device tree that preserves
UART settings from a previous boot phase.

This is useful when the UART is already configured by firmware (e.g.,
EFI firmware on x86 platforms) and changing the settings would disrupt
console output or cause communication issues.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
2025-10-19 12:27:49 +01:00
Simon Glass
29e8e1280f Merge branch 'proi' into 'master'
bootctl: Expand bootctl to include a new UI

See merge request u-boot/u-boot!199
2025-10-19 07:58:49 +00:00
Simon Glass
b03a940085 efi: x86: Use only serial for input
We don't need to enable USB or i8042 for the app. Enable only serial for
now.

Series-to: concept
Cover-letter:
bootctl: Expand bootctl to include a new UI
The current bootctl UI is fairly basic, just supporting a keyboard menu
with text.

Now that expo supports a mouse, add a more interesting UI, with more
graphical elements. Provide a way to switch between this and the simple
UI.

This series also includes some small test improvements, along with a
patch to remove a blob from a bloblist.
END

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-10-18 09:39:54 +01:00
Simon Glass
db20730abb efi: x86: Enable required Kconfig options for bootctl
Adjust the configuration to support truetype fonts, more bitmap formats,
VIDEO_COPY (for smoother display) and bloblist for ACPI tables.

Disable the pager since it can be confusing when using bootctl.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-10-18 09:38:26 +01:00
Simon Glass
4d17240033 efi: x86: Provide settings for bootctl
Provide some basic settings so that bootctl can be used with the EFI app
on x86.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-10-18 09:38:26 +01:00
Simon Glass
fd200b4ff4 bootctl: Add a test for the multi UI
Add a test which switches between the simple and the mouse-based UI.

For now the tests are not enabled, due to an integration problem which
causes bootflow_efi() to detect and invalid free()

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-10-18 09:38:26 +01:00