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-10-23 15:18:28 -04:00
|
|
|
tpmr unseal 4d47 0,1,2,3,4,7 312 "$TOTP_SECRET" ||
|
|
|
|
die "Unable to unseal TOTP secret"
|
|
|
|
fi
|
2017-04-12 06:49:39 -04:00
|
|
|
|
2023-10-23 15:18:28 -04:00
|
|
|
if ! totp -q <"$TOTP_SECRET"; then
|
|
|
|
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
|
|
|
|
|
2023-10-23 15:18:28 -04:00
|
|
|
shred -n 10 -z -u "$TOTP_SECRET" 2>/dev/null
|
2017-04-12 06:49:39 -04:00
|
|
|
exit 0
|