2023-02-08 21:01:48 +00:00
|
|
|
#!/bin/bash
|
2023-09-01 19:18:36 +00:00
|
|
|
# Measure all of the LUKS Disk Encryption headers into
|
2017-04-02 03:02:00 +00:00
|
|
|
# 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"
|
2023-09-01 19:18:36 +00:00
|
|
|
DEBUG "Arguments passed to qubes-measure-luks: $@"
|
2017-04-02 03:02:00 +00:00
|
|
|
|
2023-09-01 19:18:36 +00:00
|
|
|
# Measure the LUKS headers into PCR 6
|
2017-04-02 03:02:00 +00:00
|
|
|
for dev in "$@"; do
|
2023-09-01 19:18:36 +00:00
|
|
|
DEBUG "Storing LUKS header for $dev into /tmp/lukshdr-$(echo "$dev" | sed 's/\//_/g')"
|
2022-01-19 05:07:03 +00:00
|
|
|
cryptsetup luksHeaderBackup $dev \
|
2023-09-01 19:18:36 +00:00
|
|
|
--header-backup-file /tmp/lukshdr-$(echo "$dev" | sed 's/\//_/g') ||
|
|
|
|
die "$dev: Unable to read LUKS header"
|
2022-01-19 05:07:03 +00:00
|
|
|
done
|
|
|
|
|
2023-09-01 19:18:36 +00:00
|
|
|
DEBUG "Hashing luks headers into /tmp/luksDump.txt"
|
|
|
|
sha256sum /tmp/lukshdr-* >/tmp/luksDump.txt || die "Unable to hash luks headers"
|
|
|
|
DEBUG "Removing /tmp/lukshdr-*"
|
2022-01-19 05:07:03 +00:00
|
|
|
rm /tmp/lukshdr-*
|
2017-04-02 03:02:00 +00:00
|
|
|
|
2023-09-01 19:18:36 +00:00
|
|
|
DEBUG "Extending PCR 6 with /tmp/luksDump.txt"
|
|
|
|
tpmr extend -ix 6 -if /tmp/luksDump.txt ||
|
|
|
|
die "Unable to extend PCR"
|