-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add secureboot pre-signing to the kernel
If it detects a secure boot certificate at `keys/MOK.key` and `keys/MOK.cer`, the kernel Makefile will automatically sign the vmlinux / bzImage file that gets generated, and that is then used in packaging. By integrating it into the kernel build system directly, it is fully integrated with targets like `make deb-pkg` (opposed to `make all`, sign, `make bindeb-pkg`) and it gets added to every tree by the same mechanism that is used to apply the other surface patches anyways. Signed-off-by: Dorian Stoll <dorian.stoll@tmsp.io>
- Loading branch information
Showing
3 changed files
with
34 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#!/bin/sh | ||
# SPDX-License-Identifier: GPL-2.0 | ||
|
||
# The path to the compiled kernel image is passed as the first argument | ||
BUILDDIR=$(dirname $(dirname $0)) | ||
VMLINUX=$1 | ||
|
||
# Keys are stored in a toplevel directory called keys | ||
# The following files need to be there: | ||
# * MOK.priv (private key) | ||
# * MOK.pem (public key) | ||
# | ||
# If the files don't exist, this script will do nothing. | ||
if [[ ! -f "$BUILDDIR/keys/MOK.key" ]]; then | ||
exit 0 | ||
fi | ||
if [[ ! -f "$BUILDDIR/keys/MOK.crt" ]]; then | ||
exit 0 | ||
fi | ||
|
||
# Both required certificates were found. Check if sbsign is installed. | ||
echo "Keys for automatic secureboot signing found." | ||
if [[ ! -x "$(command -v sbsign)" ]]; then | ||
echo "ERROR: sbsign not found!" | ||
exit -2 | ||
fi | ||
|
||
# Sign the kernel | ||
sbsign --key $BUILDDIR/keys/MOK.key --cert $BUILDDIR/keys/MOK.crt \ | ||
--output $VMLINUX $VMLINUX |