Skip to content

Commit

Permalink
balena-keys: Distinguish EFI devices
Browse files Browse the repository at this point in the history
Non EFI devices do not need the UEFI secure boot keys.

Change-type: patch
Signed-off-by: Alex Gonzalez <alexg@balena.io>
  • Loading branch information
alexgg committed Jan 12, 2024
1 parent 0c0966b commit dc78e4f
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions meta-balena-common/recipes-support/balena-keys/balena-keys.bb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ inherit allarch deploy
EXCLUDE_FROM_WORLD = "1"
INHIBIT_DEFAULT_DEPS = "1"
ALLOW_EMPTY:${PN} = "1"
DEPENDS = "balena-db-hashes"
DEPENDS = "${@bb.utils.contains("MACHINE_FEATURES","efi","balena-db-hashes","",d)}"

# Fetch the specified public key from the signing server
#
Expand All @@ -27,7 +27,7 @@ fetch_key() {
RESPONSE_FILE=$(mktemp)
export CURL_CA_BUNDLE="${STAGING_DIR_NATIVE}/etc/ssl/certs/ca-certificates.crt"
curl --fail "${SIGN_API}/${1}" -o "${RESPONSE_FILE}"
if [ "${2}" = ".key" ]; then
if echo "${1}" | grep -q -w 'gpg/key' && [ "${2}" = ".key" ]; then
jq -r "${2}" < "${RESPONSE_FILE}" | gpg --dearmor > "${DEST_DIR}/${3}"
else
jq -r "${2}" < "${RESPONSE_FILE}" > "${DEST_DIR}/${3}"
Expand All @@ -45,12 +45,14 @@ fetch_key() {
}

do_get_public_keys() {
fetch_key "gpg/key/${SIGN_GRUB_KEY_ID}" ".key" "grub.gpg"
fetch_key "kmod/cert/${SIGN_KMOD_KEY_ID}" ".cert" "kmod.crt"
fetch_key "secureboot/pk/${SIGN_EFI_PK_KEY_ID}" ".pk" "PK.auth"
fetch_key "secureboot/pk/${SIGN_EFI_PK_KEY_ID}" ".esl" "PK.esl"
fetch_key "secureboot/kek/${SIGN_EFI_KEK_KEY_ID}" ".kek" "KEK.auth"
fetch_key "secureboot/kek/${SIGN_EFI_KEK_KEY_ID}" ".esl" "KEK.esl"
if ${@bb.utils.contains('MACHINE_FEATURES', 'efi', 'true', 'false', d)}; then
fetch_key "gpg/key/${SIGN_GRUB_KEY_ID}" ".key" "grub.gpg"
fetch_key "secureboot/pk/${SIGN_EFI_PK_KEY_ID}" ".pk" "PK.auth"
fetch_key "secureboot/pk/${SIGN_EFI_PK_KEY_ID}" ".esl" "PK.esl"
fetch_key "secureboot/kek/${SIGN_EFI_KEK_KEY_ID}" ".kek" "KEK.auth"
fetch_key "secureboot/kek/${SIGN_EFI_KEK_KEY_ID}" ".esl" "KEK.esl"
fi

if [ -n "${SIGN_KMOD_KEY_APPEND}" ]; then
bbnote "Appending additional module signing key(s) to trusted keys"
Expand Down

0 comments on commit dc78e4f

Please sign in to comment.