2023-02-08 21:01:48 +00:00
|
|
|
#!/bin/bash
|
2017-04-12 10:45:15 +00:00
|
|
|
. /etc/functions
|
|
|
|
|
2023-02-22 21:26:53 +00:00
|
|
|
echo '*****'
|
|
|
|
echo '***** WARNING: This will erase all keys and secrets from the TPM'
|
|
|
|
echo '*****'
|
2022-08-25 18:43:31 +00:00
|
|
|
|
2023-02-22 21:26:53 +00:00
|
|
|
read -s -p "New TPM owner password: " key_password
|
|
|
|
echo
|
2022-08-25 18:43:31 +00:00
|
|
|
|
2023-02-22 21:26:53 +00:00
|
|
|
if [ -z "$key_password" ]; then
|
|
|
|
die "Empty owner password is not allowed"
|
|
|
|
fi
|
2022-08-25 18:43:31 +00:00
|
|
|
|
2023-02-22 21:26:53 +00:00
|
|
|
read -s -p "Repeat owner password: " key_password2
|
|
|
|
echo
|
2022-08-25 18:43:31 +00:00
|
|
|
|
|
|
|
|
2023-02-22 21:26:53 +00:00
|
|
|
if [ "$key_password" != "$key_password2" ]; then
|
|
|
|
die "Key passwords do not match"
|
|
|
|
fi
|
2022-08-25 18:43:31 +00:00
|
|
|
|
2023-02-22 21:26:53 +00:00
|
|
|
if [ "$CONFIG_TPM" = "y" ]; then
|
2022-08-25 18:43:31 +00:00
|
|
|
# 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
|
2017-04-12 10:45:15 +00:00
|
|
|
fi
|
|
|
|
|
2022-08-25 18:43:31 +00:00
|
|
|
if [ "$CONFIG_TPM2_TOOLS" = "y" ]; then
|
2023-02-22 21:26:53 +00:00
|
|
|
tpmr reset "$key_password"
|
2017-04-12 10:45:15 +00:00
|
|
|
fi
|