2017-04-12 10:49:39 +00:00
|
|
|
#!/bin/sh
|
|
|
|
# Retrieve the sealed file from the NVRAM, unseal it and compute the totp
|
|
|
|
|
|
|
|
. /etc/functions
|
|
|
|
|
|
|
|
TOTP_SEALED="/tmp/secret/totp.sealed"
|
|
|
|
TOTP_SECRET="/tmp/secret/totp.key"
|
|
|
|
|
|
|
|
tpm nv_readvalue \
|
|
|
|
-in 4d47 \
|
|
|
|
-sz 312 \
|
|
|
|
-of "$TOTP_SEALED" \
|
|
|
|
|| die "Unable to retrieve sealed file from TPM NV"
|
|
|
|
|
|
|
|
tpm unsealfile \
|
|
|
|
-hk 40000000 \
|
|
|
|
-if "$TOTP_SEALED" \
|
|
|
|
-of "$TOTP_SECRET" \
|
|
|
|
|| die "Unable to unseal totp secret"
|
|
|
|
|
2019-02-22 01:16:02 +00:00
|
|
|
shred -n 10 -z -u "$TOTP_SEALED" 2> /dev/null
|
2017-04-12 10:49:39 +00:00
|
|
|
|
2017-04-12 12:28:31 +00:00
|
|
|
if ! totp -q < "$TOTP_SECRET"; then
|
2019-02-22 01:16:02 +00:00
|
|
|
shred -n 10 -z -u "$TOTP_SECRET" 2> /dev/null
|
2017-04-12 10:49:39 +00:00
|
|
|
die 'Unable to compute TOTP hash?'
|
|
|
|
fi
|
|
|
|
|
2019-02-22 01:16:02 +00:00
|
|
|
shred -n 10 -z -u "$TOTP_SECRET" 2> /dev/null
|
2017-04-12 10:49:39 +00:00
|
|
|
exit 0
|