tpm2_eventlog.h 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /* SPDX-License-Identifier: BSD-3-Clause */
  2. #ifndef TPM2_EVENTLOG_H
  3. #define TPM2_EVENTLOG_H
  4. #include <stdbool.h>
  5. #include <stdlib.h>
  6. #include <tss2/tss2_tpm2_types.h>
  7. #include "efi_event.h"
  8. typedef bool (*DIGEST2_CALLBACK)(TCG_DIGEST2 const *digest, size_t size,
  9. void *data);
  10. typedef bool (*EVENT2_CALLBACK)(TCG_EVENT_HEADER2 const *event_hdr, size_t size,
  11. void *data);
  12. typedef bool (*EVENT2DATA_CALLBACK)(TCG_EVENT2 const *event, UINT32 type,
  13. void *data, uint32_t eventlog_version);
  14. typedef bool (*SPECID_CALLBACK)(TCG_EVENT const *event, void *data);
  15. typedef bool (*LOG_EVENT_CALLBACK)(TCG_EVENT const *event_hdr, size_t size,
  16. void *data);
  17. typedef struct {
  18. void *data;
  19. SPECID_CALLBACK specid_cb;
  20. LOG_EVENT_CALLBACK log_eventhdr_cb;
  21. EVENT2_CALLBACK event2hdr_cb;
  22. DIGEST2_CALLBACK digest2_cb;
  23. EVENT2DATA_CALLBACK event2_cb;
  24. uint32_t sha1_used;
  25. uint32_t sha256_used;
  26. uint32_t sha384_used;
  27. uint32_t sha512_used;
  28. uint32_t sm3_256_used;
  29. uint8_t sha1_pcrs[TPM2_MAX_PCRS][TPM2_SHA1_DIGEST_SIZE];
  30. uint8_t sha256_pcrs[TPM2_MAX_PCRS][TPM2_SHA256_DIGEST_SIZE];
  31. uint8_t sha384_pcrs[TPM2_MAX_PCRS][TPM2_SHA384_DIGEST_SIZE];
  32. uint8_t sha512_pcrs[TPM2_MAX_PCRS][TPM2_SHA512_DIGEST_SIZE];
  33. uint8_t sm3_256_pcrs[TPM2_MAX_PCRS][TPM2_SM3_256_DIGEST_SIZE];
  34. uint32_t eventlog_version;
  35. } tpm2_eventlog_context;
  36. bool digest2_accumulator_callback(TCG_DIGEST2 const *digest, size_t size,
  37. void *data);
  38. bool parse_event2body(TCG_EVENT2 const *event, UINT32 type);
  39. bool foreach_digest2(tpm2_eventlog_context *ctx, unsigned pcr_index,
  40. TCG_DIGEST2 const *event_hdr, size_t count, size_t size);
  41. bool parse_event2(TCG_EVENT_HEADER2 const *eventhdr, size_t buf_size,
  42. size_t *event_size, size_t *digests_size);
  43. bool foreach_event2(tpm2_eventlog_context *ctx, TCG_EVENT_HEADER2 const *eventhdr_start, size_t size);
  44. bool specid_event(TCG_EVENT const *event, size_t size, TCG_EVENT_HEADER2 **next);
  45. bool parse_eventlog(tpm2_eventlog_context *ctx, BYTE const *eventlog, size_t size);
  46. #endif