object.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. #ifndef LIB_OBJECT_H_
  2. #define LIB_OBJECT_H_
  3. #include "tool_rc.h"
  4. #include "tpm2_session.h"
  5. #include "tpm2_util.h"
  6. typedef struct tpm2_loaded_object tpm2_loaded_object;
  7. struct tpm2_loaded_object {
  8. TPM2_HANDLE handle;
  9. ESYS_TR tr_handle;
  10. const char *path;
  11. tpm2_session *session;
  12. };
  13. /**
  14. * Parses a string representation of a context object, either a file or handle,
  15. * and loads the context object ensuring the handle member of the out object is
  16. * set.
  17. * The objectstr will recognised as a context file when prefixed with "file:"
  18. * or should the value not be parsable as a handle number (as understood by
  19. * strtoul()).
  20. * @param ctx
  21. * a TSS ESAPI context.
  22. * @param objectstr
  23. * The string representation of the object to be loaded.
  24. * @param outobject
  25. * A *tpm2_loaded_object* with a loaded handle. The path member will also be
  26. * set when the *objectstr* is a context file.
  27. * @param flags
  28. * A *tpm2_hierarchy_flags* value to specify expected valid hierarchy
  29. * @return
  30. * tool_rc indicating status.
  31. *
  32. */
  33. tool_rc tpm2_util_object_load(ESYS_CONTEXT *ctx, const char *objectstr,
  34. tpm2_loaded_object *outobject, tpm2_handle_flags flags);
  35. /**
  36. * Same as tpm2_util_object_load but allows the auth string value to be populated
  37. * as a session associated with the object.
  38. * @param ctx
  39. * a TSS ESAPI context.
  40. * @param objectstr
  41. * The string representation of the object to be loaded.
  42. * @param auth
  43. * The auth string for the object.
  44. * @param is_restricted_pswd_session
  45. * The auth session associated with the object is restricted to TPM2_RS_PW
  46. * @param outobject
  47. * A *tpm2_loaded_object* with a loaded handle. The path member will also be
  48. * set when the *objectstr* is a context file.
  49. * @param flags
  50. * A *tpm2_hierarchy_flags* value to specify expected valid hierarchy
  51. * @return
  52. * tool_rc indicating status.
  53. * @return
  54. * tool_rc indicating status
  55. */
  56. tool_rc tpm2_util_object_load_auth(ESYS_CONTEXT *ctx, const char *objectstr,
  57. const char *auth, tpm2_loaded_object *outobject,
  58. bool is_restricted_pswd_session, tpm2_handle_flags flags);
  59. #endif /* LIB_OBJECT_H_ */