public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Heinrich Schuchardt" <heinrich.schuchardt@canonical.com>
To: Stuart Yoder <stuart.yoder@arm.com>
Cc: Alex_Fox@phoenix.com, David_Wright@phoenix.com,
	lichao@loongson.cn, devel@edk2.groups.io,
	Edhaya.Chandran@arm.com, gaojie@byosoft.com.cn
Subject: Re: [edk2-devel] [PATCH v1 1/3] uefi-sct/SctPkg: TCG2 Protocol: correct definition of TPMT_HA struct
Date: Tue, 16 Apr 2024 08:44:41 +0200	[thread overview]
Message-ID: <920e607b-a945-4bb1-a1bf-6cc4de3f5aa7@canonical.com> (raw)
In-Reply-To: <20240415222322.3167566-2-stuart.yoder@arm.com>

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.
> 
> 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 <stuart.yoder@arm.com>
> ---
>   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
>   
>   #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 
3 in the test too.

#define SM3_256_DIGEST_SIZE  32

> +#define SHA384_DIGEST_SIZE  48
> +#define SHA512_DIGEST_SIZE  64
>   
>   typedef struct _EFI_TCG2_PROTOCOL EFI_TCG2_PROTOCOL;
>   
> @@ -117,9 +121,16 @@ 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];

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;
>   
>   typedef struct tdTPML_DIGEST_VALUES {



-=-=-=-=-=-=-=-=-=-=-=-
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]
-=-=-=-=-=-=-=-=-=-=-=-



  reply	other threads:[~2024-04-16  6:44 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-15 22:23 [edk2-devel] [PATCH v1 0/3] TCG2 protocol clean up Stuart Yoder
2024-04-15 22:23 ` [edk2-devel] [PATCH v1 1/3] uefi-sct/SctPkg: TCG2 Protocol: correct definition of TPMT_HA struct Stuart Yoder
2024-04-16  6:44   ` Heinrich Schuchardt [this message]
2024-04-15 22:23 ` [edk2-devel] [PATCH v1 2/3] uefi-sct/SctPkg: TCG2 Protocol: use OFFSET_OF for computing offsets Stuart Yoder
2024-04-15 22:23 ` [edk2-devel] [PATCH v1 3/3] uefi-sct/SctPkg: TCG2 Protocol: #pragma pack cleanup Stuart Yoder
2024-04-16  6:54   ` Heinrich Schuchardt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=920e607b-a945-4bb1-a1bf-6cc4de3f5aa7@canonical.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox