1 /* SPDX-License-Identifier: BSD-3-Clause */
3 #ifndef __TPM2_LOG_SERIALIZED_H__
4 #define __TPM2_LOG_SERIALIZED_H__
6 #include <commonlib/bsd/tpm_log_defs.h>
8 #define TPM_20_SPEC_ID_EVENT_SIGNATURE "Spec ID Event03"
9 #define TPM_20_LOG_DATA_MAX_LENGTH 50
11 #define TPM_20_LOG_VI_MAGIC 0x32544243 /* "CBT2" in LE */
12 #define TPM_20_LOG_VI_MAJOR 1
13 #define TPM_20_LOG_VI_MINOR 0
16 * TPM2.0 log entries can't be generally represented as C structures due to
17 * varying number of digests and their sizes. However, it works as long as
18 * we're only using single kind of digests.
20 #if CONFIG(TPM_LOG_TPM2)
21 # if CONFIG(TPM_HASH_SHA1)
22 # define TPM_20_LOG_DIGEST_MAX_LENGTH SHA1_DIGEST_SIZE
24 # if CONFIG(TPM_HASH_SHA256)
25 # define TPM_20_LOG_DIGEST_MAX_LENGTH SHA256_DIGEST_SIZE
27 # if CONFIG(TPM_HASH_SHA384)
28 # define TPM_20_LOG_DIGEST_MAX_LENGTH SHA384_DIGEST_SIZE
30 # if CONFIG(TPM_HASH_SHA512)
31 # define TPM_20_LOG_DIGEST_MAX_LENGTH SHA512_DIGEST_SIZE
34 # ifndef TPM_20_LOG_DIGEST_MAX_LENGTH
35 # error "Misconfiguration: failed to determine TPM hashing algorithm"
38 # define TPM_20_LOG_DIGEST_MAX_LENGTH 1 /* To avoid compilation error */
42 struct tpm_2_log_entry
{
45 uint32_t digest_count
; /* Always 1 in current implementation */
47 uint8_t digest
[TPM_20_LOG_DIGEST_MAX_LENGTH
];
49 uint8_t data
[TPM_20_LOG_DATA_MAX_LENGTH
];
54 uint8_t version_major
;
55 uint8_t version_minor
;
62 struct tpm_2_log_table
{
63 struct tcg_efi_spec_id_event header
; /* TCG_PCR_EVENT actually */
64 struct tpm_digest_sizes digest_sizes
[1];
65 uint8_t vendor_info_size
;
66 struct tpm_2_vendor vendor
;
67 struct tpm_2_log_entry entries
[]; /* Variable number of entries */