Re: [edk2-devel] [PATCH v2 6/6] uefi-sct/SctPkg: TCG2 Protocol: add SubmitCommand test

2024-03-19 Thread G Edhaya Chandran
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/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




Re: [edk2-devel] [PATCH v2 6/6] uefi-sct/SctPkg: TCG2 Protocol: add SubmitCommand test

2024-03-18 Thread 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 

-Original Message-
From: 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 ; 
gao...@byosoft.com.cn
Cc: ilias.apalodi...@linaro.org; heinrich.schucha...@canonical.com; Samer 
El-Haj-Mahmoud ; jiewen@intel.com
Subject: [edk2-devel] [PATCH v2 6/6] uefi-sct/SctPkg: TCG2 Protocol: add 
SubmitCommand test

From: Joseph Hemann 

Add test verifying the functionality of the SubmitCommand function
using the TPM command TPM2_HASH_COMMAND.

Signed-off-by: Joseph Hemann 
Signed-off-by: Stuart Yoder 
---
 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 0x0010



+// 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) 0x000

+

+// TPM_CC_Hash as defined in Table 12 of TPM Library Spec Part 2: Structures

+#define TPM_CC_Hash(UINT32)(0x017D)

+

+#define TPM_RH_NULL(UINT32) 0x4007

+

+#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

Re: [edk2-devel] [PATCH v2 6/6] uefi-sct/SctPkg: TCG2 Protocol: add SubmitCommand test

2024-03-05 Thread G Edhaya Chandran
Reviewed-by: G Edhaya Chandran 


-=-=-=-=-=-=-=-=-=-=-=-
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/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




[edk2-devel] [PATCH v2 6/6] uefi-sct/SctPkg: TCG2 Protocol: add SubmitCommand test

2024-01-09 Thread Stuart Yoder
From: Joseph Hemann 

Add test verifying the functionality of the SubmitCommand function
using the TPM command TPM2_HASH_COMMAND.

Signed-off-by: Joseph Hemann 
Signed-off-by: Stuart Yoder 
---
 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 0x0010
 
+// 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) 0x000
+
+// TPM_CC_Hash as defined in Table 12 of TPM Library Spec Part 2: Structures
+#define TPM_CC_Hash(UINT32)(0x017D)
+
+#define TPM_RH_NULL(UINT32) 0x4007
+
+#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