public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Sunny Wang" <Sunny.Wang@arm.com>
To: "devel@edk2.groups.io" <devel@edk2.groups.io>,
	Stuart Yoder <Stuart.Yoder@arm.com>,
	G Edhaya Chandran <Edhaya.Chandran@arm.com>,
	"gaojie@byosoft.com.cn" <gaojie@byosoft.com.cn>
Cc: "ilias.apalodimas@linaro.org" <ilias.apalodimas@linaro.org>,
	"heinrich.schuchardt@canonical.com"
	<heinrich.schuchardt@canonical.com>,
	Samer El-Haj-Mahmoud <Samer.El-Haj-Mahmoud@arm.com>,
	"Jiewen.Yao@intel.com" <Jiewen.Yao@intel.com>,
	Sunny Wang <Sunny.Wang@arm.com>
Subject: Re: [edk2-devel] [PATCH v2 2/6] uefi-sct/SctPkg: TCG2 Protocol: add test infrastructure and GetCapability Test
Date: Mon, 18 Mar 2024 20:43:21 +0000	[thread overview]
Message-ID: <AS8PR08MB77912471A73CCC62FE32C532852D2@AS8PR08MB7791.eurprd08.prod.outlook.com> (raw)
In-Reply-To: <20240109182053.2540542-3-stuart.yoder@arm.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 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]
-=-=-=-=-=-=-=-=-=-=-=-



  parent reply	other threads:[~2024-03-18 20:43 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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-03-05 15:47   ` G Edhaya Chandran
2024-03-18 20:42   ` Sunny Wang
2024-03-19  9:15   ` G Edhaya Chandran
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 [this message]
2024-03-19  9:15   ` G Edhaya Chandran
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
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
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
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
2024-03-05 15:46 ` [edk2-devel] [PATCH v2 0/6] Tests for TCG2 Protocol G Edhaya Chandran

Reply instructions:

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

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

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

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

  git send-email \
    --in-reply-to=AS8PR08MB77912471A73CCC62FE32C532852D2@AS8PR08MB7791.eurprd08.prod.outlook.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

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

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