mirror of
https://github.com/linuxboot/heads.git
synced 2024-12-30 09:48:56 +00:00
b500505312
Most logic throughout Heads doesn't need to know TPM1 versus TPM2 (and shouldn't, the differences should be localized). Some checks were incorrect and are fixed by this change. Most checks are now unchanged relative to master. There are not that many places outside of tpmr that need to differentiate TPM1 and TPM2. Some of those are duplicate code that should be consolidated (seal-hotpkey, unseal-totp, unseal-hotp), and some more are probably good candidates for abstracting in tpmr so the business logic doesn't have to know TPM1 vs. TPM2. Previously, CONFIG_TPM could be variously 'y', 'n', or empty. Now it is always 'y' or 'n', and 'y' means "any TPM". Board configs are unchanged, setting CONFIG_TPM2_TOOLS=y implies CONFIG_TPM=y so this doesn't have to be duplicated and can't be mistakenly mismatched. There were a few checks for CONFIG_TPM = n that only coincidentally worked for TPM2 because CONFIG_TPM was empty (not 'n'). This test is now OK, but the checks were also cleaned up to '!= "y"' for robustness. Signed-off-by: Jonathon Hall <jonathon.hall@puri.sm>
39 lines
852 B
Bash
Executable File
39 lines
852 B
Bash
Executable File
#!/bin/bash
|
|
. /etc/functions
|
|
|
|
echo '*****'
|
|
echo '***** WARNING: This will erase all keys and secrets from the TPM'
|
|
echo '*****'
|
|
|
|
read -s -p "New TPM owner password: " key_password
|
|
echo
|
|
|
|
if [ -z "$key_password" ]; then
|
|
die "Empty owner password is not allowed"
|
|
fi
|
|
|
|
read -s -p "Repeat owner password: " key_password2
|
|
echo
|
|
|
|
|
|
if [ "$key_password" != "$key_password2" ]; then
|
|
die "Key passwords do not match"
|
|
fi
|
|
|
|
if [ "$CONFIG_TPM2_TOOLS" = "y" ]; then
|
|
tpmr reset "$key_password"
|
|
elif [ "$CONFIG_TPM" = "y" ]; then
|
|
# Make sure the TPM is ready to be reset
|
|
tpm physicalpresence -s
|
|
tpm physicalenable
|
|
tpm physicalsetdeactivated -c
|
|
tpm forceclear
|
|
tpm physicalenable
|
|
tpm takeown -pwdo "$key_password"
|
|
|
|
# And now turn it all back on
|
|
tpm physicalpresence -s
|
|
tpm physicalenable
|
|
tpm physicalsetdeactivated -c
|
|
fi
|