|
|
8e15ce |
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
|
8e15ce |
From: Daniel Axtens <dja@axtens.net>
|
|
|
8e15ce |
Date: Sat, 15 Aug 2020 02:19:36 +1000
|
|
|
8e15ce |
Subject: [PATCH] docs/grub: Document signing grub with an appended signature
|
|
|
8e15ce |
|
|
|
8e15ce |
Signing grub for firmware that verifies an appended signature is a
|
|
|
8e15ce |
bit fiddly. I don't want people to have to figure it out from scratch
|
|
|
8e15ce |
so document it here.
|
|
|
8e15ce |
|
|
|
8e15ce |
Signed-off-by: Daniel Axtens <dja@axtens.net>
|
|
|
8e15ce |
---
|
|
|
8e15ce |
docs/grub.texi | 42 ++++++++++++++++++++++++++++++++++++++++++
|
|
|
8e15ce |
1 file changed, 42 insertions(+)
|
|
|
8e15ce |
|
|
|
8e15ce |
diff --git a/docs/grub.texi b/docs/grub.texi
|
|
|
b35c50 |
index 365d1d6931..afbde7c1f7 100644
|
|
|
8e15ce |
--- a/docs/grub.texi
|
|
|
8e15ce |
+++ b/docs/grub.texi
|
|
|
8e15ce |
@@ -6087,6 +6087,48 @@ image works under UEFI secure boot and can maintain the secure-boot chain. It
|
|
|
8e15ce |
will also be necessary to enrol the public key used into a relevant firmware
|
|
|
8e15ce |
key database.
|
|
|
8e15ce |
|
|
|
8e15ce |
+@section Signing GRUB with an appended signature
|
|
|
8e15ce |
+
|
|
|
8e15ce |
+The @file{core.elf} itself can be signed with a Linux kernel module-style
|
|
|
8e15ce |
+appended signature.
|
|
|
8e15ce |
+
|
|
|
8e15ce |
+To support IEEE1275 platforms where the boot image is often loaded directly
|
|
|
8e15ce |
+from a disk partition rather than from a file system, the @file{core.elf}
|
|
|
8e15ce |
+can specify the size and location of the appended signature with an ELF
|
|
|
8e15ce |
+note added by @command{grub-install}.
|
|
|
8e15ce |
+
|
|
|
8e15ce |
+An image can be signed this way using the @command{sign-file} command from
|
|
|
8e15ce |
+the Linux kernel:
|
|
|
8e15ce |
+
|
|
|
8e15ce |
+@example
|
|
|
8e15ce |
+@group
|
|
|
8e15ce |
+# grub.key is your private key and certificate.der is your public key
|
|
|
8e15ce |
+
|
|
|
8e15ce |
+# Determine the size of the appended signature. It depends on the signing
|
|
|
8e15ce |
+# certificate and the hash algorithm
|
|
|
8e15ce |
+touch empty
|
|
|
8e15ce |
+sign-file SHA256 grub.key certificate.der empty empty.sig
|
|
|
8e15ce |
+SIG_SIZE=`stat -c '%s' empty.sig`
|
|
|
8e15ce |
+rm empty empty.sig
|
|
|
8e15ce |
+
|
|
|
8e15ce |
+# Build a grub image with $SIG_SIZE reserved for the signature
|
|
|
8e15ce |
+grub-install --appended-signature-size $SIG_SIZE --modules="..." ...
|
|
|
8e15ce |
+
|
|
|
8e15ce |
+# Replace the reserved size with a signature:
|
|
|
8e15ce |
+# cut off the last $SIG_SIZE bytes with truncate's minus modifier
|
|
|
8e15ce |
+truncate -s -$SIG_SIZE /boot/grub/powerpc-ieee1275/core.elf core.elf.unsigned
|
|
|
8e15ce |
+# sign the trimmed file with an appended signature, restoring the correct size
|
|
|
8e15ce |
+sign-file SHA256 grub.key certificate.der core.elf.unsigned core.elf.signed
|
|
|
8e15ce |
+
|
|
|
8e15ce |
+# Don't forget to install the signed image as required
|
|
|
8e15ce |
+# (e.g. on powerpc-ieee1275, to the PReP partition)
|
|
|
8e15ce |
+@end group
|
|
|
8e15ce |
+@end example
|
|
|
8e15ce |
+
|
|
|
8e15ce |
+As with UEFI secure boot, it is necessary to build in the required modules,
|
|
|
8e15ce |
+or sign them separately.
|
|
|
8e15ce |
+
|
|
|
8e15ce |
+
|
|
|
8e15ce |
@node Platform limitations
|
|
|
8e15ce |
@chapter Platform limitations
|
|
|
8e15ce |
|