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 EDD5E7803DA for ; Tue, 16 Apr 2024 14:54:34 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=nNM+uuLhEsU8d+e6zhrBHalpuOV9vNpGRbC1yvGMWY4=; 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=1713279273; v=1; b=A/NOT2DDHY3rYNrHM39RFzEyr4mFl+YRosgJ94THd3rwPryEcL2U5nnyONqV04BQMRfEFBU1 qHQFaXAXBrW2Wl6tEJcukv9ZRU7970ahonTgUkp7GLaqIYWS9mvnijSN7e5viBvcrmgo74qITHL xb4GIfv+z8G6GT++pGHAAP66kggBRRG4R/69G5zvLdUBWYjSkpFxvdh5dHKXXVpMFFwcwYQdMi5 vDEgEIaPg/pGkBUt5oOPYaJQ1gWfJjV5S0EXsoepkssBmPipwSbhK5p3ES9iskbFJviEsIdUooc T8apJ7pJ0TDr3HikjC181VZcKKD/zQfmwGeBY7dfHKSWQ== X-Received: by 127.0.0.2 with SMTP id GlZ0YY7687511x1iCTXiHJxd; Tue, 16 Apr 2024 07:54:33 -0700 X-Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web10.23017.1713279272862624788 for ; Tue, 16 Apr 2024 07:54: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 B03CEDA7; Tue, 16 Apr 2024 07:55: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 55BC03F792; Tue, 16 Apr 2024 07:54: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 v2 1/4] uefi-sct/SctPkg: TCG2 Protocol: correct definition of TPMT_HA struct Date: Tue, 16 Apr 2024 09:53:58 -0500 Message-Id: <20240416145401.3213797-2-stuart.yoder@arm.com> In-Reply-To: <20240416145401.3213797-1-stuart.yoder@arm.com> References: <20240416145401.3213797-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: Tue, 16 Apr 2024 07:54:33 -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: itklEnbxhFkTtbcKjTGtgfpGx7686176AA= 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="A/NOT2DD"; 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. In addition, added the SM3 hash type to align with the TPM Library spec. Signed-off-by: Stuart Yoder --- 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: =20 #define EFI_TCG2_EVENT_LOG_FORMAT_TCG_2 0x00000002 =20 -#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 =20 typedef struct _EFI_TCG2_PROTOCOL EFI_TCG2_PROTOCOL; =20 @@ -117,9 +122,17 @@ typedef struct tdEFI_TCG2_EVENT { UINT8 Event[]; } EFI_TCG2_EVENT; =20 +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; =20 typedef struct tdTPML_DIGEST_VALUES { --=20 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/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=-=-=-=-=-=-=-=-=-=-=-