* [edk2-devel] [PATCH v2 1/6] uefi-sct/SctPkg: TCG2 Protocol: add header with TCG2 protocol definitions
2024-01-09 18:20 [edk2-devel] [PATCH v2 0/6] Tests for TCG2 Protocol Stuart Yoder
@ 2024-01-09 18:20 ` Stuart Yoder
2024-03-05 15:47 ` G Edhaya Chandran
` (2 more replies)
2024-01-09 18:20 ` [edk2-devel] [PATCH v2 2/6] uefi-sct/SctPkg: TCG2 Protocol: add test infrastructure and GetCapability Test Stuart Yoder
` (5 subsequent siblings)
6 siblings, 3 replies; 26+ messages in thread
From: Stuart Yoder @ 2024-01-09 18:20 UTC (permalink / raw)
To: devel, Edhaya.Chandran, gaojie
Cc: ilias.apalodimas, heinrich.schuchardt, Samer.El-Haj-Mahmoud,
Jiewen.Yao
From: Joseph Hemann <joseph.hemann@arm.com>
Define constants and data structure specified in the TCG EFI Protocol
specification.
Signed-off-by: Joseph Hemann <Joseph.hemann@arm.com>
Signed-off-by: Stuart Yoder <stuart.yoder@arm.com>
---
uefi-sct/SctPkg/UEFI/Protocol/TCG2.h | 177 ++++++++++++++++++++
1 file changed, 177 insertions(+)
diff --git a/uefi-sct/SctPkg/UEFI/Protocol/TCG2.h b/uefi-sct/SctPkg/UEFI/Protocol/TCG2.h
new file mode 100644
index 000000000000..e62ecd85cbe9
--- /dev/null
+++ b/uefi-sct/SctPkg/UEFI/Protocol/TCG2.h
@@ -0,0 +1,177 @@
+/** @file
+
+ Copyright 2006 - 2016 Unified EFI, Inc.<BR>
+ Copyright (c) 2013 - 2016, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2021 - 2023, Arm Inc. All rights reserved.<BR>
+
+ This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+/*++
+
+Module Name:
+
+ TCG2.h
+
+Abstract:
+
+ EFI TCG Protocol
+
+--*/
+
+
+#ifndef __TCG2_PROTOCOL_H__
+#define __TCG2_PROTOCOL_H__
+
+//
+// Global ID for the TCG2 Protocol
+//
+#define EFI_TCG2_PROTOCOL_GUID \
+ {0x607f766c, 0x7455, 0x42be, {0x93, 0x0b, 0xe4, 0xd7, 0x6d, 0xb2, 0x72, 0x0f}}
+
+// Following defintions come from TCG2 Efi Protocol Spec
+#define EFI_TCG2_BOOT_HASH_ALG_SHA1 0x00000001
+
+#define EFI_TCG2_BOOT_HASH_ALG_SHA256 0x00000002
+
+#define EFI_TCG2_BOOT_HASH_ALG_SHA384 0x00000004
+
+#define EFI_TCG2_BOOT_HASH_ALG_SHA512 0x00000008
+
+#define EFI_TCG2_BOOT_HASH_ALG_SM3_256 0x00000010
+
+#define EFI_TCG2_EVENT_LOG_FORMAT_TCG_1_2 0x00000001
+
+#define EFI_TCG2_EVENT_LOG_FORMAT_TCG_2 0x00000002
+
+typedef struct _EFI_TCG2_PROTOCOL EFI_TCG2_PROTOCOL;
+
+typedef UINT32 EFI_TCG2_EVENT_LOG_BITMAP;
+
+typedef UINT32 EFI_TCG2_EVENT_LOG_FORMAT;
+
+typedef UINT32 EFI_TCG2_EVENT_ALGORITHM_BITMAP;
+
+typedef UINT32 TCG_PCRINDEX;
+
+typedef UINT32 TCG_EVENTTYPE;
+
+// Following struct defintions come from TCG2 Efi Protocol Spec
+typedef struct {
+ UINT8 Major;
+ UINT8 Minor;
+} EFI_TCG2_VERSION;
+
+typedef struct {
+ UINT8 Size;
+ EFI_TCG2_VERSION StructureVersion;
+ EFI_TCG2_VERSION ProtocolVersion;
+ EFI_TCG2_EVENT_ALGORITHM_BITMAP HashAlgorithmBitmap;
+ EFI_TCG2_EVENT_LOG_BITMAP SupportedEventLogs;
+ BOOLEAN TPMPresentFlag;
+ UINT16 MaxCommandSize;
+ UINT16 MaxResponseSize;
+ UINT32 ManufacturerID;
+ UINT32 NumberOfPcrBanks;
+ EFI_TCG2_EVENT_ALGORITHM_BITMAP ActivePcrBanks;
+} EFI_TCG2_BOOT_SERVICE_CAPABILITY;
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_TCG2_GET_CAPABILITY) (
+ IN EFI_TCG2_PROTOCOL *This,
+ IN OUT EFI_TCG2_BOOT_SERVICE_CAPABILITY *ProtocolCapability
+);
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_TCG2_GET_EVENT_LOG) (
+ IN EFI_TCG2_PROTOCOL *This,
+ IN EFI_TCG2_EVENT_LOG_FORMAT EventLogFormat,
+ OUT EFI_PHYSICAL_ADDRESS *EventLogLocation,
+ OUT EFI_PHYSICAL_ADDRESS *EventLogLastEntry,
+ OUT BOOLEAN *EventLogTruncated
+);
+
+// all structs except EFI_TCG2_BOOT_SERVICE_CAPABILITY are packed
+#pragma pack(1)
+
+typedef struct tdEFI_TCG2_EVENT_HEADER {
+ UINT32 HeaderSize;
+ UINT16 HeaderVersion;
+ TCG_PCRINDEX PCRIndex;
+ TCG_EVENTTYPE EventType;
+} EFI_TCG2_EVENT_HEADER;
+
+typedef struct tdEFI_TCG2_EVENT {
+ UINT32 Size;
+ EFI_TCG2_EVENT_HEADER Header;
+ UINT8 Event[];
+} EFI_TCG2_EVENT;
+
+#pragma pack()
+
+typedef
+EFI_STATUS
+(EFIAPI * EFI_TCG2_HASH_LOG_EXTEND_EVENT) (
+ IN EFI_TCG2_PROTOCOL *This,
+ IN UINT64 Flags,
+ IN EFI_PHYSICAL_ADDRESS DataToHash,
+ IN UINT64 DataToHashLen,
+ IN EFI_TCG2_EVENT *EfiTcgEvent
+);
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_TCG2_SUBMIT_COMMAND) (
+ IN EFI_TCG2_PROTOCOL *This,
+ IN UINT32 InputParameterBlockSize,
+ IN UINT8 *InputParameterBlock,
+ IN UINT32 OutputParameterBlockSize,
+ IN UINT8 *OutputParameterBlock
+);
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_TCG2_GET_ACTIVE_PCR_BANKS) (
+ IN EFI_TCG2_PROTOCOL *This,
+ OUT UINT32 *ActivePcrBanks
+);
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_TCG2_SET_ACTIVE_PCR_BANKS) (
+ IN EFI_TCG2_PROTOCOL *This,
+ IN UINT32 ActivePcrBanks
+);
+
+typedef
+EFI_STATUS
+(EFIAPI * EFI_TCG2_GET_RESULT_OF_SET_ACTIVE_PCR_BANKS) (
+ IN EFI_TCG2_PROTOCOL *This,
+ OUT UINT32 *OperationPresent,
+ OUT UINT32 *Response
+);
+
+//
+// Interface structure for the TCG2 Protocol
+//
+struct _EFI_TCG2_PROTOCOL {
+ EFI_TCG2_GET_CAPABILITY GetCapability;
+ EFI_TCG2_GET_EVENT_LOG GetEventLog;
+ EFI_TCG2_HASH_LOG_EXTEND_EVENT HashLogExtendEvent;
+ EFI_TCG2_SUBMIT_COMMAND SubmitCommand;
+ EFI_TCG2_GET_ACTIVE_PCR_BANKS GetActivePcrBanks;
+ EFI_TCG2_SET_ACTIVE_PCR_BANKS SetActivePcrBanks;
+ EFI_TCG2_GET_RESULT_OF_SET_ACTIVE_PCR_BANKS GetResultOfSetActivePcrBanks;
+};
+
+extern EFI_GUID gEfiTcg2ProtocolGuid;
+
+#endif
--
2.34.1
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#113490): https://edk2.groups.io/g/devel/message/113490
Mute This Topic: https://groups.io/mt/103625305/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-
^ permalink raw reply related [flat|nested] 26+ messages in thread
* Re: [edk2-devel] [PATCH v2 1/6] uefi-sct/SctPkg: TCG2 Protocol: add header with TCG2 protocol definitions
2024-01-09 18:20 ` [edk2-devel] [PATCH v2 1/6] uefi-sct/SctPkg: TCG2 Protocol: add header with TCG2 protocol definitions Stuart Yoder
@ 2024-03-05 15:47 ` G Edhaya Chandran
2024-03-18 20:42 ` Sunny Wang
2024-03-19 9:15 ` G Edhaya Chandran
2 siblings, 0 replies; 26+ messages in thread
From: G Edhaya Chandran @ 2024-03-05 15:47 UTC (permalink / raw)
To: Stuart Yoder, devel
[-- Attachment #1: Type: text/plain, Size: 424 bytes --]
Reviewed-by: G Edhaya Chandran <edhaya.chandran@arm.com>
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#116398): https://edk2.groups.io/g/devel/message/116398
Mute This Topic: https://groups.io/mt/103625305/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-
[-- Attachment #2: Type: text/html, Size: 842 bytes --]
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [edk2-devel] [PATCH v2 1/6] uefi-sct/SctPkg: TCG2 Protocol: add header with TCG2 protocol definitions
2024-01-09 18:20 ` [edk2-devel] [PATCH v2 1/6] uefi-sct/SctPkg: TCG2 Protocol: add header with TCG2 protocol definitions Stuart Yoder
2024-03-05 15:47 ` G Edhaya Chandran
@ 2024-03-18 20:42 ` Sunny Wang
2024-03-19 9:15 ` G Edhaya Chandran
2 siblings, 0 replies; 26+ messages in thread
From: Sunny Wang @ 2024-03-18 20:42 UTC (permalink / raw)
To: devel@edk2.groups.io, Stuart Yoder, G Edhaya Chandran,
gaojie@byosoft.com.cn
Cc: ilias.apalodimas@linaro.org, heinrich.schuchardt@canonical.com,
Samer El-Haj-Mahmoud, Jiewen.Yao@intel.com, Sunny Wang
Looks good to me.
For others' reference, the change has been already verified by running SystemReady SIE (Security Interface extension) tests on multiple SystemReady certified Arm systems.
Reviewed-by: Sunny Wang <sunny.wang@arm.com>
-----Original Message-----
From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Stuart Yoder via groups.io
Sent: Tuesday, January 9, 2024 12:21 PM
To: devel@edk2.groups.io; G Edhaya Chandran <Edhaya.Chandran@arm.com>; gaojie@byosoft.com.cn
Cc: ilias.apalodimas@linaro.org; heinrich.schuchardt@canonical.com; Samer El-Haj-Mahmoud <Samer.El-Haj-Mahmoud@arm.com>; Jiewen.Yao@intel.com
Subject: [edk2-devel] [PATCH v2 1/6] uefi-sct/SctPkg: TCG2 Protocol: add header with TCG2 protocol definitions
From: Joseph Hemann <joseph.hemann@arm.com>
Define constants and data structure specified in the TCG EFI Protocol
specification.
Signed-off-by: Joseph Hemann <Joseph.hemann@arm.com>
Signed-off-by: Stuart Yoder <stuart.yoder@arm.com>
---
uefi-sct/SctPkg/UEFI/Protocol/TCG2.h | 177 ++++++++++++++++++++
1 file changed, 177 insertions(+)
diff --git a/uefi-sct/SctPkg/UEFI/Protocol/TCG2.h b/uefi-sct/SctPkg/UEFI/Protocol/TCG2.h
new file mode 100644
index 000000000000..e62ecd85cbe9
--- /dev/null
+++ b/uefi-sct/SctPkg/UEFI/Protocol/TCG2.h
@@ -0,0 +1,177 @@
+/** @file
+
+ Copyright 2006 - 2016 Unified EFI, Inc.<BR>
+ Copyright (c) 2013 - 2016, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2021 - 2023, Arm Inc. All rights reserved.<BR>
+
+ This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+/*++
+
+Module Name:
+
+ TCG2.h
+
+Abstract:
+
+ EFI TCG Protocol
+
+--*/
+
+
+#ifndef __TCG2_PROTOCOL_H__
+#define __TCG2_PROTOCOL_H__
+
+//
+// Global ID for the TCG2 Protocol
+//
+#define EFI_TCG2_PROTOCOL_GUID \
+ {0x607f766c, 0x7455, 0x42be, {0x93, 0x0b, 0xe4, 0xd7, 0x6d, 0xb2, 0x72, 0x0f}}
+
+// Following defintions come from TCG2 Efi Protocol Spec
+#define EFI_TCG2_BOOT_HASH_ALG_SHA1 0x00000001
+
+#define EFI_TCG2_BOOT_HASH_ALG_SHA256 0x00000002
+
+#define EFI_TCG2_BOOT_HASH_ALG_SHA384 0x00000004
+
+#define EFI_TCG2_BOOT_HASH_ALG_SHA512 0x00000008
+
+#define EFI_TCG2_BOOT_HASH_ALG_SM3_256 0x00000010
+
+#define EFI_TCG2_EVENT_LOG_FORMAT_TCG_1_2 0x00000001
+
+#define EFI_TCG2_EVENT_LOG_FORMAT_TCG_2 0x00000002
+
+typedef struct _EFI_TCG2_PROTOCOL EFI_TCG2_PROTOCOL;
+
+typedef UINT32 EFI_TCG2_EVENT_LOG_BITMAP;
+
+typedef UINT32 EFI_TCG2_EVENT_LOG_FORMAT;
+
+typedef UINT32 EFI_TCG2_EVENT_ALGORITHM_BITMAP;
+
+typedef UINT32 TCG_PCRINDEX;
+
+typedef UINT32 TCG_EVENTTYPE;
+
+// Following struct defintions come from TCG2 Efi Protocol Spec
+typedef struct {
+ UINT8 Major;
+ UINT8 Minor;
+} EFI_TCG2_VERSION;
+
+typedef struct {
+ UINT8 Size;
+ EFI_TCG2_VERSION StructureVersion;
+ EFI_TCG2_VERSION ProtocolVersion;
+ EFI_TCG2_EVENT_ALGORITHM_BITMAP HashAlgorithmBitmap;
+ EFI_TCG2_EVENT_LOG_BITMAP SupportedEventLogs;
+ BOOLEAN TPMPresentFlag;
+ UINT16 MaxCommandSize;
+ UINT16 MaxResponseSize;
+ UINT32 ManufacturerID;
+ UINT32 NumberOfPcrBanks;
+ EFI_TCG2_EVENT_ALGORITHM_BITMAP ActivePcrBanks;
+} EFI_TCG2_BOOT_SERVICE_CAPABILITY;
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_TCG2_GET_CAPABILITY) (
+ IN EFI_TCG2_PROTOCOL *This,
+ IN OUT EFI_TCG2_BOOT_SERVICE_CAPABILITY *ProtocolCapability
+);
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_TCG2_GET_EVENT_LOG) (
+ IN EFI_TCG2_PROTOCOL *This,
+ IN EFI_TCG2_EVENT_LOG_FORMAT EventLogFormat,
+ OUT EFI_PHYSICAL_ADDRESS *EventLogLocation,
+ OUT EFI_PHYSICAL_ADDRESS *EventLogLastEntry,
+ OUT BOOLEAN *EventLogTruncated
+);
+
+// all structs except EFI_TCG2_BOOT_SERVICE_CAPABILITY are packed
+#pragma pack(1)
+
+typedef struct tdEFI_TCG2_EVENT_HEADER {
+ UINT32 HeaderSize;
+ UINT16 HeaderVersion;
+ TCG_PCRINDEX PCRIndex;
+ TCG_EVENTTYPE EventType;
+} EFI_TCG2_EVENT_HEADER;
+
+typedef struct tdEFI_TCG2_EVENT {
+ UINT32 Size;
+ EFI_TCG2_EVENT_HEADER Header;
+ UINT8 Event[];
+} EFI_TCG2_EVENT;
+
+#pragma pack()
+
+typedef
+EFI_STATUS
+(EFIAPI * EFI_TCG2_HASH_LOG_EXTEND_EVENT) (
+ IN EFI_TCG2_PROTOCOL *This,
+ IN UINT64 Flags,
+ IN EFI_PHYSICAL_ADDRESS DataToHash,
+ IN UINT64 DataToHashLen,
+ IN EFI_TCG2_EVENT *EfiTcgEvent
+);
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_TCG2_SUBMIT_COMMAND) (
+ IN EFI_TCG2_PROTOCOL *This,
+ IN UINT32 InputParameterBlockSize,
+ IN UINT8 *InputParameterBlock,
+ IN UINT32 OutputParameterBlockSize,
+ IN UINT8 *OutputParameterBlock
+);
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_TCG2_GET_ACTIVE_PCR_BANKS) (
+ IN EFI_TCG2_PROTOCOL *This,
+ OUT UINT32 *ActivePcrBanks
+);
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_TCG2_SET_ACTIVE_PCR_BANKS) (
+ IN EFI_TCG2_PROTOCOL *This,
+ IN UINT32 ActivePcrBanks
+);
+
+typedef
+EFI_STATUS
+(EFIAPI * EFI_TCG2_GET_RESULT_OF_SET_ACTIVE_PCR_BANKS) (
+ IN EFI_TCG2_PROTOCOL *This,
+ OUT UINT32 *OperationPresent,
+ OUT UINT32 *Response
+);
+
+//
+// Interface structure for the TCG2 Protocol
+//
+struct _EFI_TCG2_PROTOCOL {
+ EFI_TCG2_GET_CAPABILITY GetCapability;
+ EFI_TCG2_GET_EVENT_LOG GetEventLog;
+ EFI_TCG2_HASH_LOG_EXTEND_EVENT HashLogExtendEvent;
+ EFI_TCG2_SUBMIT_COMMAND SubmitCommand;
+ EFI_TCG2_GET_ACTIVE_PCR_BANKS GetActivePcrBanks;
+ EFI_TCG2_SET_ACTIVE_PCR_BANKS SetActivePcrBanks;
+ EFI_TCG2_GET_RESULT_OF_SET_ACTIVE_PCR_BANKS GetResultOfSetActivePcrBanks;
+};
+
+extern EFI_GUID gEfiTcg2ProtocolGuid;
+
+#endif
--
2.34.1
-=-=-=-=-=-=
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#113490): https://edk2.groups.io/g/devel/message/113490
Mute This Topic: https://groups.io/mt/103625305/5985097
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [Sunny.Wang@arm.com]
-=-=-=-=-=-=
IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#116845): https://edk2.groups.io/g/devel/message/116845
Mute This Topic: https://groups.io/mt/103625305/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-
^ permalink raw reply related [flat|nested] 26+ messages in thread
* Re: [edk2-devel] [PATCH v2 1/6] uefi-sct/SctPkg: TCG2 Protocol: add header with TCG2 protocol definitions
2024-01-09 18:20 ` [edk2-devel] [PATCH v2 1/6] uefi-sct/SctPkg: TCG2 Protocol: add header with TCG2 protocol definitions Stuart Yoder
2024-03-05 15:47 ` G Edhaya Chandran
2024-03-18 20:42 ` Sunny Wang
@ 2024-03-19 9:15 ` G Edhaya Chandran
2 siblings, 0 replies; 26+ messages in thread
From: G Edhaya Chandran @ 2024-03-19 9:15 UTC (permalink / raw)
To: Stuart Yoder, devel
[-- Attachment #1: Type: text/plain, Size: 494 bytes --]
The patch is upstreamed by the commit:
https://github.com/tianocore/edk2-test/commit/49620fa0bb9757bce13f41f604001114ea6c40de
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#116888): https://edk2.groups.io/g/devel/message/116888
Mute This Topic: https://groups.io/mt/103625305/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-
[-- Attachment #2: Type: text/html, Size: 910 bytes --]
^ permalink raw reply [flat|nested] 26+ messages in thread
* [edk2-devel] [PATCH v2 2/6] uefi-sct/SctPkg: TCG2 Protocol: add test infrastructure and GetCapability Test
2024-01-09 18:20 [edk2-devel] [PATCH v2 0/6] Tests for TCG2 Protocol Stuart Yoder
2024-01-09 18:20 ` [edk2-devel] [PATCH v2 1/6] uefi-sct/SctPkg: TCG2 Protocol: add header with TCG2 protocol definitions Stuart Yoder
@ 2024-01-09 18:20 ` Stuart Yoder
2024-03-05 15:47 ` G Edhaya Chandran
` (2 more replies)
2024-01-09 18:20 ` [edk2-devel] [PATCH v2 3/6] uefi-sct/SctPkg: TCG2 Protocol: add GetActivePcrBanks test Stuart Yoder
` (4 subsequent siblings)
6 siblings, 3 replies; 26+ messages in thread
From: Stuart Yoder @ 2024-01-09 18:20 UTC (permalink / raw)
To: devel, Edhaya.Chandran, gaojie
Cc: ilias.apalodimas, heinrich.schuchardt, Samer.El-Haj-Mahmoud,
Jiewen.Yao
From: Joseph Hemann <joseph.hemann@arm.com>
-implement initial infrastructure for the TCG2 protocol test
including updates to .dsc file, inf file, GUID source files,
update to Category.ini.
-add test case for GetCapability(), as defined in the TCG EFI
Protocol Spec 6.4.4.
-add checkpoint for NULL pointer passed for buffer
-add checkpoint for validating fields of the struct returned by GetCapability()
Signed-off-by: Joseph Hemann <Joseph.hemann@arm.com>
Signed-off-by: Stuart Yoder <stuart.yoder@arm.com>
---
uefi-sct/SctPkg/UEFI/UEFI_SCT.dsc | 1 +
uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTest.inf | 51 +++
uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.h | 47 +++
uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTest.h | 77 +++++
uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.c | 37 ++
uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTestConformance.c | 361 ++++++++++++++++++++
uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTestMain.c | 102 ++++++
uefi-sct/SctPkg/CommonGenFramework.sh | 1 +
uefi-sct/SctPkg/Config/Data/Category.ini | 7 +
9 files changed, 684 insertions(+)
diff --git a/uefi-sct/SctPkg/UEFI/UEFI_SCT.dsc b/uefi-sct/SctPkg/UEFI/UEFI_SCT.dsc
index 155490fa39d3..96c93e73992c 100644
--- a/uefi-sct/SctPkg/UEFI/UEFI_SCT.dsc
+++ b/uefi-sct/SctPkg/UEFI/UEFI_SCT.dsc
@@ -301,6 +301,7 @@ SctPkg/TestCase/UEFI/EFI/Protocol/StorageSecurityCommand/BlackBoxTest/StorageSec
SctPkg/TestCase/UEFI/EFI/Protocol/AdapterInfo/BlackBoxTest/AdapterInfoProtocolBBTest.inf
SctPkg/TestCase/UEFI/EFI/Protocol/TimeStamp/BlackBoxTest/TimeStampProtocolBBTest.inf
SctPkg/TestCase/UEFI/EFI/Protocol/RandomNumber/BlackBoxTest/RandomNumberBBTest.inf
+SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTest.inf
SctPkg/TestCase/UEFI/EFI/Protocol/Hash2/BlackBoxTest/Hash2BBTest.inf
SctPkg/TestCase/UEFI/EFI/Protocol/PKCS7Verify/BlackBoxTest/Pkcs7BBTest.inf
diff --git a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTest.inf b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTest.inf
new file mode 100644
index 000000000000..563d81b7e859
--- /dev/null
+++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTest.inf
@@ -0,0 +1,51 @@
+## @file
+#
+# Copyright 2006 - 2015 Unified EFI, Inc.<BR>
+# Copyright (c) 2013, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2021 - 2023, Arm Inc. All rights reserved.<BR>
+#
+# This program and the accompanying materials
+# are licensed and made available under the terms and conditions of the BSD License
+# which accompanies this distribution. The full text of the license may be found at
+# http://opensource.org/licenses/bsd-license.php
+#
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+#
+##
+#/*++
+#
+# Module Name:
+#
+# TCG2ProtocolBBTest.inf
+#
+# Abstract:
+#
+# Component description file for TCG2 Protocol Black-Box Test.
+#
+#--*/
+
+[defines]
+ INF_VERSION = 0x00010005
+ BASE_NAME = TCG2ProtocolBBTest
+ FILE_GUID = BD8CB762-3935-434C-AC3F-462244910A2D
+ MODULE_TYPE = UEFI_DRIVER
+ VERSION_STRING = 1.0
+ ENTRY_POINT = InitializeBBTestTCG2Protocol
+
+[sources.common]
+ Guid.c
+ TCG2ProtocolBBTestMain.c
+ TCG2ProtocolBBTestConformance.c
+
+[Packages]
+ MdePkg/MdePkg.dec
+ SctPkg/SctPkg.dec
+ SctPkg/UEFI/UEFI.dec
+
+[LibraryClasses]
+ UefiDriverEntryPoint
+ SctLib
+ EfiTestLib
+
+[Protocols]
diff --git a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.h b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.h
new file mode 100644
index 000000000000..50b14272939f
--- /dev/null
+++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.h
@@ -0,0 +1,47 @@
+/** @file
+
+ Copyright 2006 - 2016 Unified EFI, Inc.<BR>
+ Copyright (c) 2013, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2021 - 2023, Arm Inc. All rights reserved.<BR>
+
+ This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+/*++
+
+Module Name:
+
+ guid.h
+
+Abstract:
+
+ GUIDs auto-generated for EFI test assertion.
+
+--*/
+
+
+#define EFI_TEST_TCG2CONFORMANCE_ASSERTION_001_GUID \
+{ 0xca93b02a, 0xe897, 0x4400, {0x81, 0x38, 0xc8, 0xa8, 0xcb, 0x2f, 0xc1, 0xed }}
+
+extern EFI_GUID gTcg2ConformanceTestAssertionGuid001;
+
+#define EFI_TEST_TCG2CONFORMANCE_ASSERTION_002_GUID \
+{ 0xfdee7001, 0x7e28, 0x4e35, {0x99, 0x66, 0x98, 0x0b, 0xeb, 0xba, 0xf1, 0x57 }}
+
+extern EFI_GUID gTcg2ConformanceTestAssertionGuid002;
+
+#define EFI_TEST_TCG2CONFORMANCE_ASSERTION_003_GUID \
+{ 0xda8821d9, 0x3d2c, 0x4698, {0x8c, 0xd5, 0x0f, 0x0c, 0x82, 0x94, 0x1d, 0x0c }}
+
+extern EFI_GUID gTcg2ConformanceTestAssertionGuid003;
+
+#define EFI_TEST_TCG2CONFORMANCE_ASSERTION_004_GUID \
+{ 0x8ddb031b, 0x7448, 0x40ee, {0xb1, 0xa2, 0xe6, 0xf8, 0xe8, 0xc4, 0xe5, 0x5f }}
+
+extern EFI_GUID gTcg2ConformanceTestAssertionGuid004;
diff --git a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTest.h b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTest.h
new file mode 100644
index 000000000000..a7ce2db322d9
--- /dev/null
+++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTest.h
@@ -0,0 +1,77 @@
+/** @file
+
+ Copyright 2006 - 2017 Unified EFI, Inc.<BR>
+ Copyright (c) 2013, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2021 - 2023, Arm Inc. All rights reserved.<BR>
+
+ This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+/*++
+
+Module Name:
+ TCG2ProtocolBBTest.h
+
+Abstract:
+ head file of test driver of EFI TCG2 Protocol Test
+
+--*/
+
+#include "SctLib.h"
+#include <Library/EfiTestLib.h>
+#include <UEFI/Protocol/TCG2.h>
+#include "Guid.h"
+
+#define EFI_TCG2_TEST_REVISION 0x00010000
+
+//////////////////////////////////////////////////////////////////////////////
+//
+// Entry GUIDs for Function Test
+//
+#define EFI_TCG2_PROTOCOL_TEST_ENTRY_GUID0101 \
+ {0x39ff9c71, 0x4b41, 0x4e5b, {0xae, 0xd7, 0x87, 0xc7, 0x94, 0x18, 0x7d, 0x67} }
+
+EFI_STATUS
+EFIAPI
+BBTestTCG2ProtocolUnload (
+ IN EFI_HANDLE ImageHandle
+ );
+
+EFI_STATUS
+BBTestGetCapabilityConformanceTestCheckpoint1 (
+ IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib,
+ IN EFI_TCG2_PROTOCOL *TCG2
+ );
+
+EFI_STATUS
+BBTestGetCapabilityConformanceTestCheckpoint2 (
+ IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib,
+ IN EFI_TCG2_PROTOCOL *TCG2
+ );
+
+EFI_STATUS
+BBTestGetCapabilityConformanceTestCheckpoint3 (
+ IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib,
+ IN EFI_TCG2_PROTOCOL *TCG2
+ );
+
+EFI_STATUS
+BBTestGetCapabilityConformanceTestCheckpoint4 (
+ IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib,
+ IN EFI_TCG2_PROTOCOL *TCG2
+ );
+
+EFI_STATUS
+BBTestGetCapabilityConformanceTest (
+ IN EFI_BB_TEST_PROTOCOL *This,
+ IN VOID *ClientInterface,
+ IN EFI_TEST_LEVEL TestLevel,
+ IN EFI_HANDLE SupportHandle
+ );
+
diff --git a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.c b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.c
new file mode 100644
index 000000000000..3e75ffdc0a60
--- /dev/null
+++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.c
@@ -0,0 +1,37 @@
+/** @file
+
+ Copyright 2006 - 2013 Unified EFI, Inc.<BR>
+ Copyright (c) 2013, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2021 - 2023, Arm Inc. All rights reserved.<BR>
+
+ This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+/*++
+
+Module Name:
+
+ guid.c
+
+Abstract:
+
+ GUIDs auto-generated for EFI test assertion.
+
+--*/
+
+#include "Efi.h"
+#include "Guid.h"
+
+EFI_GUID gTcg2ConformanceTestAssertionGuid001 = EFI_TEST_TCG2CONFORMANCE_ASSERTION_001_GUID;
+
+EFI_GUID gTcg2ConformanceTestAssertionGuid002 = EFI_TEST_TCG2CONFORMANCE_ASSERTION_002_GUID;
+
+EFI_GUID gTcg2ConformanceTestAssertionGuid003 = EFI_TEST_TCG2CONFORMANCE_ASSERTION_003_GUID;
+
+EFI_GUID gTcg2ConformanceTestAssertionGuid004 = EFI_TEST_TCG2CONFORMANCE_ASSERTION_004_GUID;
diff --git a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTestConformance.c b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTestConformance.c
new file mode 100644
index 000000000000..686cf4baebcd
--- /dev/null
+++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTestConformance.c
@@ -0,0 +1,361 @@
+/** @file
+
+ Copyright 2006 - 2016 Unified EFI, Inc.<BR>
+ Copyright (c) 2021 - 2023, Arm Inc. All rights reserved.<BR>
+
+ This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+/*++
+
+Module Name:
+
+ TCG2BBTestConformance.c
+
+Abstract:
+
+ for EFI Driver TCG2 Protocol's Basic Test
+
+--*/
+
+#include "TCG2ProtocolBBTest.h"
+
+#define offsetof(st, m) __builtin_offsetof(st, m)
+
+/**
+ * @brief Entrypoint for GetCapability() Function Test.
+ * 4 checkpoints will be tested.
+ * @param This a pointer of EFI_BB_TEST_PROTOCOL
+ * @param ClientInterface A pointer to the interface array under test
+ * @param TestLevel Test "thoroughness" control
+ * @param SupportHandle A handle containing protocols required
+ * @return EFI_SUCCESS
+ * @return EFI_NOT_FOUND
+ */
+
+EFI_STATUS
+BBTestGetCapabilityConformanceTest (
+ IN EFI_BB_TEST_PROTOCOL *This,
+ IN VOID *ClientInterface,
+ IN EFI_TEST_LEVEL TestLevel,
+ IN EFI_HANDLE SupportHandle
+ )
+{
+ EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib;
+ EFI_STATUS Status;
+ EFI_TCG2_PROTOCOL *TCG2;
+
+ //
+ // init
+ //
+ TCG2 = (EFI_TCG2_PROTOCOL*)ClientInterface;
+
+ // Ensure Protocol not NULL
+ if (TCG2 == NULL)
+ return EFI_UNSUPPORTED;
+
+ //
+ // Get the Standard Library Interface
+ //
+ Status = gtBS->HandleProtocol (
+ SupportHandle,
+ &gEfiStandardTestLibraryGuid,
+ (VOID **) &StandardLib
+ );
+ if (EFI_ERROR(Status)) {
+ return Status;
+ }
+
+ // Test Using NULL BootCapability Pointer
+ BBTestGetCapabilityConformanceTestCheckpoint1 (StandardLib, TCG2);
+
+ // Test for validating fields of struct returned by GetCapability()
+ BBTestGetCapabilityConformanceTestCheckpoint2 (StandardLib, TCG2);
+
+ // Test Using Capability struct with struct size less than 1.0 size
+ BBTestGetCapabilityConformanceTestCheckpoint3 (StandardLib, TCG2);
+
+ // Test Using Capability struct with struct size equal to 1.0 size
+ BBTestGetCapabilityConformanceTestCheckpoint4 (StandardLib, TCG2);
+
+ return EFI_SUCCESS;
+}
+
+
+EFI_STATUS
+BBTestGetCapabilityConformanceTestCheckpoint1 (
+ IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib,
+ IN EFI_TCG2_PROTOCOL *TCG2
+ )
+{
+ EFI_TEST_ASSERTION AssertionType;
+ EFI_STATUS Status;
+ EFI_TCG2_BOOT_SERVICE_CAPABILITY *BootServiceCapPtr = NULL;
+
+ Status = TCG2->GetCapability (
+ TCG2,
+ BootServiceCapPtr);
+
+ // Ensure GetCapability returns Invalid Parameter when passing in NULL pointer
+ if (EFI_INVALID_PARAMETER == Status) {
+ AssertionType = EFI_TEST_ASSERTION_PASSED;
+ } else {
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ }
+
+ StandardLib->RecordAssertion (
+ StandardLib,
+ AssertionType,
+ gTcg2ConformanceTestAssertionGuid001,
+ L"TCG2_PROTOCOL.GetCapability - GetCapability() returns EFI_INVALID_PARAMETER with NULL pointer Capability Struct Passed in",
+ L"%a:%d: Status - %r",
+ __FILE__,
+ (UINTN)__LINE__,
+ Status
+ );
+
+ return EFI_SUCCESS;
+}
+
+
+EFI_STATUS
+BBTestGetCapabilityConformanceTestCheckpoint2 (
+ IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib,
+ IN EFI_TCG2_PROTOCOL *TCG2
+ )
+{
+ EFI_TEST_ASSERTION AssertionType;
+ EFI_STATUS Status;
+ CHAR8 StructureVersionMajor;
+ CHAR8 StructureVersionMinor;
+ CHAR8 ProtocolVersionMajor;
+ CHAR8 ProtocolVersionMinor;
+ EFI_TCG2_BOOT_SERVICE_CAPABILITY BootServiceCap;
+
+ BootServiceCap.Size = sizeof(EFI_TCG2_BOOT_SERVICE_CAPABILITY);
+
+ Status = TCG2->GetCapability (
+ TCG2,
+ &BootServiceCap);
+
+ AssertionType = EFI_TEST_ASSERTION_PASSED;
+
+ if (Status != EFI_SUCCESS) {
+ StandardLib->RecordMessage (
+ StandardLib,
+ EFI_VERBOSE_LEVEL_DEFAULT,
+ L"\r\nTCG2 Protocol GetCapability Test: GetCapability should return EFI_SUCCESS"
+ );
+
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ }
+
+ StructureVersionMajor = BootServiceCap.StructureVersion.Major;
+ StructureVersionMinor = BootServiceCap.StructureVersion.Minor;
+
+ // TCG EFI Protocol spec 6.4.4 #4
+ if ((StructureVersionMajor != 1) | (StructureVersionMinor != 1)) {
+ StandardLib->RecordMessage (
+ StandardLib,
+ EFI_VERBOSE_LEVEL_DEFAULT,
+ L"\r\nTCG2 Protocol GetCapability Test: GetCapability should have StructureVersion 1.1, reported value = %d.%d",
+ StructureVersionMajor,
+ StructureVersionMinor
+ );
+
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ }
+
+ ProtocolVersionMajor = BootServiceCap.ProtocolVersion.Major;
+ ProtocolVersionMinor = BootServiceCap.ProtocolVersion.Minor;
+
+ // TCG EFI Protocol spec 6.4.4 #4
+ if ((ProtocolVersionMajor != 1) | (ProtocolVersionMinor != 1)) {
+ StandardLib->RecordMessage (
+ StandardLib,
+ EFI_VERBOSE_LEVEL_DEFAULT,
+ L"\r\nTCG2 Protocol GetCapability Test: GetCapability should have ProtocolVersion 1.1, reported value = %d.%d",
+ ProtocolVersionMajor,
+ ProtocolVersionMinor
+ );
+
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ }
+
+ if (!(BootServiceCap.HashAlgorithmBitmap & EFI_TCG2_BOOT_HASH_ALG_SHA256)) {
+ StandardLib->RecordMessage (
+ StandardLib,
+ EFI_VERBOSE_LEVEL_DEFAULT,
+ L"\r\nTCG2 Protocol GetCapability Test: unexpected hash algorithms reported = %x",
+ BootServiceCap.HashAlgorithmBitmap
+ );
+
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ }
+
+ if (!(BootServiceCap.SupportedEventLogs & EFI_TCG2_EVENT_LOG_FORMAT_TCG_2)) {
+ StandardLib->RecordMessage (
+ StandardLib,
+ EFI_VERBOSE_LEVEL_DEFAULT,
+ L"\r\nTCG2 Protocol GetCapability Test: GetCapability must support TCG2 event log format"
+ );
+
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ }
+
+ for (int i = 0; i < sizeof(BootServiceCap.ActivePcrBanks); i++) {
+ if (((BootServiceCap.ActivePcrBanks & (1u << i)) != 0) &&
+ ((BootServiceCap.HashAlgorithmBitmap & (1u << i)) == 0)) {
+ StandardLib->RecordMessage (
+ StandardLib,
+ EFI_VERBOSE_LEVEL_DEFAULT,
+ L"\r\nTCG2 Protocol GetCapability Test: ActivePcrBanks is not a subset of HashAlgorithmBitmap. Reported ActivePcrBanks:0x%x HashAlgorithmBitmap=0x%x",
+ BootServiceCap.ActivePcrBanks,
+ BootServiceCap.HashAlgorithmBitmap
+ );
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ }
+ }
+
+ if (BootServiceCap.NumberOfPcrBanks < 1 ) {
+ StandardLib->RecordMessage (
+ StandardLib,
+ EFI_VERBOSE_LEVEL_DEFAULT,
+ L"\r\nTCG2 Protocol GetCapability Test: expect at least 1 PCR bank"
+ );
+
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ }
+
+ // Verify that ActivePcrBanks includes SHA256, SHA384, or SHA512
+ EFI_TCG2_EVENT_ALGORITHM_BITMAP HashBitMapAlgos = EFI_TCG2_BOOT_HASH_ALG_SHA256 | EFI_TCG2_BOOT_HASH_ALG_SHA384 | EFI_TCG2_BOOT_HASH_ALG_SHA512;
+
+ if (!(BootServiceCap.ActivePcrBanks & HashBitMapAlgos)) {
+ StandardLib->RecordMessage (
+ StandardLib,
+ EFI_VERBOSE_LEVEL_DEFAULT,
+ L"\r\nTCG2 Protocol GetCapability Test: ActivePcrBanks doesn't includes SHA256, SHA384, or SHA512",
+ BootServiceCap.ActivePcrBanks
+ );
+
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ }
+
+ StandardLib->RecordAssertion (
+ StandardLib,
+ AssertionType,
+ gTcg2ConformanceTestAssertionGuid002,
+ L"TCG2_PROTOCOL.GetCapability - GetCapability() populates all elements of EFI_TCG_BOOT_SERVICE_CAPABILITY",
+ L"%a:%d: Status - %r",
+ __FILE__,
+ (UINTN)__LINE__,
+ Status
+ );
+
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+BBTestGetCapabilityConformanceTestCheckpoint3 (
+ IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib,
+ IN EFI_TCG2_PROTOCOL *TCG2
+ )
+{
+ EFI_TEST_ASSERTION AssertionType;
+ EFI_STATUS Status;
+ EFI_TCG2_BOOT_SERVICE_CAPABILITY BootServiceCap;
+
+ // set size to be value less than 1.0 or 1.1 struct
+ BootServiceCap.Size = 4;
+
+ Status = TCG2->GetCapability (
+ TCG2,
+ &BootServiceCap);
+
+ AssertionType = EFI_TEST_ASSERTION_PASSED;
+
+ if (Status != EFI_BUFFER_TOO_SMALL && BootServiceCap.Size != sizeof(EFI_TCG2_BOOT_SERVICE_CAPABILITY)) {
+ StandardLib->RecordMessage (
+ StandardLib,
+ EFI_VERBOSE_LEVEL_DEFAULT,
+ L"\r\nTCG2 Protocol GetCapability Test: Did not return Status == EFI_BUFFER_TOO_SMALL and Size == sizeof(EFI_TCG2_BOOT_SERVICE_CAPABILITY)"
+ );
+
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ }
+
+ StandardLib->RecordAssertion (
+ StandardLib,
+ AssertionType,
+ gTcg2ConformanceTestAssertionGuid003,
+ L"TCG2_PROTOCOL.GetCapability() - GetCapability() handling of input struct size less than the size of EFI_TCG2_BOOT_SERVICE_CAPABILITY up to and including the ManufacturerID field",
+ L"%a:%d: Status - %r",
+ __FILE__,
+ (UINTN)__LINE__,
+ Status
+ );
+
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+BBTestGetCapabilityConformanceTestCheckpoint4 (
+ IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib,
+ IN EFI_TCG2_PROTOCOL *TCG2
+ )
+{
+ EFI_TEST_ASSERTION AssertionType;
+ EFI_STATUS Status;
+ EFI_TCG2_BOOT_SERVICE_CAPABILITY BootServiceCap;
+
+ // set size of struct to be up to and including the ManufacturerID
+ // (this acts like a client with a 1.0 version of the struct)
+ BootServiceCap.Size = offsetof(EFI_TCG2_BOOT_SERVICE_CAPABILITY, NumberOfPcrBanks);
+
+ Status = TCG2->GetCapability (
+ TCG2,
+ &BootServiceCap);
+
+ AssertionType = EFI_TEST_ASSERTION_PASSED;
+
+ if (Status != EFI_SUCCESS) {
+ StandardLib->RecordMessage (
+ StandardLib,
+ EFI_VERBOSE_LEVEL_DEFAULT,
+ L"\r\nTCG2 Protocol GetCapability Test: 1.0 Compatibility. GetCapability should return EFI_SUCCESS"
+ );
+
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ }
+
+ // Verify returned Size equals the size of EFI_TCG2_BOOT_SERVICE_CAPABILITY up to and including the ManufacturerID field.
+ if (BootServiceCap.Size != offsetof(EFI_TCG2_BOOT_SERVICE_CAPABILITY, NumberOfPcrBanks)) {
+ StandardLib->RecordMessage (
+ StandardLib,
+ EFI_VERBOSE_LEVEL_DEFAULT,
+ L"\r\nTCG2 Protocol GetCapability Test: Did not return Size == EFI_TCG2_BOOT_SERVICE_CAPABILITY up to and including the ManufacturerID field"
+ );
+
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ }
+
+ StandardLib->RecordAssertion (
+ StandardLib,
+ AssertionType,
+ gTcg2ConformanceTestAssertionGuid004,
+ L"TCG2_PROTOCOL.GetCapability - GetCapability() backwards compatibility check for 1.0 version of EFI_TCG_BOOT_SERVICE_CAPABILITY",
+ L"%a:%d: Status - %r",
+ __FILE__,
+ (UINTN)__LINE__,
+ Status
+ );
+
+ return EFI_SUCCESS;
+}
+
diff --git a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTestMain.c b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTestMain.c
new file mode 100644
index 000000000000..1de87e9d4c66
--- /dev/null
+++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTestMain.c
@@ -0,0 +1,102 @@
+/** @file
+
+ Copyright 2006 - 2017 Unified EFI, Inc.<BR>
+ Copyright (c) 2013, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2021 - 2023, Arm Inc. All rights reserved.<BR>
+
+ This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+/*++
+
+Module Name:
+ TCG2ProtocolBBTestMain.c
+
+Abstract:
+ for EFI TCG2 Protocol Test
+
+--*/
+
+#include "TCG2ProtocolBBTest.h"
+
+EFI_BB_TEST_PROTOCOL_FIELD gBBTestProtocolField = {
+ EFI_TCG2_TEST_REVISION,
+ EFI_TCG2_PROTOCOL_GUID,
+ L"Testing For EFI TCG2 Protocol",
+ L"Total # test cases for the EFI TCG2 Protocol"
+};
+
+EFI_GUID gSupportProtocolGuid1[2] = {
+ EFI_STANDARD_TEST_LIBRARY_GUID,
+ EFI_NULL_GUID
+};
+
+EFI_BB_TEST_ENTRY_FIELD gBBTestEntryField[] = {
+ {
+ EFI_TCG2_PROTOCOL_TEST_ENTRY_GUID0101,
+ L"GetCapability_Conf",
+ L"Test the GetCapablity API",
+ EFI_TEST_LEVEL_DEFAULT,
+ gSupportProtocolGuid1,
+ EFI_TEST_CASE_AUTO,
+ BBTestGetCapabilityConformanceTest
+ },
+ 0
+};
+
+EFI_BB_TEST_PROTOCOL *gBBTestProtocolInterface;
+
+/**
+ * Creates/installs the BlackBox Interface and eminating Entry Point
+ * node list.
+ * @param ImageHandle The test driver image handle
+ * @param SystemTable Pointer to System Table
+ * @return EFI_SUCCESS Indicates the interface was installed
+ * @return EFI_OUT_OF_RESOURCES Indicates space for the new handle could not be allocated
+ * @return EFI_INVALID_PARAMETER: One of the parameters has an invalid value.
+ */
+EFI_STATUS
+EFIAPI
+InitializeBBTestTCG2Protocol (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ )
+{
+ EfiInitializeTestLib (ImageHandle, SystemTable);
+
+ //
+ // initialize test utility lib
+ //
+ SctInitializeLib (ImageHandle, SystemTable);
+
+ return EfiInitAndInstallBBTestInterface (
+ &ImageHandle,
+ &gBBTestProtocolField,
+ gBBTestEntryField,
+ BBTestTCG2ProtocolUnload,
+ &gBBTestProtocolInterface
+ );
+}
+
+/**
+ * The driver's Unload function
+ * @param ImageHandle The test driver image handle
+ * @return EFI_SUCCESS Indicates the interface was Uninstalled
+*/
+EFI_STATUS
+EFIAPI
+BBTestTCG2ProtocolUnload (
+ IN EFI_HANDLE ImageHandle
+ )
+{
+ return EfiUninstallAndFreeBBTestInterface (
+ ImageHandle,
+ gBBTestProtocolInterface
+ );
+}
diff --git a/uefi-sct/SctPkg/CommonGenFramework.sh b/uefi-sct/SctPkg/CommonGenFramework.sh
index fb9043b56bca..9c8662d841ae 100755
--- a/uefi-sct/SctPkg/CommonGenFramework.sh
+++ b/uefi-sct/SctPkg/CommonGenFramework.sh
@@ -210,6 +210,7 @@ then
cp $ProcessorType/DiskIo2BBTest.efi $Framework/Test/ > NUL
cp $ProcessorType/TimeStampBBTest.efi $Framework/Test/ > NUL
cp $ProcessorType/RandomNumberBBTest.efi $Framework/Test/ > NUL
+ cp $ProcessorType/TCG2ProtocolBBTest.efi $Framework/Test/ > NUL
cp $ProcessorType/Hash2BBTest.efi $Framework/Test/ > NUL
cp $ProcessorType/Pkcs7BBTest.efi $Framework/Test/ > NUL
cp $ProcessorType/ConfigKeywordHandlerBBTest.efi $Framework/Test/ > NUL
diff --git a/uefi-sct/SctPkg/Config/Data/Category.ini b/uefi-sct/SctPkg/Config/Data/Category.ini
index b34d35db9ac8..4a53115b4d7d 100644
--- a/uefi-sct/SctPkg/Config/Data/Category.ini
+++ b/uefi-sct/SctPkg/Config/Data/Category.ini
@@ -1032,3 +1032,10 @@ CategoryGuid = CCD15FEC-6F73-4EEC-8395-3E69E4B940BF
InterfaceGuid = CCD15FEC-6F73-4EEC-8395-3E69E4B940BF
Name = RiscvBootProtocolTest
Description = RISC-V Boot Protocol Test
+
+[Category Data]
+Revision = 0x00010000
+CategoryGuid = 607f766c-7455-42be-930b-e4d76db2720f
+InterfaceGuid = 607f766c-7455-42be-930b-e4d76db2720f
+Name = TCG2ProtocolTest
+Description = TCG2 Protocol Test
--
2.34.1
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#113489): https://edk2.groups.io/g/devel/message/113489
Mute This Topic: https://groups.io/mt/103625304/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-
^ permalink raw reply related [flat|nested] 26+ messages in thread
* Re: [edk2-devel] [PATCH v2 2/6] uefi-sct/SctPkg: TCG2 Protocol: add test infrastructure and GetCapability Test
2024-01-09 18:20 ` [edk2-devel] [PATCH v2 2/6] uefi-sct/SctPkg: TCG2 Protocol: add test infrastructure and GetCapability Test Stuart Yoder
@ 2024-03-05 15:47 ` G Edhaya Chandran
2024-03-18 20:43 ` Sunny Wang
2024-03-19 9:15 ` G Edhaya Chandran
2 siblings, 0 replies; 26+ messages in thread
From: G Edhaya Chandran @ 2024-03-05 15:47 UTC (permalink / raw)
To: Stuart Yoder, devel
[-- Attachment #1: Type: text/plain, Size: 424 bytes --]
Reviewed-by: G Edhaya Chandran <edhaya.chandran@arm.com>
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#116399): https://edk2.groups.io/g/devel/message/116399
Mute This Topic: https://groups.io/mt/103625304/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-
[-- Attachment #2: Type: text/html, Size: 842 bytes --]
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [edk2-devel] [PATCH v2 2/6] uefi-sct/SctPkg: TCG2 Protocol: add test infrastructure and GetCapability Test
2024-01-09 18:20 ` [edk2-devel] [PATCH v2 2/6] uefi-sct/SctPkg: TCG2 Protocol: add test infrastructure and GetCapability Test Stuart Yoder
2024-03-05 15:47 ` G Edhaya Chandran
@ 2024-03-18 20:43 ` Sunny Wang
2024-03-19 9:15 ` G Edhaya Chandran
2 siblings, 0 replies; 26+ messages in thread
From: Sunny Wang @ 2024-03-18 20:43 UTC (permalink / raw)
To: devel@edk2.groups.io, Stuart Yoder, G Edhaya Chandran,
gaojie@byosoft.com.cn
Cc: ilias.apalodimas@linaro.org, heinrich.schuchardt@canonical.com,
Samer El-Haj-Mahmoud, Jiewen.Yao@intel.com, Sunny Wang
Looks good to me.
For others' reference, the change has been already verified by running SystemReady SIE (Security Interface extension) tests on multiple SystemReady certified Arm systems.
Reviewed-by: Sunny Wang <sunny.wang@arm.com>
-----Original Message-----
From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Stuart Yoder via groups.io
Sent: Tuesday, January 9, 2024 12:21 PM
To: devel@edk2.groups.io; G Edhaya Chandran <Edhaya.Chandran@arm.com>; gaojie@byosoft.com.cn
Cc: ilias.apalodimas@linaro.org; heinrich.schuchardt@canonical.com; Samer El-Haj-Mahmoud <Samer.El-Haj-Mahmoud@arm.com>; Jiewen.Yao@intel.com
Subject: [edk2-devel] [PATCH v2 2/6] uefi-sct/SctPkg: TCG2 Protocol: add test infrastructure and GetCapability Test
From: Joseph Hemann <joseph.hemann@arm.com>
-implement initial infrastructure for the TCG2 protocol test
including updates to .dsc file, inf file, GUID source files,
update to Category.ini.
-add test case for GetCapability(), as defined in the TCG EFI
Protocol Spec 6.4.4.
-add checkpoint for NULL pointer passed for buffer
-add checkpoint for validating fields of the struct returned by GetCapability()
Signed-off-by: Joseph Hemann <Joseph.hemann@arm.com>
Signed-off-by: Stuart Yoder <stuart.yoder@arm.com>
---
uefi-sct/SctPkg/UEFI/UEFI_SCT.dsc | 1 +
uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTest.inf | 51 +++
uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.h | 47 +++
uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTest.h | 77 +++++
uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.c | 37 ++
uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTestConformance.c | 361 ++++++++++++++++++++
uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTestMain.c | 102 ++++++
uefi-sct/SctPkg/CommonGenFramework.sh | 1 +
uefi-sct/SctPkg/Config/Data/Category.ini | 7 +
9 files changed, 684 insertions(+)
diff --git a/uefi-sct/SctPkg/UEFI/UEFI_SCT.dsc b/uefi-sct/SctPkg/UEFI/UEFI_SCT.dsc
index 155490fa39d3..96c93e73992c 100644
--- a/uefi-sct/SctPkg/UEFI/UEFI_SCT.dsc
+++ b/uefi-sct/SctPkg/UEFI/UEFI_SCT.dsc
@@ -301,6 +301,7 @@ SctPkg/TestCase/UEFI/EFI/Protocol/StorageSecurityCommand/BlackBoxTest/StorageSec
SctPkg/TestCase/UEFI/EFI/Protocol/AdapterInfo/BlackBoxTest/AdapterInfoProtocolBBTest.inf
SctPkg/TestCase/UEFI/EFI/Protocol/TimeStamp/BlackBoxTest/TimeStampProtocolBBTest.inf
SctPkg/TestCase/UEFI/EFI/Protocol/RandomNumber/BlackBoxTest/RandomNumberBBTest.inf
+SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTest.inf
SctPkg/TestCase/UEFI/EFI/Protocol/Hash2/BlackBoxTest/Hash2BBTest.inf
SctPkg/TestCase/UEFI/EFI/Protocol/PKCS7Verify/BlackBoxTest/Pkcs7BBTest.inf
diff --git a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTest.inf b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTest.inf
new file mode 100644
index 000000000000..563d81b7e859
--- /dev/null
+++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTest.inf
@@ -0,0 +1,51 @@
+## @file
+#
+# Copyright 2006 - 2015 Unified EFI, Inc.<BR>
+# Copyright (c) 2013, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2021 - 2023, Arm Inc. All rights reserved.<BR>
+#
+# This program and the accompanying materials
+# are licensed and made available under the terms and conditions of the BSD License
+# which accompanies this distribution. The full text of the license may be found at
+# http://opensource.org/licenses/bsd-license.php
+#
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+#
+##
+#/*++
+#
+# Module Name:
+#
+# TCG2ProtocolBBTest.inf
+#
+# Abstract:
+#
+# Component description file for TCG2 Protocol Black-Box Test.
+#
+#--*/
+
+[defines]
+ INF_VERSION = 0x00010005
+ BASE_NAME = TCG2ProtocolBBTest
+ FILE_GUID = BD8CB762-3935-434C-AC3F-462244910A2D
+ MODULE_TYPE = UEFI_DRIVER
+ VERSION_STRING = 1.0
+ ENTRY_POINT = InitializeBBTestTCG2Protocol
+
+[sources.common]
+ Guid.c
+ TCG2ProtocolBBTestMain.c
+ TCG2ProtocolBBTestConformance.c
+
+[Packages]
+ MdePkg/MdePkg.dec
+ SctPkg/SctPkg.dec
+ SctPkg/UEFI/UEFI.dec
+
+[LibraryClasses]
+ UefiDriverEntryPoint
+ SctLib
+ EfiTestLib
+
+[Protocols]
diff --git a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.h b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.h
new file mode 100644
index 000000000000..50b14272939f
--- /dev/null
+++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.h
@@ -0,0 +1,47 @@
+/** @file
+
+ Copyright 2006 - 2016 Unified EFI, Inc.<BR>
+ Copyright (c) 2013, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2021 - 2023, Arm Inc. All rights reserved.<BR>
+
+ This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+/*++
+
+Module Name:
+
+ guid.h
+
+Abstract:
+
+ GUIDs auto-generated for EFI test assertion.
+
+--*/
+
+
+#define EFI_TEST_TCG2CONFORMANCE_ASSERTION_001_GUID \
+{ 0xca93b02a, 0xe897, 0x4400, {0x81, 0x38, 0xc8, 0xa8, 0xcb, 0x2f, 0xc1, 0xed }}
+
+extern EFI_GUID gTcg2ConformanceTestAssertionGuid001;
+
+#define EFI_TEST_TCG2CONFORMANCE_ASSERTION_002_GUID \
+{ 0xfdee7001, 0x7e28, 0x4e35, {0x99, 0x66, 0x98, 0x0b, 0xeb, 0xba, 0xf1, 0x57 }}
+
+extern EFI_GUID gTcg2ConformanceTestAssertionGuid002;
+
+#define EFI_TEST_TCG2CONFORMANCE_ASSERTION_003_GUID \
+{ 0xda8821d9, 0x3d2c, 0x4698, {0x8c, 0xd5, 0x0f, 0x0c, 0x82, 0x94, 0x1d, 0x0c }}
+
+extern EFI_GUID gTcg2ConformanceTestAssertionGuid003;
+
+#define EFI_TEST_TCG2CONFORMANCE_ASSERTION_004_GUID \
+{ 0x8ddb031b, 0x7448, 0x40ee, {0xb1, 0xa2, 0xe6, 0xf8, 0xe8, 0xc4, 0xe5, 0x5f }}
+
+extern EFI_GUID gTcg2ConformanceTestAssertionGuid004;
diff --git a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTest.h b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTest.h
new file mode 100644
index 000000000000..a7ce2db322d9
--- /dev/null
+++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTest.h
@@ -0,0 +1,77 @@
+/** @file
+
+ Copyright 2006 - 2017 Unified EFI, Inc.<BR>
+ Copyright (c) 2013, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2021 - 2023, Arm Inc. All rights reserved.<BR>
+
+ This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+/*++
+
+Module Name:
+ TCG2ProtocolBBTest.h
+
+Abstract:
+ head file of test driver of EFI TCG2 Protocol Test
+
+--*/
+
+#include "SctLib.h"
+#include <Library/EfiTestLib.h>
+#include <UEFI/Protocol/TCG2.h>
+#include "Guid.h"
+
+#define EFI_TCG2_TEST_REVISION 0x00010000
+
+//////////////////////////////////////////////////////////////////////////////
+//
+// Entry GUIDs for Function Test
+//
+#define EFI_TCG2_PROTOCOL_TEST_ENTRY_GUID0101 \
+ {0x39ff9c71, 0x4b41, 0x4e5b, {0xae, 0xd7, 0x87, 0xc7, 0x94, 0x18, 0x7d, 0x67} }
+
+EFI_STATUS
+EFIAPI
+BBTestTCG2ProtocolUnload (
+ IN EFI_HANDLE ImageHandle
+ );
+
+EFI_STATUS
+BBTestGetCapabilityConformanceTestCheckpoint1 (
+ IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib,
+ IN EFI_TCG2_PROTOCOL *TCG2
+ );
+
+EFI_STATUS
+BBTestGetCapabilityConformanceTestCheckpoint2 (
+ IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib,
+ IN EFI_TCG2_PROTOCOL *TCG2
+ );
+
+EFI_STATUS
+BBTestGetCapabilityConformanceTestCheckpoint3 (
+ IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib,
+ IN EFI_TCG2_PROTOCOL *TCG2
+ );
+
+EFI_STATUS
+BBTestGetCapabilityConformanceTestCheckpoint4 (
+ IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib,
+ IN EFI_TCG2_PROTOCOL *TCG2
+ );
+
+EFI_STATUS
+BBTestGetCapabilityConformanceTest (
+ IN EFI_BB_TEST_PROTOCOL *This,
+ IN VOID *ClientInterface,
+ IN EFI_TEST_LEVEL TestLevel,
+ IN EFI_HANDLE SupportHandle
+ );
+
diff --git a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.c b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.c
new file mode 100644
index 000000000000..3e75ffdc0a60
--- /dev/null
+++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.c
@@ -0,0 +1,37 @@
+/** @file
+
+ Copyright 2006 - 2013 Unified EFI, Inc.<BR>
+ Copyright (c) 2013, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2021 - 2023, Arm Inc. All rights reserved.<BR>
+
+ This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+/*++
+
+Module Name:
+
+ guid.c
+
+Abstract:
+
+ GUIDs auto-generated for EFI test assertion.
+
+--*/
+
+#include "Efi.h"
+#include "Guid.h"
+
+EFI_GUID gTcg2ConformanceTestAssertionGuid001 = EFI_TEST_TCG2CONFORMANCE_ASSERTION_001_GUID;
+
+EFI_GUID gTcg2ConformanceTestAssertionGuid002 = EFI_TEST_TCG2CONFORMANCE_ASSERTION_002_GUID;
+
+EFI_GUID gTcg2ConformanceTestAssertionGuid003 = EFI_TEST_TCG2CONFORMANCE_ASSERTION_003_GUID;
+
+EFI_GUID gTcg2ConformanceTestAssertionGuid004 = EFI_TEST_TCG2CONFORMANCE_ASSERTION_004_GUID;
diff --git a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTestConformance.c b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTestConformance.c
new file mode 100644
index 000000000000..686cf4baebcd
--- /dev/null
+++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTestConformance.c
@@ -0,0 +1,361 @@
+/** @file
+
+ Copyright 2006 - 2016 Unified EFI, Inc.<BR>
+ Copyright (c) 2021 - 2023, Arm Inc. All rights reserved.<BR>
+
+ This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+/*++
+
+Module Name:
+
+ TCG2BBTestConformance.c
+
+Abstract:
+
+ for EFI Driver TCG2 Protocol's Basic Test
+
+--*/
+
+#include "TCG2ProtocolBBTest.h"
+
+#define offsetof(st, m) __builtin_offsetof(st, m)
+
+/**
+ * @brief Entrypoint for GetCapability() Function Test.
+ * 4 checkpoints will be tested.
+ * @param This a pointer of EFI_BB_TEST_PROTOCOL
+ * @param ClientInterface A pointer to the interface array under test
+ * @param TestLevel Test "thoroughness" control
+ * @param SupportHandle A handle containing protocols required
+ * @return EFI_SUCCESS
+ * @return EFI_NOT_FOUND
+ */
+
+EFI_STATUS
+BBTestGetCapabilityConformanceTest (
+ IN EFI_BB_TEST_PROTOCOL *This,
+ IN VOID *ClientInterface,
+ IN EFI_TEST_LEVEL TestLevel,
+ IN EFI_HANDLE SupportHandle
+ )
+{
+ EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib;
+ EFI_STATUS Status;
+ EFI_TCG2_PROTOCOL *TCG2;
+
+ //
+ // init
+ //
+ TCG2 = (EFI_TCG2_PROTOCOL*)ClientInterface;
+
+ // Ensure Protocol not NULL
+ if (TCG2 == NULL)
+ return EFI_UNSUPPORTED;
+
+ //
+ // Get the Standard Library Interface
+ //
+ Status = gtBS->HandleProtocol (
+ SupportHandle,
+ &gEfiStandardTestLibraryGuid,
+ (VOID **) &StandardLib
+ );
+ if (EFI_ERROR(Status)) {
+ return Status;
+ }
+
+ // Test Using NULL BootCapability Pointer
+ BBTestGetCapabilityConformanceTestCheckpoint1 (StandardLib, TCG2);
+
+ // Test for validating fields of struct returned by GetCapability()
+ BBTestGetCapabilityConformanceTestCheckpoint2 (StandardLib, TCG2);
+
+ // Test Using Capability struct with struct size less than 1.0 size
+ BBTestGetCapabilityConformanceTestCheckpoint3 (StandardLib, TCG2);
+
+ // Test Using Capability struct with struct size equal to 1.0 size
+ BBTestGetCapabilityConformanceTestCheckpoint4 (StandardLib, TCG2);
+
+ return EFI_SUCCESS;
+}
+
+
+EFI_STATUS
+BBTestGetCapabilityConformanceTestCheckpoint1 (
+ IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib,
+ IN EFI_TCG2_PROTOCOL *TCG2
+ )
+{
+ EFI_TEST_ASSERTION AssertionType;
+ EFI_STATUS Status;
+ EFI_TCG2_BOOT_SERVICE_CAPABILITY *BootServiceCapPtr = NULL;
+
+ Status = TCG2->GetCapability (
+ TCG2,
+ BootServiceCapPtr);
+
+ // Ensure GetCapability returns Invalid Parameter when passing in NULL pointer
+ if (EFI_INVALID_PARAMETER == Status) {
+ AssertionType = EFI_TEST_ASSERTION_PASSED;
+ } else {
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ }
+
+ StandardLib->RecordAssertion (
+ StandardLib,
+ AssertionType,
+ gTcg2ConformanceTestAssertionGuid001,
+ L"TCG2_PROTOCOL.GetCapability - GetCapability() returns EFI_INVALID_PARAMETER with NULL pointer Capability Struct Passed in",
+ L"%a:%d: Status - %r",
+ __FILE__,
+ (UINTN)__LINE__,
+ Status
+ );
+
+ return EFI_SUCCESS;
+}
+
+
+EFI_STATUS
+BBTestGetCapabilityConformanceTestCheckpoint2 (
+ IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib,
+ IN EFI_TCG2_PROTOCOL *TCG2
+ )
+{
+ EFI_TEST_ASSERTION AssertionType;
+ EFI_STATUS Status;
+ CHAR8 StructureVersionMajor;
+ CHAR8 StructureVersionMinor;
+ CHAR8 ProtocolVersionMajor;
+ CHAR8 ProtocolVersionMinor;
+ EFI_TCG2_BOOT_SERVICE_CAPABILITY BootServiceCap;
+
+ BootServiceCap.Size = sizeof(EFI_TCG2_BOOT_SERVICE_CAPABILITY);
+
+ Status = TCG2->GetCapability (
+ TCG2,
+ &BootServiceCap);
+
+ AssertionType = EFI_TEST_ASSERTION_PASSED;
+
+ if (Status != EFI_SUCCESS) {
+ StandardLib->RecordMessage (
+ StandardLib,
+ EFI_VERBOSE_LEVEL_DEFAULT,
+ L"\r\nTCG2 Protocol GetCapability Test: GetCapability should return EFI_SUCCESS"
+ );
+
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ }
+
+ StructureVersionMajor = BootServiceCap.StructureVersion.Major;
+ StructureVersionMinor = BootServiceCap.StructureVersion.Minor;
+
+ // TCG EFI Protocol spec 6.4.4 #4
+ if ((StructureVersionMajor != 1) | (StructureVersionMinor != 1)) {
+ StandardLib->RecordMessage (
+ StandardLib,
+ EFI_VERBOSE_LEVEL_DEFAULT,
+ L"\r\nTCG2 Protocol GetCapability Test: GetCapability should have StructureVersion 1.1, reported value = %d.%d",
+ StructureVersionMajor,
+ StructureVersionMinor
+ );
+
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ }
+
+ ProtocolVersionMajor = BootServiceCap.ProtocolVersion.Major;
+ ProtocolVersionMinor = BootServiceCap.ProtocolVersion.Minor;
+
+ // TCG EFI Protocol spec 6.4.4 #4
+ if ((ProtocolVersionMajor != 1) | (ProtocolVersionMinor != 1)) {
+ StandardLib->RecordMessage (
+ StandardLib,
+ EFI_VERBOSE_LEVEL_DEFAULT,
+ L"\r\nTCG2 Protocol GetCapability Test: GetCapability should have ProtocolVersion 1.1, reported value = %d.%d",
+ ProtocolVersionMajor,
+ ProtocolVersionMinor
+ );
+
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ }
+
+ if (!(BootServiceCap.HashAlgorithmBitmap & EFI_TCG2_BOOT_HASH_ALG_SHA256)) {
+ StandardLib->RecordMessage (
+ StandardLib,
+ EFI_VERBOSE_LEVEL_DEFAULT,
+ L"\r\nTCG2 Protocol GetCapability Test: unexpected hash algorithms reported = %x",
+ BootServiceCap.HashAlgorithmBitmap
+ );
+
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ }
+
+ if (!(BootServiceCap.SupportedEventLogs & EFI_TCG2_EVENT_LOG_FORMAT_TCG_2)) {
+ StandardLib->RecordMessage (
+ StandardLib,
+ EFI_VERBOSE_LEVEL_DEFAULT,
+ L"\r\nTCG2 Protocol GetCapability Test: GetCapability must support TCG2 event log format"
+ );
+
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ }
+
+ for (int i = 0; i < sizeof(BootServiceCap.ActivePcrBanks); i++) {
+ if (((BootServiceCap.ActivePcrBanks & (1u << i)) != 0) &&
+ ((BootServiceCap.HashAlgorithmBitmap & (1u << i)) == 0)) {
+ StandardLib->RecordMessage (
+ StandardLib,
+ EFI_VERBOSE_LEVEL_DEFAULT,
+ L"\r\nTCG2 Protocol GetCapability Test: ActivePcrBanks is not a subset of HashAlgorithmBitmap. Reported ActivePcrBanks:0x%x HashAlgorithmBitmap=0x%x",
+ BootServiceCap.ActivePcrBanks,
+ BootServiceCap.HashAlgorithmBitmap
+ );
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ }
+ }
+
+ if (BootServiceCap.NumberOfPcrBanks < 1 ) {
+ StandardLib->RecordMessage (
+ StandardLib,
+ EFI_VERBOSE_LEVEL_DEFAULT,
+ L"\r\nTCG2 Protocol GetCapability Test: expect at least 1 PCR bank"
+ );
+
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ }
+
+ // Verify that ActivePcrBanks includes SHA256, SHA384, or SHA512
+ EFI_TCG2_EVENT_ALGORITHM_BITMAP HashBitMapAlgos = EFI_TCG2_BOOT_HASH_ALG_SHA256 | EFI_TCG2_BOOT_HASH_ALG_SHA384 | EFI_TCG2_BOOT_HASH_ALG_SHA512;
+
+ if (!(BootServiceCap.ActivePcrBanks & HashBitMapAlgos)) {
+ StandardLib->RecordMessage (
+ StandardLib,
+ EFI_VERBOSE_LEVEL_DEFAULT,
+ L"\r\nTCG2 Protocol GetCapability Test: ActivePcrBanks doesn't includes SHA256, SHA384, or SHA512",
+ BootServiceCap.ActivePcrBanks
+ );
+
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ }
+
+ StandardLib->RecordAssertion (
+ StandardLib,
+ AssertionType,
+ gTcg2ConformanceTestAssertionGuid002,
+ L"TCG2_PROTOCOL.GetCapability - GetCapability() populates all elements of EFI_TCG_BOOT_SERVICE_CAPABILITY",
+ L"%a:%d: Status - %r",
+ __FILE__,
+ (UINTN)__LINE__,
+ Status
+ );
+
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+BBTestGetCapabilityConformanceTestCheckpoint3 (
+ IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib,
+ IN EFI_TCG2_PROTOCOL *TCG2
+ )
+{
+ EFI_TEST_ASSERTION AssertionType;
+ EFI_STATUS Status;
+ EFI_TCG2_BOOT_SERVICE_CAPABILITY BootServiceCap;
+
+ // set size to be value less than 1.0 or 1.1 struct
+ BootServiceCap.Size = 4;
+
+ Status = TCG2->GetCapability (
+ TCG2,
+ &BootServiceCap);
+
+ AssertionType = EFI_TEST_ASSERTION_PASSED;
+
+ if (Status != EFI_BUFFER_TOO_SMALL && BootServiceCap.Size != sizeof(EFI_TCG2_BOOT_SERVICE_CAPABILITY)) {
+ StandardLib->RecordMessage (
+ StandardLib,
+ EFI_VERBOSE_LEVEL_DEFAULT,
+ L"\r\nTCG2 Protocol GetCapability Test: Did not return Status == EFI_BUFFER_TOO_SMALL and Size == sizeof(EFI_TCG2_BOOT_SERVICE_CAPABILITY)"
+ );
+
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ }
+
+ StandardLib->RecordAssertion (
+ StandardLib,
+ AssertionType,
+ gTcg2ConformanceTestAssertionGuid003,
+ L"TCG2_PROTOCOL.GetCapability() - GetCapability() handling of input struct size less than the size of EFI_TCG2_BOOT_SERVICE_CAPABILITY up to and including the ManufacturerID field",
+ L"%a:%d: Status - %r",
+ __FILE__,
+ (UINTN)__LINE__,
+ Status
+ );
+
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+BBTestGetCapabilityConformanceTestCheckpoint4 (
+ IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib,
+ IN EFI_TCG2_PROTOCOL *TCG2
+ )
+{
+ EFI_TEST_ASSERTION AssertionType;
+ EFI_STATUS Status;
+ EFI_TCG2_BOOT_SERVICE_CAPABILITY BootServiceCap;
+
+ // set size of struct to be up to and including the ManufacturerID
+ // (this acts like a client with a 1.0 version of the struct)
+ BootServiceCap.Size = offsetof(EFI_TCG2_BOOT_SERVICE_CAPABILITY, NumberOfPcrBanks);
+
+ Status = TCG2->GetCapability (
+ TCG2,
+ &BootServiceCap);
+
+ AssertionType = EFI_TEST_ASSERTION_PASSED;
+
+ if (Status != EFI_SUCCESS) {
+ StandardLib->RecordMessage (
+ StandardLib,
+ EFI_VERBOSE_LEVEL_DEFAULT,
+ L"\r\nTCG2 Protocol GetCapability Test: 1.0 Compatibility. GetCapability should return EFI_SUCCESS"
+ );
+
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ }
+
+ // Verify returned Size equals the size of EFI_TCG2_BOOT_SERVICE_CAPABILITY up to and including the ManufacturerID field.
+ if (BootServiceCap.Size != offsetof(EFI_TCG2_BOOT_SERVICE_CAPABILITY, NumberOfPcrBanks)) {
+ StandardLib->RecordMessage (
+ StandardLib,
+ EFI_VERBOSE_LEVEL_DEFAULT,
+ L"\r\nTCG2 Protocol GetCapability Test: Did not return Size == EFI_TCG2_BOOT_SERVICE_CAPABILITY up to and including the ManufacturerID field"
+ );
+
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ }
+
+ StandardLib->RecordAssertion (
+ StandardLib,
+ AssertionType,
+ gTcg2ConformanceTestAssertionGuid004,
+ L"TCG2_PROTOCOL.GetCapability - GetCapability() backwards compatibility check for 1.0 version of EFI_TCG_BOOT_SERVICE_CAPABILITY",
+ L"%a:%d: Status - %r",
+ __FILE__,
+ (UINTN)__LINE__,
+ Status
+ );
+
+ return EFI_SUCCESS;
+}
+
diff --git a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTestMain.c b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTestMain.c
new file mode 100644
index 000000000000..1de87e9d4c66
--- /dev/null
+++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTestMain.c
@@ -0,0 +1,102 @@
+/** @file
+
+ Copyright 2006 - 2017 Unified EFI, Inc.<BR>
+ Copyright (c) 2013, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2021 - 2023, Arm Inc. All rights reserved.<BR>
+
+ This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+/*++
+
+Module Name:
+ TCG2ProtocolBBTestMain.c
+
+Abstract:
+ for EFI TCG2 Protocol Test
+
+--*/
+
+#include "TCG2ProtocolBBTest.h"
+
+EFI_BB_TEST_PROTOCOL_FIELD gBBTestProtocolField = {
+ EFI_TCG2_TEST_REVISION,
+ EFI_TCG2_PROTOCOL_GUID,
+ L"Testing For EFI TCG2 Protocol",
+ L"Total # test cases for the EFI TCG2 Protocol"
+};
+
+EFI_GUID gSupportProtocolGuid1[2] = {
+ EFI_STANDARD_TEST_LIBRARY_GUID,
+ EFI_NULL_GUID
+};
+
+EFI_BB_TEST_ENTRY_FIELD gBBTestEntryField[] = {
+ {
+ EFI_TCG2_PROTOCOL_TEST_ENTRY_GUID0101,
+ L"GetCapability_Conf",
+ L"Test the GetCapablity API",
+ EFI_TEST_LEVEL_DEFAULT,
+ gSupportProtocolGuid1,
+ EFI_TEST_CASE_AUTO,
+ BBTestGetCapabilityConformanceTest
+ },
+ 0
+};
+
+EFI_BB_TEST_PROTOCOL *gBBTestProtocolInterface;
+
+/**
+ * Creates/installs the BlackBox Interface and eminating Entry Point
+ * node list.
+ * @param ImageHandle The test driver image handle
+ * @param SystemTable Pointer to System Table
+ * @return EFI_SUCCESS Indicates the interface was installed
+ * @return EFI_OUT_OF_RESOURCES Indicates space for the new handle could not be allocated
+ * @return EFI_INVALID_PARAMETER: One of the parameters has an invalid value.
+ */
+EFI_STATUS
+EFIAPI
+InitializeBBTestTCG2Protocol (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ )
+{
+ EfiInitializeTestLib (ImageHandle, SystemTable);
+
+ //
+ // initialize test utility lib
+ //
+ SctInitializeLib (ImageHandle, SystemTable);
+
+ return EfiInitAndInstallBBTestInterface (
+ &ImageHandle,
+ &gBBTestProtocolField,
+ gBBTestEntryField,
+ BBTestTCG2ProtocolUnload,
+ &gBBTestProtocolInterface
+ );
+}
+
+/**
+ * The driver's Unload function
+ * @param ImageHandle The test driver image handle
+ * @return EFI_SUCCESS Indicates the interface was Uninstalled
+*/
+EFI_STATUS
+EFIAPI
+BBTestTCG2ProtocolUnload (
+ IN EFI_HANDLE ImageHandle
+ )
+{
+ return EfiUninstallAndFreeBBTestInterface (
+ ImageHandle,
+ gBBTestProtocolInterface
+ );
+}
diff --git a/uefi-sct/SctPkg/CommonGenFramework.sh b/uefi-sct/SctPkg/CommonGenFramework.sh
index fb9043b56bca..9c8662d841ae 100755
--- a/uefi-sct/SctPkg/CommonGenFramework.sh
+++ b/uefi-sct/SctPkg/CommonGenFramework.sh
@@ -210,6 +210,7 @@ then
cp $ProcessorType/DiskIo2BBTest.efi $Framework/Test/ > NUL
cp $ProcessorType/TimeStampBBTest.efi $Framework/Test/ > NUL
cp $ProcessorType/RandomNumberBBTest.efi $Framework/Test/ > NUL
+ cp $ProcessorType/TCG2ProtocolBBTest.efi $Framework/Test/ > NUL
cp $ProcessorType/Hash2BBTest.efi $Framework/Test/ > NUL
cp $ProcessorType/Pkcs7BBTest.efi $Framework/Test/ > NUL
cp $ProcessorType/ConfigKeywordHandlerBBTest.efi $Framework/Test/ > NUL
diff --git a/uefi-sct/SctPkg/Config/Data/Category.ini b/uefi-sct/SctPkg/Config/Data/Category.ini
index b34d35db9ac8..4a53115b4d7d 100644
--- a/uefi-sct/SctPkg/Config/Data/Category.ini
+++ b/uefi-sct/SctPkg/Config/Data/Category.ini
@@ -1032,3 +1032,10 @@ CategoryGuid = CCD15FEC-6F73-4EEC-8395-3E69E4B940BF
InterfaceGuid = CCD15FEC-6F73-4EEC-8395-3E69E4B940BF
Name = RiscvBootProtocolTest
Description = RISC-V Boot Protocol Test
+
+[Category Data]
+Revision = 0x00010000
+CategoryGuid = 607f766c-7455-42be-930b-e4d76db2720f
+InterfaceGuid = 607f766c-7455-42be-930b-e4d76db2720f
+Name = TCG2ProtocolTest
+Description = TCG2 Protocol Test
--
2.34.1
-=-=-=-=-=-=
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#113489): https://edk2.groups.io/g/devel/message/113489
Mute This Topic: https://groups.io/mt/103625304/5985097
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [Sunny.Wang@arm.com]
-=-=-=-=-=-=
IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#116846): https://edk2.groups.io/g/devel/message/116846
Mute This Topic: https://groups.io/mt/103625304/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-
^ permalink raw reply related [flat|nested] 26+ messages in thread
* Re: [edk2-devel] [PATCH v2 2/6] uefi-sct/SctPkg: TCG2 Protocol: add test infrastructure and GetCapability Test
2024-01-09 18:20 ` [edk2-devel] [PATCH v2 2/6] uefi-sct/SctPkg: TCG2 Protocol: add test infrastructure and GetCapability Test Stuart Yoder
2024-03-05 15:47 ` G Edhaya Chandran
2024-03-18 20:43 ` Sunny Wang
@ 2024-03-19 9:15 ` G Edhaya Chandran
2 siblings, 0 replies; 26+ messages in thread
From: G Edhaya Chandran @ 2024-03-19 9:15 UTC (permalink / raw)
To: Stuart Yoder, devel
[-- Attachment #1: Type: text/plain, Size: 496 bytes --]
The patch is upstreamed by the commit:
https://github.com/tianocore/edk2-test/commit/ff8a146ace642cadc83b58cd4382181ec2dac633
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#116887): https://edk2.groups.io/g/devel/message/116887
Mute This Topic: https://groups.io/mt/103625304/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-
[-- Attachment #2: Type: text/html, Size: 920 bytes --]
^ permalink raw reply [flat|nested] 26+ messages in thread
* [edk2-devel] [PATCH v2 3/6] uefi-sct/SctPkg: TCG2 Protocol: add GetActivePcrBanks test
2024-01-09 18:20 [edk2-devel] [PATCH v2 0/6] Tests for TCG2 Protocol Stuart Yoder
2024-01-09 18:20 ` [edk2-devel] [PATCH v2 1/6] uefi-sct/SctPkg: TCG2 Protocol: add header with TCG2 protocol definitions Stuart Yoder
2024-01-09 18:20 ` [edk2-devel] [PATCH v2 2/6] uefi-sct/SctPkg: TCG2 Protocol: add test infrastructure and GetCapability Test Stuart Yoder
@ 2024-01-09 18:20 ` Stuart Yoder
2024-03-05 15:48 ` G Edhaya Chandran
` (2 more replies)
2024-01-09 18:20 ` [edk2-devel] [PATCH v2 4/6] uefi-sct/SctPkg: TCG2 Protocol: add HashLogExtendEvent test Stuart Yoder
` (3 subsequent siblings)
6 siblings, 3 replies; 26+ messages in thread
From: Stuart Yoder @ 2024-01-09 18:20 UTC (permalink / raw)
To: devel, Edhaya.Chandran, gaojie
Cc: ilias.apalodimas, heinrich.schuchardt, Samer.El-Haj-Mahmoud,
Jiewen.Yao
From: Joseph Hemann <joseph.hemann@arm.com>
-add test for GetActivePcrBanks()
-checkpoint for NULL pointer passed for buffer
-checkpoint for test of function with proper input
Signed-off-by: Joseph Hemann <Joseph.hemann@arm.com>
Signed-off-by: Stuart Yoder <stuart.yoder@arm.com>
---
uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.h | 11 ++
uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTest.h | 23 +++
uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.c | 4 +
uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTestConformance.c | 159 ++++++++++++++++++++
uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTestMain.c | 9 ++
5 files changed, 206 insertions(+)
diff --git a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.h b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.h
index 50b14272939f..d6797f5287f4 100644
--- a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.h
+++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.h
@@ -45,3 +45,14 @@ extern EFI_GUID gTcg2ConformanceTestAssertionGuid003;
{ 0x8ddb031b, 0x7448, 0x40ee, {0xb1, 0xa2, 0xe6, 0xf8, 0xe8, 0xc4, 0xe5, 0x5f }}
extern EFI_GUID gTcg2ConformanceTestAssertionGuid004;
+
+#define EFI_TEST_TCG2CONFORMANCE_ASSERTION_005_GUID \
+{ 0x7a1e79a3, 0x4064, 0x4372, {0xbb, 0x64, 0x55, 0xb8, 0xf2, 0xa5, 0xa3, 0x26 }}
+
+extern EFI_GUID gTcg2ConformanceTestAssertionGuid005;
+
+#define EFI_TEST_TCG2CONFORMANCE_ASSERTION_006_GUID \
+{ 0xb0e717c4, 0xb1e2, 0x49f7, {0xb2, 0xd7, 0x60, 0x58, 0x97, 0x7d, 0x09, 0x2c }}
+
+extern EFI_GUID gTcg2ConformanceTestAssertionGuid006;
+
diff --git a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTest.h b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTest.h
index a7ce2db322d9..80c02d9ed2d2 100644
--- a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTest.h
+++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTest.h
@@ -37,6 +37,9 @@ Abstract:
#define EFI_TCG2_PROTOCOL_TEST_ENTRY_GUID0101 \
{0x39ff9c71, 0x4b41, 0x4e5b, {0xae, 0xd7, 0x87, 0xc7, 0x94, 0x18, 0x7d, 0x67} }
+#define EFI_TCG2_PROTOCOL_TEST_ENTRY_GUID0102 \
+ {0x847f1ae0, 0xb429, 0x49f1, {0x9e, 0x0c, 0x8f, 0x43, 0xfb, 0x55, 0x34, 0x54} }
+
EFI_STATUS
EFIAPI
BBTestTCG2ProtocolUnload (
@@ -67,6 +70,18 @@ BBTestGetCapabilityConformanceTestCheckpoint4 (
IN EFI_TCG2_PROTOCOL *TCG2
);
+EFI_STATUS
+BBTestGetActivePcrBanksConformanceTestCheckpoint1 (
+ IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib,
+ IN EFI_TCG2_PROTOCOL *TCG2
+ );
+
+EFI_STATUS
+BBTestGetActivePcrBanksConformanceTestCheckpoint2 (
+ IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib,
+ IN EFI_TCG2_PROTOCOL *TCG2
+ );
+
EFI_STATUS
BBTestGetCapabilityConformanceTest (
IN EFI_BB_TEST_PROTOCOL *This,
@@ -75,3 +90,11 @@ BBTestGetCapabilityConformanceTest (
IN EFI_HANDLE SupportHandle
);
+EFI_STATUS
+BBTestGetActivePcrBanksConformanceTest (
+ IN EFI_BB_TEST_PROTOCOL *This,
+ IN VOID *ClientInterface,
+ IN EFI_TEST_LEVEL TestLevel,
+ IN EFI_HANDLE SupportHandle
+ );
+
diff --git a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.c b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.c
index 3e75ffdc0a60..0dc2cfddfcbf 100644
--- a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.c
+++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.c
@@ -35,3 +35,7 @@ EFI_GUID gTcg2ConformanceTestAssertionGuid002 = EFI_TEST_TCG2CONFORMANCE_ASSERTI
EFI_GUID gTcg2ConformanceTestAssertionGuid003 = EFI_TEST_TCG2CONFORMANCE_ASSERTION_003_GUID;
EFI_GUID gTcg2ConformanceTestAssertionGuid004 = EFI_TEST_TCG2CONFORMANCE_ASSERTION_004_GUID;
+
+EFI_GUID gTcg2ConformanceTestAssertionGuid005 = EFI_TEST_TCG2CONFORMANCE_ASSERTION_005_GUID;
+
+EFI_GUID gTcg2ConformanceTestAssertionGuid006 = EFI_TEST_TCG2CONFORMANCE_ASSERTION_006_GUID;
diff --git a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTestConformance.c b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTestConformance.c
index 686cf4baebcd..681f57ac224a 100644
--- a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTestConformance.c
+++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTestConformance.c
@@ -87,6 +87,58 @@ BBTestGetCapabilityConformanceTest (
return EFI_SUCCESS;
}
+/**
+ * @brief Entrypoint for GetActivePcrBanks() Function Test.
+ * 2 checkpoints will be tested.
+ * @param This a pointer of EFI_BB_TEST_PROTOCOL
+ * @param ClientInterface A pointer to the interface array under test
+ * @param TestLevel Test "thoroughness" control
+ * @param SupportHandle A handle containing protocols required
+ * @return EFI_SUCCESS
+ * @return EFI_NOT_FOUND
+ */
+
+EFI_STATUS
+BBTestGetActivePcrBanksConformanceTest (
+ IN EFI_BB_TEST_PROTOCOL *This,
+ IN VOID *ClientInterface,
+ IN EFI_TEST_LEVEL TestLevel,
+ IN EFI_HANDLE SupportHandle
+ )
+{
+ EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib;
+ EFI_STATUS Status;
+ EFI_TCG2_PROTOCOL *TCG2;
+
+ //
+ // init
+ //
+ TCG2 = (EFI_TCG2_PROTOCOL*)ClientInterface;
+
+ // Ensure Protocol not NULL
+ if (TCG2 == NULL)
+ return EFI_UNSUPPORTED;
+
+ //
+ // Get the Standard Library Interface
+ //
+ Status = gtBS->HandleProtocol (
+ SupportHandle,
+ &gEfiStandardTestLibraryGuid,
+ (VOID **) &StandardLib
+ );
+ if (EFI_ERROR(Status)) {
+ return Status;
+ }
+
+ // Test with invalid (NULL) bitmap
+ BBTestGetActivePcrBanksConformanceTestCheckpoint1 (StandardLib, TCG2);
+
+ // Test with valid bitmap
+ BBTestGetActivePcrBanksConformanceTestCheckpoint2 (StandardLib, TCG2);
+
+ return EFI_SUCCESS;
+}
EFI_STATUS
BBTestGetCapabilityConformanceTestCheckpoint1 (
@@ -359,3 +411,110 @@ BBTestGetCapabilityConformanceTestCheckpoint4 (
return EFI_SUCCESS;
}
+EFI_STATUS
+BBTestGetActivePcrBanksConformanceTestCheckpoint1 (
+ IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib,
+ IN EFI_TCG2_PROTOCOL *TCG2
+ )
+{
+ EFI_TEST_ASSERTION AssertionType;
+ EFI_STATUS Status;
+
+ EFI_TCG2_EVENT_ALGORITHM_BITMAP *ActivePcrBanks = NULL;
+ Status = TCG2->GetActivePcrBanks (
+ TCG2,
+ ActivePcrBanks);
+
+ // Ensure GetActivePcrBanks returns Invalid Parameter when passing in NULL pointer
+ if (EFI_INVALID_PARAMETER == Status) {
+ AssertionType = EFI_TEST_ASSERTION_PASSED;
+ } else {
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ }
+
+ StandardLib->RecordAssertion (
+ StandardLib,
+ AssertionType,
+ gTcg2ConformanceTestAssertionGuid005,
+ L"TCG2_PROTOCOL.GetActivePcrBanks - GetActivePcrBanks() returns EFI_INVALID_PARAMETER with NULL pointer Passed in",
+ L"%a:%d: Status - %r",
+ __FILE__,
+ (UINTN)__LINE__,
+ Status
+ );
+
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+BBTestGetActivePcrBanksConformanceTestCheckpoint2 (
+ IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib,
+ IN EFI_TCG2_PROTOCOL *TCG2
+ )
+{
+ EFI_TEST_ASSERTION AssertionType;
+ EFI_STATUS Status;
+ EFI_TCG2_EVENT_ALGORITHM_BITMAP ActivePcrBanks;
+ EFI_TCG2_BOOT_SERVICE_CAPABILITY BootServiceCap;
+
+ Status = TCG2->GetActivePcrBanks (
+ TCG2,
+ &ActivePcrBanks);
+
+ // Ensure GetActivePcrBanks returns EFI_SUCCESS
+ if (Status == EFI_SUCCESS) {
+ AssertionType = EFI_TEST_ASSERTION_PASSED;
+ } else {
+ StandardLib->RecordMessage (
+ StandardLib,
+ EFI_VERBOSE_LEVEL_DEFAULT,
+ L"\r\nTCG2 Protocol GetActivePcrBanks Test: GetActivePcrBanks should return EFI_SUCCESS"
+ );
+
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ }
+
+ EFI_TCG2_EVENT_ALGORITHM_BITMAP BitMapAlgos = EFI_TCG2_BOOT_HASH_ALG_SHA256 | EFI_TCG2_BOOT_HASH_ALG_SHA384 | EFI_TCG2_BOOT_HASH_ALG_SHA512;
+
+ // Ensure ActivePcrBanks has SHA256/384/512 in its Bitmap
+ if (!(ActivePcrBanks & BitMapAlgos)) {
+ StandardLib->RecordMessage (
+ StandardLib,
+ EFI_VERBOSE_LEVEL_DEFAULT,
+ L"\r\nTCG2 Protocol GetActivePcrBanks Test: GetActivePcrBanks should have SHA256/384/512 Algorithm in its Bitmap. ActivePcrBanks = %x",
+ ActivePcrBanks
+ );
+
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ }
+
+ BootServiceCap.Size = sizeof(EFI_TCG2_BOOT_SERVICE_CAPABILITY);
+
+ Status = TCG2->GetCapability (
+ TCG2,
+ &BootServiceCap);
+
+ // Ensure ActivePcrBanks is the same returned as GetCapability()
+ if (ActivePcrBanks != BootServiceCap.ActivePcrBanks) {
+ StandardLib->RecordMessage (
+ StandardLib,
+ EFI_VERBOSE_LEVEL_DEFAULT,
+ L"\r\nTCG2 Protocol GetActivePcrBanks Test:Returned ActivePcrBanks should match the one returned by GetCapability()"
+ );
+
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ }
+
+ StandardLib->RecordAssertion (
+ StandardLib,
+ AssertionType,
+ gTcg2ConformanceTestAssertionGuid006,
+ L"TCG2_PROTOCOL.GetActivePcrBanks - GetActivePcrBanks should return with EFI_SUCCESS and have SHA256/384/512 Algoritms in its Bitmap",
+ L"%a:%d: Status - %r",
+ __FILE__,
+ (UINTN)__LINE__,
+ Status
+ );
+
+ return EFI_SUCCESS;
+}
diff --git a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTestMain.c b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTestMain.c
index 1de87e9d4c66..7fc202246cd8 100644
--- a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTestMain.c
+++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTestMain.c
@@ -47,6 +47,15 @@ EFI_BB_TEST_ENTRY_FIELD gBBTestEntryField[] = {
EFI_TEST_CASE_AUTO,
BBTestGetCapabilityConformanceTest
},
+ {
+ EFI_TCG2_PROTOCOL_TEST_ENTRY_GUID0102,
+ L"GetActivePcrBanks_Conf",
+ L"Test the GetActivePcrBanks API",
+ EFI_TEST_LEVEL_DEFAULT,
+ gSupportProtocolGuid1,
+ EFI_TEST_CASE_AUTO,
+ BBTestGetActivePcrBanksConformanceTest
+ },
0
};
--
2.34.1
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#113486): https://edk2.groups.io/g/devel/message/113486
Mute This Topic: https://groups.io/mt/103625301/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-
^ permalink raw reply related [flat|nested] 26+ messages in thread
* Re: [edk2-devel] [PATCH v2 3/6] uefi-sct/SctPkg: TCG2 Protocol: add GetActivePcrBanks test
2024-01-09 18:20 ` [edk2-devel] [PATCH v2 3/6] uefi-sct/SctPkg: TCG2 Protocol: add GetActivePcrBanks test Stuart Yoder
@ 2024-03-05 15:48 ` G Edhaya Chandran
2024-03-18 20:43 ` Sunny Wang
2024-03-19 9:13 ` G Edhaya Chandran
2 siblings, 0 replies; 26+ messages in thread
From: G Edhaya Chandran @ 2024-03-05 15:48 UTC (permalink / raw)
To: Stuart Yoder, devel
[-- Attachment #1: Type: text/plain, Size: 424 bytes --]
Reviewed-by: G Edhaya Chandran <edhaya.chandran@arm.com>
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#116400): https://edk2.groups.io/g/devel/message/116400
Mute This Topic: https://groups.io/mt/103625301/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-
[-- Attachment #2: Type: text/html, Size: 842 bytes --]
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [edk2-devel] [PATCH v2 3/6] uefi-sct/SctPkg: TCG2 Protocol: add GetActivePcrBanks test
2024-01-09 18:20 ` [edk2-devel] [PATCH v2 3/6] uefi-sct/SctPkg: TCG2 Protocol: add GetActivePcrBanks test Stuart Yoder
2024-03-05 15:48 ` G Edhaya Chandran
@ 2024-03-18 20:43 ` Sunny Wang
2024-03-19 9:13 ` G Edhaya Chandran
2 siblings, 0 replies; 26+ messages in thread
From: Sunny Wang @ 2024-03-18 20:43 UTC (permalink / raw)
To: devel@edk2.groups.io, Stuart Yoder, G Edhaya Chandran,
gaojie@byosoft.com.cn
Cc: ilias.apalodimas@linaro.org, heinrich.schuchardt@canonical.com,
Samer El-Haj-Mahmoud, Jiewen.Yao@intel.com
Looks good to me.
For others' reference, the change has been already verified by running SystemReady SIE (Security Interface extension) tests on multiple SystemReady certified Arm systems.
Reviewed-by: Sunny Wang <sunny.wang@arm.com>
-----Original Message-----
From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Stuart Yoder via groups.io
Sent: Tuesday, January 9, 2024 12:21 PM
To: devel@edk2.groups.io; G Edhaya Chandran <Edhaya.Chandran@arm.com>; gaojie@byosoft.com.cn
Cc: ilias.apalodimas@linaro.org; heinrich.schuchardt@canonical.com; Samer El-Haj-Mahmoud <Samer.El-Haj-Mahmoud@arm.com>; Jiewen.Yao@intel.com
Subject: [edk2-devel] [PATCH v2 3/6] uefi-sct/SctPkg: TCG2 Protocol: add GetActivePcrBanks test
From: Joseph Hemann <joseph.hemann@arm.com>
-add test for GetActivePcrBanks()
-checkpoint for NULL pointer passed for buffer
-checkpoint for test of function with proper input
Signed-off-by: Joseph Hemann <Joseph.hemann@arm.com>
Signed-off-by: Stuart Yoder <stuart.yoder@arm.com>
---
uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.h | 11 ++
uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTest.h | 23 +++
uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.c | 4 +
uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTestConformance.c | 159 ++++++++++++++++++++
uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTestMain.c | 9 ++
5 files changed, 206 insertions(+)
diff --git a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.h b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.h
index 50b14272939f..d6797f5287f4 100644
--- a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.h
+++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.h
@@ -45,3 +45,14 @@ extern EFI_GUID gTcg2ConformanceTestAssertionGuid003;
{ 0x8ddb031b, 0x7448, 0x40ee, {0xb1, 0xa2, 0xe6, 0xf8, 0xe8, 0xc4, 0xe5, 0x5f }}
extern EFI_GUID gTcg2ConformanceTestAssertionGuid004;
+
+#define EFI_TEST_TCG2CONFORMANCE_ASSERTION_005_GUID \
+{ 0x7a1e79a3, 0x4064, 0x4372, {0xbb, 0x64, 0x55, 0xb8, 0xf2, 0xa5, 0xa3, 0x26 }}
+
+extern EFI_GUID gTcg2ConformanceTestAssertionGuid005;
+
+#define EFI_TEST_TCG2CONFORMANCE_ASSERTION_006_GUID \
+{ 0xb0e717c4, 0xb1e2, 0x49f7, {0xb2, 0xd7, 0x60, 0x58, 0x97, 0x7d, 0x09, 0x2c }}
+
+extern EFI_GUID gTcg2ConformanceTestAssertionGuid006;
+
diff --git a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTest.h b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTest.h
index a7ce2db322d9..80c02d9ed2d2 100644
--- a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTest.h
+++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTest.h
@@ -37,6 +37,9 @@ Abstract:
#define EFI_TCG2_PROTOCOL_TEST_ENTRY_GUID0101 \
{0x39ff9c71, 0x4b41, 0x4e5b, {0xae, 0xd7, 0x87, 0xc7, 0x94, 0x18, 0x7d, 0x67} }
+#define EFI_TCG2_PROTOCOL_TEST_ENTRY_GUID0102 \
+ {0x847f1ae0, 0xb429, 0x49f1, {0x9e, 0x0c, 0x8f, 0x43, 0xfb, 0x55, 0x34, 0x54} }
+
EFI_STATUS
EFIAPI
BBTestTCG2ProtocolUnload (
@@ -67,6 +70,18 @@ BBTestGetCapabilityConformanceTestCheckpoint4 (
IN EFI_TCG2_PROTOCOL *TCG2
);
+EFI_STATUS
+BBTestGetActivePcrBanksConformanceTestCheckpoint1 (
+ IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib,
+ IN EFI_TCG2_PROTOCOL *TCG2
+ );
+
+EFI_STATUS
+BBTestGetActivePcrBanksConformanceTestCheckpoint2 (
+ IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib,
+ IN EFI_TCG2_PROTOCOL *TCG2
+ );
+
EFI_STATUS
BBTestGetCapabilityConformanceTest (
IN EFI_BB_TEST_PROTOCOL *This,
@@ -75,3 +90,11 @@ BBTestGetCapabilityConformanceTest (
IN EFI_HANDLE SupportHandle
);
+EFI_STATUS
+BBTestGetActivePcrBanksConformanceTest (
+ IN EFI_BB_TEST_PROTOCOL *This,
+ IN VOID *ClientInterface,
+ IN EFI_TEST_LEVEL TestLevel,
+ IN EFI_HANDLE SupportHandle
+ );
+
diff --git a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.c b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.c
index 3e75ffdc0a60..0dc2cfddfcbf 100644
--- a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.c
+++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.c
@@ -35,3 +35,7 @@ EFI_GUID gTcg2ConformanceTestAssertionGuid002 = EFI_TEST_TCG2CONFORMANCE_ASSERTI
EFI_GUID gTcg2ConformanceTestAssertionGuid003 = EFI_TEST_TCG2CONFORMANCE_ASSERTION_003_GUID;
EFI_GUID gTcg2ConformanceTestAssertionGuid004 = EFI_TEST_TCG2CONFORMANCE_ASSERTION_004_GUID;
+
+EFI_GUID gTcg2ConformanceTestAssertionGuid005 = EFI_TEST_TCG2CONFORMANCE_ASSERTION_005_GUID;
+
+EFI_GUID gTcg2ConformanceTestAssertionGuid006 = EFI_TEST_TCG2CONFORMANCE_ASSERTION_006_GUID;
diff --git a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTestConformance.c b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTestConformance.c
index 686cf4baebcd..681f57ac224a 100644
--- a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTestConformance.c
+++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTestConformance.c
@@ -87,6 +87,58 @@ BBTestGetCapabilityConformanceTest (
return EFI_SUCCESS;
}
+/**
+ * @brief Entrypoint for GetActivePcrBanks() Function Test.
+ * 2 checkpoints will be tested.
+ * @param This a pointer of EFI_BB_TEST_PROTOCOL
+ * @param ClientInterface A pointer to the interface array under test
+ * @param TestLevel Test "thoroughness" control
+ * @param SupportHandle A handle containing protocols required
+ * @return EFI_SUCCESS
+ * @return EFI_NOT_FOUND
+ */
+
+EFI_STATUS
+BBTestGetActivePcrBanksConformanceTest (
+ IN EFI_BB_TEST_PROTOCOL *This,
+ IN VOID *ClientInterface,
+ IN EFI_TEST_LEVEL TestLevel,
+ IN EFI_HANDLE SupportHandle
+ )
+{
+ EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib;
+ EFI_STATUS Status;
+ EFI_TCG2_PROTOCOL *TCG2;
+
+ //
+ // init
+ //
+ TCG2 = (EFI_TCG2_PROTOCOL*)ClientInterface;
+
+ // Ensure Protocol not NULL
+ if (TCG2 == NULL)
+ return EFI_UNSUPPORTED;
+
+ //
+ // Get the Standard Library Interface
+ //
+ Status = gtBS->HandleProtocol (
+ SupportHandle,
+ &gEfiStandardTestLibraryGuid,
+ (VOID **) &StandardLib
+ );
+ if (EFI_ERROR(Status)) {
+ return Status;
+ }
+
+ // Test with invalid (NULL) bitmap
+ BBTestGetActivePcrBanksConformanceTestCheckpoint1 (StandardLib, TCG2);
+
+ // Test with valid bitmap
+ BBTestGetActivePcrBanksConformanceTestCheckpoint2 (StandardLib, TCG2);
+
+ return EFI_SUCCESS;
+}
EFI_STATUS
BBTestGetCapabilityConformanceTestCheckpoint1 (
@@ -359,3 +411,110 @@ BBTestGetCapabilityConformanceTestCheckpoint4 (
return EFI_SUCCESS;
}
+EFI_STATUS
+BBTestGetActivePcrBanksConformanceTestCheckpoint1 (
+ IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib,
+ IN EFI_TCG2_PROTOCOL *TCG2
+ )
+{
+ EFI_TEST_ASSERTION AssertionType;
+ EFI_STATUS Status;
+
+ EFI_TCG2_EVENT_ALGORITHM_BITMAP *ActivePcrBanks = NULL;
+ Status = TCG2->GetActivePcrBanks (
+ TCG2,
+ ActivePcrBanks);
+
+ // Ensure GetActivePcrBanks returns Invalid Parameter when passing in NULL pointer
+ if (EFI_INVALID_PARAMETER == Status) {
+ AssertionType = EFI_TEST_ASSERTION_PASSED;
+ } else {
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ }
+
+ StandardLib->RecordAssertion (
+ StandardLib,
+ AssertionType,
+ gTcg2ConformanceTestAssertionGuid005,
+ L"TCG2_PROTOCOL.GetActivePcrBanks - GetActivePcrBanks() returns EFI_INVALID_PARAMETER with NULL pointer Passed in",
+ L"%a:%d: Status - %r",
+ __FILE__,
+ (UINTN)__LINE__,
+ Status
+ );
+
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+BBTestGetActivePcrBanksConformanceTestCheckpoint2 (
+ IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib,
+ IN EFI_TCG2_PROTOCOL *TCG2
+ )
+{
+ EFI_TEST_ASSERTION AssertionType;
+ EFI_STATUS Status;
+ EFI_TCG2_EVENT_ALGORITHM_BITMAP ActivePcrBanks;
+ EFI_TCG2_BOOT_SERVICE_CAPABILITY BootServiceCap;
+
+ Status = TCG2->GetActivePcrBanks (
+ TCG2,
+ &ActivePcrBanks);
+
+ // Ensure GetActivePcrBanks returns EFI_SUCCESS
+ if (Status == EFI_SUCCESS) {
+ AssertionType = EFI_TEST_ASSERTION_PASSED;
+ } else {
+ StandardLib->RecordMessage (
+ StandardLib,
+ EFI_VERBOSE_LEVEL_DEFAULT,
+ L"\r\nTCG2 Protocol GetActivePcrBanks Test: GetActivePcrBanks should return EFI_SUCCESS"
+ );
+
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ }
+
+ EFI_TCG2_EVENT_ALGORITHM_BITMAP BitMapAlgos = EFI_TCG2_BOOT_HASH_ALG_SHA256 | EFI_TCG2_BOOT_HASH_ALG_SHA384 | EFI_TCG2_BOOT_HASH_ALG_SHA512;
+
+ // Ensure ActivePcrBanks has SHA256/384/512 in its Bitmap
+ if (!(ActivePcrBanks & BitMapAlgos)) {
+ StandardLib->RecordMessage (
+ StandardLib,
+ EFI_VERBOSE_LEVEL_DEFAULT,
+ L"\r\nTCG2 Protocol GetActivePcrBanks Test: GetActivePcrBanks should have SHA256/384/512 Algorithm in its Bitmap. ActivePcrBanks = %x",
+ ActivePcrBanks
+ );
+
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ }
+
+ BootServiceCap.Size = sizeof(EFI_TCG2_BOOT_SERVICE_CAPABILITY);
+
+ Status = TCG2->GetCapability (
+ TCG2,
+ &BootServiceCap);
+
+ // Ensure ActivePcrBanks is the same returned as GetCapability()
+ if (ActivePcrBanks != BootServiceCap.ActivePcrBanks) {
+ StandardLib->RecordMessage (
+ StandardLib,
+ EFI_VERBOSE_LEVEL_DEFAULT,
+ L"\r\nTCG2 Protocol GetActivePcrBanks Test:Returned ActivePcrBanks should match the one returned by GetCapability()"
+ );
+
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ }
+
+ StandardLib->RecordAssertion (
+ StandardLib,
+ AssertionType,
+ gTcg2ConformanceTestAssertionGuid006,
+ L"TCG2_PROTOCOL.GetActivePcrBanks - GetActivePcrBanks should return with EFI_SUCCESS and have SHA256/384/512 Algoritms in its Bitmap",
+ L"%a:%d: Status - %r",
+ __FILE__,
+ (UINTN)__LINE__,
+ Status
+ );
+
+ return EFI_SUCCESS;
+}
diff --git a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTestMain.c b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTestMain.c
index 1de87e9d4c66..7fc202246cd8 100644
--- a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTestMain.c
+++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTestMain.c
@@ -47,6 +47,15 @@ EFI_BB_TEST_ENTRY_FIELD gBBTestEntryField[] = {
EFI_TEST_CASE_AUTO,
BBTestGetCapabilityConformanceTest
},
+ {
+ EFI_TCG2_PROTOCOL_TEST_ENTRY_GUID0102,
+ L"GetActivePcrBanks_Conf",
+ L"Test the GetActivePcrBanks API",
+ EFI_TEST_LEVEL_DEFAULT,
+ gSupportProtocolGuid1,
+ EFI_TEST_CASE_AUTO,
+ BBTestGetActivePcrBanksConformanceTest
+ },
0
};
--
2.34.1
-=-=-=-=-=-=
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#113486): https://edk2.groups.io/g/devel/message/113486
Mute This Topic: https://groups.io/mt/103625301/5985097
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [Sunny.Wang@arm.com]
-=-=-=-=-=-=
IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#116847): https://edk2.groups.io/g/devel/message/116847
Mute This Topic: https://groups.io/mt/103625301/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-
^ permalink raw reply related [flat|nested] 26+ messages in thread
* Re: [edk2-devel] [PATCH v2 3/6] uefi-sct/SctPkg: TCG2 Protocol: add GetActivePcrBanks test
2024-01-09 18:20 ` [edk2-devel] [PATCH v2 3/6] uefi-sct/SctPkg: TCG2 Protocol: add GetActivePcrBanks test Stuart Yoder
2024-03-05 15:48 ` G Edhaya Chandran
2024-03-18 20:43 ` Sunny Wang
@ 2024-03-19 9:13 ` G Edhaya Chandran
2 siblings, 0 replies; 26+ messages in thread
From: G Edhaya Chandran @ 2024-03-19 9:13 UTC (permalink / raw)
To: Stuart Yoder, devel
[-- Attachment #1: Type: text/plain, Size: 494 bytes --]
The patch is upstreamed by the commit:
https://github.com/tianocore/edk2-test/commit/bebabc28d9471de17b9dbebf83d4dfb54624ac0c
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#116886): https://edk2.groups.io/g/devel/message/116886
Mute This Topic: https://groups.io/mt/103625301/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-
[-- Attachment #2: Type: text/html, Size: 910 bytes --]
^ permalink raw reply [flat|nested] 26+ messages in thread
* [edk2-devel] [PATCH v2 4/6] uefi-sct/SctPkg: TCG2 Protocol: add HashLogExtendEvent test
2024-01-09 18:20 [edk2-devel] [PATCH v2 0/6] Tests for TCG2 Protocol Stuart Yoder
` (2 preceding siblings ...)
2024-01-09 18:20 ` [edk2-devel] [PATCH v2 3/6] uefi-sct/SctPkg: TCG2 Protocol: add GetActivePcrBanks test Stuart Yoder
@ 2024-01-09 18:20 ` Stuart Yoder
2024-03-05 15:48 ` G Edhaya Chandran
` (2 more replies)
2024-01-09 18:20 ` [edk2-devel] [PATCH v2 5/6] uefi-sct/SctPkg: TCG2 Protocol: add GetEventLog test Stuart Yoder
` (2 subsequent siblings)
6 siblings, 3 replies; 26+ messages in thread
From: Stuart Yoder @ 2024-01-09 18:20 UTC (permalink / raw)
To: devel, Edhaya.Chandran, gaojie
Cc: ilias.apalodimas, heinrich.schuchardt, Samer.El-Haj-Mahmoud,
Jiewen.Yao
From: Joseph Hemann <joseph.hemann@arm.com>
-add tests for HashLogExtendEvent()
-tests with valid, invalid, and out of range parameters
-do extend of data to PCR 16
Signed-off-by: Joseph Hemann <Joseph.hemann@arm.com>
Signed-off-by: Stuart Yoder <stuart.yoder@arm.com>
---
uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.h | 29 ++
uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTest.h | 29 ++
uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.c | 12 +
uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTestConformance.c | 283 ++++++++++++++++++++
uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTestMain.c | 9 +
5 files changed, 362 insertions(+)
diff --git a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.h b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.h
index d6797f5287f4..dcfd5919acda 100644
--- a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.h
+++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.h
@@ -56,3 +56,32 @@ extern EFI_GUID gTcg2ConformanceTestAssertionGuid005;
extern EFI_GUID gTcg2ConformanceTestAssertionGuid006;
+#define EFI_TEST_TCG2CONFORMANCE_ASSERTION_007_GUID \
+{ 0xa8e1b5e6, 0xfc09, 0x461c, {0xb0, 0xe9, 0x2a, 0x49, 0xcd, 0x25, 0xc1, 0x24 }}
+
+extern EFI_GUID gTcg2ConformanceTestAssertionGuid007;
+
+#define EFI_TEST_TCG2CONFORMANCE_ASSERTION_008_GUID \
+{ 0x26f04a9b, 0x7b7a, 0x4f47, {0xbe, 0xa8, 0xb1, 0xa6, 0x02, 0x65, 0x19, 0x8a }}
+
+extern EFI_GUID gTcg2ConformanceTestAssertionGuid008;
+
+#define EFI_TEST_TCG2CONFORMANCE_ASSERTION_009_GUID \
+{ 0x4d1d9985, 0x91e2, 0x4948, {0x89, 0x16, 0xbb, 0x98, 0x13, 0x62, 0x39, 0x1d }}
+
+extern EFI_GUID gTcg2ConformanceTestAssertionGuid009;
+
+#define EFI_TEST_TCG2CONFORMANCE_ASSERTION_010_GUID \
+{ 0xfb59cab7, 0x4f8c, 0x4ded, {0xa4, 0x1c, 0xc8, 0x41, 0x20, 0x1c, 0x37, 0x22 }}
+
+extern EFI_GUID gTcg2ConformanceTestAssertionGuid010;
+
+#define EFI_TEST_TCG2CONFORMANCE_ASSERTION_011_GUID \
+{ 0x0363d22f, 0xc66a, 0x4872, {0xa5, 0x46, 0x06, 0x7f, 0x6a, 0x0d, 0xdb, 0xcd }}
+
+extern EFI_GUID gTcg2ConformanceTestAssertionGuid011;
+
+#define EFI_TEST_TCG2CONFORMANCE_ASSERTION_012_GUID \
+{ 0x9cd6d636, 0x603a, 0x4b78, {0x80, 0xa3, 0xa3, 0xb9, 0xcc, 0x6a, 0x0b, 0x08 }}
+
+extern EFI_GUID gTcg2ConformanceTestAssertionGuid012;
diff --git a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTest.h b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTest.h
index 80c02d9ed2d2..cbbadef4a5c7 100644
--- a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTest.h
+++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTest.h
@@ -40,6 +40,15 @@ Abstract:
#define EFI_TCG2_PROTOCOL_TEST_ENTRY_GUID0102 \
{0x847f1ae0, 0xb429, 0x49f1, {0x9e, 0x0c, 0x8f, 0x43, 0xfb, 0x55, 0x34, 0x54} }
+#define EFI_TCG2_PROTOCOL_TEST_ENTRY_GUID0103 \
+ {0x907a7878, 0xb294, 0xf147, {0xe9, 0x0a, 0x65, 0x43, 0xab, 0x55, 0x76, 0x46} }
+
+#define EV_POST_CODE 0x01
+
+#define EFI_TCG2_EXTEND_ONLY 0x0000000000000001
+
+#define PE_COFF_IMAGE 0x0000000000000010
+
EFI_STATUS
EFIAPI
BBTestTCG2ProtocolUnload (
@@ -82,6 +91,18 @@ BBTestGetActivePcrBanksConformanceTestCheckpoint2 (
IN EFI_TCG2_PROTOCOL *TCG2
);
+EFI_STATUS
+BBTestHashLogExtendEventConformanceTestCheckpoint1 (
+ IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib,
+ IN EFI_TCG2_PROTOCOL *TCG2
+ );
+
+EFI_STATUS
+BBTestHashLogExtendEventConformanceTestCheckpoint2 (
+ IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib,
+ IN EFI_TCG2_PROTOCOL *TCG2
+ );
+
EFI_STATUS
BBTestGetCapabilityConformanceTest (
IN EFI_BB_TEST_PROTOCOL *This,
@@ -98,3 +119,11 @@ BBTestGetActivePcrBanksConformanceTest (
IN EFI_HANDLE SupportHandle
);
+EFI_STATUS
+BBTestHashLogExtendEventConformanceTest (
+ IN EFI_BB_TEST_PROTOCOL *This,
+ IN VOID *ClientInterface,
+ IN EFI_TEST_LEVEL TestLevel,
+ IN EFI_HANDLE SupportHandle
+ );
+
diff --git a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.c b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.c
index 0dc2cfddfcbf..ccc20259d128 100644
--- a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.c
+++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.c
@@ -39,3 +39,15 @@ EFI_GUID gTcg2ConformanceTestAssertionGuid004 = EFI_TEST_TCG2CONFORMANCE_ASSERTI
EFI_GUID gTcg2ConformanceTestAssertionGuid005 = EFI_TEST_TCG2CONFORMANCE_ASSERTION_005_GUID;
EFI_GUID gTcg2ConformanceTestAssertionGuid006 = EFI_TEST_TCG2CONFORMANCE_ASSERTION_006_GUID;
+
+EFI_GUID gTcg2ConformanceTestAssertionGuid007 = EFI_TEST_TCG2CONFORMANCE_ASSERTION_007_GUID;
+
+EFI_GUID gTcg2ConformanceTestAssertionGuid008 = EFI_TEST_TCG2CONFORMANCE_ASSERTION_008_GUID;
+
+EFI_GUID gTcg2ConformanceTestAssertionGuid009 = EFI_TEST_TCG2CONFORMANCE_ASSERTION_009_GUID;
+
+EFI_GUID gTcg2ConformanceTestAssertionGuid010 = EFI_TEST_TCG2CONFORMANCE_ASSERTION_010_GUID;
+
+EFI_GUID gTcg2ConformanceTestAssertionGuid011 = EFI_TEST_TCG2CONFORMANCE_ASSERTION_011_GUID;
+
+EFI_GUID gTcg2ConformanceTestAssertionGuid012 = EFI_TEST_TCG2CONFORMANCE_ASSERTION_012_GUID;
diff --git a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTestConformance.c b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTestConformance.c
index 681f57ac224a..2768eef725e8 100644
--- a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTestConformance.c
+++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTestConformance.c
@@ -140,6 +140,57 @@ BBTestGetActivePcrBanksConformanceTest (
return EFI_SUCCESS;
}
+/**
+ * @brief Entrypoint for HashLogExtendEvent() Function Test.
+ * 2 checkpoints will be tested.
+ * @param This a pointer of EFI_BB_TEST_PROTOCOL
+ * @param ClientInterface A pointer to the interface array under test
+ * @param TestLevel Test "thoroughness" control
+ * @param SupportHandle A handle containing protocols required
+ * @return EFI_SUCCESS
+ * @return EFI_NOT_FOUND
+ */
+
+EFI_STATUS
+BBTestHashLogExtendEventConformanceTest (
+ IN EFI_BB_TEST_PROTOCOL *This,
+ IN VOID *ClientInterface,
+ IN EFI_TEST_LEVEL TestLevel,
+ IN EFI_HANDLE SupportHandle
+ )
+{
+ EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib;
+ EFI_STATUS Status;
+ EFI_TCG2_PROTOCOL *TCG2;
+ //
+ // init
+ //
+ TCG2 = (EFI_TCG2_PROTOCOL*)ClientInterface;
+
+ // Ensure Protocol not NULL
+ if (TCG2 == NULL)
+ return EFI_UNSUPPORTED;
+
+ // Get the Standard Library Interface
+ //
+ Status = gtBS->HandleProtocol (
+ SupportHandle,
+ &gEfiStandardTestLibraryGuid,
+ (VOID **) &StandardLib
+ );
+ if (EFI_ERROR(Status)) {
+ return Status;
+ }
+
+ // Test HashLogExtendEvent with invalid arguments
+ BBTestHashLogExtendEventConformanceTestCheckpoint1 (StandardLib, TCG2);
+
+ // Test HashLogExtendEvent with valid arguments
+ BBTestHashLogExtendEventConformanceTestCheckpoint2 (StandardLib, TCG2);
+
+ return EFI_SUCCESS;
+}
+
EFI_STATUS
BBTestGetCapabilityConformanceTestCheckpoint1 (
IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib,
@@ -518,3 +569,235 @@ BBTestGetActivePcrBanksConformanceTestCheckpoint2 (
return EFI_SUCCESS;
}
+
+EFI_STATUS
+BBTestHashLogExtendEventConformanceTestCheckpoint1 (
+ IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib,
+ IN EFI_TCG2_PROTOCOL *TCG2
+ )
+{
+ EFI_TEST_ASSERTION AssertionType;
+ EFI_STATUS Status;
+ UINT64 Flags = 0;
+ EFI_PHYSICAL_ADDRESS DataToHash;
+ UINT64 DataToHashLen;
+ EFI_TCG2_EVENT *EfiTcgEvent;
+ const CHAR8 *EventData = "TCG2 Protocol Test";
+ const CHAR8 *Str = "The quick brown fox jumps over the lazy dog";
+ UINT32 EfiTcgEventSize = sizeof(EFI_TCG2_EVENT) + SctAsciiStrLen(EventData);
+
+ DataToHash = (EFI_PHYSICAL_ADDRESS)Str;
+ DataToHashLen = SctAsciiStrLen(Str);
+
+ Status = gtBS->AllocatePool (
+ EfiBootServicesData,
+ EfiTcgEventSize,
+ (VOID **)&EfiTcgEvent
+ );
+
+ EfiTcgEvent->Header.HeaderSize = sizeof(EFI_TCG2_EVENT_HEADER);
+ EfiTcgEvent->Header.HeaderVersion = 1;
+ EfiTcgEvent->Header.EventType = EV_POST_CODE;
+ EfiTcgEvent->Header.PCRIndex = 16;
+ EfiTcgEvent->Size = EfiTcgEvent->Header.HeaderSize + SctAsciiStrLen(EventData);
+
+ // Ensure HashLogExtendEvent returns Invalid Parameter when passing in NULL DataToHash pointer
+ // EFI Protocol Spec Section 6.6.5 #1
+ Status = TCG2->HashLogExtendEvent (
+ TCG2,
+ Flags,
+ (EFI_PHYSICAL_ADDRESS)NULL,
+ 0,
+ EfiTcgEvent);
+
+ if (EFI_INVALID_PARAMETER != Status) {
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ } else {
+ AssertionType = EFI_TEST_ASSERTION_PASSED;
+ }
+
+ StandardLib->RecordAssertion (
+ StandardLib,
+ AssertionType,
+ gTcg2ConformanceTestAssertionGuid007,
+ L"TCG2_PROTOCOL.HashLogExtendEvent - Test with NULL DataToHash Pointer should return EFI_INVALID_PARAMETER",
+ L"%a:%d: Status - %r",
+ __FILE__,
+ (UINTN)__LINE__,
+ Status
+ );
+
+ // Ensure HashLogExtendEvent returns Invalid Parameter when passing in NULL EfiTcgEvent pointer
+ // EFI Protocol Spec Section 6.6.5 #1
+ Status = TCG2->HashLogExtendEvent (
+ TCG2,
+ Flags,
+ DataToHash,
+ DataToHashLen,
+ NULL);
+
+ if (EFI_INVALID_PARAMETER != Status) {
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ } else {
+ AssertionType = EFI_TEST_ASSERTION_PASSED;
+ }
+
+ StandardLib->RecordAssertion (
+ StandardLib,
+ AssertionType,
+ gTcg2ConformanceTestAssertionGuid008,
+ L"TCG2_PROTOCOL.HashLogExtendEvent - Test with NULL EfiTcgEvent Pointer should return EFI_INVALID_PARAMETER",
+ L"%a:%d: Status - %r",
+ __FILE__,
+ (UINTN)__LINE__,
+ Status
+ );
+
+ // Ensure HashLogExtendEvent returns Invalid Parameter when passed in EventSize < HeaderSize + sizeof(UINT32)
+ // EFI Protocol Spec Section 6.6.5 #2
+ EfiTcgEvent->Size = EfiTcgEvent->Header.HeaderSize + sizeof(UINT32) - 1;
+
+ Status = TCG2->HashLogExtendEvent (
+ TCG2,
+ Flags,
+ DataToHash,
+ DataToHashLen,
+ EfiTcgEvent);
+
+ if (EFI_INVALID_PARAMETER != Status) {
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ } else {
+ AssertionType = EFI_TEST_ASSERTION_PASSED;
+ }
+
+ StandardLib->RecordAssertion (
+ StandardLib,
+ AssertionType,
+ gTcg2ConformanceTestAssertionGuid009,
+ L"TCG2_PROTOCOL.HashLogExtendEvent - Test with Event.Size < Event.Header.HeaderSize + sizeof(UINT32) should return EFI_INVALID_PARAMETER",
+ L"%a:%d: Status - %r",
+ __FILE__,
+ (UINTN)__LINE__,
+ Status
+ );
+
+ // Ensure HashLogExtendEvent returns Invalid Parameter when passing in PCR Index > 23
+ // EFI Protocol Spec Section 6.6.5 #3
+ EfiTcgEvent->Header.PCRIndex = 24;
+ EfiTcgEvent->Size = EfiTcgEvent->Header.HeaderSize + SctAsciiStrLen(EventData);
+
+ Status = TCG2->HashLogExtendEvent (
+ TCG2,
+ Flags,
+ DataToHash,
+ DataToHashLen,
+ EfiTcgEvent);
+
+ if (EFI_INVALID_PARAMETER != Status) {
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ } else {
+ AssertionType = EFI_TEST_ASSERTION_PASSED;
+ }
+
+ StandardLib->RecordAssertion (
+ StandardLib,
+ AssertionType,
+ gTcg2ConformanceTestAssertionGuid010,
+ L"TCG2_PROTOCOL.HashLogExtendEvent - Test with PCRIndex > 23 should return EFI_INVALID_PARAMETER",
+ L"%a:%d: Status - %r",
+ __FILE__,
+ (UINTN)__LINE__,
+ Status
+ );
+
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+BBTestHashLogExtendEventConformanceTestCheckpoint2 (
+ IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib,
+ IN EFI_TCG2_PROTOCOL *TCG2
+ )
+{
+ EFI_TCG2_EVENT *EfiTcgEvent;
+ EFI_TEST_ASSERTION AssertionType;
+ EFI_STATUS Status;
+ UINT64 Flags = 0;
+ EFI_PHYSICAL_ADDRESS DataToHash;
+ UINT64 DataToHashLen;
+ const CHAR8 *Str = "The quick brown fox jumps over the lazy dog";
+ const CHAR8 *EventData = "TCG2 Protocol Test";
+ UINT32 EfiTcgEventSize = sizeof(EFI_TCG2_EVENT) + SctAsciiStrLen(EventData);
+
+ DataToHash = (EFI_PHYSICAL_ADDRESS)Str;
+ DataToHashLen = SctAsciiStrLen(Str);
+
+ Status = gtBS->AllocatePool (
+ EfiBootServicesData,
+ EfiTcgEventSize,
+ (VOID **)&EfiTcgEvent
+ );
+
+ EfiTcgEvent->Header.HeaderSize = sizeof(EFI_TCG2_EVENT_HEADER);
+ EfiTcgEvent->Header.HeaderVersion = 1;
+ EfiTcgEvent->Header.EventType = EV_POST_CODE;
+ EfiTcgEvent->Header.PCRIndex = 16;
+ EfiTcgEvent->Size = EfiTcgEvent->Header.HeaderSize + SctAsciiStrLen(EventData);
+
+ // Perform HashLogExtendEvent over test buffer to PCR 16
+ Status = TCG2->HashLogExtendEvent (
+ TCG2,
+ Flags,
+ DataToHash,
+ DataToHashLen,
+ EfiTcgEvent);
+
+ if (Status != EFI_SUCCESS) {
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ } else {
+ AssertionType = EFI_TEST_ASSERTION_PASSED;
+ }
+
+ StandardLib->RecordAssertion (
+ StandardLib,
+ AssertionType,
+ gTcg2ConformanceTestAssertionGuid011,
+ L"TCG2_PROTOCOL.HashLogExtendEvent - HashLogExtendEvent() Test: HashLogExtendEvent should return EFI_SUCCESS",
+ L"%a:%d: Status - %r",
+ __FILE__,
+ (UINTN)__LINE__,
+ Status
+ );
+
+ // Test with valid Parameters but with Flags = PE_COFF_IMAGE
+ // EFI Protocol Spec Section 6.6.5 #4
+ Flags = PE_COFF_IMAGE;
+
+ Status = TCG2->HashLogExtendEvent (
+ TCG2,
+ Flags,
+ DataToHash,
+ DataToHashLen,
+ EfiTcgEvent);
+
+ if (Status != EFI_UNSUPPORTED) {
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ } else {
+ AssertionType = EFI_TEST_ASSERTION_PASSED;
+ }
+
+ StandardLib->RecordAssertion (
+ StandardLib,
+ AssertionType,
+ gTcg2ConformanceTestAssertionGuid012,
+ L"TCG2_PROTOCOL.HashLogExtendEvent - HashLogExtendEvent() Test Handling of PE_COFF_IMAGE flag",
+ L"%a:%d: Status - %r",
+ __FILE__,
+ (UINTN)__LINE__,
+ Status
+ );
+
+ gtBS->FreePool (EfiTcgEvent);
+
+ return EFI_SUCCESS;
+}
diff --git a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTestMain.c b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTestMain.c
index 7fc202246cd8..f7b9e487eda2 100644
--- a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTestMain.c
+++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTestMain.c
@@ -56,6 +56,15 @@ EFI_BB_TEST_ENTRY_FIELD gBBTestEntryField[] = {
EFI_TEST_CASE_AUTO,
BBTestGetActivePcrBanksConformanceTest
},
+ {
+ EFI_TCG2_PROTOCOL_TEST_ENTRY_GUID0103,
+ L"HashLogExtendEvent_Conf",
+ L"Test the HashLogExtendEvent API",
+ EFI_TEST_LEVEL_DEFAULT,
+ gSupportProtocolGuid1,
+ EFI_TEST_CASE_AUTO,
+ BBTestHashLogExtendEventConformanceTest
+ },
0
};
--
2.34.1
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#113488): https://edk2.groups.io/g/devel/message/113488
Mute This Topic: https://groups.io/mt/103625303/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-
^ permalink raw reply related [flat|nested] 26+ messages in thread
* Re: [edk2-devel] [PATCH v2 4/6] uefi-sct/SctPkg: TCG2 Protocol: add HashLogExtendEvent test
2024-01-09 18:20 ` [edk2-devel] [PATCH v2 4/6] uefi-sct/SctPkg: TCG2 Protocol: add HashLogExtendEvent test Stuart Yoder
@ 2024-03-05 15:48 ` G Edhaya Chandran
2024-03-18 20:43 ` Sunny Wang
2024-03-19 9:13 ` G Edhaya Chandran
2 siblings, 0 replies; 26+ messages in thread
From: G Edhaya Chandran @ 2024-03-05 15:48 UTC (permalink / raw)
To: Stuart Yoder, devel
[-- Attachment #1: Type: text/plain, Size: 424 bytes --]
Reviewed-by: G Edhaya Chandran <edhaya.chandran@arm.com>
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#116401): https://edk2.groups.io/g/devel/message/116401
Mute This Topic: https://groups.io/mt/103625303/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-
[-- Attachment #2: Type: text/html, Size: 842 bytes --]
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [edk2-devel] [PATCH v2 4/6] uefi-sct/SctPkg: TCG2 Protocol: add HashLogExtendEvent test
2024-01-09 18:20 ` [edk2-devel] [PATCH v2 4/6] uefi-sct/SctPkg: TCG2 Protocol: add HashLogExtendEvent test Stuart Yoder
2024-03-05 15:48 ` G Edhaya Chandran
@ 2024-03-18 20:43 ` Sunny Wang
2024-03-19 9:13 ` G Edhaya Chandran
2 siblings, 0 replies; 26+ messages in thread
From: Sunny Wang @ 2024-03-18 20:43 UTC (permalink / raw)
To: devel@edk2.groups.io, Stuart Yoder, G Edhaya Chandran,
gaojie@byosoft.com.cn
Cc: ilias.apalodimas@linaro.org, heinrich.schuchardt@canonical.com,
Samer El-Haj-Mahmoud, Jiewen.Yao@intel.com, Sunny Wang
Looks good to me.
For others' reference, the change has been already verified by running SystemReady SIE (Security Interface extension) tests on multiple SystemReady certified Arm systems.
Reviewed-by: Sunny Wang <sunny.wang@arm.com>
-----Original Message-----
From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Stuart Yoder via groups.io
Sent: Tuesday, January 9, 2024 12:21 PM
To: devel@edk2.groups.io; G Edhaya Chandran <Edhaya.Chandran@arm.com>; gaojie@byosoft.com.cn
Cc: ilias.apalodimas@linaro.org; heinrich.schuchardt@canonical.com; Samer El-Haj-Mahmoud <Samer.El-Haj-Mahmoud@arm.com>; Jiewen.Yao@intel.com
Subject: [edk2-devel] [PATCH v2 4/6] uefi-sct/SctPkg: TCG2 Protocol: add HashLogExtendEvent test
From: Joseph Hemann <joseph.hemann@arm.com>
-add tests for HashLogExtendEvent()
-tests with valid, invalid, and out of range parameters
-do extend of data to PCR 16
Signed-off-by: Joseph Hemann <Joseph.hemann@arm.com>
Signed-off-by: Stuart Yoder <stuart.yoder@arm.com>
---
uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.h | 29 ++
uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTest.h | 29 ++
uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.c | 12 +
uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTestConformance.c | 283 ++++++++++++++++++++
uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTestMain.c | 9 +
5 files changed, 362 insertions(+)
diff --git a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.h b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.h
index d6797f5287f4..dcfd5919acda 100644
--- a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.h
+++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.h
@@ -56,3 +56,32 @@ extern EFI_GUID gTcg2ConformanceTestAssertionGuid005;
extern EFI_GUID gTcg2ConformanceTestAssertionGuid006;
+#define EFI_TEST_TCG2CONFORMANCE_ASSERTION_007_GUID \
+{ 0xa8e1b5e6, 0xfc09, 0x461c, {0xb0, 0xe9, 0x2a, 0x49, 0xcd, 0x25, 0xc1, 0x24 }}
+
+extern EFI_GUID gTcg2ConformanceTestAssertionGuid007;
+
+#define EFI_TEST_TCG2CONFORMANCE_ASSERTION_008_GUID \
+{ 0x26f04a9b, 0x7b7a, 0x4f47, {0xbe, 0xa8, 0xb1, 0xa6, 0x02, 0x65, 0x19, 0x8a }}
+
+extern EFI_GUID gTcg2ConformanceTestAssertionGuid008;
+
+#define EFI_TEST_TCG2CONFORMANCE_ASSERTION_009_GUID \
+{ 0x4d1d9985, 0x91e2, 0x4948, {0x89, 0x16, 0xbb, 0x98, 0x13, 0x62, 0x39, 0x1d }}
+
+extern EFI_GUID gTcg2ConformanceTestAssertionGuid009;
+
+#define EFI_TEST_TCG2CONFORMANCE_ASSERTION_010_GUID \
+{ 0xfb59cab7, 0x4f8c, 0x4ded, {0xa4, 0x1c, 0xc8, 0x41, 0x20, 0x1c, 0x37, 0x22 }}
+
+extern EFI_GUID gTcg2ConformanceTestAssertionGuid010;
+
+#define EFI_TEST_TCG2CONFORMANCE_ASSERTION_011_GUID \
+{ 0x0363d22f, 0xc66a, 0x4872, {0xa5, 0x46, 0x06, 0x7f, 0x6a, 0x0d, 0xdb, 0xcd }}
+
+extern EFI_GUID gTcg2ConformanceTestAssertionGuid011;
+
+#define EFI_TEST_TCG2CONFORMANCE_ASSERTION_012_GUID \
+{ 0x9cd6d636, 0x603a, 0x4b78, {0x80, 0xa3, 0xa3, 0xb9, 0xcc, 0x6a, 0x0b, 0x08 }}
+
+extern EFI_GUID gTcg2ConformanceTestAssertionGuid012;
diff --git a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTest.h b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTest.h
index 80c02d9ed2d2..cbbadef4a5c7 100644
--- a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTest.h
+++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTest.h
@@ -40,6 +40,15 @@ Abstract:
#define EFI_TCG2_PROTOCOL_TEST_ENTRY_GUID0102 \
{0x847f1ae0, 0xb429, 0x49f1, {0x9e, 0x0c, 0x8f, 0x43, 0xfb, 0x55, 0x34, 0x54} }
+#define EFI_TCG2_PROTOCOL_TEST_ENTRY_GUID0103 \
+ {0x907a7878, 0xb294, 0xf147, {0xe9, 0x0a, 0x65, 0x43, 0xab, 0x55, 0x76, 0x46} }
+
+#define EV_POST_CODE 0x01
+
+#define EFI_TCG2_EXTEND_ONLY 0x0000000000000001
+
+#define PE_COFF_IMAGE 0x0000000000000010
+
EFI_STATUS
EFIAPI
BBTestTCG2ProtocolUnload (
@@ -82,6 +91,18 @@ BBTestGetActivePcrBanksConformanceTestCheckpoint2 (
IN EFI_TCG2_PROTOCOL *TCG2
);
+EFI_STATUS
+BBTestHashLogExtendEventConformanceTestCheckpoint1 (
+ IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib,
+ IN EFI_TCG2_PROTOCOL *TCG2
+ );
+
+EFI_STATUS
+BBTestHashLogExtendEventConformanceTestCheckpoint2 (
+ IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib,
+ IN EFI_TCG2_PROTOCOL *TCG2
+ );
+
EFI_STATUS
BBTestGetCapabilityConformanceTest (
IN EFI_BB_TEST_PROTOCOL *This,
@@ -98,3 +119,11 @@ BBTestGetActivePcrBanksConformanceTest (
IN EFI_HANDLE SupportHandle
);
+EFI_STATUS
+BBTestHashLogExtendEventConformanceTest (
+ IN EFI_BB_TEST_PROTOCOL *This,
+ IN VOID *ClientInterface,
+ IN EFI_TEST_LEVEL TestLevel,
+ IN EFI_HANDLE SupportHandle
+ );
+
diff --git a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.c b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.c
index 0dc2cfddfcbf..ccc20259d128 100644
--- a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.c
+++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.c
@@ -39,3 +39,15 @@ EFI_GUID gTcg2ConformanceTestAssertionGuid004 = EFI_TEST_TCG2CONFORMANCE_ASSERTI
EFI_GUID gTcg2ConformanceTestAssertionGuid005 = EFI_TEST_TCG2CONFORMANCE_ASSERTION_005_GUID;
EFI_GUID gTcg2ConformanceTestAssertionGuid006 = EFI_TEST_TCG2CONFORMANCE_ASSERTION_006_GUID;
+
+EFI_GUID gTcg2ConformanceTestAssertionGuid007 = EFI_TEST_TCG2CONFORMANCE_ASSERTION_007_GUID;
+
+EFI_GUID gTcg2ConformanceTestAssertionGuid008 = EFI_TEST_TCG2CONFORMANCE_ASSERTION_008_GUID;
+
+EFI_GUID gTcg2ConformanceTestAssertionGuid009 = EFI_TEST_TCG2CONFORMANCE_ASSERTION_009_GUID;
+
+EFI_GUID gTcg2ConformanceTestAssertionGuid010 = EFI_TEST_TCG2CONFORMANCE_ASSERTION_010_GUID;
+
+EFI_GUID gTcg2ConformanceTestAssertionGuid011 = EFI_TEST_TCG2CONFORMANCE_ASSERTION_011_GUID;
+
+EFI_GUID gTcg2ConformanceTestAssertionGuid012 = EFI_TEST_TCG2CONFORMANCE_ASSERTION_012_GUID;
diff --git a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTestConformance.c b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTestConformance.c
index 681f57ac224a..2768eef725e8 100644
--- a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTestConformance.c
+++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTestConformance.c
@@ -140,6 +140,57 @@ BBTestGetActivePcrBanksConformanceTest (
return EFI_SUCCESS;
}
+/**
+ * @brief Entrypoint for HashLogExtendEvent() Function Test.
+ * 2 checkpoints will be tested.
+ * @param This a pointer of EFI_BB_TEST_PROTOCOL
+ * @param ClientInterface A pointer to the interface array under test
+ * @param TestLevel Test "thoroughness" control
+ * @param SupportHandle A handle containing protocols required
+ * @return EFI_SUCCESS
+ * @return EFI_NOT_FOUND
+ */
+
+EFI_STATUS
+BBTestHashLogExtendEventConformanceTest (
+ IN EFI_BB_TEST_PROTOCOL *This,
+ IN VOID *ClientInterface,
+ IN EFI_TEST_LEVEL TestLevel,
+ IN EFI_HANDLE SupportHandle
+ )
+{
+ EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib;
+ EFI_STATUS Status;
+ EFI_TCG2_PROTOCOL *TCG2;
+ //
+ // init
+ //
+ TCG2 = (EFI_TCG2_PROTOCOL*)ClientInterface;
+
+ // Ensure Protocol not NULL
+ if (TCG2 == NULL)
+ return EFI_UNSUPPORTED;
+
+ // Get the Standard Library Interface
+ //
+ Status = gtBS->HandleProtocol (
+ SupportHandle,
+ &gEfiStandardTestLibraryGuid,
+ (VOID **) &StandardLib
+ );
+ if (EFI_ERROR(Status)) {
+ return Status;
+ }
+
+ // Test HashLogExtendEvent with invalid arguments
+ BBTestHashLogExtendEventConformanceTestCheckpoint1 (StandardLib, TCG2);
+
+ // Test HashLogExtendEvent with valid arguments
+ BBTestHashLogExtendEventConformanceTestCheckpoint2 (StandardLib, TCG2);
+
+ return EFI_SUCCESS;
+}
+
EFI_STATUS
BBTestGetCapabilityConformanceTestCheckpoint1 (
IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib,
@@ -518,3 +569,235 @@ BBTestGetActivePcrBanksConformanceTestCheckpoint2 (
return EFI_SUCCESS;
}
+
+EFI_STATUS
+BBTestHashLogExtendEventConformanceTestCheckpoint1 (
+ IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib,
+ IN EFI_TCG2_PROTOCOL *TCG2
+ )
+{
+ EFI_TEST_ASSERTION AssertionType;
+ EFI_STATUS Status;
+ UINT64 Flags = 0;
+ EFI_PHYSICAL_ADDRESS DataToHash;
+ UINT64 DataToHashLen;
+ EFI_TCG2_EVENT *EfiTcgEvent;
+ const CHAR8 *EventData = "TCG2 Protocol Test";
+ const CHAR8 *Str = "The quick brown fox jumps over the lazy dog";
+ UINT32 EfiTcgEventSize = sizeof(EFI_TCG2_EVENT) + SctAsciiStrLen(EventData);
+
+ DataToHash = (EFI_PHYSICAL_ADDRESS)Str;
+ DataToHashLen = SctAsciiStrLen(Str);
+
+ Status = gtBS->AllocatePool (
+ EfiBootServicesData,
+ EfiTcgEventSize,
+ (VOID **)&EfiTcgEvent
+ );
+
+ EfiTcgEvent->Header.HeaderSize = sizeof(EFI_TCG2_EVENT_HEADER);
+ EfiTcgEvent->Header.HeaderVersion = 1;
+ EfiTcgEvent->Header.EventType = EV_POST_CODE;
+ EfiTcgEvent->Header.PCRIndex = 16;
+ EfiTcgEvent->Size = EfiTcgEvent->Header.HeaderSize + SctAsciiStrLen(EventData);
+
+ // Ensure HashLogExtendEvent returns Invalid Parameter when passing in NULL DataToHash pointer
+ // EFI Protocol Spec Section 6.6.5 #1
+ Status = TCG2->HashLogExtendEvent (
+ TCG2,
+ Flags,
+ (EFI_PHYSICAL_ADDRESS)NULL,
+ 0,
+ EfiTcgEvent);
+
+ if (EFI_INVALID_PARAMETER != Status) {
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ } else {
+ AssertionType = EFI_TEST_ASSERTION_PASSED;
+ }
+
+ StandardLib->RecordAssertion (
+ StandardLib,
+ AssertionType,
+ gTcg2ConformanceTestAssertionGuid007,
+ L"TCG2_PROTOCOL.HashLogExtendEvent - Test with NULL DataToHash Pointer should return EFI_INVALID_PARAMETER",
+ L"%a:%d: Status - %r",
+ __FILE__,
+ (UINTN)__LINE__,
+ Status
+ );
+
+ // Ensure HashLogExtendEvent returns Invalid Parameter when passing in NULL EfiTcgEvent pointer
+ // EFI Protocol Spec Section 6.6.5 #1
+ Status = TCG2->HashLogExtendEvent (
+ TCG2,
+ Flags,
+ DataToHash,
+ DataToHashLen,
+ NULL);
+
+ if (EFI_INVALID_PARAMETER != Status) {
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ } else {
+ AssertionType = EFI_TEST_ASSERTION_PASSED;
+ }
+
+ StandardLib->RecordAssertion (
+ StandardLib,
+ AssertionType,
+ gTcg2ConformanceTestAssertionGuid008,
+ L"TCG2_PROTOCOL.HashLogExtendEvent - Test with NULL EfiTcgEvent Pointer should return EFI_INVALID_PARAMETER",
+ L"%a:%d: Status - %r",
+ __FILE__,
+ (UINTN)__LINE__,
+ Status
+ );
+
+ // Ensure HashLogExtendEvent returns Invalid Parameter when passed in EventSize < HeaderSize + sizeof(UINT32)
+ // EFI Protocol Spec Section 6.6.5 #2
+ EfiTcgEvent->Size = EfiTcgEvent->Header.HeaderSize + sizeof(UINT32) - 1;
+
+ Status = TCG2->HashLogExtendEvent (
+ TCG2,
+ Flags,
+ DataToHash,
+ DataToHashLen,
+ EfiTcgEvent);
+
+ if (EFI_INVALID_PARAMETER != Status) {
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ } else {
+ AssertionType = EFI_TEST_ASSERTION_PASSED;
+ }
+
+ StandardLib->RecordAssertion (
+ StandardLib,
+ AssertionType,
+ gTcg2ConformanceTestAssertionGuid009,
+ L"TCG2_PROTOCOL.HashLogExtendEvent - Test with Event.Size < Event.Header.HeaderSize + sizeof(UINT32) should return EFI_INVALID_PARAMETER",
+ L"%a:%d: Status - %r",
+ __FILE__,
+ (UINTN)__LINE__,
+ Status
+ );
+
+ // Ensure HashLogExtendEvent returns Invalid Parameter when passing in PCR Index > 23
+ // EFI Protocol Spec Section 6.6.5 #3
+ EfiTcgEvent->Header.PCRIndex = 24;
+ EfiTcgEvent->Size = EfiTcgEvent->Header.HeaderSize + SctAsciiStrLen(EventData);
+
+ Status = TCG2->HashLogExtendEvent (
+ TCG2,
+ Flags,
+ DataToHash,
+ DataToHashLen,
+ EfiTcgEvent);
+
+ if (EFI_INVALID_PARAMETER != Status) {
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ } else {
+ AssertionType = EFI_TEST_ASSERTION_PASSED;
+ }
+
+ StandardLib->RecordAssertion (
+ StandardLib,
+ AssertionType,
+ gTcg2ConformanceTestAssertionGuid010,
+ L"TCG2_PROTOCOL.HashLogExtendEvent - Test with PCRIndex > 23 should return EFI_INVALID_PARAMETER",
+ L"%a:%d: Status - %r",
+ __FILE__,
+ (UINTN)__LINE__,
+ Status
+ );
+
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+BBTestHashLogExtendEventConformanceTestCheckpoint2 (
+ IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib,
+ IN EFI_TCG2_PROTOCOL *TCG2
+ )
+{
+ EFI_TCG2_EVENT *EfiTcgEvent;
+ EFI_TEST_ASSERTION AssertionType;
+ EFI_STATUS Status;
+ UINT64 Flags = 0;
+ EFI_PHYSICAL_ADDRESS DataToHash;
+ UINT64 DataToHashLen;
+ const CHAR8 *Str = "The quick brown fox jumps over the lazy dog";
+ const CHAR8 *EventData = "TCG2 Protocol Test";
+ UINT32 EfiTcgEventSize = sizeof(EFI_TCG2_EVENT) + SctAsciiStrLen(EventData);
+
+ DataToHash = (EFI_PHYSICAL_ADDRESS)Str;
+ DataToHashLen = SctAsciiStrLen(Str);
+
+ Status = gtBS->AllocatePool (
+ EfiBootServicesData,
+ EfiTcgEventSize,
+ (VOID **)&EfiTcgEvent
+ );
+
+ EfiTcgEvent->Header.HeaderSize = sizeof(EFI_TCG2_EVENT_HEADER);
+ EfiTcgEvent->Header.HeaderVersion = 1;
+ EfiTcgEvent->Header.EventType = EV_POST_CODE;
+ EfiTcgEvent->Header.PCRIndex = 16;
+ EfiTcgEvent->Size = EfiTcgEvent->Header.HeaderSize + SctAsciiStrLen(EventData);
+
+ // Perform HashLogExtendEvent over test buffer to PCR 16
+ Status = TCG2->HashLogExtendEvent (
+ TCG2,
+ Flags,
+ DataToHash,
+ DataToHashLen,
+ EfiTcgEvent);
+
+ if (Status != EFI_SUCCESS) {
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ } else {
+ AssertionType = EFI_TEST_ASSERTION_PASSED;
+ }
+
+ StandardLib->RecordAssertion (
+ StandardLib,
+ AssertionType,
+ gTcg2ConformanceTestAssertionGuid011,
+ L"TCG2_PROTOCOL.HashLogExtendEvent - HashLogExtendEvent() Test: HashLogExtendEvent should return EFI_SUCCESS",
+ L"%a:%d: Status - %r",
+ __FILE__,
+ (UINTN)__LINE__,
+ Status
+ );
+
+ // Test with valid Parameters but with Flags = PE_COFF_IMAGE
+ // EFI Protocol Spec Section 6.6.5 #4
+ Flags = PE_COFF_IMAGE;
+
+ Status = TCG2->HashLogExtendEvent (
+ TCG2,
+ Flags,
+ DataToHash,
+ DataToHashLen,
+ EfiTcgEvent);
+
+ if (Status != EFI_UNSUPPORTED) {
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ } else {
+ AssertionType = EFI_TEST_ASSERTION_PASSED;
+ }
+
+ StandardLib->RecordAssertion (
+ StandardLib,
+ AssertionType,
+ gTcg2ConformanceTestAssertionGuid012,
+ L"TCG2_PROTOCOL.HashLogExtendEvent - HashLogExtendEvent() Test Handling of PE_COFF_IMAGE flag",
+ L"%a:%d: Status - %r",
+ __FILE__,
+ (UINTN)__LINE__,
+ Status
+ );
+
+ gtBS->FreePool (EfiTcgEvent);
+
+ return EFI_SUCCESS;
+}
diff --git a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTestMain.c b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTestMain.c
index 7fc202246cd8..f7b9e487eda2 100644
--- a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTestMain.c
+++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTestMain.c
@@ -56,6 +56,15 @@ EFI_BB_TEST_ENTRY_FIELD gBBTestEntryField[] = {
EFI_TEST_CASE_AUTO,
BBTestGetActivePcrBanksConformanceTest
},
+ {
+ EFI_TCG2_PROTOCOL_TEST_ENTRY_GUID0103,
+ L"HashLogExtendEvent_Conf",
+ L"Test the HashLogExtendEvent API",
+ EFI_TEST_LEVEL_DEFAULT,
+ gSupportProtocolGuid1,
+ EFI_TEST_CASE_AUTO,
+ BBTestHashLogExtendEventConformanceTest
+ },
0
};
--
2.34.1
-=-=-=-=-=-=
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#113488): https://edk2.groups.io/g/devel/message/113488
Mute This Topic: https://groups.io/mt/103625303/5985097
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [Sunny.Wang@arm.com]
-=-=-=-=-=-=
IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#116848): https://edk2.groups.io/g/devel/message/116848
Mute This Topic: https://groups.io/mt/103625303/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-
^ permalink raw reply related [flat|nested] 26+ messages in thread
* Re: [edk2-devel] [PATCH v2 4/6] uefi-sct/SctPkg: TCG2 Protocol: add HashLogExtendEvent test
2024-01-09 18:20 ` [edk2-devel] [PATCH v2 4/6] uefi-sct/SctPkg: TCG2 Protocol: add HashLogExtendEvent test Stuart Yoder
2024-03-05 15:48 ` G Edhaya Chandran
2024-03-18 20:43 ` Sunny Wang
@ 2024-03-19 9:13 ` G Edhaya Chandran
2 siblings, 0 replies; 26+ messages in thread
From: G Edhaya Chandran @ 2024-03-19 9:13 UTC (permalink / raw)
To: Stuart Yoder, devel
[-- Attachment #1: Type: text/plain, Size: 494 bytes --]
The patch is upstreamed by the commit:
https://github.com/tianocore/edk2-test/commit/244ebf6954c43496ca173e9091de92b061e0957e
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#116885): https://edk2.groups.io/g/devel/message/116885
Mute This Topic: https://groups.io/mt/103625303/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-
[-- Attachment #2: Type: text/html, Size: 910 bytes --]
^ permalink raw reply [flat|nested] 26+ messages in thread
* [edk2-devel] [PATCH v2 5/6] uefi-sct/SctPkg: TCG2 Protocol: add GetEventLog test
2024-01-09 18:20 [edk2-devel] [PATCH v2 0/6] Tests for TCG2 Protocol Stuart Yoder
` (3 preceding siblings ...)
2024-01-09 18:20 ` [edk2-devel] [PATCH v2 4/6] uefi-sct/SctPkg: TCG2 Protocol: add HashLogExtendEvent test Stuart Yoder
@ 2024-01-09 18:20 ` Stuart Yoder
2024-03-05 15:49 ` G Edhaya Chandran
` (2 more replies)
2024-01-09 18:20 ` [edk2-devel] [PATCH v2 6/6] uefi-sct/SctPkg: TCG2 Protocol: add SubmitCommand test Stuart Yoder
2024-03-05 15:46 ` [edk2-devel] [PATCH v2 0/6] Tests for TCG2 Protocol G Edhaya Chandran
6 siblings, 3 replies; 26+ messages in thread
From: Stuart Yoder @ 2024-01-09 18:20 UTC (permalink / raw)
To: devel, Edhaya.Chandran, gaojie
Cc: ilias.apalodimas, heinrich.schuchardt, Samer.El-Haj-Mahmoud,
Jiewen.Yao
From: Joseph Hemann <joseph.hemann@arm.com>
-add test for GetEventLog()
-test for valid and invalid event log format
-test event log header
-verify expected event log entry
Signed-off-by: Joseph Hemann <Joseph.hemann@arm.com>
Signed-off-by: Stuart Yoder <stuart.yoder@arm.com>
---
uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.h | 20 ++
uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTest.h | 17 ++
uefi-sct/SctPkg/UEFI/Protocol/TCG2.h | 46 +++++
uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.c | 8 +
uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTestConformance.c | 207 +++++++++++++++++++-
5 files changed, 297 insertions(+), 1 deletion(-)
diff --git a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.h b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.h
index dcfd5919acda..746ff83f899c 100644
--- a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.h
+++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.h
@@ -85,3 +85,23 @@ extern EFI_GUID gTcg2ConformanceTestAssertionGuid011;
{ 0x9cd6d636, 0x603a, 0x4b78, {0x80, 0xa3, 0xa3, 0xb9, 0xcc, 0x6a, 0x0b, 0x08 }}
extern EFI_GUID gTcg2ConformanceTestAssertionGuid012;
+
+#define EFI_TEST_TCG2CONFORMANCE_ASSERTION_013_GUID \
+{ 0xfc80408e, 0x9a3c, 0x4054, {0x96, 0xf9, 0x31, 0x23, 0x35, 0xc2, 0x31, 0x35 }}
+
+extern EFI_GUID gTcg2ConformanceTestAssertionGuid013;
+
+#define EFI_TEST_TCG2CONFORMANCE_ASSERTION_014_GUID \
+{ 0x45fa1a42, 0x912a, 0x5124, {0x84, 0xf4, 0x41, 0x67, 0xab, 0xb5, 0x89, 0x90 }}
+
+extern EFI_GUID gTcg2ConformanceTestAssertionGuid014;
+
+#define EFI_TEST_TCG2CONFORMANCE_ASSERTION_015_GUID \
+{ 0x1689bc3a, 0x2298, 0xa116, {0x28, 0x4c, 0xc1, 0xdd, 0xaa, 0xd8, 0xef, 0x51 }}
+
+extern EFI_GUID gTcg2ConformanceTestAssertionGuid015;
+
+#define EFI_TEST_TCG2CONFORMANCE_ASSERTION_016_GUID \
+{ 0x126a789a, 0x1932, 0x3234, {0x21, 0xab, 0x42, 0x64, 0x8a, 0x7b, 0x63, 0x76 }}
+
+extern EFI_GUID gTcg2ConformanceTestAssertionGuid016;
diff --git a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTest.h b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTest.h
index cbbadef4a5c7..5ce275dc6258 100644
--- a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTest.h
+++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTest.h
@@ -43,8 +43,13 @@ Abstract:
#define EFI_TCG2_PROTOCOL_TEST_ENTRY_GUID0103 \
{0x907a7878, 0xb294, 0xf147, {0xe9, 0x0a, 0x65, 0x43, 0xab, 0x55, 0x76, 0x46} }
+#define EFI_TCG2_PROTOCOL_TEST_ENTRY_GUID0104 \
+ {0x9087ad78, 0x9ad2, 0x4172, {0x9a, 0xbc, 0x98, 0x23, 0x08, 0xf5, 0x6d, 0x26} }
+
#define EV_POST_CODE 0x01
+#define EV_NO_ACTION 0x03
+
#define EFI_TCG2_EXTEND_ONLY 0x0000000000000001
#define PE_COFF_IMAGE 0x0000000000000010
@@ -103,6 +108,18 @@ BBTestHashLogExtendEventConformanceTestCheckpoint2 (
IN EFI_TCG2_PROTOCOL *TCG2
);
+EFI_STATUS
+BBTestGetEventLogConformanceTestCheckpoint1 (
+ IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib,
+ IN EFI_TCG2_PROTOCOL *TCG2
+ );
+
+EFI_STATUS
+BBTestGetEventLogConformanceTestCheckpoint2 (
+ IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib,
+ IN EFI_TCG2_PROTOCOL *TCG2
+ );
+
EFI_STATUS
BBTestGetCapabilityConformanceTest (
IN EFI_BB_TEST_PROTOCOL *This,
diff --git a/uefi-sct/SctPkg/UEFI/Protocol/TCG2.h b/uefi-sct/SctPkg/UEFI/Protocol/TCG2.h
index e62ecd85cbe9..fd31204a9299 100644
--- a/uefi-sct/SctPkg/UEFI/Protocol/TCG2.h
+++ b/uefi-sct/SctPkg/UEFI/Protocol/TCG2.h
@@ -50,6 +50,8 @@ Abstract:
#define EFI_TCG2_EVENT_LOG_FORMAT_TCG_2 0x00000002
+#define HASH_NUMBER 0x04
+
typedef struct _EFI_TCG2_PROTOCOL EFI_TCG2_PROTOCOL;
typedef UINT32 EFI_TCG2_EVENT_LOG_BITMAP;
@@ -115,6 +117,50 @@ typedef struct tdEFI_TCG2_EVENT {
UINT8 Event[];
} EFI_TCG2_EVENT;
+typedef struct {
+ UINT16 hashAlg;
+ UINT8 digest[];
+} TPMT_HA;
+
+typedef struct tdTPML_DIGEST_VALUES {
+ UINT32 Count; // number of digests
+ TPMT_HA Digests[HASH_NUMBER]; // Count digests
+} TPML_DIGEST_VALUES;
+
+// This Declaration is for parsing the eventlog header which is defined to be 20 bytes in TCG EFI Protocol Spec
+typedef UINT8 TCG_DIGEST[20];
+
+typedef struct tdTCG_PCR_EVENT2 {
+ TCG_PCRINDEX PCRIndex; // PCRIndex event extended to
+ TCG_EVENTTYPE EventType; // Type of event (see [2])
+ TPML_DIGEST_VALUES Digests; // List of digests extended to //PCRIndex
+ UINT32 EventSize; // Size of the event data
+ UINT8 *Event; // The event data
+} TCG_PCR_EVENT2;
+
+typedef struct tdTCG_PCR_EVENT {
+ UINT32 PCRIndex; // PCRIndex event extended to
+ UINT32 EventType; // Type of event (see EFI specs)
+ TCG_DIGEST Digest; // Value extended into PCRIndex
+ UINT32 EventSize; // Size of the event data
+ UINT8 Event[0]; // The event data
+} TCG_PCR_EVENT;
+// Structure to be added to the Event Log
+
+typedef struct tdTCG_EfiSpecIdEventAlgorithmSize {
+ UINT16 algorithmId;
+ UINT16 digestSize;
+} TCG_EfiSpecIdEventAlgorithmSize;
+
+typedef struct tdTCG_EfiSpecIdEventStruct {
+ UINT8 signature[16];
+ UINT32 platformClass;
+ UINT8 specVersionMinor;
+ UINT8 specVersionMajor;
+ UINT8 specErrata;
+ UINT8 uintnSize;
+} TCG_EfiSpecIDEventStruct;
+
#pragma pack()
typedef
diff --git a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.c b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.c
index ccc20259d128..8c528aa8ddfc 100644
--- a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.c
+++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.c
@@ -51,3 +51,11 @@ EFI_GUID gTcg2ConformanceTestAssertionGuid010 = EFI_TEST_TCG2CONFORMANCE_ASSERTI
EFI_GUID gTcg2ConformanceTestAssertionGuid011 = EFI_TEST_TCG2CONFORMANCE_ASSERTION_011_GUID;
EFI_GUID gTcg2ConformanceTestAssertionGuid012 = EFI_TEST_TCG2CONFORMANCE_ASSERTION_012_GUID;
+
+EFI_GUID gTcg2ConformanceTestAssertionGuid013 = EFI_TEST_TCG2CONFORMANCE_ASSERTION_013_GUID;
+
+EFI_GUID gTcg2ConformanceTestAssertionGuid014 = EFI_TEST_TCG2CONFORMANCE_ASSERTION_014_GUID;
+
+EFI_GUID gTcg2ConformanceTestAssertionGuid015 = EFI_TEST_TCG2CONFORMANCE_ASSERTION_015_GUID;
+
+EFI_GUID gTcg2ConformanceTestAssertionGuid016 = EFI_TEST_TCG2CONFORMANCE_ASSERTION_016_GUID;
diff --git a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTestConformance.c b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTestConformance.c
index 2768eef725e8..ebe04d42aff5 100644
--- a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTestConformance.c
+++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTestConformance.c
@@ -142,7 +142,7 @@ BBTestGetActivePcrBanksConformanceTest (
/**
* @brief Entrypoint for HashLogExtendEvent() Function Test.
- * 2 checkpoints will be tested.
+ * 4 checkpoints will be tested.
* @param This a pointer of EFI_BB_TEST_PROTOCOL
* @param ClientInterface A pointer to the interface array under test
* @param TestLevel Test "thoroughness" control
@@ -188,6 +188,12 @@ BBTestHashLogExtendEventConformanceTest (
// Test HashLogExtendEvent with valid arguments
BBTestHashLogExtendEventConformanceTestCheckpoint2 (StandardLib, TCG2);
+ // Test GetEventLog using invalid EventLog Format
+ BBTestGetEventLogConformanceTestCheckpoint1 (StandardLib, TCG2);
+
+ // Test GetEventLog using valid EventLog Format
+ BBTestGetEventLogConformanceTestCheckpoint2 (StandardLib, TCG2);
+
return EFI_SUCCESS;
}
@@ -801,3 +807,202 @@ BBTestHashLogExtendEventConformanceTestCheckpoint2 (
return EFI_SUCCESS;
}
+
+#define EFI_TCG2_INVALID_EVENT_LOG_FORMAT 0x20
+
+EFI_STATUS
+BBTestGetEventLogConformanceTestCheckpoint1 (
+ IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib,
+ IN EFI_TCG2_PROTOCOL *TCG2
+ )
+{
+ EFI_TEST_ASSERTION AssertionType;
+ EFI_STATUS Status;
+ EFI_TCG2_EVENT_LOG_FORMAT EventLogFormat;
+ EFI_PHYSICAL_ADDRESS EventLogLocation;
+ EFI_PHYSICAL_ADDRESS EventLogLastEntry;
+ BOOLEAN EventLogTruncated;
+
+ // Ensure Get EventLog returns Invalid Parameter when passed invalid format
+ EventLogFormat = EFI_TCG2_INVALID_EVENT_LOG_FORMAT;
+
+ Status = TCG2->GetEventLog (
+ TCG2,
+ EventLogFormat,
+ &EventLogLocation,
+ &EventLogLastEntry,
+ &EventLogTruncated);
+
+ if (EFI_INVALID_PARAMETER != Status) {
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ } else {
+ AssertionType = EFI_TEST_ASSERTION_PASSED;
+ }
+
+ StandardLib->RecordAssertion (
+ StandardLib,
+ AssertionType,
+ gTcg2ConformanceTestAssertionGuid013,
+ L"TCG2_PROTOCOL.GetEventLog - GetEventLog() should return EFI_INVALID_PARAMETER when passed in invalid EventLog Format",
+ L"%a:%d: Status - %r",
+ __FILE__,
+ (UINTN)__LINE__,
+ Status
+ );
+
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+BBTestGetEventLogConformanceTestCheckpoint2 (
+ IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib,
+ IN EFI_TCG2_PROTOCOL *TCG2
+ )
+{
+ EFI_TEST_ASSERTION AssertionType;
+ EFI_STATUS Status;
+ EFI_TCG2_EVENT_LOG_FORMAT EventLogFormat;
+ EFI_PHYSICAL_ADDRESS EventLogLocation;
+ EFI_PHYSICAL_ADDRESS EventLogLastEntry;
+ BOOLEAN EventLogTruncated;
+ TCG_PCR_EVENT *EventLogHeader;
+ TCG_EfiSpecIDEventStruct *EventLogHeaderSpecEvent;
+ TCG_PCR_EVENT2 *LastEvent;
+ // signature as defined in the EFI protocol spec: "Spec ID Event03"
+ UINT8 signature[] = {0x53, 0x70, 0x65, 0x63, 0x20, 0x49, 0x44, 0x20, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x30, 0x33, 0x00};
+
+ EventLogFormat = EFI_TCG2_EVENT_LOG_FORMAT_TCG_2;
+
+ // Call GetEventLog with valid EventLogFormat
+ Status = TCG2->GetEventLog (
+ TCG2,
+ EventLogFormat,
+ &EventLogLocation,
+ &EventLogLastEntry,
+ &EventLogTruncated);
+
+ AssertionType = EFI_TEST_ASSERTION_PASSED;
+
+ // Verify GetEventLog returns EFI_SUCCESS
+ if (Status != EFI_SUCCESS) {
+ StandardLib->RecordMessage (
+ StandardLib,
+ EFI_VERBOSE_LEVEL_DEFAULT,
+ L"\r\nTCG2 Protocol GetEventLog Test: GetEventLog should return EFI_SUCCESS with valid EventLogFormat, Status = %r",
+ Status
+ );
+
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+
+ }
+
+ StandardLib->RecordAssertion (
+ StandardLib,
+ AssertionType,
+ gTcg2ConformanceTestAssertionGuid014,
+ L"TCG2_PROTOCOL.GetEventLog - GetEventLog() should return EFI_SUCCESS",
+ L"%a:%d: Status - %r",
+ __FILE__,
+ (UINTN)__LINE__,
+ Status
+ );
+
+ // If GetEventLog doesn't return EFI_SUCCESS abort test
+ if (Status != EFI_SUCCESS) {
+ return Status;
+ }
+
+ EventLogHeader = (TCG_PCR_EVENT *) EventLogLocation;
+ EventLogHeaderSpecEvent = (TCG_EfiSpecIDEventStruct *) EventLogHeader->Event;
+
+ AssertionType = EFI_TEST_ASSERTION_PASSED;
+
+
+ // Verify valid eventlog header is returned
+ // Verify EventLogHeader PCR index == 0
+ if (EventLogHeader->PCRIndex != 0) {
+ StandardLib->RecordMessage (
+ StandardLib,
+ EFI_VERBOSE_LEVEL_DEFAULT,
+ L"\r\nTCG2 Protocol GetEventLog Test: EventLogHeader should have PCR index == 0"
+ );
+
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ }
+
+ // Verify EventLogHeader event type = EV_NO_ACTION
+ if (EventLogHeader->EventType != EV_NO_ACTION) {
+ StandardLib->RecordMessage (
+ StandardLib,
+ EFI_VERBOSE_LEVEL_DEFAULT,
+ L"\r\nTCG2 Protocol GetEventLog Test: EventLogHeader should be EventType == EV_NO_ACTION"
+ );
+
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ }
+
+ // Verify EventLog Signature
+ Status = SctCompareMem(EventLogHeaderSpecEvent->signature, signature, sizeof(signature));
+
+ if (Status != EFI_SUCCESS) {
+ StandardLib->RecordMessage (
+ StandardLib,
+ EFI_VERBOSE_LEVEL_DEFAULT,
+ L"\r\nTCG2 Protocol GetEventLog Test: EventLogHeader Signature did not match \'Spec ID Event03\'"
+ );
+
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ }
+
+ StandardLib->RecordAssertion (
+ StandardLib,
+ AssertionType,
+ gTcg2ConformanceTestAssertionGuid015,
+ L"TCG2_PROTOCOL.GetEventLog - GetEventLog() should return correct EventLogHeader",
+ L"%a:%d: Status - %r",
+ __FILE__,
+ (UINTN)__LINE__,
+ Status
+ );
+
+ // Verify that the event log created by HashLogExtendEvent in the
+ // BBTestHashLogExtendEventConformanceTestCheckpoint2 function
+ // is actually in Eventlog
+ LastEvent = (TCG_PCR_EVENT2 *) EventLogLastEntry;
+ Status = EFI_SUCCESS;
+
+ // Verify Last Event PCR = 16
+ if (LastEvent->PCRIndex != 16) {
+ StandardLib->RecordMessage (
+ StandardLib,
+ EFI_VERBOSE_LEVEL_DEFAULT,
+ L"\r\nTCG2 Protocol GetEventLog Test: PCR Index of Last event should be 16"
+ );
+
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ }
+
+ // Verify last event type = EV_POST_CODE
+ if (LastEvent->EventType != EV_POST_CODE) {
+ StandardLib->RecordMessage (
+ StandardLib,
+ EFI_VERBOSE_LEVEL_DEFAULT,
+ L"\r\nTCG2 Protocol GetEventLog Test: PCR Index of last event should be type EV_POST_CODE"
+ );
+
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ }
+
+ StandardLib->RecordAssertion (
+ StandardLib,
+ AssertionType,
+ gTcg2ConformanceTestAssertionGuid016,
+ L"TCG2_PROTOCOL.GetEventLog - verify that event log has expected entry from previous HashLogExtendEvent",
+ L"%a:%d: Status - %r",
+ __FILE__,
+ (UINTN)__LINE__,
+ Status
+ );
+
+ return EFI_SUCCESS;
+}
--
2.34.1
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#113491): https://edk2.groups.io/g/devel/message/113491
Mute This Topic: https://groups.io/mt/103625306/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-
^ permalink raw reply related [flat|nested] 26+ messages in thread
* Re: [edk2-devel] [PATCH v2 5/6] uefi-sct/SctPkg: TCG2 Protocol: add GetEventLog test
2024-01-09 18:20 ` [edk2-devel] [PATCH v2 5/6] uefi-sct/SctPkg: TCG2 Protocol: add GetEventLog test Stuart Yoder
@ 2024-03-05 15:49 ` G Edhaya Chandran
2024-03-18 20:44 ` Sunny Wang
2024-03-19 9:12 ` G Edhaya Chandran
2 siblings, 0 replies; 26+ messages in thread
From: G Edhaya Chandran @ 2024-03-05 15:49 UTC (permalink / raw)
To: Stuart Yoder, devel
[-- Attachment #1: Type: text/plain, Size: 424 bytes --]
Reviewed-by: G Edhaya Chandran <edhaya.chandran@arm.com>
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#116402): https://edk2.groups.io/g/devel/message/116402
Mute This Topic: https://groups.io/mt/103625306/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-
[-- Attachment #2: Type: text/html, Size: 842 bytes --]
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [edk2-devel] [PATCH v2 5/6] uefi-sct/SctPkg: TCG2 Protocol: add GetEventLog test
2024-01-09 18:20 ` [edk2-devel] [PATCH v2 5/6] uefi-sct/SctPkg: TCG2 Protocol: add GetEventLog test Stuart Yoder
2024-03-05 15:49 ` G Edhaya Chandran
@ 2024-03-18 20:44 ` Sunny Wang
2024-03-19 9:12 ` G Edhaya Chandran
2 siblings, 0 replies; 26+ messages in thread
From: Sunny Wang @ 2024-03-18 20:44 UTC (permalink / raw)
To: devel@edk2.groups.io, Stuart Yoder, G Edhaya Chandran,
gaojie@byosoft.com.cn
Cc: ilias.apalodimas@linaro.org, heinrich.schuchardt@canonical.com,
Samer El-Haj-Mahmoud, Jiewen.Yao@intel.com, Sunny Wang
Looks good to me.
For others' reference, the change has been already verified by running SystemReady SIE (Security Interface extension) tests on multiple SystemReady certified Arm systems.
Reviewed-by: Sunny Wang <sunny.wang@arm.com>
-----Original Message-----
From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Stuart Yoder via groups.io
Sent: Tuesday, January 9, 2024 12:21 PM
To: devel@edk2.groups.io; G Edhaya Chandran <Edhaya.Chandran@arm.com>; gaojie@byosoft.com.cn
Cc: ilias.apalodimas@linaro.org; heinrich.schuchardt@canonical.com; Samer El-Haj-Mahmoud <Samer.El-Haj-Mahmoud@arm.com>; Jiewen.Yao@intel.com
Subject: [edk2-devel] [PATCH v2 5/6] uefi-sct/SctPkg: TCG2 Protocol: add GetEventLog test
From: Joseph Hemann <joseph.hemann@arm.com>
-add test for GetEventLog()
-test for valid and invalid event log format
-test event log header
-verify expected event log entry
Signed-off-by: Joseph Hemann <Joseph.hemann@arm.com>
Signed-off-by: Stuart Yoder <stuart.yoder@arm.com>
---
uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.h | 20 ++
uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTest.h | 17 ++
uefi-sct/SctPkg/UEFI/Protocol/TCG2.h | 46 +++++
uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.c | 8 +
uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTestConformance.c | 207 +++++++++++++++++++-
5 files changed, 297 insertions(+), 1 deletion(-)
diff --git a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.h b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.h
index dcfd5919acda..746ff83f899c 100644
--- a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.h
+++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.h
@@ -85,3 +85,23 @@ extern EFI_GUID gTcg2ConformanceTestAssertionGuid011;
{ 0x9cd6d636, 0x603a, 0x4b78, {0x80, 0xa3, 0xa3, 0xb9, 0xcc, 0x6a, 0x0b, 0x08 }}
extern EFI_GUID gTcg2ConformanceTestAssertionGuid012;
+
+#define EFI_TEST_TCG2CONFORMANCE_ASSERTION_013_GUID \
+{ 0xfc80408e, 0x9a3c, 0x4054, {0x96, 0xf9, 0x31, 0x23, 0x35, 0xc2, 0x31, 0x35 }}
+
+extern EFI_GUID gTcg2ConformanceTestAssertionGuid013;
+
+#define EFI_TEST_TCG2CONFORMANCE_ASSERTION_014_GUID \
+{ 0x45fa1a42, 0x912a, 0x5124, {0x84, 0xf4, 0x41, 0x67, 0xab, 0xb5, 0x89, 0x90 }}
+
+extern EFI_GUID gTcg2ConformanceTestAssertionGuid014;
+
+#define EFI_TEST_TCG2CONFORMANCE_ASSERTION_015_GUID \
+{ 0x1689bc3a, 0x2298, 0xa116, {0x28, 0x4c, 0xc1, 0xdd, 0xaa, 0xd8, 0xef, 0x51 }}
+
+extern EFI_GUID gTcg2ConformanceTestAssertionGuid015;
+
+#define EFI_TEST_TCG2CONFORMANCE_ASSERTION_016_GUID \
+{ 0x126a789a, 0x1932, 0x3234, {0x21, 0xab, 0x42, 0x64, 0x8a, 0x7b, 0x63, 0x76 }}
+
+extern EFI_GUID gTcg2ConformanceTestAssertionGuid016;
diff --git a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTest.h b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTest.h
index cbbadef4a5c7..5ce275dc6258 100644
--- a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTest.h
+++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTest.h
@@ -43,8 +43,13 @@ Abstract:
#define EFI_TCG2_PROTOCOL_TEST_ENTRY_GUID0103 \
{0x907a7878, 0xb294, 0xf147, {0xe9, 0x0a, 0x65, 0x43, 0xab, 0x55, 0x76, 0x46} }
+#define EFI_TCG2_PROTOCOL_TEST_ENTRY_GUID0104 \
+ {0x9087ad78, 0x9ad2, 0x4172, {0x9a, 0xbc, 0x98, 0x23, 0x08, 0xf5, 0x6d, 0x26} }
+
#define EV_POST_CODE 0x01
+#define EV_NO_ACTION 0x03
+
#define EFI_TCG2_EXTEND_ONLY 0x0000000000000001
#define PE_COFF_IMAGE 0x0000000000000010
@@ -103,6 +108,18 @@ BBTestHashLogExtendEventConformanceTestCheckpoint2 (
IN EFI_TCG2_PROTOCOL *TCG2
);
+EFI_STATUS
+BBTestGetEventLogConformanceTestCheckpoint1 (
+ IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib,
+ IN EFI_TCG2_PROTOCOL *TCG2
+ );
+
+EFI_STATUS
+BBTestGetEventLogConformanceTestCheckpoint2 (
+ IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib,
+ IN EFI_TCG2_PROTOCOL *TCG2
+ );
+
EFI_STATUS
BBTestGetCapabilityConformanceTest (
IN EFI_BB_TEST_PROTOCOL *This,
diff --git a/uefi-sct/SctPkg/UEFI/Protocol/TCG2.h b/uefi-sct/SctPkg/UEFI/Protocol/TCG2.h
index e62ecd85cbe9..fd31204a9299 100644
--- a/uefi-sct/SctPkg/UEFI/Protocol/TCG2.h
+++ b/uefi-sct/SctPkg/UEFI/Protocol/TCG2.h
@@ -50,6 +50,8 @@ Abstract:
#define EFI_TCG2_EVENT_LOG_FORMAT_TCG_2 0x00000002
+#define HASH_NUMBER 0x04
+
typedef struct _EFI_TCG2_PROTOCOL EFI_TCG2_PROTOCOL;
typedef UINT32 EFI_TCG2_EVENT_LOG_BITMAP;
@@ -115,6 +117,50 @@ typedef struct tdEFI_TCG2_EVENT {
UINT8 Event[];
} EFI_TCG2_EVENT;
+typedef struct {
+ UINT16 hashAlg;
+ UINT8 digest[];
+} TPMT_HA;
+
+typedef struct tdTPML_DIGEST_VALUES {
+ UINT32 Count; // number of digests
+ TPMT_HA Digests[HASH_NUMBER]; // Count digests
+} TPML_DIGEST_VALUES;
+
+// This Declaration is for parsing the eventlog header which is defined to be 20 bytes in TCG EFI Protocol Spec
+typedef UINT8 TCG_DIGEST[20];
+
+typedef struct tdTCG_PCR_EVENT2 {
+ TCG_PCRINDEX PCRIndex; // PCRIndex event extended to
+ TCG_EVENTTYPE EventType; // Type of event (see [2])
+ TPML_DIGEST_VALUES Digests; // List of digests extended to //PCRIndex
+ UINT32 EventSize; // Size of the event data
+ UINT8 *Event; // The event data
+} TCG_PCR_EVENT2;
+
+typedef struct tdTCG_PCR_EVENT {
+ UINT32 PCRIndex; // PCRIndex event extended to
+ UINT32 EventType; // Type of event (see EFI specs)
+ TCG_DIGEST Digest; // Value extended into PCRIndex
+ UINT32 EventSize; // Size of the event data
+ UINT8 Event[0]; // The event data
+} TCG_PCR_EVENT;
+// Structure to be added to the Event Log
+
+typedef struct tdTCG_EfiSpecIdEventAlgorithmSize {
+ UINT16 algorithmId;
+ UINT16 digestSize;
+} TCG_EfiSpecIdEventAlgorithmSize;
+
+typedef struct tdTCG_EfiSpecIdEventStruct {
+ UINT8 signature[16];
+ UINT32 platformClass;
+ UINT8 specVersionMinor;
+ UINT8 specVersionMajor;
+ UINT8 specErrata;
+ UINT8 uintnSize;
+} TCG_EfiSpecIDEventStruct;
+
#pragma pack()
typedef
diff --git a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.c b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.c
index ccc20259d128..8c528aa8ddfc 100644
--- a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.c
+++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.c
@@ -51,3 +51,11 @@ EFI_GUID gTcg2ConformanceTestAssertionGuid010 = EFI_TEST_TCG2CONFORMANCE_ASSERTI
EFI_GUID gTcg2ConformanceTestAssertionGuid011 = EFI_TEST_TCG2CONFORMANCE_ASSERTION_011_GUID;
EFI_GUID gTcg2ConformanceTestAssertionGuid012 = EFI_TEST_TCG2CONFORMANCE_ASSERTION_012_GUID;
+
+EFI_GUID gTcg2ConformanceTestAssertionGuid013 = EFI_TEST_TCG2CONFORMANCE_ASSERTION_013_GUID;
+
+EFI_GUID gTcg2ConformanceTestAssertionGuid014 = EFI_TEST_TCG2CONFORMANCE_ASSERTION_014_GUID;
+
+EFI_GUID gTcg2ConformanceTestAssertionGuid015 = EFI_TEST_TCG2CONFORMANCE_ASSERTION_015_GUID;
+
+EFI_GUID gTcg2ConformanceTestAssertionGuid016 = EFI_TEST_TCG2CONFORMANCE_ASSERTION_016_GUID;
diff --git a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTestConformance.c b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTestConformance.c
index 2768eef725e8..ebe04d42aff5 100644
--- a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTestConformance.c
+++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTestConformance.c
@@ -142,7 +142,7 @@ BBTestGetActivePcrBanksConformanceTest (
/**
* @brief Entrypoint for HashLogExtendEvent() Function Test.
- * 2 checkpoints will be tested.
+ * 4 checkpoints will be tested.
* @param This a pointer of EFI_BB_TEST_PROTOCOL
* @param ClientInterface A pointer to the interface array under test
* @param TestLevel Test "thoroughness" control
@@ -188,6 +188,12 @@ BBTestHashLogExtendEventConformanceTest (
// Test HashLogExtendEvent with valid arguments
BBTestHashLogExtendEventConformanceTestCheckpoint2 (StandardLib, TCG2);
+ // Test GetEventLog using invalid EventLog Format
+ BBTestGetEventLogConformanceTestCheckpoint1 (StandardLib, TCG2);
+
+ // Test GetEventLog using valid EventLog Format
+ BBTestGetEventLogConformanceTestCheckpoint2 (StandardLib, TCG2);
+
return EFI_SUCCESS;
}
@@ -801,3 +807,202 @@ BBTestHashLogExtendEventConformanceTestCheckpoint2 (
return EFI_SUCCESS;
}
+
+#define EFI_TCG2_INVALID_EVENT_LOG_FORMAT 0x20
+
+EFI_STATUS
+BBTestGetEventLogConformanceTestCheckpoint1 (
+ IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib,
+ IN EFI_TCG2_PROTOCOL *TCG2
+ )
+{
+ EFI_TEST_ASSERTION AssertionType;
+ EFI_STATUS Status;
+ EFI_TCG2_EVENT_LOG_FORMAT EventLogFormat;
+ EFI_PHYSICAL_ADDRESS EventLogLocation;
+ EFI_PHYSICAL_ADDRESS EventLogLastEntry;
+ BOOLEAN EventLogTruncated;
+
+ // Ensure Get EventLog returns Invalid Parameter when passed invalid format
+ EventLogFormat = EFI_TCG2_INVALID_EVENT_LOG_FORMAT;
+
+ Status = TCG2->GetEventLog (
+ TCG2,
+ EventLogFormat,
+ &EventLogLocation,
+ &EventLogLastEntry,
+ &EventLogTruncated);
+
+ if (EFI_INVALID_PARAMETER != Status) {
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ } else {
+ AssertionType = EFI_TEST_ASSERTION_PASSED;
+ }
+
+ StandardLib->RecordAssertion (
+ StandardLib,
+ AssertionType,
+ gTcg2ConformanceTestAssertionGuid013,
+ L"TCG2_PROTOCOL.GetEventLog - GetEventLog() should return EFI_INVALID_PARAMETER when passed in invalid EventLog Format",
+ L"%a:%d: Status - %r",
+ __FILE__,
+ (UINTN)__LINE__,
+ Status
+ );
+
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+BBTestGetEventLogConformanceTestCheckpoint2 (
+ IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib,
+ IN EFI_TCG2_PROTOCOL *TCG2
+ )
+{
+ EFI_TEST_ASSERTION AssertionType;
+ EFI_STATUS Status;
+ EFI_TCG2_EVENT_LOG_FORMAT EventLogFormat;
+ EFI_PHYSICAL_ADDRESS EventLogLocation;
+ EFI_PHYSICAL_ADDRESS EventLogLastEntry;
+ BOOLEAN EventLogTruncated;
+ TCG_PCR_EVENT *EventLogHeader;
+ TCG_EfiSpecIDEventStruct *EventLogHeaderSpecEvent;
+ TCG_PCR_EVENT2 *LastEvent;
+ // signature as defined in the EFI protocol spec: "Spec ID Event03"
+ UINT8 signature[] = {0x53, 0x70, 0x65, 0x63, 0x20, 0x49, 0x44, 0x20, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x30, 0x33, 0x00};
+
+ EventLogFormat = EFI_TCG2_EVENT_LOG_FORMAT_TCG_2;
+
+ // Call GetEventLog with valid EventLogFormat
+ Status = TCG2->GetEventLog (
+ TCG2,
+ EventLogFormat,
+ &EventLogLocation,
+ &EventLogLastEntry,
+ &EventLogTruncated);
+
+ AssertionType = EFI_TEST_ASSERTION_PASSED;
+
+ // Verify GetEventLog returns EFI_SUCCESS
+ if (Status != EFI_SUCCESS) {
+ StandardLib->RecordMessage (
+ StandardLib,
+ EFI_VERBOSE_LEVEL_DEFAULT,
+ L"\r\nTCG2 Protocol GetEventLog Test: GetEventLog should return EFI_SUCCESS with valid EventLogFormat, Status = %r",
+ Status
+ );
+
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+
+ }
+
+ StandardLib->RecordAssertion (
+ StandardLib,
+ AssertionType,
+ gTcg2ConformanceTestAssertionGuid014,
+ L"TCG2_PROTOCOL.GetEventLog - GetEventLog() should return EFI_SUCCESS",
+ L"%a:%d: Status - %r",
+ __FILE__,
+ (UINTN)__LINE__,
+ Status
+ );
+
+ // If GetEventLog doesn't return EFI_SUCCESS abort test
+ if (Status != EFI_SUCCESS) {
+ return Status;
+ }
+
+ EventLogHeader = (TCG_PCR_EVENT *) EventLogLocation;
+ EventLogHeaderSpecEvent = (TCG_EfiSpecIDEventStruct *) EventLogHeader->Event;
+
+ AssertionType = EFI_TEST_ASSERTION_PASSED;
+
+
+ // Verify valid eventlog header is returned
+ // Verify EventLogHeader PCR index == 0
+ if (EventLogHeader->PCRIndex != 0) {
+ StandardLib->RecordMessage (
+ StandardLib,
+ EFI_VERBOSE_LEVEL_DEFAULT,
+ L"\r\nTCG2 Protocol GetEventLog Test: EventLogHeader should have PCR index == 0"
+ );
+
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ }
+
+ // Verify EventLogHeader event type = EV_NO_ACTION
+ if (EventLogHeader->EventType != EV_NO_ACTION) {
+ StandardLib->RecordMessage (
+ StandardLib,
+ EFI_VERBOSE_LEVEL_DEFAULT,
+ L"\r\nTCG2 Protocol GetEventLog Test: EventLogHeader should be EventType == EV_NO_ACTION"
+ );
+
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ }
+
+ // Verify EventLog Signature
+ Status = SctCompareMem(EventLogHeaderSpecEvent->signature, signature, sizeof(signature));
+
+ if (Status != EFI_SUCCESS) {
+ StandardLib->RecordMessage (
+ StandardLib,
+ EFI_VERBOSE_LEVEL_DEFAULT,
+ L"\r\nTCG2 Protocol GetEventLog Test: EventLogHeader Signature did not match \'Spec ID Event03\'"
+ );
+
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ }
+
+ StandardLib->RecordAssertion (
+ StandardLib,
+ AssertionType,
+ gTcg2ConformanceTestAssertionGuid015,
+ L"TCG2_PROTOCOL.GetEventLog - GetEventLog() should return correct EventLogHeader",
+ L"%a:%d: Status - %r",
+ __FILE__,
+ (UINTN)__LINE__,
+ Status
+ );
+
+ // Verify that the event log created by HashLogExtendEvent in the
+ // BBTestHashLogExtendEventConformanceTestCheckpoint2 function
+ // is actually in Eventlog
+ LastEvent = (TCG_PCR_EVENT2 *) EventLogLastEntry;
+ Status = EFI_SUCCESS;
+
+ // Verify Last Event PCR = 16
+ if (LastEvent->PCRIndex != 16) {
+ StandardLib->RecordMessage (
+ StandardLib,
+ EFI_VERBOSE_LEVEL_DEFAULT,
+ L"\r\nTCG2 Protocol GetEventLog Test: PCR Index of Last event should be 16"
+ );
+
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ }
+
+ // Verify last event type = EV_POST_CODE
+ if (LastEvent->EventType != EV_POST_CODE) {
+ StandardLib->RecordMessage (
+ StandardLib,
+ EFI_VERBOSE_LEVEL_DEFAULT,
+ L"\r\nTCG2 Protocol GetEventLog Test: PCR Index of last event should be type EV_POST_CODE"
+ );
+
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ }
+
+ StandardLib->RecordAssertion (
+ StandardLib,
+ AssertionType,
+ gTcg2ConformanceTestAssertionGuid016,
+ L"TCG2_PROTOCOL.GetEventLog - verify that event log has expected entry from previous HashLogExtendEvent",
+ L"%a:%d: Status - %r",
+ __FILE__,
+ (UINTN)__LINE__,
+ Status
+ );
+
+ return EFI_SUCCESS;
+}
--
2.34.1
-=-=-=-=-=-=
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#113491): https://edk2.groups.io/g/devel/message/113491
Mute This Topic: https://groups.io/mt/103625306/5985097
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [Sunny.Wang@arm.com]
-=-=-=-=-=-=
IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#116849): https://edk2.groups.io/g/devel/message/116849
Mute This Topic: https://groups.io/mt/103625306/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-
^ permalink raw reply related [flat|nested] 26+ messages in thread
* Re: [edk2-devel] [PATCH v2 5/6] uefi-sct/SctPkg: TCG2 Protocol: add GetEventLog test
2024-01-09 18:20 ` [edk2-devel] [PATCH v2 5/6] uefi-sct/SctPkg: TCG2 Protocol: add GetEventLog test Stuart Yoder
2024-03-05 15:49 ` G Edhaya Chandran
2024-03-18 20:44 ` Sunny Wang
@ 2024-03-19 9:12 ` G Edhaya Chandran
2 siblings, 0 replies; 26+ messages in thread
From: G Edhaya Chandran @ 2024-03-19 9:12 UTC (permalink / raw)
To: Stuart Yoder, devel
[-- Attachment #1: Type: text/plain, Size: 494 bytes --]
The patch is upstreamed by the commit:
https://github.com/tianocore/edk2-test/commit/7ec35ffac51d0682c1368041ca1e599189a58223
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#116884): https://edk2.groups.io/g/devel/message/116884
Mute This Topic: https://groups.io/mt/103625306/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-
[-- Attachment #2: Type: text/html, Size: 910 bytes --]
^ permalink raw reply [flat|nested] 26+ messages in thread
* [edk2-devel] [PATCH v2 6/6] uefi-sct/SctPkg: TCG2 Protocol: add SubmitCommand test
2024-01-09 18:20 [edk2-devel] [PATCH v2 0/6] Tests for TCG2 Protocol Stuart Yoder
` (4 preceding siblings ...)
2024-01-09 18:20 ` [edk2-devel] [PATCH v2 5/6] uefi-sct/SctPkg: TCG2 Protocol: add GetEventLog test Stuart Yoder
@ 2024-01-09 18:20 ` Stuart Yoder
2024-03-05 15:49 ` G Edhaya Chandran
` (2 more replies)
2024-03-05 15:46 ` [edk2-devel] [PATCH v2 0/6] Tests for TCG2 Protocol G Edhaya Chandran
6 siblings, 3 replies; 26+ messages in thread
From: Stuart Yoder @ 2024-01-09 18:20 UTC (permalink / raw)
To: devel, Edhaya.Chandran, gaojie
Cc: ilias.apalodimas, heinrich.schuchardt, Samer.El-Haj-Mahmoud,
Jiewen.Yao
From: Joseph Hemann <Joseph.hemann@arm.com>
Add test verifying the functionality of the SubmitCommand function
using the TPM command TPM2_HASH_COMMAND.
Signed-off-by: Joseph Hemann <Joseph.hemann@arm.com>
Signed-off-by: Stuart Yoder <stuart.yoder@arm.com>
---
uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.h | 5 +
uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTest.h | 71 ++++++++
uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.c | 2 +
uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTestConformance.c | 173 ++++++++++++++++++++
uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTestMain.c | 9 +
5 files changed, 260 insertions(+)
diff --git a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.h b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.h
index 746ff83f899c..044e549ce8f0 100644
--- a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.h
+++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.h
@@ -105,3 +105,8 @@ extern EFI_GUID gTcg2ConformanceTestAssertionGuid015;
{ 0x126a789a, 0x1932, 0x3234, {0x21, 0xab, 0x42, 0x64, 0x8a, 0x7b, 0x63, 0x76 }}
extern EFI_GUID gTcg2ConformanceTestAssertionGuid016;
+
+#define EFI_TEST_TCG2CONFORMANCE_ASSERTION_017_GUID \
+{ 0x3aac8b9a, 0x312a, 0x4dcf, {0x12, 0x76, 0x54, 0x55, 0x32, 0xcd, 0x3a, 0xea }}
+
+extern EFI_GUID gTcg2ConformanceTestAssertionGuid017;
diff --git a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTest.h b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTest.h
index 5ce275dc6258..f8880599f150 100644
--- a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTest.h
+++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTest.h
@@ -54,6 +54,64 @@ Abstract:
#define PE_COFF_IMAGE 0x0000000000000010
+// ST_NO_SESSION as defined in Table 19 of TPM Library Part 2: Structures
+#define ST_NO_SESSIONS (UINT16) 0x8001
+
+// TPM_RC_SUCCESS as defined in Table 16 of TPM Library Spec Part 2: Structures
+#define TPM_RC_SUCCESS (UINT32) 0x0000000
+
+// TPM_CC_Hash as defined in Table 12 of TPM Library Spec Part 2: Structures
+#define TPM_CC_Hash (UINT32)(0x0000017D)
+
+#define TPM_RH_NULL (UINT32) 0x40000007
+
+#define TPM_ALG_SHA256 (UINT16) 0x000B
+
+#define SHA256_LENGTH (UINT16) 0x0020
+
+#pragma pack(1)
+// TPM2B_MAX_BUFFER as defined in Table 86 of TPM Library Spec Part 2: Structures
+// Size of buffer in spec is variable length, but hash test will always use a fixed length string
+// of length 43
+#define TEST_STRING_LEN 43
+typedef struct {
+ UINT16 size;
+ UINT8 buffer[TEST_STRING_LEN];
+} TPM2B_MAX_BUFFER;
+
+#pragma pack(1)
+// TPM2B_DIGEST as defined in Table 73 of TPM Library Spec Part 2: Structures
+typedef struct {
+ UINT16 size;
+ UINT8 digest[32]; // Size of buffer in spec is defined to be variable length but for this test will always be 32
+} TPM2B_DIGEST;
+
+typedef struct {
+ UINT16 tag;
+ UINT32 hierarchy;
+ UINT16 digest; // Size of buffer in spec is defined to be variable length but for this test will always be UINT16
+} TPMT_TK_HASHCHECK;
+
+// TPM2_Hash command Structure as defined in Section 15.4 of TPM Spec Part 3: Commands
+typedef struct {
+ UINT16 Tag;
+ UINT32 CommandSize;
+ UINT32 CommandCode;
+ TPM2B_MAX_BUFFER data;
+ UINT16 hashAlg;
+ UINT32 hierarchy;
+} TPM2_HASH_COMMAND;
+
+// TPM2_Hash Response Structure as defined in Section 15.4 of TPM Spec Part 3: Commands
+typedef struct {
+ UINT16 Tag;
+ UINT32 ResponseSize;
+ UINT32 ResponseCode;
+ TPM2B_DIGEST data;
+ TPMT_TK_HASHCHECK validation;
+} TPM2_HASH_RESPONSE;
+#pragma
+
EFI_STATUS
EFIAPI
BBTestTCG2ProtocolUnload (
@@ -120,6 +178,12 @@ BBTestGetEventLogConformanceTestCheckpoint2 (
IN EFI_TCG2_PROTOCOL *TCG2
);
+EFI_STATUS
+BBTestSubmitCommandConformanceTestCheckpoint1 (
+ IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib,
+ IN EFI_TCG2_PROTOCOL *TCG2
+ );
+
EFI_STATUS
BBTestGetCapabilityConformanceTest (
IN EFI_BB_TEST_PROTOCOL *This,
@@ -144,3 +208,10 @@ BBTestHashLogExtendEventConformanceTest (
IN EFI_HANDLE SupportHandle
);
+EFI_STATUS
+BBTestSubmitCommandConformanceTest (
+ IN EFI_BB_TEST_PROTOCOL *This,
+ IN VOID *ClientInterface,
+ IN EFI_TEST_LEVEL TestLevel,
+ IN EFI_HANDLE SupportHandle
+ );
diff --git a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.c b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.c
index 8c528aa8ddfc..9aa5315e670e 100644
--- a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.c
+++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.c
@@ -59,3 +59,5 @@ EFI_GUID gTcg2ConformanceTestAssertionGuid014 = EFI_TEST_TCG2CONFORMANCE_ASSERTI
EFI_GUID gTcg2ConformanceTestAssertionGuid015 = EFI_TEST_TCG2CONFORMANCE_ASSERTION_015_GUID;
EFI_GUID gTcg2ConformanceTestAssertionGuid016 = EFI_TEST_TCG2CONFORMANCE_ASSERTION_016_GUID;
+
+EFI_GUID gTcg2ConformanceTestAssertionGuid017 = EFI_TEST_TCG2CONFORMANCE_ASSERTION_017_GUID;
diff --git a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTestConformance.c b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTestConformance.c
index ebe04d42aff5..5abf8e7934cf 100644
--- a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTestConformance.c
+++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTestConformance.c
@@ -197,6 +197,56 @@ BBTestHashLogExtendEventConformanceTest (
return EFI_SUCCESS;
}
+/**
+ * @brief Entrypoint for SubmitCommand() Function Test.
+ * 1 checkpoint will be tested.
+ * @param This a pointer of EFI_BB_TEST_PROTOCOL
+ * @param ClientInterface A pointer to the interface array under test
+ * @param TestLevel Test "thoroughness" control
+ * @param SupportHandle A handle containing protocols required
+ * @return EFI_SUCCESS
+ * @return EFI_NOT_FOUND
+ */
+
+EFI_STATUS
+BBTestSubmitCommandConformanceTest (
+ IN EFI_BB_TEST_PROTOCOL *This,
+ IN VOID *ClientInterface,
+ IN EFI_TEST_LEVEL TestLevel,
+ IN EFI_HANDLE SupportHandle
+ )
+{
+ EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib;
+ EFI_STATUS Status;
+ EFI_TCG2_PROTOCOL *TCG2;
+
+ //
+ // init
+ //
+ TCG2 = (EFI_TCG2_PROTOCOL*)ClientInterface;
+
+ // Ensure Protocol not NULL
+ if (TCG2 == NULL)
+ return EFI_UNSUPPORTED;
+
+ //
+ // Get the Standard Library Interface
+ //
+ Status = gtBS->HandleProtocol (
+ SupportHandle,
+ &gEfiStandardTestLibraryGuid,
+ (VOID **) &StandardLib
+ );
+ if (EFI_ERROR(Status)) {
+ return Status;
+ }
+
+ // Test GetRandom TPM Command
+ BBTestSubmitCommandConformanceTestCheckpoint1 (StandardLib, TCG2);
+
+ return EFI_SUCCESS;
+}
+
EFI_STATUS
BBTestGetCapabilityConformanceTestCheckpoint1 (
IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib,
@@ -1006,3 +1056,126 @@ BBTestGetEventLogConformanceTestCheckpoint2 (
return EFI_SUCCESS;
}
+
+// Expected SHA256 Hash of the string "The quick brown fox jumps over the lazy dog"
+UINT8 Tpm2HashOut[32] = {0xd7,0xa8,0xfb,0xb3,0x07,0xd7,0x80,0x94,0x69,0xca,0x9a,0xbc,0xb0,0x08,0x2e,0x4f, \
+0x8d,0x56,0x51,0xe4,0x6d,0x3c,0xdb,0x76,0x2d,0x02,0xd0,0xbf,0x37,0xc9,0xe5,0x92};
+
+EFI_STATUS
+BBTestSubmitCommandConformanceTestCheckpoint1 (
+ IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib,
+ IN EFI_TCG2_PROTOCOL *TCG2
+ )
+{
+ EFI_TEST_ASSERTION AssertionType;
+ EFI_STATUS Status;
+ TPM2_HASH_RESPONSE CommandResponse;
+ TPM2_HASH_COMMAND CommandInput;
+ CHAR8 *Str ="The quick brown fox jumps over the lazy dog";
+
+ // Build TPM2 Hash command to hash test string
+ CommandInput.Tag = SctSwapBytes16(ST_NO_SESSIONS);
+ CommandInput.CommandSize = SctSwapBytes32(sizeof(TPM2_HASH_COMMAND));
+ CommandInput.CommandCode = SctSwapBytes32(TPM_CC_Hash);
+ CommandInput.data.size = SctSwapBytes16(SctAsciiStrLen(Str));
+ SctAsciiStrCpy((CHAR8 *)CommandInput.data.buffer, Str);
+ CommandInput.hashAlg = SctSwapBytes16(TPM_ALG_SHA256);
+ CommandInput.hierarchy = SctSwapBytes32(TPM_RH_NULL);
+
+ // allocate buffer for response
+ SctZeroMem(&CommandResponse, sizeof(TPM2_HASH_RESPONSE));
+
+ Status = TCG2->SubmitCommand (
+ TCG2,
+ sizeof(TPM2_HASH_COMMAND),
+ (UINT8 *)&CommandInput,
+ sizeof(TPM2_HASH_RESPONSE),
+ (UINT8 *)&CommandResponse);
+
+
+ AssertionType = EFI_TEST_ASSERTION_PASSED;
+
+ // Verify SubmitCommand returns EFI_SUCCESS
+ if (Status != EFI_SUCCESS) {
+ StandardLib->RecordMessage (
+ StandardLib,
+ EFI_VERBOSE_LEVEL_DEFAULT,
+ L"\r\nTCG2 Protocol SubmitCommand Test: SubmitCommand should return EFI_SUCCESS, Status = %r",
+ Status
+ );
+
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ }
+
+ // Verify SubmitCommand returns correct Response Tag
+ if (SctSwapBytes16(CommandResponse.Tag) != ST_NO_SESSIONS) {
+ StandardLib->RecordMessage (
+ StandardLib,
+ EFI_VERBOSE_LEVEL_DEFAULT,
+ L"\r\nTCG2 Protocol SubmitCommand Test: SubmitCommand should return ST_NO_SESSIONS response Tag"
+ );
+
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ }
+
+ // Verify SubmitCommand returns correct Response Code
+ if (SctSwapBytes32(CommandResponse.ResponseCode) != TPM_RC_SUCCESS) {
+ StandardLib->RecordMessage (
+ StandardLib,
+ EFI_VERBOSE_LEVEL_DEFAULT,
+ L"\r\nTCG2 Protocol SubmitCommand Test: SubmitCommand should return Correct ResponseCode, ResponseCode = %x",
+ SctSwapBytes32(CommandResponse.ResponseCode)
+ );
+
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ }
+
+
+ // Verify SubmitCommand returns correct Response Size
+ if (SctSwapBytes32(CommandResponse.ResponseSize) != sizeof(TPM2_HASH_RESPONSE)) {
+ StandardLib->RecordMessage (
+ StandardLib,
+ EFI_VERBOSE_LEVEL_DEFAULT,
+ L"\r\nTCG2 Protocol SubmitCommand Test: SubmitCommand should return Correct ResponseSize, Size = %x",
+ SctSwapBytes32(CommandResponse.ResponseSize)
+ );
+
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ }
+
+ // Check that the size of the buffer returned is size of SHA256 hash
+ if (SctSwapBytes16(CommandResponse.data.size) != 32) {
+ StandardLib->RecordMessage (
+ StandardLib,
+ EFI_VERBOSE_LEVEL_DEFAULT,
+ L"\r\nTCG2 Protocol SubmitCommand Test: SubmitCommand should return correct size digest for SHA256, Size = %x",
+ SctSwapBytes16(CommandResponse.data.size)
+ );
+
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ }
+
+ // Ensure Hash returned matches expected response for input
+ if (0 != SctCompareMem(Tpm2HashOut, CommandResponse.data.digest, SHA256_LENGTH) ) {
+ StandardLib->RecordMessage (
+ StandardLib,
+ EFI_VERBOSE_LEVEL_DEFAULT,
+ L"\r\nTCG2 Protocol SubmitCommand Test: SubmitCommand should return expected Hash for data that was hashed."
+ );
+
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ }
+
+ StandardLib->RecordAssertion (
+ StandardLib,
+ AssertionType,
+ gTcg2ConformanceTestAssertionGuid017,
+ L"EFI_TCG2_PROTOCOL. SubmitComand() - SubmitCommand() shall populate the response buffer and return with a status of EFI_SUCCESS when valid command parameters are passed in.",
+ L"%a:%d: Status - %r",
+ __FILE__,
+ (UINTN)__LINE__,
+ Status
+ );
+
+ return EFI_SUCCESS;
+}
diff --git a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTestMain.c b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTestMain.c
index f7b9e487eda2..25c3eab2cccd 100644
--- a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTestMain.c
+++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTestMain.c
@@ -65,6 +65,15 @@ EFI_BB_TEST_ENTRY_FIELD gBBTestEntryField[] = {
EFI_TEST_CASE_AUTO,
BBTestHashLogExtendEventConformanceTest
},
+ {
+ EFI_TCG2_PROTOCOL_TEST_ENTRY_GUID0104,
+ L"SubmitCommand_Conf",
+ L"Test the SubmitCommmand API",
+ EFI_TEST_LEVEL_DEFAULT,
+ gSupportProtocolGuid1,
+ EFI_TEST_CASE_AUTO,
+ BBTestSubmitCommandConformanceTest
+ },
0
};
--
2.34.1
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#113492): https://edk2.groups.io/g/devel/message/113492
Mute This Topic: https://groups.io/mt/103625307/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-
^ permalink raw reply related [flat|nested] 26+ messages in thread
* Re: [edk2-devel] [PATCH v2 6/6] uefi-sct/SctPkg: TCG2 Protocol: add SubmitCommand test
2024-01-09 18:20 ` [edk2-devel] [PATCH v2 6/6] uefi-sct/SctPkg: TCG2 Protocol: add SubmitCommand test Stuart Yoder
@ 2024-03-05 15:49 ` G Edhaya Chandran
2024-03-18 20:44 ` Sunny Wang
2024-03-19 9:11 ` G Edhaya Chandran
2 siblings, 0 replies; 26+ messages in thread
From: G Edhaya Chandran @ 2024-03-05 15:49 UTC (permalink / raw)
To: Stuart Yoder, devel
[-- Attachment #1: Type: text/plain, Size: 424 bytes --]
Reviewed-by: G Edhaya Chandran <edhaya.chandran@arm.com>
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#116403): https://edk2.groups.io/g/devel/message/116403
Mute This Topic: https://groups.io/mt/103625307/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-
[-- Attachment #2: Type: text/html, Size: 842 bytes --]
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [edk2-devel] [PATCH v2 6/6] uefi-sct/SctPkg: TCG2 Protocol: add SubmitCommand test
2024-01-09 18:20 ` [edk2-devel] [PATCH v2 6/6] uefi-sct/SctPkg: TCG2 Protocol: add SubmitCommand test Stuart Yoder
2024-03-05 15:49 ` G Edhaya Chandran
@ 2024-03-18 20:44 ` Sunny Wang
2024-03-19 9:11 ` G Edhaya Chandran
2 siblings, 0 replies; 26+ messages in thread
From: Sunny Wang @ 2024-03-18 20:44 UTC (permalink / raw)
To: devel@edk2.groups.io, Stuart Yoder, G Edhaya Chandran,
gaojie@byosoft.com.cn
Cc: ilias.apalodimas@linaro.org, heinrich.schuchardt@canonical.com,
Samer El-Haj-Mahmoud, Jiewen.Yao@intel.com, Sunny Wang
Looks good to me.
For others' reference, the change has been already verified by running SystemReady SIE (Security Interface extension) tests on multiple SystemReady certified Arm systems.
Reviewed-by: Sunny Wang <sunny.wang@arm.com>
-----Original Message-----
From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Stuart Yoder via groups.io
Sent: Tuesday, January 9, 2024 12:21 PM
To: devel@edk2.groups.io; G Edhaya Chandran <Edhaya.Chandran@arm.com>; gaojie@byosoft.com.cn
Cc: ilias.apalodimas@linaro.org; heinrich.schuchardt@canonical.com; Samer El-Haj-Mahmoud <Samer.El-Haj-Mahmoud@arm.com>; Jiewen.Yao@intel.com
Subject: [edk2-devel] [PATCH v2 6/6] uefi-sct/SctPkg: TCG2 Protocol: add SubmitCommand test
From: Joseph Hemann <Joseph.hemann@arm.com>
Add test verifying the functionality of the SubmitCommand function
using the TPM command TPM2_HASH_COMMAND.
Signed-off-by: Joseph Hemann <Joseph.hemann@arm.com>
Signed-off-by: Stuart Yoder <stuart.yoder@arm.com>
---
uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.h | 5 +
uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTest.h | 71 ++++++++
uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.c | 2 +
uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTestConformance.c | 173 ++++++++++++++++++++
uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTestMain.c | 9 +
5 files changed, 260 insertions(+)
diff --git a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.h b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.h
index 746ff83f899c..044e549ce8f0 100644
--- a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.h
+++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.h
@@ -105,3 +105,8 @@ extern EFI_GUID gTcg2ConformanceTestAssertionGuid015;
{ 0x126a789a, 0x1932, 0x3234, {0x21, 0xab, 0x42, 0x64, 0x8a, 0x7b, 0x63, 0x76 }}
extern EFI_GUID gTcg2ConformanceTestAssertionGuid016;
+
+#define EFI_TEST_TCG2CONFORMANCE_ASSERTION_017_GUID \
+{ 0x3aac8b9a, 0x312a, 0x4dcf, {0x12, 0x76, 0x54, 0x55, 0x32, 0xcd, 0x3a, 0xea }}
+
+extern EFI_GUID gTcg2ConformanceTestAssertionGuid017;
diff --git a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTest.h b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTest.h
index 5ce275dc6258..f8880599f150 100644
--- a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTest.h
+++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTest.h
@@ -54,6 +54,64 @@ Abstract:
#define PE_COFF_IMAGE 0x0000000000000010
+// ST_NO_SESSION as defined in Table 19 of TPM Library Part 2: Structures
+#define ST_NO_SESSIONS (UINT16) 0x8001
+
+// TPM_RC_SUCCESS as defined in Table 16 of TPM Library Spec Part 2: Structures
+#define TPM_RC_SUCCESS (UINT32) 0x0000000
+
+// TPM_CC_Hash as defined in Table 12 of TPM Library Spec Part 2: Structures
+#define TPM_CC_Hash (UINT32)(0x0000017D)
+
+#define TPM_RH_NULL (UINT32) 0x40000007
+
+#define TPM_ALG_SHA256 (UINT16) 0x000B
+
+#define SHA256_LENGTH (UINT16) 0x0020
+
+#pragma pack(1)
+// TPM2B_MAX_BUFFER as defined in Table 86 of TPM Library Spec Part 2: Structures
+// Size of buffer in spec is variable length, but hash test will always use a fixed length string
+// of length 43
+#define TEST_STRING_LEN 43
+typedef struct {
+ UINT16 size;
+ UINT8 buffer[TEST_STRING_LEN];
+} TPM2B_MAX_BUFFER;
+
+#pragma pack(1)
+// TPM2B_DIGEST as defined in Table 73 of TPM Library Spec Part 2: Structures
+typedef struct {
+ UINT16 size;
+ UINT8 digest[32]; // Size of buffer in spec is defined to be variable length but for this test will always be 32
+} TPM2B_DIGEST;
+
+typedef struct {
+ UINT16 tag;
+ UINT32 hierarchy;
+ UINT16 digest; // Size of buffer in spec is defined to be variable length but for this test will always be UINT16
+} TPMT_TK_HASHCHECK;
+
+// TPM2_Hash command Structure as defined in Section 15.4 of TPM Spec Part 3: Commands
+typedef struct {
+ UINT16 Tag;
+ UINT32 CommandSize;
+ UINT32 CommandCode;
+ TPM2B_MAX_BUFFER data;
+ UINT16 hashAlg;
+ UINT32 hierarchy;
+} TPM2_HASH_COMMAND;
+
+// TPM2_Hash Response Structure as defined in Section 15.4 of TPM Spec Part 3: Commands
+typedef struct {
+ UINT16 Tag;
+ UINT32 ResponseSize;
+ UINT32 ResponseCode;
+ TPM2B_DIGEST data;
+ TPMT_TK_HASHCHECK validation;
+} TPM2_HASH_RESPONSE;
+#pragma
+
EFI_STATUS
EFIAPI
BBTestTCG2ProtocolUnload (
@@ -120,6 +178,12 @@ BBTestGetEventLogConformanceTestCheckpoint2 (
IN EFI_TCG2_PROTOCOL *TCG2
);
+EFI_STATUS
+BBTestSubmitCommandConformanceTestCheckpoint1 (
+ IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib,
+ IN EFI_TCG2_PROTOCOL *TCG2
+ );
+
EFI_STATUS
BBTestGetCapabilityConformanceTest (
IN EFI_BB_TEST_PROTOCOL *This,
@@ -144,3 +208,10 @@ BBTestHashLogExtendEventConformanceTest (
IN EFI_HANDLE SupportHandle
);
+EFI_STATUS
+BBTestSubmitCommandConformanceTest (
+ IN EFI_BB_TEST_PROTOCOL *This,
+ IN VOID *ClientInterface,
+ IN EFI_TEST_LEVEL TestLevel,
+ IN EFI_HANDLE SupportHandle
+ );
diff --git a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.c b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.c
index 8c528aa8ddfc..9aa5315e670e 100644
--- a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.c
+++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.c
@@ -59,3 +59,5 @@ EFI_GUID gTcg2ConformanceTestAssertionGuid014 = EFI_TEST_TCG2CONFORMANCE_ASSERTI
EFI_GUID gTcg2ConformanceTestAssertionGuid015 = EFI_TEST_TCG2CONFORMANCE_ASSERTION_015_GUID;
EFI_GUID gTcg2ConformanceTestAssertionGuid016 = EFI_TEST_TCG2CONFORMANCE_ASSERTION_016_GUID;
+
+EFI_GUID gTcg2ConformanceTestAssertionGuid017 = EFI_TEST_TCG2CONFORMANCE_ASSERTION_017_GUID;
diff --git a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTestConformance.c b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTestConformance.c
index ebe04d42aff5..5abf8e7934cf 100644
--- a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTestConformance.c
+++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTestConformance.c
@@ -197,6 +197,56 @@ BBTestHashLogExtendEventConformanceTest (
return EFI_SUCCESS;
}
+/**
+ * @brief Entrypoint for SubmitCommand() Function Test.
+ * 1 checkpoint will be tested.
+ * @param This a pointer of EFI_BB_TEST_PROTOCOL
+ * @param ClientInterface A pointer to the interface array under test
+ * @param TestLevel Test "thoroughness" control
+ * @param SupportHandle A handle containing protocols required
+ * @return EFI_SUCCESS
+ * @return EFI_NOT_FOUND
+ */
+
+EFI_STATUS
+BBTestSubmitCommandConformanceTest (
+ IN EFI_BB_TEST_PROTOCOL *This,
+ IN VOID *ClientInterface,
+ IN EFI_TEST_LEVEL TestLevel,
+ IN EFI_HANDLE SupportHandle
+ )
+{
+ EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib;
+ EFI_STATUS Status;
+ EFI_TCG2_PROTOCOL *TCG2;
+
+ //
+ // init
+ //
+ TCG2 = (EFI_TCG2_PROTOCOL*)ClientInterface;
+
+ // Ensure Protocol not NULL
+ if (TCG2 == NULL)
+ return EFI_UNSUPPORTED;
+
+ //
+ // Get the Standard Library Interface
+ //
+ Status = gtBS->HandleProtocol (
+ SupportHandle,
+ &gEfiStandardTestLibraryGuid,
+ (VOID **) &StandardLib
+ );
+ if (EFI_ERROR(Status)) {
+ return Status;
+ }
+
+ // Test GetRandom TPM Command
+ BBTestSubmitCommandConformanceTestCheckpoint1 (StandardLib, TCG2);
+
+ return EFI_SUCCESS;
+}
+
EFI_STATUS
BBTestGetCapabilityConformanceTestCheckpoint1 (
IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib,
@@ -1006,3 +1056,126 @@ BBTestGetEventLogConformanceTestCheckpoint2 (
return EFI_SUCCESS;
}
+
+// Expected SHA256 Hash of the string "The quick brown fox jumps over the lazy dog"
+UINT8 Tpm2HashOut[32] = {0xd7,0xa8,0xfb,0xb3,0x07,0xd7,0x80,0x94,0x69,0xca,0x9a,0xbc,0xb0,0x08,0x2e,0x4f, \
+0x8d,0x56,0x51,0xe4,0x6d,0x3c,0xdb,0x76,0x2d,0x02,0xd0,0xbf,0x37,0xc9,0xe5,0x92};
+
+EFI_STATUS
+BBTestSubmitCommandConformanceTestCheckpoint1 (
+ IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib,
+ IN EFI_TCG2_PROTOCOL *TCG2
+ )
+{
+ EFI_TEST_ASSERTION AssertionType;
+ EFI_STATUS Status;
+ TPM2_HASH_RESPONSE CommandResponse;
+ TPM2_HASH_COMMAND CommandInput;
+ CHAR8 *Str ="The quick brown fox jumps over the lazy dog";
+
+ // Build TPM2 Hash command to hash test string
+ CommandInput.Tag = SctSwapBytes16(ST_NO_SESSIONS);
+ CommandInput.CommandSize = SctSwapBytes32(sizeof(TPM2_HASH_COMMAND));
+ CommandInput.CommandCode = SctSwapBytes32(TPM_CC_Hash);
+ CommandInput.data.size = SctSwapBytes16(SctAsciiStrLen(Str));
+ SctAsciiStrCpy((CHAR8 *)CommandInput.data.buffer, Str);
+ CommandInput.hashAlg = SctSwapBytes16(TPM_ALG_SHA256);
+ CommandInput.hierarchy = SctSwapBytes32(TPM_RH_NULL);
+
+ // allocate buffer for response
+ SctZeroMem(&CommandResponse, sizeof(TPM2_HASH_RESPONSE));
+
+ Status = TCG2->SubmitCommand (
+ TCG2,
+ sizeof(TPM2_HASH_COMMAND),
+ (UINT8 *)&CommandInput,
+ sizeof(TPM2_HASH_RESPONSE),
+ (UINT8 *)&CommandResponse);
+
+
+ AssertionType = EFI_TEST_ASSERTION_PASSED;
+
+ // Verify SubmitCommand returns EFI_SUCCESS
+ if (Status != EFI_SUCCESS) {
+ StandardLib->RecordMessage (
+ StandardLib,
+ EFI_VERBOSE_LEVEL_DEFAULT,
+ L"\r\nTCG2 Protocol SubmitCommand Test: SubmitCommand should return EFI_SUCCESS, Status = %r",
+ Status
+ );
+
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ }
+
+ // Verify SubmitCommand returns correct Response Tag
+ if (SctSwapBytes16(CommandResponse.Tag) != ST_NO_SESSIONS) {
+ StandardLib->RecordMessage (
+ StandardLib,
+ EFI_VERBOSE_LEVEL_DEFAULT,
+ L"\r\nTCG2 Protocol SubmitCommand Test: SubmitCommand should return ST_NO_SESSIONS response Tag"
+ );
+
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ }
+
+ // Verify SubmitCommand returns correct Response Code
+ if (SctSwapBytes32(CommandResponse.ResponseCode) != TPM_RC_SUCCESS) {
+ StandardLib->RecordMessage (
+ StandardLib,
+ EFI_VERBOSE_LEVEL_DEFAULT,
+ L"\r\nTCG2 Protocol SubmitCommand Test: SubmitCommand should return Correct ResponseCode, ResponseCode = %x",
+ SctSwapBytes32(CommandResponse.ResponseCode)
+ );
+
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ }
+
+
+ // Verify SubmitCommand returns correct Response Size
+ if (SctSwapBytes32(CommandResponse.ResponseSize) != sizeof(TPM2_HASH_RESPONSE)) {
+ StandardLib->RecordMessage (
+ StandardLib,
+ EFI_VERBOSE_LEVEL_DEFAULT,
+ L"\r\nTCG2 Protocol SubmitCommand Test: SubmitCommand should return Correct ResponseSize, Size = %x",
+ SctSwapBytes32(CommandResponse.ResponseSize)
+ );
+
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ }
+
+ // Check that the size of the buffer returned is size of SHA256 hash
+ if (SctSwapBytes16(CommandResponse.data.size) != 32) {
+ StandardLib->RecordMessage (
+ StandardLib,
+ EFI_VERBOSE_LEVEL_DEFAULT,
+ L"\r\nTCG2 Protocol SubmitCommand Test: SubmitCommand should return correct size digest for SHA256, Size = %x",
+ SctSwapBytes16(CommandResponse.data.size)
+ );
+
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ }
+
+ // Ensure Hash returned matches expected response for input
+ if (0 != SctCompareMem(Tpm2HashOut, CommandResponse.data.digest, SHA256_LENGTH) ) {
+ StandardLib->RecordMessage (
+ StandardLib,
+ EFI_VERBOSE_LEVEL_DEFAULT,
+ L"\r\nTCG2 Protocol SubmitCommand Test: SubmitCommand should return expected Hash for data that was hashed."
+ );
+
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ }
+
+ StandardLib->RecordAssertion (
+ StandardLib,
+ AssertionType,
+ gTcg2ConformanceTestAssertionGuid017,
+ L"EFI_TCG2_PROTOCOL. SubmitComand() - SubmitCommand() shall populate the response buffer and return with a status of EFI_SUCCESS when valid command parameters are passed in.",
+ L"%a:%d: Status - %r",
+ __FILE__,
+ (UINTN)__LINE__,
+ Status
+ );
+
+ return EFI_SUCCESS;
+}
diff --git a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTestMain.c b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTestMain.c
index f7b9e487eda2..25c3eab2cccd 100644
--- a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTestMain.c
+++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTestMain.c
@@ -65,6 +65,15 @@ EFI_BB_TEST_ENTRY_FIELD gBBTestEntryField[] = {
EFI_TEST_CASE_AUTO,
BBTestHashLogExtendEventConformanceTest
},
+ {
+ EFI_TCG2_PROTOCOL_TEST_ENTRY_GUID0104,
+ L"SubmitCommand_Conf",
+ L"Test the SubmitCommmand API",
+ EFI_TEST_LEVEL_DEFAULT,
+ gSupportProtocolGuid1,
+ EFI_TEST_CASE_AUTO,
+ BBTestSubmitCommandConformanceTest
+ },
0
};
--
2.34.1
-=-=-=-=-=-=
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#113492): https://edk2.groups.io/g/devel/message/113492
Mute This Topic: https://groups.io/mt/103625307/5985097
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [Sunny.Wang@arm.com]
-=-=-=-=-=-=
IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#116850): https://edk2.groups.io/g/devel/message/116850
Mute This Topic: https://groups.io/mt/103625307/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-
^ permalink raw reply related [flat|nested] 26+ messages in thread
* Re: [edk2-devel] [PATCH v2 6/6] uefi-sct/SctPkg: TCG2 Protocol: add SubmitCommand test
2024-01-09 18:20 ` [edk2-devel] [PATCH v2 6/6] uefi-sct/SctPkg: TCG2 Protocol: add SubmitCommand test Stuart Yoder
2024-03-05 15:49 ` G Edhaya Chandran
2024-03-18 20:44 ` Sunny Wang
@ 2024-03-19 9:11 ` G Edhaya Chandran
2 siblings, 0 replies; 26+ messages in thread
From: G Edhaya Chandran @ 2024-03-19 9:11 UTC (permalink / raw)
To: Stuart Yoder, devel
[-- Attachment #1: Type: text/plain, Size: 494 bytes --]
The patch is upstreamed by the commit:
https://github.com/tianocore/edk2-test/commit/ee928b21d8df70c5729a6ae470366d3c6a6fd84b
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#116883): https://edk2.groups.io/g/devel/message/116883
Mute This Topic: https://groups.io/mt/103625307/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-
[-- Attachment #2: Type: text/html, Size: 910 bytes --]
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [edk2-devel] [PATCH v2 0/6] Tests for TCG2 Protocol
2024-01-09 18:20 [edk2-devel] [PATCH v2 0/6] Tests for TCG2 Protocol Stuart Yoder
` (5 preceding siblings ...)
2024-01-09 18:20 ` [edk2-devel] [PATCH v2 6/6] uefi-sct/SctPkg: TCG2 Protocol: add SubmitCommand test Stuart Yoder
@ 2024-03-05 15:46 ` G Edhaya Chandran
6 siblings, 0 replies; 26+ messages in thread
From: G Edhaya Chandran @ 2024-03-05 15:46 UTC (permalink / raw)
To: Stuart Yoder, devel
[-- Attachment #1: Type: text/plain, Size: 542 bytes --]
Hi Stuart,
Thank you for the contribution on TCG2 protocol. They significantly improve the coverage of edk2-test.
Reviewed-by: G Edhaya Chandran <edhaya.chandran@arm.com>
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#116397): https://edk2.groups.io/g/devel/message/116397
Mute This Topic: https://groups.io/mt/103625302/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-
[-- Attachment #2: Type: text/html, Size: 985 bytes --]
^ permalink raw reply [flat|nested] 26+ messages in thread