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"
|
|
|
|
|
2024-02-01 14:30:31 -05:00
|
|
|
TRACE_FUNC
|
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"
|
2023-11-03 09:31:44 -04:00
|
|
|
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
|