2023-02-08 21:01:48 +00:00
|
|
|
#!/bin/bash
|
2017-04-12 10:49:39 +00:00
|
|
|
# Retrieve the sealed file from the NVRAM, unseal it and compute the totp
|
|
|
|
|
|
|
|
. /etc/functions
|
|
|
|
|
|
|
|
TOTP_SECRET="/tmp/secret/totp.key"
|
|
|
|
|
2023-02-20 16:01:17 +00:00
|
|
|
TRACE "Under /bin/unseal-totp"
|
2023-02-18 17:58:43 +00:00
|
|
|
|
2023-02-28 18:36:11 +00:00
|
|
|
if [ "$CONFIG_TPM" = "y" ]; then
|
2023-03-08 17:39:06 +00:00
|
|
|
tpmr unseal 4d47 0,1,2,3,4,7 312 "$TOTP_SECRET" \
|
2022-08-25 18:43:31 +00:00
|
|
|
|| die "Unable to unseal totp secret"
|
|
|
|
fi
|
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
|