Secure Boot and the Chain of Trust
Secure Boot and the Chain of Trust
UEFI Secure Boot establishes a hardware-rooted cryptographic chain of trust, ensuring that only cryptographically signed, untampered software can execute during the boot process.
+-----------------------------------------------------------+
| The Secure Boot Chain |
| |
| 1. Motherboard Firmware ROM |
| - Contains Platform Key (PK) & Key Exchange Key (KEK) |
| - Signature Database (db): Microsoft Corporation UEFI CA|
| | |
| v (Validates signature on shim) |
| 2. First-Stage Shim (shimx64.efi) |
| - Signed by Microsoft 3rd Party UEFI CA |
| - Contains custom distribution certificate (Vendor CA) |
| | |
| v (Validates signature on GRUB) |
| 3. Second-Stage Bootloader (grubx64.efi) |
| - Signed by distribution vendor key |
| | |
| v (Validates signature on Linux Kernel) |
| 4. Linux Kernel Image (vmlinuz) |
| - Signed by distribution vendor key |
| | |
| v (Enforces Kernel Lockdown Mode) |
| 5. Running Operating System |
+-----------------------------------------------------------+
The “Shim” Architecture
Virtually all consumer PC motherboards ship with only one pre-installed certificate authority in their NVRAM db: Microsoft Corporation UEFI CA 2011.
Because having every custom Linux build independently certified by Microsoft is impractical, the Linux foundation engineered the Shim architecture: - Red Hat / Canonical submit a tiny EFI binary called shimx64.efi to Microsoft once for signing. - shimx64.efi embeds the distribution’s own public certificate. - When the motherboard boots, the firmware verifies shimx64.efi using Microsoft’s key. - shimx64.efi launches, then verifies grubx64.efi and the Linux kernel using the distribution’s embedded key! - It also supports MOK (Machine Owner Key): users can enroll their own custom private keys into NVRAM via an interactive blue screen at boot time.
Signing Kernel and Bootloader Binaries
To sign your custom BYOL kernel for Secure Boot:
# 1. Generate an X.509 code-signing key and certificate:
$ openssl req -new -x509 -newkey rsa:2048 -keyout byol-sb.key \
-out byol-sb.crt -nodes -days 3650 -subj "/CN=BYOL Secure Boot Key/"
# 2. Convert to DER format:
$ openssl x509 -in byol-sb.crt -outform DER -out byol-sb.der
# 3. Sign the kernel binary using sbsigntool:
$ sbsign --key byol-sb.key --cert byol-sb.crt \
--output /boot/vmlinuz-signed arch/x86/boot/bzImage
# 4. Verify the signature:
$ sbverify --cert byol-sb.crt /boot/vmlinuz-signed
Signature verification OK