tpm2_hash.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /* SPDX-License-Identifier: BSD-3-Clause */
  2. #ifndef SRC_TPM_HASH_H_
  3. #define SRC_TPM_HASH_H_
  4. #include <stdbool.h>
  5. #include <tss2/tss2_esys.h>
  6. /**
  7. * Hashes a BYTE array via the tpm.
  8. * @param context
  9. * The esapi context.
  10. * @param hash_alg
  11. * The hashing algorithm to use.
  12. * @param hierarchy
  13. * The hierarchy.
  14. * @param buffer
  15. * The data to hash.
  16. * @param length
  17. * The length of the data.
  18. * @param result
  19. * The digest result.
  20. * @param validation
  21. * The validation ticket. Note that some hierarchies don't produce a
  22. * validation ticket and thus size will be 0.
  23. * @return
  24. * A tool_rc indicating status.
  25. */
  26. tool_rc tpm2_hash_compute_data(ESYS_CONTEXT *context, TPMI_ALG_HASH halg,
  27. TPMI_RH_HIERARCHY hierarchy, BYTE *buffer, UINT16 length,
  28. TPM2B_DIGEST **result, TPMT_TK_HASHCHECK **validation);
  29. /**
  30. * Hashes a FILE * object via the tpm.
  31. * @param context
  32. * The esapi context.
  33. * @param hash_alg
  34. * The hashing algorithm to use.
  35. * @param hierarchy
  36. * The hierarchy.
  37. * @param input
  38. * The FILE object to hash.
  39. * @param result
  40. * The digest result.
  41. * @param validation
  42. * The validation ticket. Note that some hierarchies don't produce a
  43. * validation ticket and thus size will be 0.
  44. * @return
  45. * A tool_rc indicating status.
  46. */
  47. tool_rc tpm2_hash_file(ESYS_CONTEXT *ectx, TPMI_ALG_HASH halg,
  48. TPMI_RH_HIERARCHY hierarchy, FILE *input, TPM2B_DIGEST **result,
  49. TPMT_TK_HASHCHECK **validation);
  50. #endif /* SRC_TPM_HASH_H_ */