2023-02-08 16:01:48 -05:00
|
|
|
#!/bin/bash
|
2017-04-12 06:49:39 -04: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 11:01:17 -05:00
|
|
|
TRACE "Under /bin/unseal-totp"
|
2023-02-18 12:58:43 -05:00
|
|
|
|
2023-02-28 13:36:11 -05:00
|
|
|
if [ "$CONFIG_TPM" = "y" ]; then
|
2023-03-08 12:39:06 -05:00
|
|
|
tpmr unseal 4d47 0,1,2,3,4,7 312 "$TOTP_SECRET" \
|
2022-08-25 14:43:31 -04:00
|
|
|
|| die "Unable to unseal totp secret"
|
|
|
|
fi
|
2017-04-12 06:49:39 -04:00
|
|
|
|
2017-04-12 08:28:31 -04:00
|
|
|
if ! totp -q < "$TOTP_SECRET"; then
|
2019-02-21 20:16:02 -05:00
|
|
|
shred -n 10 -z -u "$TOTP_SECRET" 2> /dev/null
|
2017-04-12 06:49:39 -04:00
|
|
|
die 'Unable to compute TOTP hash?'
|
|
|
|
fi
|
|
|
|
|
2019-02-21 20:16:02 -05:00
|
|
|
shred -n 10 -z -u "$TOTP_SECRET" 2> /dev/null
|
2017-04-12 06:49:39 -04:00
|
|
|
exit 0
|