Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
tpmtotp/unsealtotp.sh
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
executable file
27 lines (21 sloc)
467 Bytes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Retrieve the sealed file from the NVRAM, unseal it and compute the totp | |
die() { | |
echo >&2 "$@" | |
rm /tmp/sealed /tmp/secret 2>&- | |
exit 1 | |
} | |
tpm nv_readvalue \ | |
-in 4d47 \ | |
-sz 312 \ | |
-of /tmp/sealed \ | |
|| die "Unable to retrieve sealed file from TPM NV" | |
tpm unsealfile \ | |
-hk 40000000 \ | |
-if /tmp/sealed \ | |
-of /tmp/secret \ | |
|| die "Unable to unseal totp secret" | |
rm /tmp/sealed | |
totp < /tmp/secret \ | |
|| die "Unable to compute TOTP hash" | |
rm /tmp/secret |