xref: /linux-6.15/include/linux/tpm_eventlog.h (revision c8faabfc)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 
3 #ifndef __LINUX_TPM_EVENTLOG_H__
4 #define __LINUX_TPM_EVENTLOG_H__
5 
6 #include <crypto/hash_info.h>
7 
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' */
11 
12 #define EFI_TCG2_EVENT_LOG_FORMAT_TCG_1_2 0x1
13 #define EFI_TCG2_EVENT_LOG_FORMAT_TCG_2   0x2
14 
15 #ifdef CONFIG_PPC64
16 #define do_endian_conversion(x) be32_to_cpu(x)
17 #else
18 #define do_endian_conversion(x) x
19 #endif
20 
21 enum bios_platform_class {
22 	BIOS_CLIENT = 0x00,
23 	BIOS_SERVER = 0x01,
24 };
25 
26 struct tcpa_event {
27 	u32 pcr_index;
28 	u32 event_type;
29 	u8 pcr_value[20];	/* SHA1 */
30 	u32 event_size;
31 	u8 event_data[0];
32 };
33 
34 enum tcpa_event_types {
35 	PREBOOT = 0,
36 	POST_CODE,
37 	UNUSED,
38 	NO_ACTION,
39 	SEPARATOR,
40 	ACTION,
41 	EVENT_TAG,
42 	SCRTM_CONTENTS,
43 	SCRTM_VERSION,
44 	CPU_MICROCODE,
45 	PLATFORM_CONFIG_FLAGS,
46 	TABLE_OF_DEVICES,
47 	COMPACT_HASH,
48 	IPL,
49 	IPL_PARTITION_DATA,
50 	NONHOST_CODE,
51 	NONHOST_CONFIG,
52 	NONHOST_INFO,
53 };
54 
55 struct tcpa_pc_event {
56 	u32 event_id;
57 	u32 event_size;
58 	u8 event_data[0];
59 };
60 
61 enum tcpa_pc_event_ids {
62 	SMBIOS = 1,
63 	BIS_CERT,
64 	POST_BIOS_ROM,
65 	ESCD,
66 	CMOS,
67 	NVRAM,
68 	OPTION_ROM_EXEC,
69 	OPTION_ROM_CONFIG,
70 	OPTION_ROM_MICROCODE = 10,
71 	S_CRTM_VERSION,
72 	S_CRTM_CONTENTS,
73 	POST_CONTENTS,
74 	HOST_TABLE_OF_DEVICES,
75 };
76 
77 /* http://www.trustedcomputinggroup.org/tcg-efi-protocol-specification/ */
78 
79 struct tcg_efi_specid_event_algs {
80 	u16 alg_id;
81 	u16 digest_size;
82 } __packed;
83 
84 struct tcg_efi_specid_event_head {
85 	u8 signature[16];
86 	u32 platform_class;
87 	u8 spec_version_minor;
88 	u8 spec_version_major;
89 	u8 spec_errata;
90 	u8 uintnsize;
91 	u32 num_algs;
92 	struct tcg_efi_specid_event_algs digest_sizes[];
93 } __packed;
94 
95 struct tcg_pcr_event {
96 	u32 pcr_idx;
97 	u32 event_type;
98 	u8 digest[20];
99 	u32 event_size;
100 	u8 event[0];
101 } __packed;
102 
103 struct tcg_event_field {
104 	u32 event_size;
105 	u8 event[0];
106 } __packed;
107 
108 struct tpm2_digest {
109 	u16 alg_id;
110 	u8 digest[SHA512_DIGEST_SIZE];
111 } __packed;
112 
113 struct tcg_pcr_event2_head {
114 	u32 pcr_idx;
115 	u32 event_type;
116 	u32 count;
117 	struct tpm2_digest digests[];
118 } __packed;
119 
120 #endif
121