tpm2_ctx_mgmt.c 846 B

12345678910111213141516171819202122232425262728293031
  1. #include "log.h"
  2. #include "tpm2.h"
  3. #include "tpm2_auth_util.h"
  4. #include "tpm2_ctx_mgmt.h"
  5. tool_rc tpm2_ctx_mgmt_evictcontrol(ESYS_CONTEXT *ectx, ESYS_TR auth,
  6. tpm2_session *sess, ESYS_TR objhandle, TPMI_DH_PERSISTENT phandle,
  7. ESYS_TR *out_tr) {
  8. ESYS_TR shandle1 = ESYS_TR_NONE;
  9. tool_rc rc = tpm2_auth_util_get_shandle(ectx, auth, sess, &shandle1);
  10. if (rc != tool_rc_success) {
  11. return rc;
  12. }
  13. ESYS_TR out_handle;
  14. TSS2_RC rval = Esys_EvictControl(ectx, auth, objhandle, shandle1,
  15. ESYS_TR_NONE, ESYS_TR_NONE, phandle, &out_handle);
  16. if (rval != TSS2_RC_SUCCESS) {
  17. LOG_PERR(Esys_EvictControl, rval);
  18. return tool_rc_from_tpm(rval);
  19. }
  20. if (out_tr) {
  21. *out_tr = out_handle;
  22. return tool_rc_success;
  23. }
  24. return tpm2_close(ectx, &out_handle);
  25. }