mirror of
https://github.com/linuxboot/heads.git
synced 2024-12-21 22:07:52 +00:00
35 lines
663 B
Bash
Executable File
35 lines
663 B
Bash
Executable File
#!/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 "$@"; }
|
|
|
|
key_file="$1"
|
|
if [ -z "$key_file" ]; then
|
|
key_file=/tmp/secret.key
|
|
fi
|
|
|
|
read -s -p "Disk encryption password: " tpm_password
|
|
echo
|
|
|
|
tpm nv_readvalue \
|
|
-in "$TPM_INDEX" \
|
|
-sz "$TPM_SIZE" \
|
|
-of /tmp/sealed \
|
|
|| die "Unable to read key from TPM NVRAM"
|
|
|
|
tpm unsealfile \
|
|
-if /tmp/sealed \
|
|
-of "$key_file" \
|
|
-pwdd "$tpm_password" \
|
|
-hk 40000000 \
|
|
|| die "Unable to unseal disk encryption key"
|
|
|
|
rm -f /tmp/sealed
|
|
|
|
exit 0
|