Greg Kroah-Hartman | b244131 | 2017-11-01 15:07:57 +0100 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
Kent Yoder | e5dcd87 | 2012-07-11 10:08:12 -0500 | [diff] [blame] | 2 | |
Thiebaud Weksteen | fd3ec36 | 2017-09-20 10:13:36 +0200 | [diff] [blame] | 3 | #ifndef __LINUX_TPM_EVENTLOG_H__ |
| 4 | #define __LINUX_TPM_EVENTLOG_H__ |
Kent Yoder | e5dcd87 | 2012-07-11 10:08:12 -0500 | [diff] [blame] | 5 | |
Nayna Jain | 4d23cc3 | 2017-01-23 02:26:27 -0500 | [diff] [blame] | 6 | #include <crypto/hash_info.h> |
| 7 | |
Kent Yoder | e5dcd87 | 2012-07-11 10:08:12 -0500 | [diff] [blame] | 8 | #define TCG_EVENT_NAME_LEN_MAX 255 |
| 9 | #define MAX_TEXT_EVENT 1000 /* Max event string length */ |
| 10 | #define ACPI_TCPA_SIG "TCPA" /* 0x41504354 /'TCPA' */ |
Nayna Jain | 4d23cc3 | 2017-01-23 02:26:27 -0500 | [diff] [blame] | 11 | #define TPM2_ACTIVE_PCR_BANKS 3 |
Kent Yoder | e5dcd87 | 2012-07-11 10:08:12 -0500 | [diff] [blame] | 12 | |
Thiebaud Weksteen | 4d01d29 | 2017-09-20 10:13:38 +0200 | [diff] [blame] | 13 | #define EFI_TCG2_EVENT_LOG_FORMAT_TCG_1_2 0x1 |
| 14 | #define EFI_TCG2_EVENT_LOG_FORMAT_TCG_2 0x2 |
| 15 | |
Hon Ching \(Vicky\) Lo | 0cc698a | 2015-06-17 18:17:08 -0400 | [diff] [blame] | 16 | #ifdef CONFIG_PPC64 |
| 17 | #define do_endian_conversion(x) be32_to_cpu(x) |
| 18 | #else |
| 19 | #define do_endian_conversion(x) x |
| 20 | #endif |
| 21 | |
Kent Yoder | e5dcd87 | 2012-07-11 10:08:12 -0500 | [diff] [blame] | 22 | enum bios_platform_class { |
| 23 | BIOS_CLIENT = 0x00, |
| 24 | BIOS_SERVER = 0x01, |
| 25 | }; |
| 26 | |
Kent Yoder | e5dcd87 | 2012-07-11 10:08:12 -0500 | [diff] [blame] | 27 | struct tcpa_event { |
| 28 | u32 pcr_index; |
| 29 | u32 event_type; |
| 30 | u8 pcr_value[20]; /* SHA1 */ |
| 31 | u32 event_size; |
| 32 | u8 event_data[0]; |
| 33 | }; |
| 34 | |
| 35 | enum tcpa_event_types { |
| 36 | PREBOOT = 0, |
| 37 | POST_CODE, |
| 38 | UNUSED, |
| 39 | NO_ACTION, |
| 40 | SEPARATOR, |
| 41 | ACTION, |
| 42 | EVENT_TAG, |
| 43 | SCRTM_CONTENTS, |
| 44 | SCRTM_VERSION, |
| 45 | CPU_MICROCODE, |
| 46 | PLATFORM_CONFIG_FLAGS, |
| 47 | TABLE_OF_DEVICES, |
| 48 | COMPACT_HASH, |
| 49 | IPL, |
| 50 | IPL_PARTITION_DATA, |
| 51 | NONHOST_CODE, |
| 52 | NONHOST_CONFIG, |
| 53 | NONHOST_INFO, |
| 54 | }; |
| 55 | |
| 56 | struct tcpa_pc_event { |
| 57 | u32 event_id; |
| 58 | u32 event_size; |
| 59 | u8 event_data[0]; |
| 60 | }; |
| 61 | |
| 62 | enum tcpa_pc_event_ids { |
| 63 | SMBIOS = 1, |
| 64 | BIS_CERT, |
| 65 | POST_BIOS_ROM, |
| 66 | ESCD, |
| 67 | CMOS, |
| 68 | NVRAM, |
| 69 | OPTION_ROM_EXEC, |
| 70 | OPTION_ROM_CONFIG, |
| 71 | OPTION_ROM_MICROCODE = 10, |
| 72 | S_CRTM_VERSION, |
| 73 | S_CRTM_CONTENTS, |
| 74 | POST_CONTENTS, |
| 75 | HOST_TABLE_OF_DEVICES, |
| 76 | }; |
| 77 | |
Nayna Jain | 4d23cc3 | 2017-01-23 02:26:27 -0500 | [diff] [blame] | 78 | /* http://www.trustedcomputinggroup.org/tcg-efi-protocol-specification/ */ |
| 79 | |
| 80 | struct tcg_efi_specid_event_algs { |
| 81 | u16 alg_id; |
| 82 | u16 digest_size; |
| 83 | } __packed; |
| 84 | |
| 85 | struct tcg_efi_specid_event { |
| 86 | u8 signature[16]; |
| 87 | u32 platform_class; |
| 88 | u8 spec_version_minor; |
| 89 | u8 spec_version_major; |
| 90 | u8 spec_errata; |
| 91 | u8 uintnsize; |
| 92 | u32 num_algs; |
| 93 | struct tcg_efi_specid_event_algs digest_sizes[TPM2_ACTIVE_PCR_BANKS]; |
| 94 | u8 vendor_info_size; |
| 95 | u8 vendor_info[0]; |
| 96 | } __packed; |
| 97 | |
| 98 | struct tcg_pcr_event { |
| 99 | u32 pcr_idx; |
| 100 | u32 event_type; |
| 101 | u8 digest[20]; |
| 102 | u32 event_size; |
| 103 | u8 event[0]; |
| 104 | } __packed; |
| 105 | |
| 106 | struct tcg_event_field { |
| 107 | u32 event_size; |
| 108 | u8 event[0]; |
| 109 | } __packed; |
| 110 | |
Thiebaud Weksteen | fd3ec36 | 2017-09-20 10:13:36 +0200 | [diff] [blame] | 111 | struct tpm2_digest { |
| 112 | u16 alg_id; |
| 113 | u8 digest[SHA512_DIGEST_SIZE]; |
| 114 | } __packed; |
| 115 | |
Nayna Jain | 4d23cc3 | 2017-01-23 02:26:27 -0500 | [diff] [blame] | 116 | struct tcg_pcr_event2 { |
| 117 | u32 pcr_idx; |
| 118 | u32 event_type; |
| 119 | u32 count; |
| 120 | struct tpm2_digest digests[TPM2_ACTIVE_PCR_BANKS]; |
| 121 | struct tcg_event_field event; |
| 122 | } __packed; |
| 123 | |
Kent Yoder | e5dcd87 | 2012-07-11 10:08:12 -0500 | [diff] [blame] | 124 | #endif |