feat: image signing
- todo: sign linux kernel for grub
This commit is contained in:
39
board/winf-photobooth/genkey.sh
Executable file
39
board/winf-photobooth/genkey.sh
Executable file
@@ -0,0 +1,39 @@
|
||||
#!/bin/bash
|
||||
|
||||
mkdir -p "$HOME/.config/winf-photobooth"
|
||||
chmod 700 "$HOME/.config/winf-photobooth"
|
||||
|
||||
|
||||
(
|
||||
set -e
|
||||
if [ -f "$HOME/.config/winf-photobooth/signing-key.pem" ]; then
|
||||
echo "Signing key exists, skipping..."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
umask 077
|
||||
openssl genpkey \
|
||||
-algorithm RSA \
|
||||
-pkeyopt rsa_keygen_bits:3072 \
|
||||
-aes-256-cbc \
|
||||
-out "$HOME/.config/winf-photobooth/signing-key.pem"
|
||||
)
|
||||
|
||||
(
|
||||
if [ -f "board/winf-photobooth/signing.crt" ]; then
|
||||
echo "Certificate already exists, skipping..."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
openssl req -new -x509 -sha256 -days 3650 \
|
||||
-key "$HOME/.config/winf-photobooth/signing-key.pem" \
|
||||
-subj "/CN=WINF Photobooth Secure Boot/" \
|
||||
-out board/winf-photobooth/signing.crt
|
||||
)
|
||||
|
||||
(
|
||||
openssl x509 \
|
||||
-in board/winf-photobooth/signing.crt \
|
||||
-outform DER \
|
||||
-out board/winf-photobooth/signing.cer
|
||||
)
|
||||
46
board/winf-photobooth/post-image.sh
Executable file
46
board/winf-photobooth/post-image.sh
Executable file
@@ -0,0 +1,46 @@
|
||||
#!/bin/sh
|
||||
set -e
|
||||
|
||||
if [ ! -z "$WINF_SKIP_SIGN" ]; then
|
||||
echo "WINF_SKIP_SIGN is set, skipping signing..."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
|
||||
# Sign the bootx64.efi
|
||||
binary="$BINARIES_DIR/efi-part/EFI/BOOT/bootx64.efi"
|
||||
cert=$(realpath "board/winf-photobooth/signing.crt")
|
||||
key="$HOME/.config/winf-photobooth/signing-key.pem"
|
||||
|
||||
if [ ! -f "$binary" ]; then
|
||||
echo "ERROR: EFI binary $binary not found"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ ! -f "$cert" ]; then
|
||||
echo "ERROR: Certificate $cert does not exist"
|
||||
echo " run ./board/winf-photobooth/genkey.sh"
|
||||
echo " or set WINF_SKIP_SIGN"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ ! -f "$key" ]; then
|
||||
echo "ERROR: Signing key $key does not exist"
|
||||
echo " set WINF_SKIP_SIGN to skip signing"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if sbverify --cert "$cert" "$binary" >/dev/null 2>&1; then
|
||||
echo "Already signed, bye!"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
|
||||
# Create signed file, remove at exit
|
||||
signed=$(mktemp "${binary}.signed.XXXXXX")
|
||||
trap 'rm -f "$signed"' EXIT
|
||||
|
||||
sbsign --key "$key" --cert "$cert" --output "$signed" "$binary"
|
||||
sbverify --cert "$cert" "$signed"
|
||||
|
||||
mv "$signed" "$binary"
|
||||
BIN
board/winf-photobooth/signing.cer
Normal file
BIN
board/winf-photobooth/signing.cer
Normal file
Binary file not shown.
25
board/winf-photobooth/signing.crt
Normal file
25
board/winf-photobooth/signing.crt
Normal file
@@ -0,0 +1,25 @@
|
||||
-----BEGIN CERTIFICATE-----
|
||||
MIIELTCCApWgAwIBAgIUKzybBakJXymsyS6T07l8aX7DpnAwDQYJKoZIhvcNAQEL
|
||||
BQAwJjEkMCIGA1UEAwwbV0lORiBQaG90b2Jvb3RoIFNlY3VyZSBCb290MB4XDTI2
|
||||
MTExMTE4MTI1OFoXDTM2MTEwODE4MTI1OFowJjEkMCIGA1UEAwwbV0lORiBQaG90
|
||||
b2Jvb3RoIFNlY3VyZSBCb290MIIBojANBgkqhkiG9w0BAQEFAAOCAY8AMIIBigKC
|
||||
AYEAmlYpsJt/itqE248WSY+W+VgNXcjYEYK1bkhRI3vLdyQKilUa/48cLIbVzQ+S
|
||||
2nPX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khv+bRqZKNmgIUlQ0wFwDLJRzwarseQQ60jBMCz/IW9R1
|
||||
UdZUMbo59/u+jueT6a+0Wg1WkSseei4iZZXscXSgMbHacFOZaTEEYfIhF2DsbH12
|
||||
W0u2Hs4c5uR2+Ps9ZuoK4E4=
|
||||
-----END CERTIFICATE-----
|
||||
Reference in New Issue
Block a user