The TPMT_HA struct defining event log hash algorithms was cut/pasted from the TCG EFI Protocol specification which used a C struct with a flexible array member as the last element. This is incorrect because TPMT_HA itself is used as an array element, and thus can't be variable size.
Because the size of hash algorithms varies, this should have been defined as a union of the sizes of supported hash algorithms. This is how is it done in the TPM Library specfication and in EDK2. In addition, added the SM3 hash type to align with the TPM Library spec. Signed-off-by: Stuart Yoder <stuart.yo...@arm.com> --- uefi-sct/SctPkg/UEFI/Protocol/TCG2.h | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/uefi-sct/SctPkg/UEFI/Protocol/TCG2.h b/uefi-sct/SctPkg/UEFI/Protocol/TCG2.h index a83a84c33134..01ef81be8793 100644 --- a/uefi-sct/SctPkg/UEFI/Protocol/TCG2.h +++ b/uefi-sct/SctPkg/UEFI/Protocol/TCG2.h @@ -50,7 +50,12 @@ Abstract: #define EFI_TCG2_EVENT_LOG_FORMAT_TCG_2 0x00000002 -#define HASH_NUMBER 0x04 +#define HASH_NUMBER 0x05 +#define SHA1_DIGEST_SIZE 20 +#define SHA256_DIGEST_SIZE 32 +#define SHA384_DIGEST_SIZE 48 +#define SHA512_DIGEST_SIZE 64 +#define SM3_256_DIGEST_SIZE 32 typedef struct _EFI_TCG2_PROTOCOL EFI_TCG2_PROTOCOL; @@ -117,9 +122,17 @@ typedef struct tdEFI_TCG2_EVENT { UINT8 Event[]; } EFI_TCG2_EVENT; +typedef union { + UINT8 sha1[SHA1_DIGEST_SIZE]; + UINT8 sha256[SHA256_DIGEST_SIZE]; + UINT8 sm3_256[SM3_256_DIGEST_SIZE]; + UINT8 sha384[SHA384_DIGEST_SIZE]; + UINT8 sha512[SHA512_DIGEST_SIZE]; +} TPMU_HA; + typedef struct { UINT16 hashAlg; - UINT8 digest[]; + TPMU_HA digest; } TPMT_HA; typedef struct tdTPML_DIGEST_VALUES { -- 2.34.1 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#117883): https://edk2.groups.io/g/devel/message/117883 Mute This Topic: https://groups.io/mt/105558006/21656 Group Owner: devel+ow...@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-