2023-02-08 16:01:48 -05:00
|
|
|
#!/bin/bash
|
2023-09-01 15:18:36 -04:00
|
|
|
# Measure all of the LUKS Disk Encryption headers into
|
2017-04-01 23:02:00 -04:00
|
|
|
# a PCR so that we can detect disk swap attacks.
|
2023-02-18 12:58:43 -05:00
|
|
|
. /etc/functions
|
|
|
|
|
2024-02-01 14:30:31 -05:00
|
|
|
TRACE_FUNC
|
2023-09-01 15:18:36 -04:00
|
|
|
DEBUG "Arguments passed to qubes-measure-luks: $@"
|
2017-04-01 23:02:00 -04:00
|
|
|
|
2023-09-01 15:18:36 -04:00
|
|
|
# Measure the LUKS headers into PCR 6
|
2017-04-01 23:02:00 -04:00
|
|
|
for dev in "$@"; do
|
2023-09-01 15:18:36 -04:00
|
|
|
DEBUG "Storing LUKS header for $dev into /tmp/lukshdr-$(echo "$dev" | sed 's/\//_/g')"
|
2022-01-19 07:07:03 +02:00
|
|
|
cryptsetup luksHeaderBackup $dev \
|
2023-09-01 15:18:36 -04:00
|
|
|
--header-backup-file /tmp/lukshdr-$(echo "$dev" | sed 's/\//_/g') ||
|
|
|
|
die "$dev: Unable to read LUKS header"
|
2022-01-19 07:07:03 +02:00
|
|
|
done
|
|
|
|
|
2023-10-23 11:52:44 -04:00
|
|
|
DEBUG "Hashing LUKS headers into /tmp/luksDump.txt"
|
|
|
|
sha256sum /tmp/lukshdr-* >/tmp/luksDump.txt || die "Unable to hash LUKS headers"
|
2023-09-01 15:18:36 -04:00
|
|
|
DEBUG "Removing /tmp/lukshdr-*"
|
2022-01-19 07:07:03 +02:00
|
|
|
rm /tmp/lukshdr-*
|
2017-04-01 23:02:00 -04:00
|
|
|
|
2023-11-06 15:53:17 -05:00
|
|
|
DEBUG "Extending TPM PCR 6 with hash of LUKS headers from /tmp/luksDump.txt"
|
2023-09-01 15:18:36 -04:00
|
|
|
tpmr extend -ix 6 -if /tmp/luksDump.txt ||
|
|
|
|
die "Unable to extend PCR"
|