flushcontext.sh 754 B

12345678910111213141516171819202122232425262728293031323334353637
  1. # SPDX-License-Identifier: BSD-3-Clause
  2. source helpers.sh
  3. start_up
  4. cleanup() {
  5. rm -f saved_session.ctx
  6. if [ "$1" != "no-shut-down" ]; then
  7. shut_down
  8. fi
  9. }
  10. trap cleanup EXIT
  11. cleanup "no-shut-down"
  12. tpm2 clear
  13. # Test for flushing the specified handle
  14. tpm2 createprimary -Q -C o -g sha256 -G rsa
  15. # tpm2-abrmd may save the transient object and restore it when using
  16. res=`tpm2 getcap handles-transient`
  17. if [ -n "$res" ]; then
  18. tpm2 flushcontext -Q -c 0x80000000
  19. fi
  20. # Test for flushing a transient object
  21. tpm2 createprimary -Q -C o -g sha256 -G rsa
  22. tpm2 flushcontext -Q -t
  23. # Test for flushing a loaded session
  24. tpm2 createpolicy -Q --policy-session --policy-pcr -l sha256:0
  25. tpm2 flushcontext -Q -l
  26. cleanup "no-shut-down"
  27. exit 0