#!/usr/bin/env bash # Copyright (c) Edgeless Systems GmbH # # SPDX-License-Identifier: AGPL-3.0-only # This script is used to precalculate the PCR[8] value for a Constellation OS image. # PCR[8] contains the hash of the kernel command line and is measured by systemd-boot. # This value is deprecated and will be moved to PCR[12] in the future. # This script may produce wrong results after 2023 (when the kernel command line is only measured in PCR[12]). # Usage: precalculate_pcr_8.sh set -euo pipefail source "$(dirname "$0")/measure_util.sh" get_cmdline_from_uki () { local uki="$1" local output="$2" objcopy -O binary --only-section=.cmdline "${uki}" "${output}" } cmdline_measure () { local path="$1" local tmp=$(mktemp) # convert to utf-16le and add a null terminator iconv -f utf-8 -t utf-16le "${path}" -o "${tmp}" truncate -s +2 "${tmp}" sha256sum "${tmp}" | cut -d " " -f 1 rm "${tmp}" } write_output () { local out="$1" cat > "${out}" <