Skip to content

Commit b46afe1

Browse files
committed
provisioner: Also sign boot.img with PKCS11-provided key
1 parent 7f665ac commit b46afe1

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

device-provisioner/provisioner.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,8 @@ cp "$(get_fastboot_config_file)" "${RPI_SB_WORKDIR}"/config.txt
212212
#boot.sig generation
213213
sha256sum "${RPI_SB_WORKDIR}"/boot.img | awk '{print $1}' > "${RPI_SB_WORKDIR}"/boot.sig
214214
echo -n "rsa2048: " >> "${RPI_SB_WORKDIR}"/boot.sig
215-
${OPENSSL} dgst -sign "${CUSTOMER_KEY_FILE_PEM}" -keyform PEM -sha256 "${RPI_SB_WORKDIR}"/boot.img | xxd -c 4096 -p >> "${RPI_SB_WORKDIR}"/boot.sig
215+
# Prefer PKCS11 over PEM keyfiles, if both are specified.
216+
${OPENSSL} dgst -sign "$(get_signing_directives)" -sha256 "${RPI_SB_WORKDIR}"/boot.img | xxd -c 4096 -p >> "${RPI_SB_WORKDIR}"/boot.sig
216217

217218
announce_stop "Finding/generating fastboot image"
218219

@@ -378,7 +379,7 @@ if [[ -z $(check_file_is_expected "${RPI_SB_WORKDIR}"/bootfs-temporary.img "img"
378379
# N.B. rpi-eeprom-digest could be used here but it includes a timestamp that is not required for this use-case
379380
sha256sum "${TMP_DIR}"/boot.img | awk '{print $1}' > "${TMP_DIR}"/boot.sig
380381
echo -n "rsa2048: " >> "${TMP_DIR}"/boot.sig
381-
${OPENSSL} dgst -sign "${CUSTOMER_KEY_FILE_PEM}" -keyform PEM -sha256 "${TMP_DIR}"/boot.img | xxd -c 4096 -p >> "${TMP_DIR}"/boot.sig
382+
${OPENSSL} dgst -sign "$(get_signing_directives)" -sha256 "${TMP_DIR}"/boot.img | xxd -c 4096 -p >> "${TMP_DIR}"/boot.sig
382383
announce_stop "boot.img signing"
383384

384385
announce_start "Boot Image partition extraction"

0 commit comments

Comments
 (0)