#!/bin/sh # Helper script to generate .sig files for use with the Raspberry Pi bootloader. # This has been implemented in a separate script in order to have avoid having # a hard dependency on OpenSSL. set -e OPENSSL=${OPENSSl:-openssl} die() { echo "$@" >&2 exit 1 } TMP_DIR="" cleanup() { if [ -f "${TMP_DIR}" ]; then rm -rf "${TMP_DIR}" fi } checkDependencies() { if ! command -v sha256sum > /dev/null; then die "sha256sum not found. Try installing the coreutilities package." fi if ! command -v openssl > /dev/null; then die "openssl not found. Try installing the openssl package." fi if ! command -v xxd > /dev/null; then die "xxd not found. Try installing the xxd package." fi } usage() { cat < "${OUTPUT}" # Include the update-timestamp echo "ts: $(date -u +%s)" >> "${OUTPUT}" if [ -n "${KEY}" ]; then [ -f "${KEY}" ] || die "RSA private \"${KEY}\" not found" "${OPENSSL}" dgst -sign "${KEY}" -keyform PEM -sha256 -out "${SIG_TMP}" "${IMAGE}" echo "rsa2048: $(xxd -c 4096 -p < "${SIG_TMP}")" >> "${OUTPUT}" fi