2017-04-01 23:02:00 -04: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 12:58:43 -05:00
|
|
|
. /etc/functions
|
|
|
|
|
2023-02-20 11:01:17 -05:00
|
|
|
TRACE "Under /bin/qubes-measure-luks"
|
2017-04-01 23:02:00 -04:00
|
|
|
|
|
|
|
die() { echo >&2 "$@"; exit 1; }
|
|
|
|
|
|
|
|
# Measure the luks headers into PCR 6
|
|
|
|
for dev in "$@"; do
|
2022-01-19 07:07:03 +02: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-01 23:02:00 -04:00
|
|
|
|
2022-08-25 14:43:31 -04:00
|
|
|
tpmr extend -ix 6 -if /tmp/luksDump.txt \
|
2017-04-01 23:02:00 -04:00
|
|
|
|| die "Unable to extend PCR"
|