2017-04-02 03:02:00 +00:00
|
|
|
#!/bin/sh
|
|
|
|
# Measure all of the luks disk encryption headers into
|
|
|
|
# a PCR so that we can detect disk swap attacks.
|
2023-02-18 17:58:43 +00:00
|
|
|
. /etc/functions
|
|
|
|
|
2023-02-20 16:01:17 +00:00
|
|
|
TRACE "Under /bin/qubes-measure-luks"
|
2017-04-02 03:02:00 +00:00
|
|
|
|
|
|
|
die() { echo >&2 "$@"; exit 1; }
|
|
|
|
|
|
|
|
# Measure the luks headers into PCR 6
|
|
|
|
for dev in "$@"; do
|
2022-01-19 05:07:03 +00:00
|
|
|
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-*
|
2017-04-02 03:02:00 +00:00
|
|
|
|
|
|
|
tpm extend -ix 6 -if /tmp/luksDump.txt \
|
|
|
|
|| die "Unable to extend PCR"
|