efi_tcg2.h 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. /* SPDX-License-Identifier: GPL-2.0+ */
  2. /*
  3. * Defines data structures and APIs that allow an OS to interact with UEFI
  4. * firmware to query information about the device
  5. *
  6. * Copyright (c) 2020, Linaro Limited
  7. */
  8. #if !defined _EFI_TCG2_PROTOCOL_H_
  9. #define _EFI_TCG2_PROTOCOL_H_
  10. #include <tpm-v2.h>
  11. #define EFI_TCG2_PROTOCOL_GUID \
  12. EFI_GUID(0x607f766c, 0x7455, 0x42be, 0x93, \
  13. 0x0b, 0xe4, 0xd7, 0x6d, 0xb2, 0x72, 0x0f)
  14. /* TPMV2 only */
  15. #define TCG2_EVENT_LOG_FORMAT_TCG_2 0x00000002
  16. /* Algorithm Registry */
  17. #define EFI_TCG2_BOOT_HASH_ALG_SHA1 0x00000001
  18. #define EFI_TCG2_BOOT_HASH_ALG_SHA256 0x00000002
  19. #define EFI_TCG2_BOOT_HASH_ALG_SHA384 0x00000004
  20. #define EFI_TCG2_BOOT_HASH_ALG_SHA512 0x00000008
  21. #define EFI_TCG2_BOOT_HASH_ALG_SM3_256 0x00000010
  22. typedef u32 efi_tcg_event_log_bitmap;
  23. typedef u32 efi_tcg_event_log_format;
  24. typedef u32 efi_tcg_event_algorithm_bitmap;
  25. struct efi_tcg2_version {
  26. u8 major;
  27. u8 minor;
  28. };
  29. struct efi_tcg2_event_header {
  30. u32 header_size;
  31. u16 header_version;
  32. u32 pcr_index;
  33. u32 event_type;
  34. } __packed;
  35. struct efi_tcg2_event {
  36. u32 size;
  37. struct efi_tcg2_event_header header;
  38. u8 event[];
  39. } __packed;
  40. struct efi_tcg2_boot_service_capability {
  41. u8 size;
  42. struct efi_tcg2_version structure_version;
  43. struct efi_tcg2_version protocol_version;
  44. efi_tcg_event_algorithm_bitmap hash_algorithm_bitmap;
  45. efi_tcg_event_log_bitmap supported_event_logs;
  46. u8 tpm_present_flag;
  47. u16 max_command_size;
  48. u16 max_response_size;
  49. u32 manufacturer_id;
  50. u32 number_of_pcr_banks;
  51. efi_tcg_event_algorithm_bitmap active_pcr_banks;
  52. };
  53. #define boot_service_capability_min \
  54. sizeof(struct efi_tcg2_boot_service_capability) - \
  55. offsetof(struct efi_tcg2_boot_service_capability, number_of_pcr_banks)
  56. struct efi_tcg2_protocol {
  57. efi_status_t (EFIAPI * get_capability)(struct efi_tcg2_protocol *this,
  58. struct efi_tcg2_boot_service_capability *capability);
  59. efi_status_t (EFIAPI * get_eventlog)(struct efi_tcg2_protocol *this,
  60. efi_tcg_event_log_format log_format,
  61. u64 *event_log_location, u64 *event_log_last_entry,
  62. bool *event_log_truncated);
  63. efi_status_t (EFIAPI * hash_log_extend_event)(struct efi_tcg2_protocol *this,
  64. u64 flags, u64 data_to_hash,
  65. u64 data_to_hash_len,
  66. struct efi_tcg2_event *efi_tcg_event);
  67. efi_status_t (EFIAPI * submit_command)(struct efi_tcg2_protocol *this,
  68. u32 input_parameter_block_size,
  69. u8 *input_parameter_block,
  70. u32 output_parameter_block_size,
  71. u8 *output_parameter_block);
  72. efi_status_t (EFIAPI * get_active_pcr_banks)(struct efi_tcg2_protocol *this,
  73. u32 *active_pcr_banks);
  74. efi_status_t (EFIAPI * set_active_pcr_banks)(struct efi_tcg2_protocol *this,
  75. u32 active_pcr_banks);
  76. efi_status_t (EFIAPI * get_result_of_set_active_pcr_banks)(struct efi_tcg2_protocol *this,
  77. u32 *operation_present,
  78. u32 *response);
  79. };
  80. #endif