#!/usr/bin/env bash # Copyright (c) Edgeless Systems GmbH # # SPDX-License-Identifier: AGPL-3.0-only # This script is used to precalculate the PCR[9] value for a Constellation OS image. # PCR[9] contains the hash of the initrd and is measured by the linux kernel after loading the initrd. # Usage: precalculate_pcr_9.sh set -euo pipefail source "$(dirname "$0")/measure_util.sh" get_initrd_from_uki () { local uki="$1" local output="$2" objcopy -O binary --only-section=.initrd "${uki}" "${output}" } initrd_measure () { local path="$1" sha256sum "${path}" | cut -d " " -f 1 } write_output () { local out="$1" cat > "${out}" <