changeeps.sh 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. # SPDX-License-Identifier: BSD-3-Clause
  2. source helpers.sh
  3. cleanup() {
  4. tpm2 changeauth -c p -p testpassword 2>/dev/null || true
  5. rm -f primary.ctx key.pub key.priv key.ctx key.name
  6. if [ "$1" != "no-shut-down" ]; then
  7. shut_down
  8. fi
  9. }
  10. trap cleanup EXIT
  11. start_up
  12. cleanup "no-shut-down"
  13. tpm2 clear -Q
  14. tpm2 createprimary -Q -C e -c primary.ctx
  15. tpm2 create -Q -C primary.ctx -u key.pub -r key.priv
  16. tpm2 load -Q -C primary.ctx -u key.pub -r key.priv -n key.name -c key.ctx
  17. tpm2 flushcontext -t
  18. #
  19. # Test that the object cannot be loaded after change the endorsement seed
  20. # which causes all transient objects created under the endorsement hierarchy
  21. # to be invalidated.
  22. #
  23. tpm2 changeeps
  24. trap - ERR
  25. tpm2 load -Q -C primary.ctx -u key.pub -r key.priv -n key.name -c key.ctx
  26. #
  27. # Test with non null platform hierarchy auth
  28. #
  29. trap onerror ERR
  30. tpm2 changeauth -c p testpassword
  31. tpm2 createprimary -Q -C e -c primary.ctx
  32. tpm2 create -Q -C primary.ctx -u key.pub -r key.priv
  33. tpm2 changeeps -p testpassword
  34. trap - ERR
  35. tpm2 load -Q -C primary.ctx -u key.pub -r key.priv -n key.name -c key.ctx
  36. exit 0