2016-10-28 08:59:51 +00:00
|
|
|
#!/bin/sh
|
|
|
|
# This will unseal and unecncrypt the drive encryption key from the TPM
|
|
|
|
# It will then need to be bundled into initrd that is booted with Qubes.
|
|
|
|
|
|
|
|
TPM_INDEX=3
|
|
|
|
TPM_SIZE=312
|
|
|
|
|
|
|
|
die() { echo >&2 "$@"; exit 1; }
|
|
|
|
warn() { echo >&2 "$@"; }
|
|
|
|
|
2016-11-23 15:45:39 +00:00
|
|
|
key_file="$1"
|
|
|
|
if [ -z "$key_file" ]; then
|
|
|
|
key_file=/tmp/secret.key
|
|
|
|
fi
|
|
|
|
|
2017-04-02 03:02:00 +00:00
|
|
|
read -s -p "Disk encryption password: " tpm_password
|
2016-10-28 08:59:51 +00:00
|
|
|
echo
|
|
|
|
|
2017-04-02 03:02:00 +00:00
|
|
|
tpm nv_readvalue \
|
2016-10-28 08:59:51 +00:00
|
|
|
-in "$TPM_INDEX" \
|
|
|
|
-sz "$TPM_SIZE" \
|
|
|
|
-of /tmp/sealed \
|
|
|
|
|| die "Unable to read key from TPM NVRAM"
|
|
|
|
|
2017-04-02 03:02:00 +00:00
|
|
|
tpm unsealfile \
|
2016-10-28 08:59:51 +00:00
|
|
|
-if /tmp/sealed \
|
2016-11-23 15:45:39 +00:00
|
|
|
-of "$key_file" \
|
2016-10-28 08:59:51 +00:00
|
|
|
-pwdd "$tpm_password" \
|
|
|
|
-hk 40000000 \
|
|
|
|
|| die "Unable to unseal disk encryption key"
|
|
|
|
|
2017-04-02 03:02:00 +00:00
|
|
|
rm -f /tmp/sealed
|
2016-11-23 15:45:39 +00:00
|
|
|
|
2017-04-02 03:02:00 +00:00
|
|
|
exit 0
|