Provide measured boot via fTPM for arm64, early deploy EFI keys
cover Provide measured boot via fTPM for arm64, early deploy EFI keys
Due to some deficits in U-Boot, the fTPM was not recognized and, thus, its PCRs for measurements were not fed. This led to the disk encryption key we are storing in the TPM not being sealed properly. Existing deployments were most likely not affected by this when they locked down U-Boot to only boot in secure mode (like we did and continue to do).
After fixing this, we are confronted with a practical problem: The QEMU target for arm64 is set up without pre-deployed UEFI keys. When we now, with working measurements, switch to secure boot after the initial disk encryption, unsealing the key will no longer work.
For this but possibly also for other scenarios, the series adds an initramfs hook which tries to deploy the secure boot keys if the target is in non-secure mode and no other keys are deployed yet.
With all that in place, we change the policy of the disk encryption hook to only perform its task when the device is securely booted. If this should break valid downstream scenarios, we may make it opt-out later on, but so far none are imaginable.
Jan
Jan Kiszka (7):
secure-boot-efi-keys: Add recipe to create EFI keys
cip-initramfs-functions: Add secure_boot_enabled helper
cip-core-initramfs: Automatically deploy secure boot keys on first
boot
u-boot: Add patches to enable measured boot with fTPM
u-boot: Refactor ftpm-stmm.cfg to enable measured boot for all
u-boot: Drop obsolete config workaround
initramfs-crypt-hook: Prevent encryption without secure boot
...ement-Fix-compilation-for-non-sandbo.patch | 43 +++++ ...-out-service-enumeration-and-binding.patch | 95 +++++++++++ ...pport-for-enumerating-services-that-.patch | 155 ++++++++++++++++++ ...-warn-about-TEE_ERROR_STORAGE_NOT_AV.patch | 33 ++++ ...to-optee-after-a-successful-mmc_init.patch | 41 +++++ ...-MMC-Device-not-found-a-debug-output.patch | 50 ++++++ recipes-bsp/u-boot/files/ftpm-stmm.cfg | 7 +- recipes-bsp/u-boot/files/qemu-extra.cfg | 2 + recipes-bsp/u-boot/files/secure-boot.cfg | 2 - recipes-bsp/u-boot/files/ti-extra.cfg | 8 +- recipes-bsp/u-boot/u-boot-common-2026.01.inc | 6 + .../single-key-to-efi-keys_0.1.bb | 41 +++++ .../cip-core-initramfs/cip-core-initramfs.bb | 1 + .../files/cip-initramfs-functions | 16 ++ .../files/local-top-complete | 4 + .../initramfs-sbkeys-hook/files/hook | 16 ++ .../initramfs-sbkeys-hook/files/local-top | 34 ++++ .../initramfs-sbkeys-hook/files/mount-stub | 13 ++ .../initramfs-sbkeys-hook_0.1.bb | 32 ++++ 19 files changed, 589 insertions(+), 10 deletions(-) create mode 100644 recipes-bsp/u-boot/files/0001-test-boot-measurement-Fix-compilation-for-non-sandbo.patch create mode 100644 recipes-bsp/u-boot/files/0002-tee-optee-Factor-out-service-enumeration-and-binding.patch create mode 100644 recipes-bsp/u-boot/files/0003-tee-optee-Add-support-for-enumerating-services-that-.patch create mode 100644 recipes-bsp/u-boot/files/0004-tee-optee-Do-not-warn-about-TEE_ERROR_STORAGE_NOT_AV.patch create mode 100644 recipes-bsp/u-boot/files/0005-mmc-Call-back-to-optee-after-a-successful-mmc_init.patch create mode 100644 recipes-bsp/u-boot/files/0006-mmc-Make-MMC-Device-not-found-a-debug-output.patch create mode 100644 recipes-devtools/secure-boot-efi-keys/single-key-to-efi-keys_0.1.bb create mode 100644 recipes-initramfs/initramfs-sbkeys-hook/files/hook create mode 100644 recipes-initramfs/initramfs-sbkeys-hook/files/local-top create mode 100755 recipes-initramfs/initramfs-sbkeys-hook/files/mount-stub create mode 100644 recipes-initramfs/initramfs-sbkeys-hook/initramfs-sbkeys-hook_0.1.bb
Signature · 1 line
2.47.3
PATCH 1/7 secure-boot-efi-keys: Add recipe to create EFI keys
From: Jan Kiszka <[email protected]>
This recipe allows to derive the PK, KEK and db values from a single signing key as we are using for demonstration/testing purposes and simple scenarios. The recipe provides abstract "secure-boot-efi-keys" which could also be offered by an alternative recipe/package that picks up differently generated keys and/or a proper key hierarchy.
--- .../single-key-to-efi-keys_0.1.bb | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 recipes-devtools/secure-boot-efi-keys/single-key-to-efi-keys_0.1.bb
recipes-devtools/secure-boot-efi-keys/single-key-to-efi-keys_0.1.bb new file +41 -0
@@ -0,0 +1,41 @@ +# +# CIP Core, generic profile +# +# Copyright (c) Siemens AG, 2026 +# +# Authors: +# Jan Kiszka <[email protected]> +# +# SPDX-License-Identifier: MIT +# + +inherit dpkg + +MAINTAINER = "cip-dev <[email protected]>" +DESCRIPTION = "Generate EFI keys from single secure boot key" + +PROVIDES += "secure-boot-efi-keys" +DEBIAN_PROVIDES = "secure-boot-efi-keys" + +DEPENDS = "secure-boot-secrets" +DEBIAN_BUILD_DEPENDS .= ", secure-boot-secrets, efitools" + +do_prepare_build() { + deb_debianize + + cat <<EOF > ${S}/debian/${BPN}.install +db.auth usr/share/secure-boot-efi-keys +KEK.auth usr/share/secure-boot-efi-keys +PK.auth usr/share/secure-boot-efi-keys +EOF + + cat <<EOF >> ${S}/debian/rules + +override_dh_auto_build: + cert-to-efi-sig-list /usr/share/secure-boot-secrets/secure-boot.pem PK.esl + sign-efi-sig-list -k /usr/share/secure-boot-secrets/secure-boot.key \ + -c /usr/share/secure-boot-secrets/secure-boot.pem PK PK.esl PK.auth + cp PK.auth KEK.auth + cp PK.auth db.auth +EOF +}
Signature · 1 line
2.47.3
Re: [isar-cip-core][PATCH 1/7] secure-boot-efi-keys: Add recipe to create EFI keys
Am 26.08.2026 um 07:41 schrieb Jan Kiszka:
Quoted 27 lines
From: Jan Kiszka <[email protected]>
This recipe allows to derive the PK, KEK and db values from a single signing key as we are using for demonstration/testing purposes and simple scenarios. The recipe provides abstract "secure-boot-efi-keys" which could also be offered by an alternative recipe/package that picks up differently generated keys and/or a proper key hierarchy.
Signed-off-by Jan Kiszka <[email protected]>--- .../single-key-to-efi-keys_0.1.bb | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+)create mode 100644 recipes-devtools/secure-boot-efi-keys/single-key-to-efi-keys_0.1.bb
recipes-devtools/secure-boot-efi-keys/single-key-to-efi-keys_0.1.bb new file +7
-0@@ -0,0 +1,41 @@ +# +# CIP Core, generic profile +# +# Copyright (c) Siemens AG, 2026 +# +# Authors: +# Jan Kiszka <[email protected]>
recipes-devtools/secure-boot-efi-keys/single-key-to-efi-keys_0.1.bb line 17
Quoted 10 lines
recipes-devtools/secure-boot-efi-keys/single-key-to-efi-keys_0.1.bb new file +10
-0+# +# SPDX-License-Identifier: MIT +# + +inherit dpkg + +MAINTAINER = "cip-dev <[email protected]>" +DESCRIPTION = "Generate EFI keys from single secure boot key" + +PROVIDES += "secure-boot-efi-keys"
The naming confuses actual keys (private portions) with authenticated efi signature list) actually holding the secure-boot-certificates - so maybe secure-boot-vars-auth, secure-boot-certificates-auth or even secure-boot-certificates is more intuitive?
Quoted 24 lines
recipes-devtools/secure-boot-efi-keys/single-key-to-efi-keys_0.1.bb new file +24
-0+DEBIAN_PROVIDES = "secure-boot-efi-keys" + +DEPENDS = "secure-boot-secrets" +DEBIAN_BUILD_DEPENDS .= ", secure-boot-secrets, efitools" + +do_prepare_build() { + deb_debianize + + cat <<EOF > ${S}/debian/${BPN}.install +db.auth usr/share/secure-boot-efi-keys +KEK.auth usr/share/secure-boot-efi-keys +PK.auth usr/share/secure-boot-efi-keys +EOF + + cat <<EOF >> ${S}/debian/rules + +override_dh_auto_build: + cert-to-efi-sig-list /usr/share/secure-boot-secrets/secure-boot.pem PK.esl + sign-efi-sig-list -k /usr/share/secure-boot-secrets/secure-boot.key \ + -c /usr/share/secure-boot-secrets/secure-boot.pem PK PK.esl PK.auth + cp PK.auth KEK.auth + cp PK.auth db.auth +EOF +}
Re: [isar-cip-core][PATCH 1/7] secure-boot-efi-keys: Add recipe to create EFI keys
Quoted 39 lines · Alexander (FT RPD CED SES-AT)
Am 26.08.2026 um 07:41 schrieb Jan Kiszka:
Quoted 36 lines
From: Jan Kiszka <[email protected]>
This recipe allows to derive the PK, KEK and db values from a single signing key as we are using for demonstration/testing purposes and simple scenarios. The recipe provides abstract "secure-boot-efi-keys" which could also be offered by an alternative recipe/package that picks up differently generated keys and/or a proper key hierarchy.
Signed-off-by Jan Kiszka <[email protected]>---
.../single-key-to-efi-keys_0.1.bb | 41 +++++++++++++++++++1 file changed, 41 insertions(+)create mode 100644 recipes-devtools/secure-boot-efi-keys/single-key- to-efi-keys_0.1.bb
(quoted diff) +0
-0keys_0.1.bb b/recipes-devtools/secure-boot-efi-keys/single-key-to-efi- keys_0.1.bb
new file mode 100644
index 00000000..cfa48b7frecipes-devtools/secure-boot-efi-keys/single-key-to-efi-keys_0.1.bb new file +13
-0@@ -0,0 +1,41 @@ +# +# CIP Core, generic profile +# +# Copyright (c) Siemens AG, 2026 +# +# Authors: +# Jan Kiszka <[email protected]> +# +# SPDX-License-Identifier: MIT +# + +inherit dpkg +
Quoted 9 lines
recipes-devtools/secure-boot-efi-keys/single-key-to-efi-keys_0.1.bb line 17
Quoted 4 lines
recipes-devtools/secure-boot-efi-keys/single-key-to-efi-keys_0.1.bb new file +4
-0+MAINTAINER = "cip-dev <[email protected]>" +DESCRIPTION = "Generate EFI keys from single secure boot key" + +PROVIDES += "secure-boot-efi-keys"The naming confuses actual keys (private portions) with authenticated efi signature list) actually holding the secure-boot-certificates - so maybe secure-boot-vars-auth, secure-boot-certificates-auth or even secure-boot-certificates is more intuitive?
Agree. How about secure-boot-efi-certs?
Jan
Signature · 2 lines
Siemens AG, Foundational Technologies Linux Expert Center
Re: [isar-cip-core][PATCH 1/7] secure-boot-efi-keys: Add recipe to create EFI keys
Am 26.08.2026 um 10:44 schrieb Jan Kiszka:
Quoted 50 lines · Alexander (FT RPD CED SES-AT)
Quoted 39 lines
Am 26.08.2026 um 07:41 schrieb Jan Kiszka:
Quoted 36 lines
From: Jan Kiszka <[email protected]>
This recipe allows to derive the PK, KEK and db values from a single signing key as we are using for demonstration/testing purposes and simple scenarios. The recipe provides abstract "secure-boot-efi-keys" which could also be offered by an alternative recipe/package that picks up differently generated keys and/or a proper key hierarchy.
Signed-off-by Jan Kiszka <[email protected]>--- .../single-key-to-efi-keys_0.1.bb | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+)create mode 100644 recipes-devtools/secure-boot-efi-keys/single-key-
to-efi-keys_0.1.bb(quoted diff) +0
-0keys_0.1.bb b/recipes-devtools/secure-boot-efi-keys/single-key-to-efi- keys_0.1.bb
new file mode 100644
index 00000000..cfa48b7frecipes-devtools/secure-boot-efi-keys/single-key-to-efi-keys_0.1.bb new file +13
-0@@ -0,0 +1,41 @@ +# +# CIP Core, generic profile +# +# Copyright (c) Siemens AG, 2026 +# +# Authors: +# Jan Kiszka <[email protected]> +# +# SPDX-License-Identifier: MIT +# + +inherit dpkg +Quoted 9 lines
recipes-devtools/secure-boot-efi-keys/single-key-to-efi-keys_0.1.bb line 17
Quoted 4 lines
recipes-devtools/secure-boot-efi-keys/single-key-to-efi-keys_0.1.bb new file +4
-0+MAINTAINER = "cip-dev <[email protected]>" +DESCRIPTION = "Generate EFI keys from single secure boot key" + +PROVIDES += "secure-boot-efi-keys"The naming confuses actual keys (private portions) with authenticated efi signature list) actually holding the secure-boot-certificates - so maybe secure-boot-vars-auth, secure-boot-certificates-auth or even secure-boot-certificates is more intuitive?
Quoted 1 line
Agree. How about secure-boot-efi-certs?
Nice.
Quoted 3 lines
Jan
PATCH 2/7 cip-initramfs-functions: Add secure_boot_enabled helper
In reply to Jan KiszkaFrom: Jan Kiszka <[email protected]>
Will allow initramfs hooks to determine whether UEFI secure boot is enabled. The user is responsible for deploying cmp and mountpoint binaries into the initramfs.
--- .../files/cip-initramfs-functions | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
recipes-initramfs/initramfs-cip-functions/files/cip-initramfs-functions +16 -0
@@ -68,3 +68,19 @@ scan_for_partitions() { fi return 1 } + +# check if system was securely booted via UEFI +secure_boot_enabled() { + efivars=/sys/firmware/efi/efivars + if ! mountpoint -q $efivars; then + mount -t efivarfs none $efivars + fi + + secure_boot="$efivars/SecureBoot-8be4df61-93ca-11d2-aa0d-00e098032b8c" + setup_mode="$efivars/SetupMode-8be4df61-93ca-11d2-aa0d-00e098032b8c" + if printf '\001' | cmp -s -i 4:0 $secure_boot && + printf '\000' | cmp -s -i 4:0 $setup_mode; then + return 0 + fi + return 1 +}
Signature · 1 line
2.47.3
Re: [isar-cip-core][PATCH 2/7] cip-initramfs-functions: Add secure_boot_enabled helper
Am 26.08.2026 um 07:41 schrieb Jan Kiszka:
Quoted 21 lines
From: Jan Kiszka <[email protected]>
Will allow initramfs hooks to determine whether UEFI secure boot is enabled. The user is responsible for deploying cmp and mountpoint binaries into the initramfs.
Signed-off-by Jan Kiszka <[email protected]>--- .../files/cip-initramfs-functions | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)recipes-initramfs/initramfs-cip-functions/files/cip-initramfs-functions +2
-0@@ -68,3 +68,19 @@ scan_for_partitions() { fi return 1 } + +# check if system was securely booted via UEFI
recipes-initramfs/initramfs-cip-functions/files/cip-initramfs-functions scan_for_partitions() { · line 82
Quoted 10 lines
recipes-initramfs/initramfs-cip-functions/files/cip-initramfs-functions +10
-0+secure_boot_enabled() { + efivars=/sys/firmware/efi/efivars + if ! mountpoint -q $efivars; then + mount -t efivarfs none $efivars + fi + + secure_boot="$efivars/SecureBoot-8be4df61-93ca-11d2-aa0d-00e098032b8c" + setup_mode="$efivars/SetupMode-8be4df61-93ca-11d2-aa0d-00e098032b8c" + if printf '\001' | cmp -s -i 4:0 $secure_boot && + printf '\000' | cmp -s -i 4:0 $setup_mode; then
What about audit mode?
recipes-initramfs/initramfs-cip-functions/files/cip-initramfs-functions scan_for_partitions() { · line 86
Quoted 4 lines
recipes-initramfs/initramfs-cip-functions/files/cip-initramfs-functions +4
-0+ return 0 + fi + return 1 +}
BR Alexander
Re: [isar-cip-core][PATCH 2/7] cip-initramfs-functions: Add secure_boot_enabled helper
Quoted 32 lines · Alexander (FT RPD CED SES-AT)
Am 26.08.2026 um 07:41 schrieb Jan Kiszka:
Quoted 29 lines
From: Jan Kiszka <[email protected]>
Will allow initramfs hooks to determine whether UEFI secure boot is enabled. The user is responsible for deploying cmp and mountpoint binaries into the initramfs.
Signed-off-by Jan Kiszka <[email protected]>---
.../files/cip-initramfs-functions | 16 ++++++++++++++++1 file changed, 16 insertions(+)(quoted diff) +0
-0initramfs-functions b/recipes-initramfs/initramfs-cip-functions/files/ cip-initramfs-functions
indexa4c1fed6..f14956d5100644
--- a/recipes-initramfs/initramfs-cip-functions/files/cip-initramfs- functions
+++ b/recipes-initramfs/initramfs-cip-functions/files/cip-initramfs- functions(quoted diff) +0
-0@@ -68,3 +68,19 @@ scan_for_partitions() {fi
return 1
}recipes-initramfs/initramfs-cip-functions/files/cip-initramfs-functions +6
-0+ +# check if system was securely booted via UEFI +secure_boot_enabled() { + efivars=/sys/firmware/efi/efivars + if ! mountpoint -q $efivars; then + mount -t efivarfs none $efivars
Quoted 8 lines
Quoted 7 lines
+ fi
+
+ secure_boot="$efivars/SecureBoot-8be4df61-93ca-11d2- aa0d-00e098032b8c"
+ setup_mode="$efivars/SetupMode-8be4df61-93ca-11d2-aa0d-00e098032b8c" + if printf '\001' | cmp -s -i 4:0 $secure_boot &&
+ printf '\000' | cmp -s -i 4:0 $setup_mode; thenWhat about audit mode?
You mean, I should check for != 1 instead? Seems that this is what the kernel does as well...
Jan
Signature · 2 lines
Siemens AG, Foundational Technologies Linux Expert Center
Re: [isar-cip-core][PATCH 2/7] cip-initramfs-functions: Add secure_boot_enabled helper
Am 26.08.2026 um 09:54 schrieb Jan Kiszka:
Quoted 42 lines · Alexander (FT RPD CED SES-AT)
Quoted 32 lines
Am 26.08.2026 um 07:41 schrieb Jan Kiszka:
Quoted 29 lines
From: Jan Kiszka <[email protected]>
Will allow initramfs hooks to determine whether UEFI secure boot is enabled. The user is responsible for deploying cmp and mountpoint binaries into the initramfs.
Signed-off-by Jan Kiszka <[email protected]>--- .../files/cip-initramfs-functions | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)(quoted diff) +0
-0initramfs-functions b/recipes-initramfs/initramfs-cip-functions/files/ cip-initramfs-functions
indexa4c1fed6..f14956d5100644
--- a/recipes-initramfs/initramfs-cip-functions/files/cip-initramfs- functions
+++ b/recipes-initramfs/initramfs-cip-functions/files/cip-initramfs- functionsrecipes-initramfs/initramfs-cip-functions/files/cip-initramfs-functions +6
-0@@ -68,3 +68,19 @@ scan_for_partitions() { fi return 1 } + +# check if system was securely booted via UEFI +secure_boot_enabled() { + efivars=/sys/firmware/efi/efivars + if ! mountpoint -q $efivars; then + mount -t efivarfs none $efivarsQuoted 8 lines
Quoted 7 lines
recipes-initramfs/initramfs-cip-functions/files/cip-initramfs-functions +3
-0+ fi + + secure_boot="$efivars/SecureBoot-8be4df61-93ca-11d2-aa0d-00e098032b8c"
+ setup_mode="$efivars/SetupMode-8be4df61-93ca-11d2-aa0d-00e098032b8c" + if printf '\001' | cmp -s -i 4:0 $secure_boot &&
+ printf '\000' | cmp -s -i 4:0 $setup_mode; thenWhat about audit mode?
Quoted 2 lines
You mean, I should check for != 1 instead? Seems that this is what the kernel does as well...
Got confused by differing PCR measuers wrt. audit and deployed mode.
If the hooks start in audit mode we end up in deployed mode, and if we start in setup mode we end up in user mode, which has effects on PCR1 and PCR7 respectivly, thus disk encryption. Not an issue, just something to be aware of :-)
I double checked with uefi spec. In audit mode SetupMode == 1 and SecureBoot == 0 => your detection already covers both cases.
Sry for the confusion.
Quoted 3 lines
Jan
PATCH 3/7 cip-core-initramfs: Automatically deploy secure boot keys on first boot
In reply to Jan KiszkaFrom: Jan Kiszka <[email protected]>
This both simplifies the initial deployment of secure boot to a device as well as makes sure that we will always seal the disk encryption key against the right state.
We only deploy if secure boot is off and the db is found empty. So this hook is not intended to be used for key exchange or key db extensions. The former will be once handled via SWUpdate packages, the latter might be considered given a concrete use case.
Note that due to the primitive implementation of efivarfs detection in efitools, we need to deploy a horrible hack to make it work against the mount implementation of busybox in the initramfs. A patch to improve that issue is pending upstream.
--- .../cip-core-initramfs/cip-core-initramfs.bb | 1 + .../initramfs-sbkeys-hook/files/hook | 16 +++++++++ .../initramfs-sbkeys-hook/files/local-top | 34 +++++++++++++++++++ .../initramfs-sbkeys-hook/files/mount-stub | 13 +++++++ .../initramfs-sbkeys-hook_0.1.bb | 32 +++++++++++++++++ 5 files changed, 96 insertions(+) create mode 100644 recipes-initramfs/initramfs-sbkeys-hook/files/hook create mode 100644 recipes-initramfs/initramfs-sbkeys-hook/files/local-top create mode 100755 recipes-initramfs/initramfs-sbkeys-hook/files/mount-stub create mode 100644 recipes-initramfs/initramfs-sbkeys-hook/initramfs-sbkeys-hook_0.1.bb
recipes-initramfs/cip-core-initramfs/cip-core-initramfs.bb +1 -0
@@ -22,6 +22,7 @@ INITRAMFS_INSTALL:append:factory-reset = " initramfs-factory-reset-hook" INITRAMFS_INSTALL:append:ftpm-stmm = " initramfs-tee-ftpm-hook" INITRAMFS_INSTALL:append:swupdate = " initramfs-abrootfs-hook" INITRAMFS_INSTALL:append:swupdate = " initramfs-${RO_ROOTFS_TYPE}-hook" +INITRAMFS_INSTALL:append:secureboot = " initramfs-sbkeys-hook" INITRAMFS_INSTALL:append:secureboot = " initramfs-verity-hook" # abrootfs cannot be installed together with verity INITRAMFS_INSTALL:remove:secureboot = "initramfs-abrootfs-hook"
recipes-initramfs/initramfs-sbkeys-hook/files/hook new file +16 -0
@@ -0,0 +1,16 @@ +# +# CIP Core, generic profile +# +# Copyright (c) Siemens AG, 2026 +# +# Authors: +# Jan Kiszka <[email protected]> +# +# SPDX-License-Identifier: MIT +# + +copy_file binary /usr/share/secure-boot-efi-keys/db.auth +copy_file binary /usr/share/secure-boot-efi-keys/KEK.auth +copy_file binary /usr/share/secure-boot-efi-keys/PK.auth + +copy_file binary /usr/share/initramfs-sbkeys-hook/mount
recipes-initramfs/initramfs-sbkeys-hook/files/local-top new file +34 -0
@@ -0,0 +1,34 @@ +# +# CIP Core, generic profile +# +# Copyright (c) Siemens AG, 2026 +# +# Authors: +# Jan Kiszka <[email protected]> +# +# SPDX-License-Identifier: MIT +# + +. /scripts/cip-initramfs-functions + +if secure_boot_enabled; then + exit 0 +fi + +ORIG_PATH="$PATH" +export PATH="/usr/share/initramfs-sbkeys-hook:$PATH" + +if ! efi-readvar -v db | grep -q "has no entries"; then + export PATH="$ORIG_PATH" + log_warning_msg "Not securely booting, but keys already deployed" + exit 0 +fi + +log_begin_msg "Deploying EFI secure boot keys" +efi-updatevar -f /usr/share/secure-boot-efi-keys/db.auth db +efi-updatevar -f /usr/share/secure-boot-efi-keys/KEK.auth KEK +efi-updatevar -f /usr/share/secure-boot-efi-keys/PK.auth PK +log_end_msg + +log_success_msg "Rebooting after key deployment..." +reboot
recipes-initramfs/initramfs-sbkeys-hook/files/mount-stub new file +13 -0
@@ -0,0 +1,13 @@ +#!/bin/sh +# +# CIP Core, generic profile +# +# Copyright (c) Siemens AG, 2026 +# +# Authors: +# Jan Kiszka <[email protected]> +# +# SPDX-License-Identifier: MIT +# + +echo "none on /sys/firmware/efi/efivars type efivarfs"
recipes-initramfs/initramfs-sbkeys-hook/initramfs-sbkeys-hook_0.1.bb new file +32 -0
@@ -0,0 +1,32 @@ +# +# CIP Core, generic profile +# +# Copyright (c) Siemens AG, 2026 +# +# Authors: +# Jan Kiszka <[email protected]> +# +# SPDX-License-Identifier: MIT +# + +inherit initramfs-hook + +MAINTAINER = "cip-dev <[email protected]>" +DESCRIPTION = "Initramfs hook to deploy UEFI secure boot keys during early boot" + +DEPENDS = "secure-boot-efi-keys initramfs-cip-functions" +DEBIAN_DEPENDS .= ", secure-boot-efi-keys, efitools, initramfs-cip-functions" + +HOOK_COPY_EXECS = "cmp mountpoint efi-readvar efi-updatevar grep" + +HOOK_ADD_MODULES = "efivarfs" + +SRC_URI += " \ + file://hook \ + file://local-top \ + file://mount-stub" + +do_install[cleandirs] += "${D}/usr/share/${BPN}" +do_install:append() { + install "${WORKDIR}/mount-stub" "${D}/usr/share/${BPN}/mount" +}
Signature · 1 line
2.47.3
Re: [isar-cip-core][PATCH 3/7] cip-core-initramfs: Automatically deploy secure boot keys on first boot
Am 26.08.2026 um 07:41 schrieb Jan Kiszka:
Quoted 112 lines
From: Jan Kiszka <[email protected]>
This both simplifies the initial deployment of secure boot to a device as well as makes sure that we will always seal the disk encryption key against the right state.
We only deploy if secure boot is off and the db is found empty. So this hook is not intended to be used for key exchange or key db extensions. The former will be once handled via SWUpdate packages, the latter might be considered given a concrete use case.
Note that due to the primitive implementation of efivarfs detection in efitools, we need to deploy a horrible hack to make it work against the mount implementation of busybox in the initramfs. A patch to improve that issue is pending upstream.
Signed-off-by Jan Kiszka <[email protected]>--- .../cip-core-initramfs/cip-core-initramfs.bb | 1 + .../initramfs-sbkeys-hook/files/hook | 16 +++++++++ .../initramfs-sbkeys-hook/files/local-top | 34 +++++++++++++++++++ .../initramfs-sbkeys-hook/files/mount-stub | 13 +++++++ .../initramfs-sbkeys-hook_0.1.bb | 32 +++++++++++++++++ 5 files changed, 96 insertions(+)create mode 100644 recipes-initramfs/initramfs-sbkeys-hook/files/hook create mode 100644 recipes-initramfs/initramfs-sbkeys-hook/files/local-top create mode 100755 recipes-initramfs/initramfs-sbkeys-hook/files/mount-stub create mode 100644 recipes-initramfs/initramfs-sbkeys-hook/initramfs-sbkeys-hook_0.1.bb
recipes-initramfs/cip-core-initramfs/cip-core-initramfs.bb +1
-0@@ -22,6 +22,7 @@ INITRAMFS_INSTALL:append:factory-reset = " initramfs-factory-reset-hook" INITRAMFS_INSTALL:append:ftpm-stmm = " initramfs-tee-ftpm-hook" INITRAMFS_INSTALL:append:swupdate = " initramfs-abrootfs-hook" INITRAMFS_INSTALL:append:swupdate = " initramfs-${RO_ROOTFS_TYPE}-hook" +INITRAMFS_INSTALL:append:secureboot = " initramfs-sbkeys-hook" INITRAMFS_INSTALL:append:secureboot = " initramfs-verity-hook" # abrootfs cannot be installed together with verity INITRAMFS_INSTALL:remove:secureboot = "initramfs-abrootfs-hook"recipes-initramfs/initramfs-sbkeys-hook/files/hook new file +16
-0@@ -0,0 +1,16 @@ +# +# CIP Core, generic profile +# +# Copyright (c) Siemens AG, 2026 +# +# Authors: +# Jan Kiszka <[email protected]> +# +# SPDX-License-Identifier: MIT +# + +copy_file binary /usr/share/secure-boot-efi-keys/db.auth +copy_file binary /usr/share/secure-boot-efi-keys/KEK.auth +copy_file binary /usr/share/secure-boot-efi-keys/PK.auth + +copy_file binary /usr/share/initramfs-sbkeys-hook/mountrecipes-initramfs/initramfs-sbkeys-hook/files/local-top new file +34
-0@@ -0,0 +1,34 @@ +# +# CIP Core, generic profile +# +# Copyright (c) Siemens AG, 2026 +# +# Authors: +# Jan Kiszka <[email protected]> +# +# SPDX-License-Identifier: MIT +# + +. /scripts/cip-initramfs-functions + +if secure_boot_enabled; then + exit 0 +fi + +ORIG_PATH="$PATH" +export PATH="/usr/share/initramfs-sbkeys-hook:$PATH" + +if ! efi-readvar -v db | grep -q "has no entries"; then + export PATH="$ORIG_PATH" + log_warning_msg "Not securely booting, but keys already deployed" + exit 0 +fi + +log_begin_msg "Deploying EFI secure boot keys" +efi-updatevar -f /usr/share/secure-boot-efi-keys/db.auth db +efi-updatevar -f /usr/share/secure-boot-efi-keys/KEK.auth KEK +efi-updatevar -f /usr/share/secure-boot-efi-keys/PK.auth PK +log_end_msg + +log_success_msg "Rebooting after key deployment..." +rebootrecipes-initramfs/initramfs-sbkeys-hook/files/mount-stub new file +3
-0@@ -0,0 +1,13 @@ +#!/bin/sh +# +# CIP Core, generic profile
recipes-initramfs/initramfs-sbkeys-hook/files/mount-stub line 13
Quoted 10 lines
recipes-initramfs/initramfs-sbkeys-hook/files/mount-stub new file +10
-0+# +# Copyright (c) Siemens AG, 2026 +# +# Authors: +# Jan Kiszka <[email protected]> +# +# SPDX-License-Identifier: MIT +# + +echo "none on /sys/firmware/efi/efivars type efivarfs"
what about "cat /proc/mounts" to get the actual systems mount points instead of mocking expected behaviour?
Quoted 38 lines
recipes-initramfs/initramfs-sbkeys-hook/initramfs-sbkeys-hook_0.1.bb new file +32
-0@@ -0,0 +1,32 @@ +# +# CIP Core, generic profile +# +# Copyright (c) Siemens AG, 2026 +# +# Authors: +# Jan Kiszka <[email protected]> +# +# SPDX-License-Identifier: MIT +# + +inherit initramfs-hook + +MAINTAINER = "cip-dev <[email protected]>" +DESCRIPTION = "Initramfs hook to deploy UEFI secure boot keys during early boot" + +DEPENDS = "secure-boot-efi-keys initramfs-cip-functions" +DEBIAN_DEPENDS .= ", secure-boot-efi-keys, efitools, initramfs-cip-functions" + +HOOK_COPY_EXECS = "cmp mountpoint efi-readvar efi-updatevar grep" + +HOOK_ADD_MODULES = "efivarfs" + +SRC_URI += " \ + file://hook \ + file://local-top \ + file://mount-stub" + +do_install[cleandirs] += "${D}/usr/share/${BPN}" +do_install:append() { + install "${WORKDIR}/mount-stub" "${D}/usr/share/${BPN}/mount" +}
Re: [isar-cip-core][PATCH 3/7] cip-core-initramfs: Automatically deploy secure boot keys on first boot
Quoted 127 lines · Alexander (FT RPD CED SES-AT)
Am 26.08.2026 um 07:41 schrieb Jan Kiszka:
Quoted 124 lines
From: Jan Kiszka <[email protected]>
This both simplifies the initial deployment of secure boot to a device as well as makes sure that we will always seal the disk encryption key against the right state.
We only deploy if secure boot is off and the db is found empty. So this hook is not intended to be used for key exchange or key db extensions. The former will be once handled via SWUpdate packages, the latter might be considered given a concrete use case.
Note that due to the primitive implementation of efivarfs detection in efitools, we need to deploy a horrible hack to make it work against the mount implementation of busybox in the initramfs. A patch to improve that issue is pending upstream.
Signed-off-by Jan Kiszka <[email protected]>---
.../cip-core-initramfs/cip-core-initramfs.bb | 1 + .../initramfs-sbkeys-hook/files/hook | 16 +++++++++ .../initramfs-sbkeys-hook/files/local-top | 34 +++++++++++++++++++ .../initramfs-sbkeys-hook/files/mount-stub | 13 +++++++ .../initramfs-sbkeys-hook_0.1.bb | 32 +++++++++++++++++5 files changed, 96 insertions(+)create mode 100644 recipes-initramfs/initramfs-sbkeys-hook/files/hook create mode 100644 recipes-initramfs/initramfs-sbkeys-hook/files/ local-top
create mode 100755 recipes-initramfs/initramfs-sbkeys-hook/files/ mount-stub
create mode 100644 recipes-initramfs/initramfs-sbkeys-hook/ initramfs-sbkeys-hook_0.1.bb(quoted diff) +0
-0initramfs.bb b/recipes-initramfs/cip-core-initramfs/cip-core-initramfs.bb index
b686185c..241e6af6100644recipes-initramfs/cip-core-initramfs/cip-core-initramfs.bb +0
-0@@ -22,6 +22,7 @@ INITRAMFS_INSTALL:append:factory-reset = "initramfs-factory-reset-hook" INITRAMFS_INSTALL:append:ftpm-stmm = " initramfs-tee-ftpm-hook" INITRAMFS_INSTALL:append:swupdate = " initramfs-abrootfs-hook" INITRAMFS_INSTALL:append:swupdate = " initramfs-${RO_ROOTFS_TYPE}-hook" +INITRAMFS_INSTALL:append:secureboot = " initramfs-sbkeys-hook" INITRAMFS_INSTALL:append:secureboot = " initramfs-verity-hook"
# abrootfs cannot be installed together with verity INITRAMFS_INSTALL:remove:secureboot = "initramfs-abrootfs-hook"(quoted diff) renamed from recipes-initramfs/initramfs-sbkeys-hook/files/hook +0
-0recipes-initramfs/initramfs-sbkeys-hook/files/hook new file mode 100644
index 00000000..770d4454recipes-initramfs/initramfs-sbkeys-hook/files/hook new file +16
-0@@ -0,0 +1,16 @@ +# +# CIP Core, generic profile +# +# Copyright (c) Siemens AG, 2026 +# +# Authors: +# Jan Kiszka <[email protected]> +# +# SPDX-License-Identifier: MIT +# + +copy_file binary /usr/share/secure-boot-efi-keys/db.auth +copy_file binary /usr/share/secure-boot-efi-keys/KEK.auth +copy_file binary /usr/share/secure-boot-efi-keys/PK.auth + +copy_file binary /usr/share/initramfs-sbkeys-hook/mountrecipes-initramfs/initramfs-sbkeys-hook/files/local-top new file +34
-0@@ -0,0 +1,34 @@ +# +# CIP Core, generic profile +# +# Copyright (c) Siemens AG, 2026 +# +# Authors: +# Jan Kiszka <[email protected]> +# +# SPDX-License-Identifier: MIT +# + +. /scripts/cip-initramfs-functions + +if secure_boot_enabled; then + exit 0 +fi + +ORIG_PATH="$PATH" +export PATH="/usr/share/initramfs-sbkeys-hook:$PATH" + +if ! efi-readvar -v db | grep -q "has no entries"; then + export PATH="$ORIG_PATH" + log_warning_msg "Not securely booting, but keys already deployed" + exit 0 +fi + +log_begin_msg "Deploying EFI secure boot keys" +efi-updatevar -f /usr/share/secure-boot-efi-keys/db.auth db +efi-updatevar -f /usr/share/secure-boot-efi-keys/KEK.auth KEK +efi-updatevar -f /usr/share/secure-boot-efi-keys/PK.auth PK +log_end_msg + +log_success_msg "Rebooting after key deployment..." +rebootrecipes-initramfs/initramfs-sbkeys-hook/files/mount-stub new file +7
-0@@ -0,0 +1,13 @@ +#!/bin/sh +# +# CIP Core, generic profile +# +# Copyright (c) Siemens AG, 2026 +# +# Authors:
Quoted 9 lines
recipes-initramfs/initramfs-sbkeys-hook/files/mount-stub line 13
Quoted 6 lines
recipes-initramfs/initramfs-sbkeys-hook/files/mount-stub new file +6
-0+# Jan Kiszka <[email protected]> +# +# SPDX-License-Identifier: MIT +# + +echo "none on /sys/firmware/efi/efivars type efivarfs"what about "cat
/proc/mounts" to get the actual systems mount points instead of mocking expected behaviour?
https://git.kernel.org/pub/scm/linux/kernel/git/jejb/efitools.git/tree/lib/kernel_efivars.c#n69
Was my first try as well, before reading that.
Jan
Signature · 2 lines
Siemens AG, Foundational Technologies Linux Expert Center
PATCH 4/7 u-boot: Add patches to enable measured boot with fTPM
In reply to Jan KiszkaFrom: Jan Kiszka <[email protected]>
U-Boot was so far not enumerating the fTPM device, and that caused the PCRs to stay zero. systemd-cryptenroll was complaining already, just not loud enough.
With these extra patches (currently under review upstream), we are getting a TPM right before the EFI loader starts, and we get valid PCR content as well.
--- ...ement-Fix-compilation-for-non-sandbo.patch | 43 +++++ ...-out-service-enumeration-and-binding.patch | 95 +++++++++++ ...pport-for-enumerating-services-that-.patch | 155 ++++++++++++++++++ ...-warn-about-TEE_ERROR_STORAGE_NOT_AV.patch | 33 ++++ ...to-optee-after-a-successful-mmc_init.patch | 41 +++++ ...-MMC-Device-not-found-a-debug-output.patch | 50 ++++++ recipes-bsp/u-boot/u-boot-common-2026.01.inc | 6 + 7 files changed, 423 insertions(+) create mode 100644 recipes-bsp/u-boot/files/0001-test-boot-measurement-Fix-compilation-for-non-sandbo.patch create mode 100644 recipes-bsp/u-boot/files/0002-tee-optee-Factor-out-service-enumeration-and-binding.patch create mode 100644 recipes-bsp/u-boot/files/0003-tee-optee-Add-support-for-enumerating-services-that-.patch create mode 100644 recipes-bsp/u-boot/files/0004-tee-optee-Do-not-warn-about-TEE_ERROR_STORAGE_NOT_AV.patch create mode 100644 recipes-bsp/u-boot/files/0005-mmc-Call-back-to-optee-after-a-successful-mmc_init.patch create mode 100644 recipes-bsp/u-boot/files/0006-mmc-Make-MMC-Device-not-found-a-debug-output.patch
recipes-bsp/u-boot/files/0001-test-boot-measurement-Fix-compilation-for-non-sandbo.patch new file +43 -0
@@ -0,0 +1,43 @@ +From 1d9a066892b73d65129cb899c6ed611eb3d1c3bc Mon Sep 17 00:00:00 2001 +From: Jan Kiszka <[email protected]> +Date: Thu, 20 Aug 2026 17:30:54 +0200 +Subject: [PATCH 1/6] test: boot: measurement: Fix compilation for non-sandbox + builds +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +asm/io.h provides map_to_sysmem() only for the sandbox. Other targets +fail the build with + +../test/boot/measurement.c: In function ‘measure’: +../test/boot/measurement.c:30:33: error: implicit declaration of function ‘map_to_sysmem’; did you mean ‘map_physmem’? [-Wimplicit-function-declaration] + 30 | images.os.image_start = map_to_sysmem(kernel); + | ^~~~~~~~~~~~~ + | map_physmem + +Use the proper header that will pull asm/io.h only where needed. + +Signed-off-by: Jan Kiszka <[email protected]> +--- + test/boot/measurement.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/test/boot/measurement.c b/test/boot/measurement.c +index 71f503f1567..85a01f1fec8 100644 +--- a/test/boot/measurement.c ++++ b/test/boot/measurement.c +@@ -9,9 +9,9 @@ + #include <bootm.h> + #include <env.h> + #include <malloc.h> ++#include <mapmem.h> + #include <test/test.h> + #include <test/ut.h> +-#include <asm/io.h> + + #define MEASUREMENT_TEST(_name, _flags) \ + UNIT_TEST(_name, _flags, measurement) +-- +2.47.3 +
recipes-bsp/u-boot/files/0002-tee-optee-Factor-out-service-enumeration-and-binding.patch new file +95 -0
95 lines not on this page · raw message
recipes-bsp/u-boot/files/0003-tee-optee-Add-support-for-enumerating-services-that-.patch new file +155 -0
155 lines not on this page · raw message
recipes-bsp/u-boot/files/0004-tee-optee-Do-not-warn-about-TEE_ERROR_STORAGE_NOT_AV.patch new file +33 -0
@@ -0,0 +1,33 @@ +From 13fc430cf440cdbc490bce630031ca49e81e1e13 Mon Sep 17 00:00:00 2001 +From: Jan Kiszka <[email protected]> +Date: Fri, 21 Aug 2026 09:02:23 +0200 +Subject: [PATCH 4/6] tee: optee: Do not warn about + TEE_ERROR_STORAGE_NOT_AVAILABLE + +This is a transitional error that is resolved once an RPMB becomes +available. Keep it as debug output only. + +Signed-off-by: Jan Kiszka <[email protected]> +--- + drivers/tee/optee/core.c | 5 ++++- + 1 file changed, 4 insertions(+), 1 deletion(-) + +diff --git a/drivers/tee/optee/core.c b/drivers/tee/optee/core.c +index ed8f2b6ec74..d3b5811afb8 100644 +--- a/drivers/tee/optee/core.c ++++ b/drivers/tee/optee/core.c +@@ -106,7 +106,10 @@ static int __enum_services(struct udevice *dev, struct tee_shm *shm, size_t *shm + + ret = tee_invoke_func(dev, &arg, 1, ¶m); + if (ret || (arg.ret && arg.ret != TEE_ERROR_SHORT_BUFFER)) { +- dev_err(dev, "Enumeration command 0x%x failed: 0x%x\n", pta_cmd, arg.ret); ++ if (arg.ret != TEE_ERROR_STORAGE_NOT_AVAILABLE) ++ dev_err(dev, "Enumeration command 0x%x failed: 0x%x\n", pta_cmd, arg.ret); ++ else ++ dev_dbg(dev, "Enumeration command 0x%x failed due to unavailable storage\n", pta_cmd); + return -EINVAL; + } + +-- +2.47.3 +
recipes-bsp/u-boot/files/0005-mmc-Call-back-to-optee-after-a-successful-mmc_init.patch new file +41 -0
41 lines not on this page · raw message
recipes-bsp/u-boot/files/0006-mmc-Make-MMC-Device-not-found-a-debug-output.patch new file +50 -0
50 lines not on this page · raw message
recipes-bsp/u-boot/u-boot-common-2026.01.inc +6 -0
@@ -26,6 +26,12 @@ SRC_URI += " \ file://0001-riscv-create-a-custom-CPU-implementation-for-PolarFi.patch \ file://0002-riscv-mpfs-move-SoC-level-options-to-the-CPU-Kconfig.patch \ file://0003-riscv-Add-support-for-BeagleV-Fire.patch \ + file://0001-test-boot-measurement-Fix-compilation-for-non-sandbo.patch \ + file://0002-tee-optee-Factor-out-service-enumeration-and-binding.patch \ + file://0003-tee-optee-Add-support-for-enumerating-services-that-.patch \ + file://0004-tee-optee-Do-not-warn-about-TEE_ERROR_STORAGE_NOT_AV.patch \ + file://0005-mmc-Call-back-to-optee-after-a-successful-mmc_init.patch \ + file://0006-mmc-Make-MMC-Device-not-found-a-debug-output.patch \ file://rules.tmpl;subdir=debian" SRC_URI[sha256sum] = "b60d5865cefdbc75da8da4156c56c458e00de75a49b80c1a2e58a96e30ad0d54"
Signature · 1 line
2.47.3
PATCH 5/7 u-boot: Refactor ftpm-stmm.cfg to enable measured boot for all
In reply to Jan KiszkaFrom: Jan Kiszka <[email protected]>
Move the common bits out the ti-extra.cfg into the shared ftpm-stmm.cfg which is consumed by the am62px unconditionally. Any commands, though, should be selected at board level because they are not needed for the fTPM and StMM functionalities.
While at it, fix the header of the ti-extra.cfg so that its bits get removed before being re-applied.
--- recipes-bsp/u-boot/files/ftpm-stmm.cfg | 7 ++++++- recipes-bsp/u-boot/files/qemu-extra.cfg | 2 ++ recipes-bsp/u-boot/files/ti-extra.cfg | 8 +------- 3 files changed, 9 insertions(+), 8 deletions(-)
recipes-bsp/u-boot/files/ftpm-stmm.cfg +6 -1
@@ -4,5 +4,10 @@ ### Enable OPTEE, fTPM and StMM CONFIG_TEE=y CONFIG_OPTEE=y -CONFIG_CMD_OPTEE_RPMB=y +CONFIG_OPTEE_SERVICE_DISCOVERY=y CONFIG_EFI_MM_COMM_TEE=y +CONFIG_TPM=y +CONFIG_TPM_V2=y +CONFIG_TPM2_FTPM_TEE=y +CONFIG_MEASURED_BOOT=y +CONFIG_EFI_TCG2_PROTOCOL=y
recipes-bsp/u-boot/files/qemu-extra.cfg +2 -0
@@ -10,3 +10,5 @@ CONFIG_MMC_SDHCI=y CONFIG_CMD_MMC=y CONFIG_CMD_MMC_REG=y CONFIG_EFI_SCROLL_ON_CLEAR_SCREEN=y +CONFIG_CMD_OPTEE_RPMB=y +CONFIG_CMD_TPM=y
recipes-bsp/u-boot/files/ti-extra.cfg +1 -7
@@ -1,17 +1,11 @@ # # SPDX-License-Identifier: MIT # -### FTPM + RPMB + StandaloneMM setup -CONFIG_OPTEE_SERVICE_DISCOVERY=y -CONFIG_TPM=y -CONFIG_TPM_V2=y +### TI extra config CONFIG_CMD_TPM=y -CONFIG_TPM2_FTPM_TEE=y CONFIG_SUPPORT_EMMC_RPMB=y -CONFIG_MEASURED_BOOT=y CONFIG_CMD_NVEDIT_EFI=y CONFIG_CMD_MMC_RPMB=y -CONFIG_EFI_TCG2_PROTOCOL=n # workaround for v2025.07 CONFIG_USB_STORAGE=y
Signature · 1 line
2.47.3
PATCH 6/7 u-boot: Drop obsolete config workaround
In reply to Jan KiszkaFrom: Jan Kiszka <[email protected]>
We moved to a newer U-Boot version meanwhile which resolved that issue.
--- recipes-bsp/u-boot/files/secure-boot.cfg | 2 -- 1 file changed, 2 deletions(-)
recipes-bsp/u-boot/files/secure-boot.cfg +0 -2
@@ -17,5 +17,3 @@ CONFIG_FS_FAT=y CONFIG_EFI_SECURE_BOOT=y # overruled by CONFIG_EFI_MM_COMM_TEE where available CONFIG_EFI_VARIABLES_PRESEED=y -# workaround for v2025.07 -CONFIG_CMD_DHCP=y
Signature · 1 line
2.47.3
PATCH 7/7 initramfs-crypt-hook: Prevent encryption without secure boot
In reply to Jan KiszkaFrom: Jan Kiszka <[email protected]>
We so far allowed to run first-boot encryption in any secure boot state. This remained unnoticed because the QEMU x86 machine is started with keys provisioned, and the QEMU arm64 machine does not support measured boot yet. The latter is fixed, and we also deploy keys during first boot now if they aren't pre-deployed. Time to raise the bar and reject generally insecure states.
--- .../initramfs-crypt-hook/files/local-top-complete | 4 ++++ 1 file changed, 4 insertions(+)
recipes-initramfs/initramfs-crypt-hook/files/local-top-complete +4 -0
@@ -297,6 +297,10 @@ for partition_set in $partition_sets; do continue fi + if ! secure_boot_enabled; then + panic "Secure boot disabled! Must be enabled to ensure correct key sealing." + fi + # check if we are trying to mount root, set ROOT to decrypted partition: if [ "$partition_mountpoint" = "/" ]; then echo "ROOT=$decrypted_part" >/conf/param.conf
Signature · 1 line
2.47.3
Re: [isar-cip-core][PATCH 7/7] initramfs-crypt-hook: Prevent encryption without secure boot
Quoted 19 lines · Jan Kiszka
From: Jan Kiszka <[email protected]>
We so far allowed to run first-boot encryption in any secure boot state. This remained unnoticed because the QEMU x86 machine is started with keys provisioned, and the QEMU arm64 machine does not support measured boot yet. The latter is fixed, and we also deploy keys during first boot now if they aren't pre-deployed. Time to raise the bar and reject generally insecure states.
Signed-off-by Jan Kiszka <[email protected]>--- .../initramfs-crypt-hook/files/local-top-complete | 4 ++++ 1 file changed, 4 insertions(+)recipes-initramfs/initramfs-crypt-hook/files/local-top-complete +0
-0
recipes-initramfs/initramfs-crypt-hook/files/local-top-complete for partition_set in $partition_sets; do · line 303
Quoted 7 lines
recipes-initramfs/initramfs-crypt-hook/files/local-top-complete +4
-0@@ -297,6 +297,10 @@ for partition_set in $partition_sets; do continue fi + if ! secure_boot_enabled; then + panic "Secure boot disabled! Must be enabled to ensure correct key sealing." + fi +
Why is this check execute for each encrypted partiton. We could test this in front of the loop?
Quirin
Quoted 3 lines
recipes-initramfs/initramfs-crypt-hook/files/local-top-complete +0
-0# check if we are trying to mount root, set ROOT to decrypted partition: if [ "$partition_mountpoint" = "/" ]; then echo "ROOT=$decrypted_part" >/conf/param.conf
Re: [isar-cip-core][PATCH 7/7] initramfs-crypt-hook: Prevent encryption without secure boot
Quoted 17 lines · Quirin Gylstorff
Quoted 14 lines · Jan Kiszka
From: Jan Kiszka <[email protected]>
We so far allowed to run first-boot encryption in any secure boot state. This remained unnoticed because the QEMU x86 machine is started with keys provisioned, and the QEMU arm64 machine does not support measured boot yet. The latter is fixed, and we also deploy keys during first boot now if they aren't pre-deployed. Time to raise the bar and reject generally insecure states.
Signed-off-by Jan Kiszka <[email protected]>---
.../initramfs-crypt-hook/files/local-top-complete | 4 ++++1 file changed, 4 insertions(+)
Quoted 17 lines
Quoted 7 lines
(quoted diff) +0
-0complete b/recipes-initramfs/initramfs-crypt-hook/files/local-top- complete
index7bc08e55..3312e632100755recipes-initramfs/initramfs-crypt-hook/files/local-top-complete +0
-0@@ -297,6 +297,10 @@ for partition_set in $partition_sets; doQuoted 7 lines
continue
fi
+ if !secure_boot_enabled; then
+ panic "Secure boot disabled! Must be enabled to ensure correct key sealing."
+ fi
+Why is this check execute for each encrypted partiton. We could test this in front of the loop?
We only want to enforce this rule when there is actually encryption requested, and that requires to iterate over the entries.
Jan
Signature · 2 lines
Siemens AG, Foundational Technologies Linux Expert Center
[isar-cip-core][PATCH 8/7] doc: Update README.secureboot regarding recent deployment enhancements
In reply to Jan KiszkaFrom: Jan Kiszka <[email protected]>
Explain the automatic certificates deployment and its dependencies. There is no longer the need to explain manual key creation, we can simply reference the new single-key-to-efi-certs package. Keep the manual deployment method for special causes.
--- doc/README.secureboot.md | 39 +++++++++++++++++++++++++++++---------- 1 file changed, 29 insertions(+), 10 deletions(-)
doc/README.secureboot.md +29 -10
@@ -273,32 +273,51 @@ lrwxrwxrwx 1 root root 0 Jun 30 13:20 sda5 -> ../../../../pci0000:00/0000:00:1f. Secureboot for a generic UEFI x86 target works similar to the QEMU target, except the enrollment of the secure boot keys. -### Generate keys from Debian snakeoil keys +### Generate keys from a single signing key -For testing purposes, the snakeoil keys from OVMF package can be used to -convert the certificate into a efi authority file use the following commands: +The recipe `single-key-to-efi-certs` can be used to generate a Debian package +that contains the required EFI certificates for enabling secure boot. It uses +a single key/cert pair as basis. Unless otherwise configured, this pair will +be taken from the corresponding Debian snakeoil set which is fine only for +testing purposes. The package will contain the `.auth` files required for +manual deployment: -```bash -cert-to-efi-sig-list recipes-devtools/secure-boot-secrets/files/bookworm/PkKek-1-snakeoil.pem PK.esl -sign-efi-sig-list -k recipes-devtools/secure-boot-secrets/files/bookworm/PkKek-1-snakeoil.key -c recipes-devtools/secure-boot-secrets/files/bookworm/PkKek-1-snakeoil.pem PK PK.esl PK.auth +``` +$ dpkg -c build/tmp/deploy/isar-apt/cip-core-trixie/apt/cip-core-trixie/pool/main/s/single-key-to-efi-certs/single-key-to-efi-certs_0.1_arm64.deb +[...] +-rw-r--r-- root/root 2549 1970-01-01 02:00 ./usr/share/secure-boot-efi-certs/KEK.auth +-rw-r--r-- root/root 2549 1970-01-01 02:00 ./usr/share/secure-boot-efi-certs/PK.auth +-rw-r--r-- root/root 2549 1970-01-01 02:00 ./usr/share/secure-boot-efi-certs/db.auth ``` -The package `efitools` needs to be installed for this. +### Automatic secure boot certificate enrollment -In this case, the PK.esl can be used as DB and KEK keys. The PK.auth file is for PK key. +By default, isar-cip-core images contain an early boot service +(initramfs-sbcerts-hook) which will deploy the required EFI certificates during +first boot and restart the machine into secure boot afterwards. This will only +happen when the machine is in Setup Mode and no other certificates have been +deployed to the Allowed Signature Database yet. This also ensures that disk +encryption on first boot will only take place when the machine was securely +booted so that the encryption key is sealed against this state in the TPM. -### Secure boot key enrollment +The certificates needed for this auto-enrollment are taken from a package that +provides `secure-boot-efi-certs`. The `single-key-to-efi-certs` package is the +default provider of this in isar-cip-core. + +### Manual secure boot certificate enrollment > :exclamation:**IMPORTANT** This document is not for generating a Machine Owner Key(MOK). > :exclamation:**IMPORTANT** Enrollment of secure boot keys must occur > in a secure environment. -The following keys need to be enrolled onto the device: +The certificates for the following keys need to be enrolled onto the device: - The Platform Key (PK) - The Key Exchange Key (KEK) - Allowed Signatures Database +You can obtain them from the single-key-to-efi-certs package described before. + The enrollment can typically be achieved with the help of [efi-updatevar](https://manpages.debian.org/bookworm/efitools/efi-updatevar.1.en.html) on the device.
Signature · 1 line
2.47.3