heads/initrd/bin/qubes-measure-luks
Thierry Laurion 8da5d5d723
Add dual support for real bash and busybox's bash(ash)
- modify bash to have it configured with -Os
2023-03-08 12:45:44 -05:00

22 lines
597 B
Bash
Executable File

#!/bin/bash
# Measure all of the luks disk encryption headers into
# a PCR so that we can detect disk swap attacks.
. /etc/functions
TRACE "Under /bin/qubes-measure-luks"
die() { echo >&2 "$@"; exit 1; }
# Measure the luks headers into PCR 6
for dev in "$@"; do
cryptsetup luksHeaderBackup $dev \
--header-backup-file /tmp/lukshdr-$(echo "$dev" | sed 's/\//_/g') \
|| die "$dev: Unable to read luks header"
done
sha256sum /tmp/lukshdr-* > /tmp/luksDump.txt || die "Unable to hash luks headers"
rm /tmp/lukshdr-*
tpmr extend -ix 6 -if /tmp/luksDump.txt \
|| die "Unable to extend PCR"