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 9798DD811C3 for ; Tue, 16 Apr 2024 06:44:55 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=Mw0DVpanAql/ewy3l4iK7+qDKCEYSxd4HQOHsb9XvFI=; c=relaxed/simple; d=groups.io; h=Message-ID:Date:MIME-Version:User-Agent:Subject:To:Cc:References:From:In-Reply-To:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Resent-Date:Resent-From:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Language:Content-Type:Content-Transfer-Encoding; s=20240206; t=1713249894; v=1; b=fsGooYS0sx1gEuAmKx+CT7TIKDxvxZBBV6GnVIXOjykl8GqeTZ3aDV7E6a0O7P3aQ5AeqIaO ZXDvj4Fg9ZcnNtADB8MCtmLwg7D3R6eklZ0ynKPLLjkGPHfZLlhSGfzIRsUMrzY9zqMIOhOjE1Q r63s6HyB6pEWm66EkS3gA4qZPkJ262XC7S3RTL3rFxmxyamiaBMNpShCxDLmvtwgTlQ7naR+BTg rttSuM2Yy9Q6uz/8uI3j4cUQ6YQhkJJM1KcZttMMxHq9Qk4RQ7It9u99+gS1K3dh7yFdDk7ggvk NkWWD4WIpebhxAuKawRoqQSpB1VB3KNuqqWF7csKU8uNg== X-Received: by 127.0.0.2 with SMTP id LrSSYY7687511xvo6Ajgbacg; Mon, 15 Apr 2024 23:44:54 -0700 X-Received: from smtp-relay-internal-0.canonical.com (smtp-relay-internal-0.canonical.com [185.125.188.122]) by mx.groups.io with SMTP id smtpd.web11.13911.1713249892732394295 for ; Mon, 15 Apr 2024 23:44:53 -0700 X-Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-0.canonical.com (Postfix) with ESMTPS id 555A240301 for ; Tue, 16 Apr 2024 06:44:49 +0000 (UTC) X-Received: by mail-wr1-f71.google.com with SMTP id ffacd0b85a97d-343e54fc19bso2657099f8f.2 for ; Mon, 15 Apr 2024 23:44:49 -0700 (PDT) X-Forwarded-Encrypted: i=1; AJvYcCWTnptQG9liRwOFUnVDFOlykM3qI5LB3sEN8kbJWle41pZEy7F7rl3+7sHYqCxbYPIvGzHcWGUsCk1n21Jz63i1S7FC5g== X-Gm-Message-State: PITNfJTPuZPyLCisv5OrmZRxx7686176AA= X-Received: by 2002:a5d:4a49:0:b0:346:305c:b0eb with SMTP id v9-20020a5d4a49000000b00346305cb0ebmr9697139wrs.22.1713249888963; Mon, 15 Apr 2024 23:44:48 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFk5tKhF2/+qi3BbSI39RPPyKH10CDAhkbDxWbo1oglZQB0Y+cLx/++jV6NdUyBnsK2lM9bmw== X-Received: by 2002:a5d:4a49:0:b0:346:305c:b0eb with SMTP id v9-20020a5d4a49000000b00346305cb0ebmr9697121wrs.22.1713249888565; Mon, 15 Apr 2024 23:44:48 -0700 (PDT) X-Received: from [192.168.123.161] ([62.143.245.32]) by smtp.gmail.com with ESMTPSA id f12-20020a0560001a8c00b0034744966ff0sm9230107wry.59.2024.04.15.23.44.47 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 15 Apr 2024 23:44:48 -0700 (PDT) Message-ID: <920e607b-a945-4bb1-a1bf-6cc4de3f5aa7@canonical.com> Date: Tue, 16 Apr 2024 08:44:41 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [edk2-devel] [PATCH v1 1/3] uefi-sct/SctPkg: TCG2 Protocol: correct definition of TPMT_HA struct To: Stuart Yoder Cc: Alex_Fox@phoenix.com, David_Wright@phoenix.com, lichao@loongson.cn, devel@edk2.groups.io, Edhaya.Chandran@arm.com, gaojie@byosoft.com.cn References: <20240415222322.3167566-1-stuart.yoder@arm.com> <20240415222322.3167566-2-stuart.yoder@arm.com> From: "Heinrich Schuchardt" In-Reply-To: <20240415222322.3167566-2-stuart.yoder@arm.com> 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 23:44:53 -0700 Resent-From: heinrich.schuchardt@canonical.com Reply-To: devel@edk2.groups.io,heinrich.schuchardt@canonical.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed 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=fsGooYS0; spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 45.79.224.9 as permitted sender) smtp.mailfrom=bounce@groups.io; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=canonical.com (policy=none) On 4/16/24 00:23, Stuart Yoder wrote: > 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. >=20 > 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. >=20 > Signed-off-by: Stuart Yoder > --- > uefi-sct/SctPkg/UEFI/Protocol/TCG2.h | 13 ++++++++++++- > 1 file changed, 12 insertions(+), 1 deletion(-) >=20 > 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 We should follow the TCG EFI Protocol Specification and support ShangMi=20 3 in the test too. #define SM3_256_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 sm3_256[SM3_256_DIGEST_SIZE]; Best regards Heinrich > + 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 { -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#117850): https://edk2.groups.io/g/devel/message/117850 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] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-