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