From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail04.groups.io (mail04.groups.io [45.79.224.9]) by spool.mail.gandi.net (Postfix) with ESMTPS id C3927941C7D for ; Mon, 15 Apr 2024 22:23:34 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=kLQWHbePaWlMMvQN8dOepfU9H+lAWF/OAZbmJwn+f2k=; c=relaxed/simple; d=groups.io; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Resent-Date:Resent-From:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Transfer-Encoding; s=20240206; t=1713219813; v=1; b=KV+pl+Mj8h4AFxG6c29pD47CeVJg3v9G9uQWUH/WOV74cinJVkrcP21TZYM/nB279WNZNWgN uprzufyWfT9FZ2b8rfRByHJjNam+VT145974uYAfBXp80yTrbuv2CPkq6kXVxO0OmGxl+kIjsKN awDqTD0gUIPeAoeYGdsb+WD7Cd1b4rABJJWuIlR2x8QBuiMS073KKHXdBmfmilBTNwd+ZJrnD8o 9f6k4fezN7nGVUfHPGtMqiRHYDCqeXirjSMH1dnKJPcPukKyS3t3MHMeGaanvTcpTHOOuguUocK 4Vb2LL/mlZPCDxlr5WK1hOSUy612YKbL7E87fEOXNwdcg== X-Received: by 127.0.0.2 with SMTP id 4ndEYY7687511x393maVzapZ; Mon, 15 Apr 2024 15:23:33 -0700 X-Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web11.5988.1713219812611622116 for ; Mon, 15 Apr 2024 15:23:32 -0700 X-Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id DDEBFDA7; Mon, 15 Apr 2024 15:24:00 -0700 (PDT) X-Received: from beelzebub.ast.arm.com (u203013-lin.austin.arm.com [10.118.29.240]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 0F69B3F738; Mon, 15 Apr 2024 15:23:32 -0700 (PDT) From: "Stuart Yoder" To: devel@edk2.groups.io, Edhaya.Chandran@arm.com, gaojie@byosoft.com.cn Cc: Alex_Fox@phoenix.com, heinrich.schuchardt@canonical.com, David_Wright@phoenix.com, lichao@loongson.cn Subject: [edk2-devel] [PATCH v1 1/3] uefi-sct/SctPkg: TCG2 Protocol: correct definition of TPMT_HA struct Date: Mon, 15 Apr 2024 17:23:20 -0500 Message-Id: <20240415222322.3167566-2-stuart.yoder@arm.com> In-Reply-To: <20240415222322.3167566-1-stuart.yoder@arm.com> References: <20240415222322.3167566-1-stuart.yoder@arm.com> MIME-Version: 1.0 Precedence: Bulk List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Resent-Date: Mon, 15 Apr 2024 15:23:32 -0700 Resent-From: stuart.yoder@arm.com Reply-To: devel@edk2.groups.io,stuart.yoder@arm.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: eikZEBWBxc1Y8yIEkNQBxixRx7686176AA= Content-Transfer-Encoding: quoted-printable X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20240206 header.b=KV+pl+Mj; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=arm.com (policy=none); spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 45.79.224.9 as permitted sender) smtp.mailfrom=bounce@groups.io 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. Signed-off-by: Stuart Yoder --- uefi-sct/SctPkg/UEFI/Protocol/TCG2.h | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/uefi-sct/SctPkg/UEFI/Protocol/TCG2.h b/uefi-sct/SctPkg/UEFI/= Protocol/TCG2.h index a83a84c33134..e42b8b347c05 100644 --- a/uefi-sct/SctPkg/UEFI/Protocol/TCG2.h +++ b/uefi-sct/SctPkg/UEFI/Protocol/TCG2.h @@ -51,6 +51,10 @@ Abstract: #define EFI_TCG2_EVENT_LOG_FORMAT_TCG_2 0x00000002 =20 #define HASH_NUMBER 0x04 +#define SHA1_DIGEST_SIZE 20 +#define SHA256_DIGEST_SIZE 32 +#define SHA384_DIGEST_SIZE 48 +#define SHA512_DIGEST_SIZE 64 =20 typedef struct _EFI_TCG2_PROTOCOL EFI_TCG2_PROTOCOL; =20 @@ -117,9 +121,16 @@ typedef struct tdEFI_TCG2_EVENT { UINT8 Event[]; } EFI_TCG2_EVENT; =20 +typedef union { + UINT8 sha1[SHA1_DIGEST_SIZE]; + UINT8 sha256[SHA256_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; =20 typedef struct tdTPML_DIGEST_VALUES { --=20 2.34.1 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#117808): https://edk2.groups.io/g/devel/message/117808 Mute This Topic: https://groups.io/mt/105546455/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=-=-=-=-=-=-=-=-=-=-=-