hierarchycontrol.sh 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. # SPDX-License-Identifier: BSD-3-Clause
  2. source helpers.sh
  3. cleanup() {
  4. if [ "$1" != "no-shut-down" ]; then
  5. shut_down
  6. fi
  7. }
  8. trap cleanup EXIT
  9. start_up
  10. if [ "$TPM2TOOLS_TEST_PERSISTENT" = false ]; then
  11. echo "Skipping persistent test (requiring a TPM reset)."
  12. echo "To execute this test, set TPM2TOOLS_TEST_PERSISTENT=true or configure " \
  13. "with --enable-persistent"
  14. skip_test
  15. fi
  16. cleanup "no-shut-down"
  17. # Storage hierarchy
  18. tpm2 hierarchycontrol -C p shEnable set
  19. tpm2 hierarchycontrol -C p shEnable clear
  20. tpm2 hierarchycontrol -C p shEnable set
  21. tpm2 hierarchycontrol -C o shEnable clear
  22. # Endorsement hierarchy
  23. tpm2 hierarchycontrol -C p ehEnable set
  24. tpm2 hierarchycontrol -C p ehEnable clear
  25. tpm2 hierarchycontrol -C p ehEnable set
  26. tpm2 hierarchycontrol -C e ehEnable clear
  27. # Platform NV
  28. tpm2 hierarchycontrol -C p phEnableNV set
  29. tpm2 hierarchycontrol -C p phEnableNV clear
  30. tpm2 hierarchycontrol -C p phEnableNV set
  31. # Platform hierarchy
  32. tpm2 hierarchycontrol -C p phEnable clear
  33. # 0 the handler
  34. trap - ERR
  35. # ERROR: phEnable may not be 1 using this command
  36. tpm2 hierarchycontrol -C p phEnable set
  37. # EROOR: Only platform hierarchy handle can be specified for 1
  38. tpm2 hierarchycontrol -C o shEnable set
  39. tpm2 hierarchycontrol -C o ehEnable set
  40. tpm2 hierarchycontrol -C o phEnable set
  41. tpm2 hierarchycontrol -C o phEnableNV set
  42. tpm2 hierarchycontrol -C e shEnable set
  43. tpm2 hierarchycontrol -C e ehEnable set
  44. tpm2 hierarchycontrol -C e phEnable set
  45. tpm2 hierarchycontrol -C e phEnableNV set
  46. # ERROR: Permanent handle lockout not supported by this command
  47. tpm2 hierarchycontrol -C l shEnable set
  48. tpm2 hierarchycontrol -C l ehEnable set
  49. tpm2 hierarchycontrol -C l phEnable set
  50. tpm2 hierarchycontrol -C l phEnableNV set
  51. tpm2 hierarchycontrol -C l shEnable clear
  52. tpm2 hierarchycontrol -C l ehEnable clear
  53. tpm2 hierarchycontrol -C l phEnable clear
  54. tpm2 hierarchycontrol -C l phEnableNV clear
  55. # ERROR: Only platform and its authorization can be specified for 0
  56. tpm2 hierarchycontrol -C o ehEnable clear
  57. tpm2 hierarchycontrol -C o phEnable clear
  58. tpm2 hierarchycontrol -C o phEnableNV clear
  59. tpm2 hierarchycontrol -C e shEnable clear
  60. tpm2 hierarchycontrol -C e phEnable clear
  61. tpm2 hierarchycontrol -C e phEnableNV clear
  62. exit 0