[edk2-devel] [PATCH V3 4/6] uefi-sct/SctPkg: TCG2 Protocol: add HashLogExtendEvent test

2022-02-08 Thread Joseph Hemann
-add initial TCG2 protocol test for HashLogExtendEvent()
  -checkpoint for test of function with invalid parameters
  -checkpoint for test of function with valid parameters

V2:
-fix issue with reused Assertion Guid

Cc: G Edhaya Chandran 
Cc: Barton Gao 
Cc: Carolyn Gjertsen 
Cc: Samer El-Haj-Mahmoud 
Cc: Eric Jin 
Cc: Arvin Chen 
Cc: Supreeth Venkatesh 
Cc: Stuart Yoder 

Signed-off-by: Joseph Hemann 
Change-Id: I126f2c6316f8469455f8e2a19ca7e945e9d5d6ae
---
 .../SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.h  |  29 +++
 .../UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTest.h|  29 +++
 .../SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.c  |  12 ++
 .../Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTestConformance.c  | 281 

 .../EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTestMain.c |   9 +
 5 files changed, 360 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 f470255ccdcf..45c2b2b22282 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
@@ -51,3 +51,32 @@ extern EFI_GUID gTcg2ConformanceTestAssertionGuid004;
 
 extern EFI_GUID gTcg2ConformanceTestAssertionGuid005;
 
+#define EFI_TEST_TCG2CONFORMANCE_ASSERTION_006_GUID \
+{ 0xa8e1b5e6, 0xfc09, 0x461c, {0xb0, 0xe9, 0x2a, 0x49, 0xcd, 0x25, 0xc1, 0x24 
}}
+
+extern EFI_GUID gTcg2ConformanceTestAssertionGuid006;
+
+#define EFI_TEST_TCG2CONFORMANCE_ASSERTION_007_GUID \
+{ 0x26f04a9b, 0x7b7a, 0x4f47, {0xbe, 0xa8, 0xb1, 0xa6, 0x02, 0x65, 0x19, 0x8a 
}}
+
+extern EFI_GUID gTcg2ConformanceTestAssertionGuid007;
+
+#define EFI_TEST_TCG2CONFORMANCE_ASSERTION_008_GUID \
+{ 0x4d1d9985, 0x91e2, 0x4948, {0x89, 0x16, 0xbb, 0x98, 0x13, 0x62, 0x39, 0x1d 
}}
+
+extern EFI_GUID gTcg2ConformanceTestAssertionGuid008;
+
+#define EFI_TEST_TCG2CONFORMANCE_ASSERTION_009_GUID \
+{ 0xfb59cab7, 0x4f8c, 0x4ded, {0xa4, 0x1c, 0xc8, 0x41, 0x20, 0x1c, 0x37, 0x22 
}}
+
+extern EFI_GUID gTcg2ConformanceTestAssertionGuid009;
+
+#define EFI_TEST_TCG2CONFORMANCE_ASSERTION_010_GUID \
+{ 0x0363d22f, 0xc66a, 0x4872, {0xa5, 0x46, 0x06, 0x7f, 0x6a, 0x0d, 0xdb, 0xcd 
}}
+
+extern EFI_GUID gTcg2ConformanceTestAssertionGuid010;
+
+#define EFI_TEST_TCG2CONFORMANCE_ASSERTION_011_GUID \
+{ 0x9cd6d636, 0x603a, 0x4b78, {0x80, 0xa3, 0xa3, 0xb9, 0xcc, 0x6a, 0x0b, 0x08 
}}
+
+extern EFI_GUID gTcg2ConformanceTestAssertionGuid011;
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 ed65bc974009..1b56852eea1f 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 0x0001
+
+#define PE_COFF_IMAGE 0x0010
+
 EFI_STATUS
 EFIAPI
 BBTestTCG2ProtocolUnload (
@@ -76,6 +85,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,
@@ -92,3 +113,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 0497f08f74f2..ed013744e209 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
@@ -37,3 +37,15 @@ EFI_GUID gTcg2ConformanceTestAssertionGuid003 = 
EFI_TEST_TCG2CONFORMANCE_ASSERTI
 EFI_GUID gTcg2ConformanceTestAssertionGuid004 = 
EFI_TEST_TCG2CONFORMANCE_ASSERTION_004_GUID;
 
 EFI_GUID gTcg2ConformanceTestAssertionGuid005 = 
EFI_TEST_TCG2CONFORMANCE_ASSERTION_005_GUID

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

2022-02-08 Thread Joseph Hemann
-add initial TCG2 protocol test for SubmitCommand()
  -checkpoint for test function with TPM2_Hash Command
V2:
-Change command submitted from GetRandom to TPM2_HASH
-combined to 2 assertions into 1

Cc: G Edhaya Chandran 
Cc: Barton Gao 
Cc: Carolyn Gjertsen 
Cc: Samer El-Haj-Mahmoud 
Cc: Eric Jin 
Cc: Arvin Chen 
Cc: Supreeth Venkatesh 
Cc: Stuart Yoder 

Signed-off-by: Joseph Hemann 
Change-Id: Ibab68cae1d49953d1076c5628ea80319ba7ca831
---
 .../SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.h  |   5 +
 .../UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTest.h|  70 
+++
 .../SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.c  |   2 +
 .../Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTestConformance.c  | 172 

 .../EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTestMain.c |   9 ++
 5 files changed, 258 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 d3a18aeebf09..507cecc67593 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
@@ -100,3 +100,8 @@ extern EFI_GUID gTcg2ConformanceTestAssertionGuid014;
 { 0xa76d2903, 0xbbcc, 0x8a72, {0x90, 0x23, 0xd3, 0xaa, 0xba, 0xb1, 0x52, 0x13 
}}

 
 extern EFI_GUID gTcg2ConformanceTestAssertionGuid015;
+
+#define EFI_TEST_TCG2CONFORMANCE_ASSERTION_016_GUID \
+{ 0x1689bc3a, 0x2298, 0xa116, {0x28, 0x4c, 0xc1, 0xdd, 0xaa, 0xd8, 0xef, 0x51 
}}

+
+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 d9c2309462d7..c8684f7915a6 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,6 +43,9 @@ 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

@@ -51,6 +54,61 @@ Abstract:
 
 #define PE_COFF_IMAGE 0x0010
 
+// ST_NO_SESSION as definied in Table 19 of TPM Library Part 2: Structures

+#define ST_NO_SESSIONS (UINT16) 0x8001

+

+// TPM_RC_SUCCESS as definied in Table 16 of TPM Library Spec Part 2: 
Structures

+#define TPM_RC_SUCCESS (UINT32) 0x000

+

+// TPM_CC_Hash as definied 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 definied in Table 86 of TPM Library Spec Part 2: 
Structures

+typedef struct {

+  UINT16 size;

+  UINT8  digest[5];  // Size of buffer in spec is defined to be variable 
length but for this test will always be 5

+} TPM2B_MAX_BUFFER;

+

+#pragma pack(1)

+// TPM2B_DIGEST as definied 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 Sectin 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 Sectin 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 (
@@ -111,6 +169,11 @@ BBTestGetEventLogConformanceTestCheckpoint2 (
   IN EFI_TCG2_PROTOCOL *TCG2

   );

 

+EFI_STATUS

+BBTestSubmitCommandConformanceTestCheckpoint1 (

+  IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL*StandardLib,

+  IN EFI_TCG2_PROTOCOL *TCG2

+  );

 
 EFI_STATUS
 BBTestGetCapabilityConformanceTest (
@@ -136,3 +199,10 @@ BBTestHashLogExtendEventConformanceTest (
   IN EFI_HANDLE SupportHandle
   );
 
+EFI_STATUS
+BBTestSubmitCommandConformanceTest (
+  IN EFI_BB_TEST_PROTOCOL   *This,
+  IN VOID   *ClientInterface,
+  IN EFI_TEST_LEVEL

[edk2-devel] [PATCH V3 5/6] uefi-sct/SctPkg: TCG2 Protocol: add GetEventLog test

2022-02-08 Thread Joseph Hemann
-add initial TCG2 protocol test for GetEventLog()
  -checkpoint for test function with invalid eventlog format
  -checkpoint for test function with valid eventlog format

V2:
-Change checkpoint names from HashLogExtendEvent to GetEventLog

Cc: G Edhaya Chandran 
Cc: Barton Gao 
Cc: Carolyn Gjertsen 
Cc: Samer El-Haj-Mahmoud 
Cc: Eric Jin 
Cc: Arvin Chen 
Cc: Supreeth Venkatesh 
Cc: Stuart Yoder 

Signed-off-by: Joseph Hemann 
Change-Id: I5ca3a46b3d36e8f11848a788f6cfdcabeb5b04c8
---
 .../SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.h  |  20 +++
 .../UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTest.h|  15 ++
 uefi-sct/SctPkg/UEFI/Protocol/TCG2.h|  46 +++
 .../SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.c  |   8 ++
 .../Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTestConformance.c  | 204 
+++-
 5 files changed, 292 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 45c2b2b22282..d3a18aeebf09 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
@@ -80,3 +80,23 @@ extern EFI_GUID gTcg2ConformanceTestAssertionGuid010;
 { 0x9cd6d636, 0x603a, 0x4b78, {0x80, 0xa3, 0xa3, 0xb9, 0xcc, 0x6a, 0x0b, 0x08 
}}
 
 extern EFI_GUID gTcg2ConformanceTestAssertionGuid011;
+
+#define EFI_TEST_TCG2CONFORMANCE_ASSERTION_012_GUID \
+{ 0x0a938567, 0xb234, 0xad21, {0x2a, 0xa6, 0x11, 0x65, 0xaa, 0xde, 0x12, 0xc2 
}}
+
+extern EFI_GUID gTcg2ConformanceTestAssertionGuid012;
+
+#define EFI_TEST_TCG2CONFORMANCE_ASSERTION_013_GUID \
+{ 0x45fa1a42, 0x912a, 0x5124, {0x84, 0xf4, 0x41, 0x67, 0xab, 0xb5, 0x89, 0x90 
}}
+
+extern EFI_GUID gTcg2ConformanceTestAssertionGuid013;
+
+#define EFI_TEST_TCG2CONFORMANCE_ASSERTION_014_GUID \
+{ 0xfc80408e, 0x9a3c, 0x4054, {0x96, 0xf9, 0x31, 0x23, 0x35, 0xc2, 0x31, 0x35 
}}
+
+extern EFI_GUID gTcg2ConformanceTestAssertionGuid014;
+
+#define EFI_TEST_TCG2CONFORMANCE_ASSERTION_015_GUID \
+{ 0xa76d2903, 0xbbcc, 0x8a72, {0x90, 0x23, 0xd3, 0xaa, 0xba, 0xb1, 0x52, 0x13 
}}

+
+extern EFI_GUID gTcg2ConformanceTestAssertionGuid015;
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 1b56852eea1f..d9c2309462d7 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
@@ -45,6 +45,8 @@ Abstract:
 
 #define EV_POST_CODE 0x01
 
+#define EV_NO_ACTION 0x03

+
 #define EFI_TCG2_EXTEND_ONLY 0x0001
 
 #define PE_COFF_IMAGE 0x0010
@@ -97,6 +99,19 @@ 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 923549e2e96b..ac66fa0e107d 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 0x0002
 
+#define HASH_NUMBER 0x04
+
 typedef struct _EFI_TCG2_PROTOCOL EFI_TCG2_PROTOCOL;
 
 typedef UINT64 EFI_PHYSICAL_ADDRESS;
@@ -114,6 +116,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

[edk2-devel] [PATCH V3 2/6] uefi-sct/SctPkg: TCG2 Protocol: add GetCapability Test

2022-02-08 Thread Joseph Hemann
-implement initial infrastructure for the TCG2 protocol test
including updates to .dsc file, inf file, GUID source files,
update to Category.ini.

-add initial TCG2 protocol test for GetCapability(), as
defined in the TCG EFI Protocol Spec 6.4.4.
  -checkpoint for NULL pointer passed for buffer
  -checkpoint for validating fields of the struct returned by GetCapabilty()

V2:
-adds checkpoint for verifying GetCapablity() when size < Capablity Struct
-adds check to ensure ActivePcrBanks is subset of HashAlgorithmBitmap
-adds checks for returned status by function

V3:
-adds check for correct size returned in checkpoint2
-fixes bug in check of ActivePcrBanks is subset of HashAlgorithmBitmap

Cc: G Edhaya Chandran 
Cc: Barton Gao 
Cc: Carolyn Gjertsen 
Cc: Samer El-Haj-Mahmoud 
Cc: Eric Jin 
Cc: Arvin Chen 
Cc: Supreeth Venkatesh 
Cc: Stuart Yoder 

Change-Id: Ib0c823ca70c5ae4054edbdeca45251e369941c1b
---
 uefi-sct/SctPkg/UEFI/UEFI_SCT.dsc   |   1 +
 .../UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTest.inf  |  51 +
 .../SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.h  |  43 
 .../UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTest.h|  71 ++
 .../SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.c  |  35 +++
 .../Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTestConformance.c  | 332 

 .../EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTestMain.c | 102 +
 uefi-sct/SctPkg/CommonGenFramework.sh   |   1 +
 uefi-sct/SctPkg/Config/Data/Category.ini|   7 +
 9 files changed, 643 insertions(+)

diff --git a/uefi-sct/SctPkg/UEFI/UEFI_SCT.dsc 
b/uefi-sct/SctPkg/UEFI/UEFI_SCT.dsc
index 5b3e5307e8f1..3d3e9704e8db 100644
--- a/uefi-sct/SctPkg/UEFI/UEFI_SCT.dsc
+++ b/uefi-sct/SctPkg/UEFI/UEFI_SCT.dsc
@@ -288,6 +288,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 ..f41d84b32a5c
--- /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.
+#  Copyright (c) 2013, Intel Corporation. All rights reserved.
+#  Copyright (c) 2021, Arm Inc. All rights reserved.

+#
+#  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 ..b675756b9fb7
--- /dev/null
+++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.h
@@ -0,0 +1,43 @@
+/** @file
+
+  Copyright 2006 - 2016 Unified EFI, Inc.
+  Copyright (c) 2013, Intel Corporation. All rights reserved.
+  Copyright (c) 2021, Arm Inc. All rights reserved.

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

[edk2-devel] [PATCH V3 3/6] uefi-sct/SctPkg: TCG2 Protocol: add GetActivePcrBanks test

2022-02-08 Thread Joseph Hemann
 -add initial TCG2 protocol test for GetActivePcrBanks()
  -checkpoint for NULL pointer passed for buffer
  -checkpoint for test of function with proper input

V2:
-add check to verify ActivePcrBanks returned by GetCapability matches that 
returned by
GetActivePcrBanks()

Cc: G Edhaya Chandran 
Cc: Barton Gao 
Cc: Carolyn Gjertsen 
Cc: Samer El-Haj-Mahmoud 
Cc: Eric Jin 
Cc: Arvin Chen 
Cc: Supreeth Venkatesh 
Cc: Stuart Yoder 

Signed-off-by: Joseph Hemann 
Change-Id: I626bc21fb3e96692f3c63043651a8e1027c6f611
---
 .../SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.h  |  10 ++
 .../UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTest.h|  23 
 .../SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.c  |   4 +
 .../Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTestConformance.c  | 159 

 .../EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTestMain.c |   9 ++
 5 files changed, 205 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 b675756b9fb7..f470255ccdcf 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
@@ -41,3 +41,13 @@ extern EFI_GUID gTcg2ConformanceTestAssertionGuid002;
 
 extern EFI_GUID gTcg2ConformanceTestAssertionGuid003;
 
+#define EFI_TEST_TCG2CONFORMANCE_ASSERTION_004_GUID \
+{ 0x7a1e79a3, 0x4064, 0x4372, {0xbb, 0x64, 0x55, 0xb8, 0xf2, 0xa5, 0xa3, 0x26 
}}
+
+extern EFI_GUID gTcg2ConformanceTestAssertionGuid004;
+
+#define EFI_TEST_TCG2CONFORMANCE_ASSERTION_005_GUID \
+{ 0xb0e717c4, 0xb1e2, 0x49f7, {0xb2, 0xd7, 0x60, 0x58, 0x97, 0x7d, 0x09, 0x2c 
}}
+
+extern EFI_GUID gTcg2ConformanceTestAssertionGuid005;
+
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 aecc5e1d7d98..ed65bc974009 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 (
@@ -61,6 +64,18 @@ BBTestGetCapabilityConformanceTestCheckpoint3 (
   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,
@@ -69,3 +84,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 206662ee7933..0497f08f74f2 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
@@ -33,3 +33,7 @@ EFI_GUID gTcg2ConformanceTestAssertionGuid001 = 
EFI_TEST_TCG2CONFORMANCE_ASSERTI
 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;
+
+EFI_GUID gTcg2ConformanceTestAssertionGuid005 = 
EFI_TEST_TCG2CONFORMANCE_ASSERTION_005_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 d91327ab18d1..84d480f6dac6 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
@@ -82,6 +82,58 @@ BBTestGetCapabilityConformanceTest (
   return EFI_SUCCESS;
 }
 
+/**
+ *  @brief Entrypoint for GetActivePcrBanks() Function Test.
+ * 2 checkpoints will be tested.
+ *  @param This a pointer

[edk2-devel] [PATCH V3 0/6] Implementation of TCG2 Protocol test

2022-02-08 Thread Joseph Hemann
This patch series implements a set of SCT tests,
for the TCG2 UEFI protocol as defined in the TCG
EFI Protocol Specification. The series implements
the code for the test, and the infrastructure
needed to run the test from the SCT UI.

Patch 1 adds header file with TCG2 protocol definitions.

Patch 2 implements initial infrastructure for the
TCG2 protocol test including updates to .dsc file,
inf file, GUID source files, update to Category.ini.
It also adds initial TCG2 protocol test for GetCapability().

Patch 3 implements TCG2 protocol test for GetActivePcrBanks().

Patch 4 implements a test for HashLogExtendEvent() by hashing,
and extending data in a test buffer to PCR[16].

Patch 5 implements a test for GetEventLog(), by checking for
the event extended in the test in Patch 4.

Patch 6 tests SubmitCommand(), by submitting a simple command
(GetRandom) to the TPM.

Compared to v1, v2 adds:
-new checks on GetCapability, GetActivePcrBanks test
-Fixes reused Guids in HashLogExtend test
-changes command used in SubmitCommand test from GetRandom To TPM2_Hash

v3:
-new check in checkpoint 2 of GetCapablity() test.
-Fix bug in checkpoint 3 of GetCapablity() test.

Cc: G Edhaya Chandran 
Cc: Barton Gao 
Cc: Carolyn Gjertsen 
Cc: Samer El-Haj-Mahmoud 
Cc: Eric Jin 
Cc: Arvin Chen 
Cc: Supreeth Venkatesh 

Joseph Hemann (6):
  uefi-sct/SctPkg: TCG2 Protocol: add header with TCG2 protocol
definitions
  uefi-sct/SctPkg: TCG2 Protocol: add GetCapability Test
  uefi-sct/SctPkg: TCG2 Protocol: add GetActivePcrBanks  test
  uefi-sct/SctPkg: TCG2 Protocol: add HashLogExtendEvent  test
  uefi-sct/SctPkg: TCG2 Protocol: add GetEventLog test
  uefi-sct/SctPkg: TCG2 Protocol: add SubmitCommand test

 uefi-sct/SctPkg/CommonGenFramework.sh |1 +
 uefi-sct/SctPkg/Config/Data/Category.ini  |7 +
 .../EFI/Protocol/TCG2/BlackBoxTest/Guid.c |   61 +
 .../EFI/Protocol/TCG2/BlackBoxTest/Guid.h |  107 ++
 .../TCG2/BlackBoxTest/TCG2ProtocolBBTest.h|  208 +++
 .../TCG2/BlackBoxTest/TCG2ProtocolBBTest.inf  |   51 +
 .../TCG2ProtocolBBTestConformance.c   | 1135 +
 .../BlackBoxTest/TCG2ProtocolBBTestMain.c |  129 ++
 uefi-sct/SctPkg/UEFI/Protocol/TCG2.h  |  220 
 uefi-sct/SctPkg/UEFI/UEFI_SCT.dsc |1 +
 10 files changed, 1920 insertions(+)
 create mode 100644 
uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.c
 create mode 100644 
uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.h
 create mode 100644 
uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTest.h
 create mode 100644 
uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTest.inf
 create mode 100644 
uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTestConformance.c
 create mode 100644 
uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTestMain.c
 create mode 100644 uefi-sct/SctPkg/UEFI/Protocol/TCG2.h

-- 
2.25.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#86456): https://edk2.groups.io/g/devel/message/86456
Mute This Topic: https://groups.io/mt/89012613/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




[edk2-devel] [PATCH V3 1/6] uefi-sct/SctPkg: TCG2 Protocol: add header with TCG2 protocol definitions

2022-02-08 Thread Joseph Hemann
Cc: G Edhaya Chandran 
Cc: Barton Gao 
Cc: Carolyn Gjertsen 
Cc: Samer El-Haj-Mahmoud 
Cc: Eric Jin 
Cc: Arvin Chen 
Cc: Supreeth Venkatesh 
Cc: Stuart Yoder 

Signed-off-by: Joseph Hemann 
Change-Id: Ie71cfebd15ddccff0d8d99359ee10761adb3001f
---
 uefi-sct/SctPkg/UEFI/Protocol/TCG2.h | 174 
+++
 1 file changed, 174 insertions(+)

diff --git a/uefi-sct/SctPkg/UEFI/Protocol/TCG2.h 
b/uefi-sct/SctPkg/UEFI/Protocol/TCG2.h
new file mode 100644
index ..923549e2e96b
--- /dev/null
+++ b/uefi-sct/SctPkg/UEFI/Protocol/TCG2.h
@@ -0,0 +1,174 @@
+/** @file
+
+  Copyright 2006 - 2016 Unified EFI, Inc.
+  Copyright (c) 2013 - 2016, Intel Corporation. All rights reserved.
+  Copyright (c) 2021, Arm Inc. All rights reserved.
+
+  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 0x0001
+
+#define EFI_TCG2_BOOT_HASH_ALG_SHA256 0x0002
+
+#define EFI_TCG2_BOOT_HASH_ALG_SHA384 0x0004
+
+#define EFI_TCG2_BOOT_HASH_ALG_SHA512 0x0008
+
+#define EFI_TCG2_BOOT_HASH_ALG_SM3_256 0x0010
+
+#define EFI_TCG2_EVENT_LOG_FORMAT_TCG_1_2 0x0001
+
+#define EFI_TCG2_EVENT_LOG_FORMAT_TCG_2 0x0002
+
+typedef struct _EFI_TCG2_PROTOCOL EFI_TCG2_PROTOCOL;
+
+typedef UINT64 EFI_PHYSICAL_ADDRESS;
+
+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
+);
+
+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;
+
+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.25.1



-=-=-=-=-=-=-=-=-=-=-=-
Group

Re: [edk2-devel] [PATCH 2/6] uefi-sct/SctPkg: TCG2 Protocol: add GetCapability Test

2022-02-07 Thread Joseph Hemann
See inline comments..

On 2/1/22, 12:33 PM, "Stuart Yoder"  wrote:

See inline comments...

> +EFI_STATUS
> +BBTestGetCapabilityConformanceTestCheckpoint2 (
> +  IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL*StandardLib,
> +  IN EFI_TCG2_PROTOCOL *TCG2
> +  )
> +{
> +  EFI_TEST_ASSERTIONAssertionType;
> +  EFI_STATUSStatus;
> +  char StructureVersionMajor;
> +  char StructureVersionMinor;
> +  char ProtocolVersionMajor;
> +  char ProtocolVersionMinor;
> +
> +  EFI_TCG2_BOOT_SERVICE_CAPABILITY  BootServiceCap;
> +  BootServiceCap.Size = sizeof(UINT8) + (sizeof(EFI_TCG2_VERSION) * 2);
> +
> +  Status = TCG2->GetCapability (
> +   TCG2,
> +   &BootServiceCap);
> +
> +  AssertionType = EFI_TEST_ASSERTION_PASSED;
> +
> +  // If the input ProtocolCapability.Size < 
sizeof(EFI_TCG2_BOOT_SERVICE_CAPABILITY) the function should return 
EFI_BUFFER_TOO_SMALL
> +  if (Status != EFI_BUFFER_TOO_SMALL) {
> + StandardLib->RecordMessage (
>
> + StandardLib,
>
> + EFI_VERBOSE_LEVEL_DEFAULT,
>
> + L"\r\nTCG2 Protocol GetCapablity Test: Did not 
return Status == EFI_BUFFER_TOO_SMALL with input ProtocolCapability.Size < 
sizeof(EFI_TCG2_BOOT_SERVICE_CAPABILITY)"
> + );
> +
> + AssertionType = EFI_TEST_ASSERTION_FAILED;
> +  }
> +
> +  StructureVersionMajor = BootServiceCap.StructureVersion.Major;
> +  StructureVersionMinor = BootServiceCap.StructureVersion.Minor;
> +
> +  // If the input ProtocolCapability.Size < 
sizeof(EFI_TCG2_BOOT_SERVICE_CAPABILITY) the function will initialize the 
fields included in ProtocolCapability.Size.
> +  if ((StructureVersionMajor != 1) | (StructureVersionMinor != 1)) {
> + StandardLib->RecordMessage (
>
> + StandardLib,
>
> + EFI_VERBOSE_LEVEL_DEFAULT,
>
> + L"\r\nTCG2 Protocol GetCapablity Test: Unexpected 
struct version numbers returned"
> + );
> +
> + AssertionType = EFI_TEST_ASSERTION_FAILED;
> +  }
> +
> +  ProtocolVersionMajor = BootServiceCap.ProtocolVersion.Major;
> +  ProtocolVersionMinor = BootServiceCap.ProtocolVersion.Minor;
> +
> +  if ((ProtocolVersionMajor != 1) | (ProtocolVersionMinor != 1)) {
> + StandardLib->RecordMessage (
>
> + StandardLib,
>
> + EFI_VERBOSE_LEVEL_DEFAULT,
>
> + L"\r\nTCG2 Protocol GetCapablity Test: Unexpected 
protocol version numbers returned."
> + );
> +
> + AssertionType = EFI_TEST_ASSERTION_FAILED;
> +  }
> +
> +  StandardLib->RecordAssertion (
> + StandardLib,
> + AssertionType,
> + gTcg2ConformanceTestAssertionGuid002,
> + L"TCG2_PROTOCOL.GetCapability() - GetCapability() shall 
populate the included structure elements and return with a Status of 
EFI_BUFFER_TOO_SMALL when structure size is set to less than the size of 
EFI_TCG_BOOT_SERVICE_CAPABILITY.",
> + L"%a:%d: Status - %r",
> + __FILE__,
> + (UINTN)__LINE__,
> + Status
> + );

>   In the SCT spec draft there is a test:
>f. Verify returned Size equal to size of the
> EFI_TCG2_BOOT_SERVICE_CAPABILITY up to and including the vendor ID
>  field.

> ...but I don't see that test covered in the code.

I will add this check to the next round of edits I send out.

> +  return EFI_SUCCESS;
> +}
> +
> +EFI_STATUS
> +BBTestGetCapabilityConformanceTestCheckpoint3 (
> +  IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL*StandardLib,
> +  IN EFI_TCG2_PROTOCOL *TCG2
> +  )
> +{
> +  EFI_TEST_ASSERTIONAssertionType;
> +  EFI_STATUSStatus;
> +  char StructureVersionMajor;
> +  char StructureVersionMinor;
> +  char ProtocolVersionMajor;
> +  char ProtocolVersionMinor;
> +  EFI_TCG2_BOOT_SERVICE_CAPABILITY  BootServiceCap;
> +
> +  BootServiceCap.Size = sizeof(EFI_TCG2_BOOT_SERVICE_CAPABILITY);

  >  BootServiceCap.Size is not used in this test, so should be able to
delete the above line.

   BootServiceCap.Size needs to be set so that GetCapability knows how much of 
the struct to fill out. Even though it is not checked it still needs to be set 
before calling  GetCapabilty.

> +  Status = TCG2->GetCapability (
> +   TCG2,
> +   &BootServiceCap);
> +
> +  AssertionTyp

[edk2-devel] [PATCH V2 0/6] Implementation of TCG2 Protocol test

2022-01-09 Thread Joseph Hemann
This patch series implements a set of SCT tests,
for the TCG2 UEFI protocol as defined in the TCG
EFI Protocol Specification. The series implements
the code for the test, and the infrastructure
needed to run the test from the SCT UI.

Patch 1 adds header file with TCG2 protocol definitions.

Patch 2 implements initial infrastructure for the
TCG2 protocol test including updates to .dsc file,
inf file, GUID source files, update to Category.ini.
It also adds initial TCG2 protocol test for GetCapability().

Patch 3 implements TCG2 protocol test for GetActivePcrBanks().

Patch 4 implements a test for HashLogExtendEvent() by hashing,
and extending data in a test buffer to PCR[16].

Patch 5 implements a test for GetEventLog(), by checking for
the event extended in the test in Patch 4.

Patch 6 tests SubmitCommand(), by submitting a simple command
(GetRandom) to the TPM.

Compared to v1, v2 adds:
-new checks on GetCapability, GetActivePcrBanks test
-Fixes reused Guids in HashLogExtend test
-changes command used in SubmitCommand test from GetRandom To TPM2_Hash

Cc: G Edhaya Chandran 
Cc: Barton Gao 
Cc: Carolyn Gjertsen 
Cc: Samer El-Haj-Mahmoud 
Cc: Eric Jin 
Cc: Arvin Chen 
Cc: Supreeth Venkatesh 

Joseph Hemann (6):
  uefi-sct/SctPkg: TCG2 Protocol: add header with TCG2 protocol
definitions
  uefi-sct/SctPkg: TCG2 Protocol: add GetCapability Test
  uefi-sct/SctPkg: TCG2 Protocol: add GetActivePcrBanks  test
  uefi-sct/SctPkg: TCG2 Protocol: add HashLogExtendEvent  test
  uefi-sct/SctPkg: TCG2 Protocol: add GetEventLog test
  uefi-sct/SctPkg: TCG2 Protocol: add SubmitCommand test

 uefi-sct/SctPkg/CommonGenFramework.sh |1 +
 uefi-sct/SctPkg/Config/Data/Category.ini  |7 +
 .../EFI/Protocol/TCG2/BlackBoxTest/Guid.c |   61 +
 .../EFI/Protocol/TCG2/BlackBoxTest/Guid.h |  107 ++
 .../TCG2/BlackBoxTest/TCG2ProtocolBBTest.h|  208 +++
 .../TCG2/BlackBoxTest/TCG2ProtocolBBTest.inf  |   51 +
 .../TCG2ProtocolBBTestConformance.c   | 1135 +
 .../BlackBoxTest/TCG2ProtocolBBTestMain.c |  129 ++
 uefi-sct/SctPkg/UEFI/Protocol/TCG2.h  |  220 
 uefi-sct/SctPkg/UEFI/UEFI_SCT.dsc |1 +
 10 files changed, 1920 insertions(+)
 create mode 100644 
uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.c
 create mode 100644 
uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.h
 create mode 100644 
uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTest.h
 create mode 100644 
uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTest.inf
 create mode 100644 
uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTestConformance.c
 create mode 100644 
uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTestMain.c
 create mode 100644 uefi-sct/SctPkg/UEFI/Protocol/TCG2.h

-- 
2.25.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#85433): https://edk2.groups.io/g/devel/message/85433
Mute This Topic: https://groups.io/mt/88309839/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




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

2022-01-09 Thread Joseph Hemann
 -add initial TCG2 protocol test for GetActivePcrBanks()
  -checkpoint for NULL pointer passed for buffer
  -checkpoint for test of function with proper input

V2:
-add check to verify ActivePcrBanks returned by GetCapability matches that 
returned by
GetActivePcrBanks()

Signed-off-by: Joseph Hemann 
Change-Id: I626bc21fb3e96692f3c63043651a8e1027c6f611
---
 .../EFI/Protocol/TCG2/BlackBoxTest/Guid.c |   4 +
 .../EFI/Protocol/TCG2/BlackBoxTest/Guid.h |  10 ++
 .../TCG2/BlackBoxTest/TCG2ProtocolBBTest.h|  23 +++
 .../TCG2ProtocolBBTestConformance.c   | 159 ++
 .../BlackBoxTest/TCG2ProtocolBBTestMain.c |   9 +
 5 files changed, 205 insertions(+)

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 206662ee..0497f08f 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
@@ -33,3 +33,7 @@ EFI_GUID gTcg2ConformanceTestAssertionGuid001 = 
EFI_TEST_TCG2CONFORMANCE_ASSERTI
 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;
+
+EFI_GUID gTcg2ConformanceTestAssertionGuid005 = 
EFI_TEST_TCG2CONFORMANCE_ASSERTION_005_GUID;
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 b675756b..f470255c 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
@@ -41,3 +41,13 @@ extern EFI_GUID gTcg2ConformanceTestAssertionGuid002;
 
 extern EFI_GUID gTcg2ConformanceTestAssertionGuid003;
 
+#define EFI_TEST_TCG2CONFORMANCE_ASSERTION_004_GUID \
+{ 0x7a1e79a3, 0x4064, 0x4372, {0xbb, 0x64, 0x55, 0xb8, 0xf2, 0xa5, 0xa3, 0x26 
}}
+
+extern EFI_GUID gTcg2ConformanceTestAssertionGuid004;
+
+#define EFI_TEST_TCG2CONFORMANCE_ASSERTION_005_GUID \
+{ 0xb0e717c4, 0xb1e2, 0x49f7, {0xb2, 0xd7, 0x60, 0x58, 0x97, 0x7d, 0x09, 0x2c 
}}
+
+extern EFI_GUID gTcg2ConformanceTestAssertionGuid005;
+
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 aecc5e1d..ed65bc97 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 (
@@ -61,6 +64,18 @@ BBTestGetCapabilityConformanceTestCheckpoint3 (
   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,
@@ -69,3 +84,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/TCG2ProtocolBBTestConformance.c
 
b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTestConformance.c
index a74b29b7..c7b326cd 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
@@ -82,6 +82,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
+ */
+
+

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

2022-01-09 Thread Joseph Hemann
-add initial TCG2 protocol test for GetEventLog()
  -checkpoint for test function with invalid eventlog format
  -checkpoint for test function with valid eventlog format

V2:
-Change checkpoint names from HashLogExtendEvent to GetEventLog

Signed-off-by: Joseph Hemann 
Change-Id: I5ca3a46b3d36e8f11848a788f6cfdcabeb5b04c8
---
 .../EFI/Protocol/TCG2/BlackBoxTest/Guid.c |   8 +
 .../EFI/Protocol/TCG2/BlackBoxTest/Guid.h |  20 ++
 .../TCG2/BlackBoxTest/TCG2ProtocolBBTest.h|  15 ++
 .../TCG2ProtocolBBTestConformance.c   | 204 +-
 uefi-sct/SctPkg/UEFI/Protocol/TCG2.h  |  46 
 5 files changed, 292 insertions(+), 1 deletion(-)

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 ed013744..b5a4e5c7 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
@@ -49,3 +49,11 @@ EFI_GUID gTcg2ConformanceTestAssertionGuid009 = 
EFI_TEST_TCG2CONFORMANCE_ASSERTI
 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;
+
+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;
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 45c2b2b2..d3a18aee 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
@@ -80,3 +80,23 @@ extern EFI_GUID gTcg2ConformanceTestAssertionGuid010;
 { 0x9cd6d636, 0x603a, 0x4b78, {0x80, 0xa3, 0xa3, 0xb9, 0xcc, 0x6a, 0x0b, 0x08 
}}
 
 extern EFI_GUID gTcg2ConformanceTestAssertionGuid011;
+
+#define EFI_TEST_TCG2CONFORMANCE_ASSERTION_012_GUID \
+{ 0x0a938567, 0xb234, 0xad21, {0x2a, 0xa6, 0x11, 0x65, 0xaa, 0xde, 0x12, 0xc2 
}}
+
+extern EFI_GUID gTcg2ConformanceTestAssertionGuid012;
+
+#define EFI_TEST_TCG2CONFORMANCE_ASSERTION_013_GUID \
+{ 0x45fa1a42, 0x912a, 0x5124, {0x84, 0xf4, 0x41, 0x67, 0xab, 0xb5, 0x89, 0x90 
}}
+
+extern EFI_GUID gTcg2ConformanceTestAssertionGuid013;
+
+#define EFI_TEST_TCG2CONFORMANCE_ASSERTION_014_GUID \
+{ 0xfc80408e, 0x9a3c, 0x4054, {0x96, 0xf9, 0x31, 0x23, 0x35, 0xc2, 0x31, 0x35 
}}
+
+extern EFI_GUID gTcg2ConformanceTestAssertionGuid014;
+
+#define EFI_TEST_TCG2CONFORMANCE_ASSERTION_015_GUID \
+{ 0xa76d2903, 0xbbcc, 0x8a72, {0x90, 0x23, 0xd3, 0xaa, 0xba, 0xb1, 0x52, 0x13 
}}

+
+extern EFI_GUID gTcg2ConformanceTestAssertionGuid015;
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 1b56852e..d9c23094 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
@@ -45,6 +45,8 @@ Abstract:
 
 #define EV_POST_CODE 0x01
 
+#define EV_NO_ACTION 0x03

+
 #define EFI_TCG2_EXTEND_ONLY 0x0001
 
 #define PE_COFF_IMAGE 0x0010
@@ -97,6 +99,19 @@ 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/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTestConformance.c
 
b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTestConformance.c
index 874e4eb8..a7bec793 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
@@ -137,7 +137,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 "thoroug

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

2022-01-09 Thread Joseph Hemann
-add initial TCG2 protocol test for HashLogExtendEvent()
  -checkpoint for test of function with invalid parameters
  -checkpoint for test of function with valid parameters

V2:
-fix issue with reused Assertion Guid

Signed-off-by: Joseph Hemann 
Change-Id: I126f2c6316f8469455f8e2a19ca7e945e9d5d6ae
---
 .../EFI/Protocol/TCG2/BlackBoxTest/Guid.c |  12 +
 .../EFI/Protocol/TCG2/BlackBoxTest/Guid.h |  29 ++
 .../TCG2/BlackBoxTest/TCG2ProtocolBBTest.h|  29 ++
 .../TCG2ProtocolBBTestConformance.c   | 281 ++
 .../BlackBoxTest/TCG2ProtocolBBTestMain.c |   9 +
 5 files changed, 360 insertions(+)

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 0497f08f..ed013744 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
@@ -37,3 +37,15 @@ EFI_GUID gTcg2ConformanceTestAssertionGuid003 = 
EFI_TEST_TCG2CONFORMANCE_ASSERTI
 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;
+
+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;
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 f470255c..45c2b2b2 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
@@ -51,3 +51,32 @@ extern EFI_GUID gTcg2ConformanceTestAssertionGuid004;
 
 extern EFI_GUID gTcg2ConformanceTestAssertionGuid005;
 
+#define EFI_TEST_TCG2CONFORMANCE_ASSERTION_006_GUID \
+{ 0xa8e1b5e6, 0xfc09, 0x461c, {0xb0, 0xe9, 0x2a, 0x49, 0xcd, 0x25, 0xc1, 0x24 
}}
+
+extern EFI_GUID gTcg2ConformanceTestAssertionGuid006;
+
+#define EFI_TEST_TCG2CONFORMANCE_ASSERTION_007_GUID \
+{ 0x26f04a9b, 0x7b7a, 0x4f47, {0xbe, 0xa8, 0xb1, 0xa6, 0x02, 0x65, 0x19, 0x8a 
}}
+
+extern EFI_GUID gTcg2ConformanceTestAssertionGuid007;
+
+#define EFI_TEST_TCG2CONFORMANCE_ASSERTION_008_GUID \
+{ 0x4d1d9985, 0x91e2, 0x4948, {0x89, 0x16, 0xbb, 0x98, 0x13, 0x62, 0x39, 0x1d 
}}
+
+extern EFI_GUID gTcg2ConformanceTestAssertionGuid008;
+
+#define EFI_TEST_TCG2CONFORMANCE_ASSERTION_009_GUID \
+{ 0xfb59cab7, 0x4f8c, 0x4ded, {0xa4, 0x1c, 0xc8, 0x41, 0x20, 0x1c, 0x37, 0x22 
}}
+
+extern EFI_GUID gTcg2ConformanceTestAssertionGuid009;
+
+#define EFI_TEST_TCG2CONFORMANCE_ASSERTION_010_GUID \
+{ 0x0363d22f, 0xc66a, 0x4872, {0xa5, 0x46, 0x06, 0x7f, 0x6a, 0x0d, 0xdb, 0xcd 
}}
+
+extern EFI_GUID gTcg2ConformanceTestAssertionGuid010;
+
+#define EFI_TEST_TCG2CONFORMANCE_ASSERTION_011_GUID \
+{ 0x9cd6d636, 0x603a, 0x4b78, {0x80, 0xa3, 0xa3, 0xb9, 0xcc, 0x6a, 0x0b, 0x08 
}}
+
+extern EFI_GUID gTcg2ConformanceTestAssertionGuid011;
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 ed65bc97..1b56852e 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 0x0001
+
+#define PE_COFF_IMAGE 0x0010
+
 EFI_STATUS
 EFIAPI
 BBTestTCG2ProtocolUnload (
@@ -76,6 +85,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,
@@ -92,3 +113,11 @@ BBTestGetActivePcrBanksConformanceTest (
   IN

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

2022-01-09 Thread Joseph Hemann
-add initial TCG2 protocol test for SubmitCommand()
  -checkpoint for test function with TPM2_Hash Command
V2:
-Change command submitted from GetRandom to TPM2_HASH
-combined to 2 assertions into 1

Signed-off-by: Joseph Hemann 
Change-Id: Ibab68cae1d49953d1076c5628ea80319ba7ca831
---
 .../EFI/Protocol/TCG2/BlackBoxTest/Guid.c |   2 +
 .../EFI/Protocol/TCG2/BlackBoxTest/Guid.h |   5 +
 .../TCG2/BlackBoxTest/TCG2ProtocolBBTest.h|  70 +++
 .../TCG2ProtocolBBTestConformance.c   | 172 ++
 .../BlackBoxTest/TCG2ProtocolBBTestMain.c |   9 +
 5 files changed, 258 insertions(+)

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 b5a4e5c7..87541743 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
@@ -57,3 +57,5 @@ EFI_GUID gTcg2ConformanceTestAssertionGuid013 = 
EFI_TEST_TCG2CONFORMANCE_ASSERTI
 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/Guid.h 
b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.h
index d3a18aee..507cecc6 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
@@ -100,3 +100,8 @@ extern EFI_GUID gTcg2ConformanceTestAssertionGuid014;
 { 0xa76d2903, 0xbbcc, 0x8a72, {0x90, 0x23, 0xd3, 0xaa, 0xba, 0xb1, 0x52, 0x13 
}}

 
 extern EFI_GUID gTcg2ConformanceTestAssertionGuid015;
+
+#define EFI_TEST_TCG2CONFORMANCE_ASSERTION_016_GUID \
+{ 0x1689bc3a, 0x2298, 0xa116, {0x28, 0x4c, 0xc1, 0xdd, 0xaa, 0xd8, 0xef, 0x51 
}}

+
+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 d9c23094..c8684f79 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,6 +43,9 @@ 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

@@ -51,6 +54,61 @@ Abstract:
 
 #define PE_COFF_IMAGE 0x0010
 
+// ST_NO_SESSION as definied in Table 19 of TPM Library Part 2: Structures

+#define ST_NO_SESSIONS (UINT16) 0x8001

+

+// TPM_RC_SUCCESS as definied in Table 16 of TPM Library Spec Part 2: 
Structures

+#define TPM_RC_SUCCESS (UINT32) 0x000

+

+// TPM_CC_Hash as definied 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 definied in Table 86 of TPM Library Spec Part 2: 
Structures

+typedef struct {

+  UINT16 size;

+  UINT8  digest[5];  // Size of buffer in spec is defined to be variable 
length but for this test will always be 5

+} TPM2B_MAX_BUFFER;

+

+#pragma pack(1)

+// TPM2B_DIGEST as definied 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 Sectin 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 Sectin 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 (
@@ -111,6 +169,11 @@ BBTestGetEventLogConformanceTestCheckpoint2 (
   IN EFI_TCG2_PROTOCOL *TCG2

   );

 

+EFI_STATUS

+BBTestSubmitCommandConformanceTestCheckpoint1 (

+  IN

[edk2-devel] [PATCH 1/6] uefi-sct/SctPkg: TCG2 Protocol: add header with TCG2 protocol definitions

2022-01-09 Thread Joseph Hemann
Signed-off-by: Joseph Hemann 
---
 uefi-sct/SctPkg/UEFI/Protocol/TCG2.h | 174 +++
 1 file changed, 174 insertions(+)
 create mode 100644 uefi-sct/SctPkg/UEFI/Protocol/TCG2.h

diff --git a/uefi-sct/SctPkg/UEFI/Protocol/TCG2.h 
b/uefi-sct/SctPkg/UEFI/Protocol/TCG2.h
new file mode 100644
index ..923549e2
--- /dev/null
+++ b/uefi-sct/SctPkg/UEFI/Protocol/TCG2.h
@@ -0,0 +1,174 @@
+/** @file
+
+  Copyright 2006 - 2016 Unified EFI, Inc.
+  Copyright (c) 2013 - 2016, Intel Corporation. All rights reserved.
+  Copyright (c) 2021, Arm Inc. All rights reserved.
+
+  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 0x0001
+
+#define EFI_TCG2_BOOT_HASH_ALG_SHA256 0x0002
+
+#define EFI_TCG2_BOOT_HASH_ALG_SHA384 0x0004
+
+#define EFI_TCG2_BOOT_HASH_ALG_SHA512 0x0008
+
+#define EFI_TCG2_BOOT_HASH_ALG_SM3_256 0x0010
+
+#define EFI_TCG2_EVENT_LOG_FORMAT_TCG_1_2 0x0001
+
+#define EFI_TCG2_EVENT_LOG_FORMAT_TCG_2 0x0002
+
+typedef struct _EFI_TCG2_PROTOCOL EFI_TCG2_PROTOCOL;
+
+typedef UINT64 EFI_PHYSICAL_ADDRESS;
+
+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
+);
+
+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;
+
+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.25.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#85428): https://edk2.groups.io/g/devel/message/85428
Mute This Topic: https://groups.io/mt/88309834/21656
Group Ow

[edk2-devel] [PATCH 2/6] uefi-sct/SctPkg: TCG2 Protocol: add GetCapability Test

2022-01-09 Thread Joseph Hemann
-implement initial infrastructure for the TCG2 protocol test
including updates to .dsc file, inf file, GUID source files,
update to Category.ini.

-add initial TCG2 protocol test for GetCapability(), as
defined in the TCG EFI Protocol Spec 6.4.4.
  -checkpoint for NULL pointer passed for buffer
  -checkpoint for validating fields of the struct returned by GetCapabilty()

V2:
-adds checkpoint for verifying GetCapablity() when size < Capablity Struct
-adds check to ensure ActivePcrBanks is subset of HashAlgorithmBitmap
-adds checks for returned status by function

Signed-off-by: Joseph Hemann 
Change-Id: Iaeefecb1a468264daf57c3a0476035d8cac4f05d
---
 uefi-sct/SctPkg/CommonGenFramework.sh |   1 +
 uefi-sct/SctPkg/Config/Data/Category.ini  |   7 +
 .../EFI/Protocol/TCG2/BlackBoxTest/Guid.c |  35 ++
 .../EFI/Protocol/TCG2/BlackBoxTest/Guid.h |  43 +++
 .../TCG2/BlackBoxTest/TCG2ProtocolBBTest.h|  71 
 .../TCG2/BlackBoxTest/TCG2ProtocolBBTest.inf  |  51 +++
 .../TCG2ProtocolBBTestConformance.c   | 321 ++
 .../BlackBoxTest/TCG2ProtocolBBTestMain.c | 102 ++
 uefi-sct/SctPkg/UEFI/UEFI_SCT.dsc |   1 +
 9 files changed, 632 insertions(+)
 create mode 100644 
uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.c
 create mode 100644 
uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.h
 create mode 100644 
uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTest.h
 create mode 100644 
uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTest.inf
 create mode 100644 
uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTestConformance.c
 create mode 100644 
uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTestMain.c

diff --git a/uefi-sct/SctPkg/CommonGenFramework.sh 
b/uefi-sct/SctPkg/CommonGenFramework.sh
index 779a6a44..997d8ba1 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 af27e362..c239fe4b 100644
--- a/uefi-sct/SctPkg/Config/Data/Category.ini
+++ b/uefi-sct/SctPkg/Config/Data/Category.ini
@@ -1026,3 +1026,10 @@ InterfaceGuid = 8D59D32B-C655-4AE9-9B15-F25904992A43
 Name  = IHV\ConsoleSupportTest\AbsolutePointerProtocolTest
 Description   = Absolute Pointer Protocol Test on IHV Drivers
 
+[Category Data]
+Revision  = 0x0001
+CategoryGuid  = 607f766c-7455-42be-930b-e4d76db2720f
+InterfaceGuid = 607f766c-7455-42be-930b-e4d76db2720f
+Name  = TCG2ProtocolTest
+Description   =
+
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 ..206662ee
--- /dev/null
+++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.c
@@ -0,0 +1,35 @@
+/** @file
+
+  Copyright 2006 - 2013 Unified EFI, Inc.
+  Copyright (c) 2013, Intel Corporation. All rights reserved.
+  Copyright (c) 2021, Arm Inc. All rights reserved.

+
+  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;
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 ..b675756b
--- /dev/null
+++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/

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

2021-10-20 Thread Joseph Hemann
From: Joseph Hemann 

-add initial TCG2 protocol test for SubmitCommand()
  -checkpoint for test function with GET_RANDOM Command

Cc: G Edhaya Chandran 
Cc: Barton Gao 
Cc: Carolyn Gjertsen 
Cc: Samer El-Haj-Mahmoud 
Cc: Eric Jin 
Cc: Arvin Chen 
Cc: Supreeth Venkatesh 
Signed-off-by: Joseph Hemann 
---
 .../EFI/Protocol/TCG2/BlackBoxTest/Guid.c |   4 +
 .../EFI/Protocol/TCG2/BlackBoxTest/Guid.h |  10 +
 .../TCG2/BlackBoxTest/TCG2ProtocolBBTest.h|  49 +
 .../TCG2ProtocolBBTestConformance.c   | 178 ++
 .../BlackBoxTest/TCG2ProtocolBBTestMain.c |  10 +
 5 files changed, 251 insertions(+)

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 89c4151752cd..b5a4e5c7218e 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
@@ -53,3 +53,7 @@ EFI_GUID gTcg2ConformanceTestAssertionGuid011 = 
EFI_TEST_TCG2CONFORMANCE_ASSERTI
 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;
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 2cb715105529..ccc5a4bef957 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
@@ -90,3 +90,13 @@ extern EFI_GUID gTcg2ConformanceTestAssertionGuid012;
 { 0x45fa1a42, 0x912a, 0x5124, {0x84, 0xf4, 0x41, 0x67, 0xab, 0xb5, 0x89, 0x90 
}}
 
 extern EFI_GUID gTcg2ConformanceTestAssertionGuid013;
+
+#define EFI_TEST_TCG2CONFORMANCE_ASSERTION_014_GUID \
+{ 0x1689bc3a, 0x2298, 0xa116, {0x28, 0x4c, 0xc1, 0xdd, 0xaa, 0xd8, 0xef, 0x51 
}}
+
+extern EFI_GUID gTcg2ConformanceTestAssertionGuid014;
+
+#define EFI_TEST_TCG2CONFORMANCE_ASSERTION_015_GUID \
+{ 0x126a789a, 0x1932, 0x3234, {0x21, 0xab, 0x42, 0x64, 0x8a, 0x7b, 0x63, 0x76 
}}
+
+extern EFI_GUID gTcg2ConformanceTestAssertionGuid015;
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 69fb358922df..0fdf753f95fa 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,6 +43,9 @@ 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
@@ -51,6 +54,39 @@ Abstract:
 
 #define PE_COFF_IMAGE 0x0010
 
+// ST_NO_SESSION as definied in Table 19 of TPM Library Part 2: Structures
+#define ST_NO_SESSIONS (UINT16) 0x8001
+
+// TPM_RC_SUCCESS as definied in Table 16 of TPM Library Spec Part 2: 
Structures
+#define TPM_RC_SUCCESS (UINT32) 0x000
+
+// TPM_CC_GetRandom as definied in Table 12 of TPM Library Spec Part 2: 
Structures
+#define TPM_CC_GetRandom (UINT32) 0x017B
+
+#pragma pack(1)
+// TPM2B_DIGEST as definied in Table 73 of TPM Library Spec Part 2: Structures
+typedef struct {
+  UINT16 size;
+  UINT8  digest[8];  // Size of buffer in spec is defined to be variable 
length but for this test will always be 8
+} TPM2B_DIGEST;
+
+// GetRandomCommand Structure as defined in Sectin 16.1 of TPM Spec Part 3: 
Commands
+typedef struct {
+  UINT16 Tag;
+  UINT32 CommandSize;
+  UINT32 CommandCode;
+  UINT16 BytesRequested;
+} GET_RANDOM_COMMAND;
+
+// GetRandomResponse Structure as defined in Sectin 16.1 of TPM Spec Part 3: 
Commands
+typedef struct {
+  UINT16 Tag;
+  UINT32 ResponseSize;
+  UINT32 ResponseCode;
+  TPM2B_DIGEST randomBytes;
+} GET_RANDOM_RESPONSE;
+#pragma
+
 EFI_STATUS
 EFIAPI
 BBTestTCG2ProtocolUnload (
@@ -105,6 +141,12 @@ BBTestHashLogExtendEventConformanceTestCheckpoint4 (
   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,
@@ -129,3 +171,10 @@ BBTestHashLogExtendEventConformanceTest (
   IN EFI_HANDLE SupportHandle
   );
 
+EFI_STATUS
+BBTestSubmitCommandConformanceTest (
+  IN EFI_BB_TEST_PROTOCOL   *This

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

2021-10-20 Thread Joseph Hemann
From: Joseph Hemann 

-add initial TCG2 protocol test for GetEventLog()
  -checkpoint for test function with invalid eventlog format
  -checkpoint for test function with valid eventlog format

Cc: G Edhaya Chandran 
Cc: Barton Gao 
Cc: Carolyn Gjertsen 
Cc: Samer El-Haj-Mahmoud 
Cc: Eric Jin 
Cc: Arvin Chen 
Cc: Supreeth Venkatesh 
Signed-off-by: Joseph Hemann 
---
 .../EFI/Protocol/TCG2/BlackBoxTest/Guid.c |   8 +
 .../EFI/Protocol/TCG2/BlackBoxTest/Guid.h |  19 ++
 .../TCG2/BlackBoxTest/TCG2ProtocolBBTest.h|  14 ++
 .../TCG2ProtocolBBTestConformance.c   | 204 +-
 uefi-sct/SctPkg/UEFI/Protocol/TCG2.h  |  45 
 5 files changed, 289 insertions(+), 1 deletion(-)

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 32438f967d41..89c4151752cd 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
@@ -45,3 +45,11 @@ EFI_GUID gTcg2ConformanceTestAssertionGuid007 = 
EFI_TEST_TCG2CONFORMANCE_ASSERTI
 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;
+
+EFI_GUID gTcg2ConformanceTestAssertionGuid013 = 
EFI_TEST_TCG2CONFORMANCE_ASSERTION_013_GUID;
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 27908816bb81..2cb715105529 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
@@ -71,3 +71,22 @@ extern EFI_GUID gTcg2ConformanceTestAssertionGuid008;
 
 extern EFI_GUID gTcg2ConformanceTestAssertionGuid009;
 
+#define EFI_TEST_TCG2CONFORMANCE_ASSERTION_010_GUID \
+{ 0x0363d22f, 0xc66a, 0x4872, {0xa5, 0x46, 0x06, 0x7f, 0x6a, 0x0d, 0xdb, 0xcd 
}}
+
+extern EFI_GUID gTcg2ConformanceTestAssertionGuid010;
+
+#define EFI_TEST_TCG2CONFORMANCE_ASSERTION_011_GUID \
+{ 0x9cd6d636, 0x603a, 0x4b78, {0x80, 0xa3, 0xa3, 0xb9, 0xcc, 0x6a, 0x0b, 0x08 
}}
+
+extern EFI_GUID gTcg2ConformanceTestAssertionGuid011;
+
+#define EFI_TEST_TCG2CONFORMANCE_ASSERTION_012_GUID \
+{ 0xfc80408e, 0x9a3c, 0x4054, {0x96, 0xf9, 0x31, 0x23, 0x35, 0xc2, 0x31, 0x35 
}}
+
+extern EFI_GUID gTcg2ConformanceTestAssertionGuid012;
+
+#define EFI_TEST_TCG2CONFORMANCE_ASSERTION_013_GUID \
+{ 0x45fa1a42, 0x912a, 0x5124, {0x84, 0xf4, 0x41, 0x67, 0xab, 0xb5, 0x89, 0x90 
}}
+
+extern EFI_GUID gTcg2ConformanceTestAssertionGuid013;
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 f552e833b42b..69fb358922df 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
@@ -45,6 +45,8 @@ Abstract:
 
 #define EV_POST_CODE 0x01
 
+#define EV_NO_ACTION 0x03
+
 #define EFI_TCG2_EXTEND_ONLY 0x0001
 
 #define PE_COFF_IMAGE 0x0010
@@ -91,6 +93,18 @@ BBTestHashLogExtendEventConformanceTestCheckpoint2 (
   IN EFI_TCG2_PROTOCOL *TCG2
   );
 
+EFI_STATUS
+BBTestHashLogExtendEventConformanceTestCheckpoint3 (
+  IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL*StandardLib,
+  IN EFI_TCG2_PROTOCOL *TCG2
+  );
+
+EFI_STATUS
+BBTestHashLogExtendEventConformanceTestCheckpoint4 (
+  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/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTestConformance.c
 
b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTestConformance.c
index a3992c4709a6..d3aaf979c087 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
@@ -126,7 +126,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&quo

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

2021-10-20 Thread Joseph Hemann
From: Joseph Hemann 

-add initial TCG2 protocol test for HashLogExtendEvent()
  -checkpoint for test of function with invalid parameters
  -checkpoint for test of function with valid parameters

Cc: G Edhaya Chandran 
Cc: Barton Gao 
Cc: Carolyn Gjertsen 
Cc: Samer El-Haj-Mahmoud 
Cc: Eric Jin 
Cc: Arvin Chen 
Cc: Supreeth Venkatesh 
Signed-off-by: Joseph Hemann 
---
 .../EFI/Protocol/TCG2/BlackBoxTest/Guid.c |   8 +
 .../EFI/Protocol/TCG2/BlackBoxTest/Guid.h |  20 ++
 .../TCG2/BlackBoxTest/TCG2ProtocolBBTest.h|  29 ++
 .../TCG2ProtocolBBTestConformance.c   | 278 ++
 .../BlackBoxTest/TCG2ProtocolBBTestMain.c |   9 +
 5 files changed, 344 insertions(+)

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 0497f08f74f2..32438f967d41 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
@@ -37,3 +37,11 @@ EFI_GUID gTcg2ConformanceTestAssertionGuid003 = 
EFI_TEST_TCG2CONFORMANCE_ASSERTI
 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;
+
+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;
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 f470255ccdcf..27908816bb81 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
@@ -51,3 +51,23 @@ extern EFI_GUID gTcg2ConformanceTestAssertionGuid004;
 
 extern EFI_GUID gTcg2ConformanceTestAssertionGuid005;
 
+#define EFI_TEST_TCG2CONFORMANCE_ASSERTION_006_GUID \
+{ 0xa8e1b5e6, 0xfc09, 0x461c, {0xb0, 0xe9, 0x2a, 0x49, 0xcd, 0x25, 0xc1, 0x24 
}}
+
+extern EFI_GUID gTcg2ConformanceTestAssertionGuid006;
+
+#define EFI_TEST_TCG2CONFORMANCE_ASSERTION_007_GUID \
+{ 0x26f04a9b, 0x7b7a, 0x4f47, {0xbe, 0xa8, 0xb1, 0xa6, 0x02, 0x65, 0x19, 0x8a 
}}
+
+extern EFI_GUID gTcg2ConformanceTestAssertionGuid007;
+
+#define EFI_TEST_TCG2CONFORMANCE_ASSERTION_008_GUID \
+{ 0x4d1d9985, 0x91e2, 0x4948, {0x89, 0x16, 0xbb, 0x98, 0x13, 0x62, 0x39, 0x1d 
}}
+
+extern EFI_GUID gTcg2ConformanceTestAssertionGuid008;
+
+#define EFI_TEST_TCG2CONFORMANCE_ASSERTION_009_GUID \
+{ 0xfb59cab7, 0x4f8c, 0x4ded, {0xa4, 0x1c, 0xc8, 0x41, 0x20, 0x1c, 0x37, 0x22 
}}
+
+extern EFI_GUID gTcg2ConformanceTestAssertionGuid009;
+
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 a6773010b64f..f552e833b42b 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 0x0001
+
+#define PE_COFF_IMAGE 0x0010
+
 EFI_STATUS
 EFIAPI
 BBTestTCG2ProtocolUnload (
@@ -70,6 +79,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,
@@ -86,3 +107,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/TCG2ProtocolBBTestConformance.c
 
b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest

[edk2-devel] [PATCH 2/6] uefi-sct/SctPkg: TCG2 Protocol: add GetCapability Test

2021-10-20 Thread Joseph Hemann
From: Joseph Hemann 

-implement initial infrastructure for the TCG2 protocol test
including updates to .dsc file, inf file, GUID source files,
update to Category.ini.

-add initial TCG2 protocol test for GetCapability(), as
defined in the TCG EFI Protocol Spec 6.4.4.
  -checkpoint for NULL pointer passed for buffer
  -checkpoint for validating fields of the struct returned by GetCapabilty()

Cc: G Edhaya Chandran 
Cc: Barton Gao 
Cc: Carolyn Gjertsen 
Cc: Samer El-Haj-Mahmoud 
Cc: Eric Jin 
Cc: Arvin Chen 
Cc: Supreeth Venkatesh 
Signed-off-by: Joseph Hemann 
---
 uefi-sct/SctPkg/CommonGenFramework.sh |   1 +
 uefi-sct/SctPkg/Config/Data/Category.ini  |   7 +
 .../EFI/Protocol/TCG2/BlackBoxTest/Guid.c |  35 +++
 .../EFI/Protocol/TCG2/BlackBoxTest/Guid.h |  43 
 .../TCG2/BlackBoxTest/TCG2ProtocolBBTest.h|  65 ++
 .../TCG2/BlackBoxTest/TCG2ProtocolBBTest.inf  |  51 
 .../TCG2ProtocolBBTestConformance.c   | 221 ++
 .../BlackBoxTest/TCG2ProtocolBBTestMain.c | 102 
 uefi-sct/SctPkg/UEFI/UEFI_SCT.dsc |   1 +
 9 files changed, 526 insertions(+)
 create mode 100644 
uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.c
 create mode 100644 
uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.h
 create mode 100644 
uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTest.h
 create mode 100644 
uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTest.inf
 create mode 100644 
uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTestConformance.c
 create mode 100644 
uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTestMain.c

diff --git a/uefi-sct/SctPkg/CommonGenFramework.sh 
b/uefi-sct/SctPkg/CommonGenFramework.sh
index 779a6a4492b3..997d8ba1638b 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 af27e362ec8a..c239fe4ba98c 100644
--- a/uefi-sct/SctPkg/Config/Data/Category.ini
+++ b/uefi-sct/SctPkg/Config/Data/Category.ini
@@ -1026,3 +1026,10 @@ InterfaceGuid = 8D59D32B-C655-4AE9-9B15-F25904992A43
 Name  = IHV\ConsoleSupportTest\AbsolutePointerProtocolTest
 Description   = Absolute Pointer Protocol Test on IHV Drivers
 
+[Category Data]
+Revision  = 0x0001
+CategoryGuid  = 607f766c-7455-42be-930b-e4d76db2720f
+InterfaceGuid = 607f766c-7455-42be-930b-e4d76db2720f
+Name  = TCG2ProtocolTest
+Description   =
+
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 ..206662ee7933
--- /dev/null
+++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.c
@@ -0,0 +1,35 @@
+/** @file
+
+  Copyright 2006 - 2013 Unified EFI, Inc.
+  Copyright (c) 2013, Intel Corporation. All rights reserved.
+  Copyright (c) 2021, Arm Inc. All rights reserved.
+
+  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;
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 ..b675756b9fb7
--- /dev/null
+++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.h
@@ -0,0 +1,43 @@
+/** @file
+
+  Copyright 

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

2021-10-20 Thread Joseph Hemann
From: Joseph Hemann 

 -add initial TCG2 protocol test for GetActivePcrBanks()
  -checkpoint for NULL pointer passed for buffer
  -checkpoint for test of function with proper input

Cc: G Edhaya Chandran 
Cc: Barton Gao 
Cc: Carolyn Gjertsen 
Cc: Samer El-Haj-Mahmoud 
Cc: Eric Jin 
Cc: Arvin Chen 
Cc: Supreeth Venkatesh 
Signed-off-by: Joseph Hemann 
---
 .../EFI/Protocol/TCG2/BlackBoxTest/Guid.c |   4 +
 .../EFI/Protocol/TCG2/BlackBoxTest/Guid.h |  10 ++
 .../TCG2/BlackBoxTest/TCG2ProtocolBBTest.h|  23 +++
 .../TCG2ProtocolBBTestConformance.c   | 140 +-
 .../BlackBoxTest/TCG2ProtocolBBTestMain.c |   9 ++
 5 files changed, 185 insertions(+), 1 deletion(-)

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 206662ee7933..0497f08f74f2 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
@@ -33,3 +33,7 @@ EFI_GUID gTcg2ConformanceTestAssertionGuid001 = 
EFI_TEST_TCG2CONFORMANCE_ASSERTI
 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;
+
+EFI_GUID gTcg2ConformanceTestAssertionGuid005 = 
EFI_TEST_TCG2CONFORMANCE_ASSERTION_005_GUID;
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 b675756b9fb7..f470255ccdcf 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
@@ -41,3 +41,13 @@ extern EFI_GUID gTcg2ConformanceTestAssertionGuid002;
 
 extern EFI_GUID gTcg2ConformanceTestAssertionGuid003;
 
+#define EFI_TEST_TCG2CONFORMANCE_ASSERTION_004_GUID \
+{ 0x7a1e79a3, 0x4064, 0x4372, {0xbb, 0x64, 0x55, 0xb8, 0xf2, 0xa5, 0xa3, 0x26 
}}
+
+extern EFI_GUID gTcg2ConformanceTestAssertionGuid004;
+
+#define EFI_TEST_TCG2CONFORMANCE_ASSERTION_005_GUID \
+{ 0xb0e717c4, 0xb1e2, 0x49f7, {0xb2, 0xd7, 0x60, 0x58, 0x97, 0x7d, 0x09, 0x2c 
}}
+
+extern EFI_GUID gTcg2ConformanceTestAssertionGuid005;
+
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 674540182d2d..a6773010b64f 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 (
@@ -55,6 +58,18 @@ BBTestGetCapabilityConformanceTestCheckpoint2 (
   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,
@@ -63,3 +78,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/TCG2ProtocolBBTestConformance.c
 
b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTestConformance.c
index fec542167171..5277f9433f7e 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
@@ -75,6 +75,54 @@ 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
+ 

[edk2-devel] [PATCH 0/6] Implementation of TCG2 Protocol test

2021-10-20 Thread Joseph Hemann
From: Joseph Hemann 

This patch series implements a set of SCT tests,
for the TCG2 UEFI protocol as defined in the TCG
EFI Protocol Specification. The series implements
the code for the test, and the infrastructure
needed to run the test from the SCT UI.

Patch 1 adds header file with TCG2 protocol definitions.

Patch 2 implements initial infrastructure for the
TCG2 protocol test including updates to .dsc file,
inf file, GUID source files, update to Category.ini.
It also adds initial TCG2 protocol test for GetCapability().

Patch 3 implements TCG2 protocol test for GetActivePcrBanks().

Patch 4 implements a test for HashLogExtendEvent() by hashing,
and extending data in a test buffer to PCR[16].

Patch 5 implements a test for GetEventLog(), by checking for
the event extended in the test in Patch 4.

Patch 6 tests SubmitCommand(), by submitting a simple command
(GetRandom) to the TPM.

Cc: G Edhaya Chandran 
Cc: Barton Gao 
Cc: Carolyn Gjertsen 
Cc: Samer El-Haj-Mahmoud 
Cc: Eric Jin 
Cc: Arvin Chen 
Cc: Supreeth Venkatesh 

Joseph Hemann (6):
  uefi-sct/SctPkg: TCG2 Protocol: add header with TCG2 protocol
definitions
  uefi-sct/SctPkg: TCG2 Protocol: add GetCapability Test
  uefi-sct/SctPkg: TCG2 Protocol: add GetActivePcrBanks  test
  uefi-sct/SctPkg: TCG2 Protocol: add HashLogExtendEvent test
  uefi-sct/SctPkg: TCG2 Protocol: add GetEventLog test
  uefi-sct/SctPkg: TCG2 Protocol: add SubmitCommand test

 uefi-sct/SctPkg/CommonGenFramework.sh |1 +
 uefi-sct/SctPkg/Config/Data/Category.ini  |7 +
 .../EFI/Protocol/TCG2/BlackBoxTest/Guid.c |   59 +
 .../EFI/Protocol/TCG2/BlackBoxTest/Guid.h |  102 ++
 .../TCG2/BlackBoxTest/TCG2ProtocolBBTest.h|  180 +++
 .../TCG2/BlackBoxTest/TCG2ProtocolBBTest.inf  |   51 +
 .../TCG2ProtocolBBTestConformance.c   | 1017 +
 .../BlackBoxTest/TCG2ProtocolBBTestMain.c |  130 +++
 uefi-sct/SctPkg/UEFI/Protocol/TCG2.h  |  219 
 uefi-sct/SctPkg/UEFI/UEFI_SCT.dsc |1 +
 10 files changed, 1767 insertions(+)
 create mode 100644 
uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.c
 create mode 100644 
uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.h
 create mode 100644 
uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTest.h
 create mode 100644 
uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTest.inf
 create mode 100644 
uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTestConformance.c
 create mode 100644 
uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTestMain.c
 create mode 100644 uefi-sct/SctPkg/UEFI/Protocol/TCG2.h

-- 
2.17.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#82422): https://edk2.groups.io/g/devel/message/82422
Mute This Topic: https://groups.io/mt/86464899/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




[edk2-devel] [PATCH 1/6] uefi-sct/SctPkg: TCG2 Protocol: add header with TCG2 protocol definitions

2021-10-20 Thread Joseph Hemann
From: Joseph Hemann 

Cc: G Edhaya Chandran 
Cc: Barton Gao 
Cc: Carolyn Gjertsen 
Cc: Samer El-Haj-Mahmoud 
Cc: Eric Jin 
Cc: Arvin Chen 
Cc: Supreeth Venkatesh 

Signed-off-by: Joseph Hemann 
---
 uefi-sct/SctPkg/UEFI/Protocol/TCG2.h | 174 +++
 1 file changed, 174 insertions(+)
 create mode 100644 uefi-sct/SctPkg/UEFI/Protocol/TCG2.h

diff --git a/uefi-sct/SctPkg/UEFI/Protocol/TCG2.h 
b/uefi-sct/SctPkg/UEFI/Protocol/TCG2.h
new file mode 100644
index ..9ece78e0deaf
--- /dev/null
+++ b/uefi-sct/SctPkg/UEFI/Protocol/TCG2.h
@@ -0,0 +1,174 @@
+/** @file
+
+  Copyright 2006 - 2016 Unified EFI, Inc.
+  Copyright (c) 2013 - 2016, Intel Corporation. All rights reserved.
+  Copyright (c) 2021, Arm Inc. All rights reserved.
+
+  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 0x0001
+
+#define EFI_TCG2_BOOT_HASH_ALG_SHA256 0x0002
+
+#define EFI_TCG2_BOOT_HASH_ALG_SHA384 0x0004
+
+#define EFI_TCG2_BOOT_HASH_ALG_SHA512 0x0008
+
+#define EFI_TCG2_BOOT_HASH_ALG_SM3_256 0x0010
+
+#define EFI_TCG2_EVENT_LOG_FORMAT_TCG_1_2 0x0001
+
+#define EFI_TCG2_EVENT_LOG_FORMAT_TCG_2 0x0002
+
+typedef struct _EFI_TCG2_PROTOCOL EFI_TCG2_PROTOCOL;
+
+typedef UINT64 EFI_PHYSICAL_ADDRESS;
+
+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
+);
+
+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;
+
+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.17.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You r

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

2021-10-15 Thread Joseph Hemann
From: Joseph Hemann 

-add initial TCG2 protocol test for SubmitCommand()
  -checkpoint for test function with GET_RANDOM Command

Signed-off-by: Joseph Hemann 
Change-Id: I364001c915b9d8d8b79eb4381d828400a1ef72a0
---
 .../EFI/Protocol/TCG2/BlackBoxTest/Guid.c |   4 +
 .../EFI/Protocol/TCG2/BlackBoxTest/Guid.h |  10 +
 .../TCG2/BlackBoxTest/TCG2ProtocolBBTest.h|  49 +
 .../TCG2ProtocolBBTestConformance.c   | 178 ++
 .../BlackBoxTest/TCG2ProtocolBBTestMain.c |  10 +
 5 files changed, 251 insertions(+)

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 89c41517..b5a4e5c7 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
@@ -53,3 +53,7 @@ EFI_GUID gTcg2ConformanceTestAssertionGuid011 = 
EFI_TEST_TCG2CONFORMANCE_ASSERTI
 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;
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 2cb71510..ccc5a4be 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
@@ -90,3 +90,13 @@ extern EFI_GUID gTcg2ConformanceTestAssertionGuid012;
 { 0x45fa1a42, 0x912a, 0x5124, {0x84, 0xf4, 0x41, 0x67, 0xab, 0xb5, 0x89, 0x90 
}}
 
 extern EFI_GUID gTcg2ConformanceTestAssertionGuid013;
+
+#define EFI_TEST_TCG2CONFORMANCE_ASSERTION_014_GUID \
+{ 0x1689bc3a, 0x2298, 0xa116, {0x28, 0x4c, 0xc1, 0xdd, 0xaa, 0xd8, 0xef, 0x51 
}}
+
+extern EFI_GUID gTcg2ConformanceTestAssertionGuid014;
+
+#define EFI_TEST_TCG2CONFORMANCE_ASSERTION_015_GUID \
+{ 0x126a789a, 0x1932, 0x3234, {0x21, 0xab, 0x42, 0x64, 0x8a, 0x7b, 0x63, 0x76 
}}
+
+extern EFI_GUID gTcg2ConformanceTestAssertionGuid015;
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 69fb3589..0fdf753f 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,6 +43,9 @@ 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
@@ -51,6 +54,39 @@ Abstract:
 
 #define PE_COFF_IMAGE 0x0010
 
+// ST_NO_SESSION as definied in Table 19 of TPM Library Part 2: Structures
+#define ST_NO_SESSIONS (UINT16) 0x8001
+
+// TPM_RC_SUCCESS as definied in Table 16 of TPM Library Spec Part 2: 
Structures
+#define TPM_RC_SUCCESS (UINT32) 0x000
+
+// TPM_CC_GetRandom as definied in Table 12 of TPM Library Spec Part 2: 
Structures
+#define TPM_CC_GetRandom (UINT32) 0x017B
+
+#pragma pack(1)
+// TPM2B_DIGEST as definied in Table 73 of TPM Library Spec Part 2: Structures
+typedef struct {
+  UINT16 size;
+  UINT8  digest[8];  // Size of buffer in spec is defined to be variable 
length but for this test will always be 8
+} TPM2B_DIGEST;
+
+// GetRandomCommand Structure as defined in Sectin 16.1 of TPM Spec Part 3: 
Commands
+typedef struct {
+  UINT16 Tag;
+  UINT32 CommandSize;
+  UINT32 CommandCode;
+  UINT16 BytesRequested;
+} GET_RANDOM_COMMAND;
+
+// GetRandomResponse Structure as defined in Sectin 16.1 of TPM Spec Part 3: 
Commands
+typedef struct {
+  UINT16 Tag;
+  UINT32 ResponseSize;
+  UINT32 ResponseCode;
+  TPM2B_DIGEST randomBytes;
+} GET_RANDOM_RESPONSE;
+#pragma
+
 EFI_STATUS
 EFIAPI
 BBTestTCG2ProtocolUnload (
@@ -105,6 +141,12 @@ BBTestHashLogExtendEventConformanceTestCheckpoint4 (
   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,
@@ -129,3 +171,10 @@ BBTestHashLogExtendEventConformanceTest (
   IN EFI_HANDLE SupportHandle
   );
 
+EFI_STATUS
+BBTestSubmitCommandConformanceTest (
+  IN EFI_BB_TEST_PROTOCOL   *This,
+  IN VOID   *ClientInterface,
+  IN EFI_TEST_LEVEL TestLevel,
+  IN

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

2021-10-15 Thread Joseph Hemann
From: Joseph Hemann 

-add initial TCG2 protocol test for GetEventLog()
  -checkpoint for test function with invalid eventlog format
  -checkpoint for test function with valid eventlog format

Signed-off-by: Joseph Hemann 
Change-Id: Ie5399f24622ce849d8f1140c56bd71cf886423e3
---
 .../EFI/Protocol/TCG2/BlackBoxTest/Guid.c |   8 +
 .../EFI/Protocol/TCG2/BlackBoxTest/Guid.h |  19 ++
 .../TCG2/BlackBoxTest/TCG2ProtocolBBTest.h|  14 ++
 .../TCG2ProtocolBBTestConformance.c   | 204 +-
 uefi-sct/SctPkg/UEFI/Protocol/TCG2.h  |  45 
 5 files changed, 289 insertions(+), 1 deletion(-)

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 32438f96..89c41517 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
@@ -45,3 +45,11 @@ EFI_GUID gTcg2ConformanceTestAssertionGuid007 = 
EFI_TEST_TCG2CONFORMANCE_ASSERTI
 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;
+
+EFI_GUID gTcg2ConformanceTestAssertionGuid013 = 
EFI_TEST_TCG2CONFORMANCE_ASSERTION_013_GUID;
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 27908816..2cb71510 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
@@ -71,3 +71,22 @@ extern EFI_GUID gTcg2ConformanceTestAssertionGuid008;
 
 extern EFI_GUID gTcg2ConformanceTestAssertionGuid009;
 
+#define EFI_TEST_TCG2CONFORMANCE_ASSERTION_010_GUID \
+{ 0x0363d22f, 0xc66a, 0x4872, {0xa5, 0x46, 0x06, 0x7f, 0x6a, 0x0d, 0xdb, 0xcd 
}}
+
+extern EFI_GUID gTcg2ConformanceTestAssertionGuid010;
+
+#define EFI_TEST_TCG2CONFORMANCE_ASSERTION_011_GUID \
+{ 0x9cd6d636, 0x603a, 0x4b78, {0x80, 0xa3, 0xa3, 0xb9, 0xcc, 0x6a, 0x0b, 0x08 
}}
+
+extern EFI_GUID gTcg2ConformanceTestAssertionGuid011;
+
+#define EFI_TEST_TCG2CONFORMANCE_ASSERTION_012_GUID \
+{ 0xfc80408e, 0x9a3c, 0x4054, {0x96, 0xf9, 0x31, 0x23, 0x35, 0xc2, 0x31, 0x35 
}}
+
+extern EFI_GUID gTcg2ConformanceTestAssertionGuid012;
+
+#define EFI_TEST_TCG2CONFORMANCE_ASSERTION_013_GUID \
+{ 0x45fa1a42, 0x912a, 0x5124, {0x84, 0xf4, 0x41, 0x67, 0xab, 0xb5, 0x89, 0x90 
}}
+
+extern EFI_GUID gTcg2ConformanceTestAssertionGuid013;
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 f552e833..69fb3589 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
@@ -45,6 +45,8 @@ Abstract:
 
 #define EV_POST_CODE 0x01
 
+#define EV_NO_ACTION 0x03
+
 #define EFI_TCG2_EXTEND_ONLY 0x0001
 
 #define PE_COFF_IMAGE 0x0010
@@ -91,6 +93,18 @@ BBTestHashLogExtendEventConformanceTestCheckpoint2 (
   IN EFI_TCG2_PROTOCOL *TCG2
   );
 
+EFI_STATUS
+BBTestHashLogExtendEventConformanceTestCheckpoint3 (
+  IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL*StandardLib,
+  IN EFI_TCG2_PROTOCOL *TCG2
+  );
+
+EFI_STATUS
+BBTestHashLogExtendEventConformanceTestCheckpoint4 (
+  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/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTestConformance.c
 
b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTestConformance.c
index 5566645c..a3477ec9 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
@@ -126,7 +126,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
@@ -168,6 +168,12 @@ BBTestHashLogExtendEventConformanceTest (
   //Test with correct 

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

2021-10-15 Thread Joseph Hemann
From: Joseph Hemann 

-add initial TCG2 protocol test for HashLogExtendEvent()
  -checkpoint for test of function with invalid parameters
  -checkpoint for test of function with valid parameters

Signed-off-by: Joseph Hemann 
Change-Id: Icac3857a5e0d877e9b21f85c20f7d391a380043e
---
 .../EFI/Protocol/TCG2/BlackBoxTest/Guid.c |   8 +
 .../EFI/Protocol/TCG2/BlackBoxTest/Guid.h |  20 ++
 .../TCG2/BlackBoxTest/TCG2ProtocolBBTest.h|  29 ++
 .../TCG2ProtocolBBTestConformance.c   | 278 ++
 .../BlackBoxTest/TCG2ProtocolBBTestMain.c |   9 +
 5 files changed, 344 insertions(+)

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 0497f08f..32438f96 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
@@ -37,3 +37,11 @@ EFI_GUID gTcg2ConformanceTestAssertionGuid003 = 
EFI_TEST_TCG2CONFORMANCE_ASSERTI
 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;
+
+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;
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 f470255c..27908816 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
@@ -51,3 +51,23 @@ extern EFI_GUID gTcg2ConformanceTestAssertionGuid004;
 
 extern EFI_GUID gTcg2ConformanceTestAssertionGuid005;
 
+#define EFI_TEST_TCG2CONFORMANCE_ASSERTION_006_GUID \
+{ 0xa8e1b5e6, 0xfc09, 0x461c, {0xb0, 0xe9, 0x2a, 0x49, 0xcd, 0x25, 0xc1, 0x24 
}}
+
+extern EFI_GUID gTcg2ConformanceTestAssertionGuid006;
+
+#define EFI_TEST_TCG2CONFORMANCE_ASSERTION_007_GUID \
+{ 0x26f04a9b, 0x7b7a, 0x4f47, {0xbe, 0xa8, 0xb1, 0xa6, 0x02, 0x65, 0x19, 0x8a 
}}
+
+extern EFI_GUID gTcg2ConformanceTestAssertionGuid007;
+
+#define EFI_TEST_TCG2CONFORMANCE_ASSERTION_008_GUID \
+{ 0x4d1d9985, 0x91e2, 0x4948, {0x89, 0x16, 0xbb, 0x98, 0x13, 0x62, 0x39, 0x1d 
}}
+
+extern EFI_GUID gTcg2ConformanceTestAssertionGuid008;
+
+#define EFI_TEST_TCG2CONFORMANCE_ASSERTION_009_GUID \
+{ 0xfb59cab7, 0x4f8c, 0x4ded, {0xa4, 0x1c, 0xc8, 0x41, 0x20, 0x1c, 0x37, 0x22 
}}
+
+extern EFI_GUID gTcg2ConformanceTestAssertionGuid009;
+
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 a6773010..f552e833 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 0x0001
+
+#define PE_COFF_IMAGE 0x0010
+
 EFI_STATUS
 EFIAPI
 BBTestTCG2ProtocolUnload (
@@ -70,6 +79,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,
@@ -86,3 +107,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/TCG2ProtocolBBTestConformance.c
 
b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTestConformance.c
index 009bd5af..5566645c 100644
--- 
a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest

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

2021-10-15 Thread Joseph Hemann
From: Joseph Hemann 

 -add initial TCG2 protocol test for GetActivePcrBanks()
  -checkpoint for NULL pointer passed for buffer
  -checkpoint for test of function with proper input

Signed-off-by: Joseph Hemann 
Change-Id: Ibf289085dc0f21952ff210757b4736619ac34046
---
 .../EFI/Protocol/TCG2/BlackBoxTest/Guid.c |   4 +
 .../EFI/Protocol/TCG2/BlackBoxTest/Guid.h |  10 ++
 .../TCG2/BlackBoxTest/TCG2ProtocolBBTest.h|  23 +++
 .../TCG2ProtocolBBTestConformance.c   | 140 +-
 .../BlackBoxTest/TCG2ProtocolBBTestMain.c |   9 ++
 5 files changed, 185 insertions(+), 1 deletion(-)

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 206662ee..0497f08f 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
@@ -33,3 +33,7 @@ EFI_GUID gTcg2ConformanceTestAssertionGuid001 = 
EFI_TEST_TCG2CONFORMANCE_ASSERTI
 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;
+
+EFI_GUID gTcg2ConformanceTestAssertionGuid005 = 
EFI_TEST_TCG2CONFORMANCE_ASSERTION_005_GUID;
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 b675756b..f470255c 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
@@ -41,3 +41,13 @@ extern EFI_GUID gTcg2ConformanceTestAssertionGuid002;
 
 extern EFI_GUID gTcg2ConformanceTestAssertionGuid003;
 
+#define EFI_TEST_TCG2CONFORMANCE_ASSERTION_004_GUID \
+{ 0x7a1e79a3, 0x4064, 0x4372, {0xbb, 0x64, 0x55, 0xb8, 0xf2, 0xa5, 0xa3, 0x26 
}}
+
+extern EFI_GUID gTcg2ConformanceTestAssertionGuid004;
+
+#define EFI_TEST_TCG2CONFORMANCE_ASSERTION_005_GUID \
+{ 0xb0e717c4, 0xb1e2, 0x49f7, {0xb2, 0xd7, 0x60, 0x58, 0x97, 0x7d, 0x09, 0x2c 
}}
+
+extern EFI_GUID gTcg2ConformanceTestAssertionGuid005;
+
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 67454018..a6773010 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 (
@@ -55,6 +58,18 @@ BBTestGetCapabilityConformanceTestCheckpoint2 (
   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,
@@ -63,3 +78,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/TCG2ProtocolBBTestConformance.c
 
b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTestConformance.c
index e1724ff3..009bd5af 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
@@ -75,6 +75,54 @@ 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   *T

[edk2-devel] [PATCH 2/6] uefi-sct/SctPkg: TCG2 Protocol: add GetCapability Test

2021-10-15 Thread Joseph Hemann
From: Joseph Hemann 

-implement initial infrastructure for the TCG2 protocol test
including updates to .dsc file, inf file, GUID source files,
update to Category.ini.

-add initial TCG2 protocol test for GetCapability(), as
defined in the TCG EFI Protocol Spec 6.4.4.
  -checkpoint for NULL pointer passed for buffer
  -checkpoint for struct with incorrect size field
  -checkpoint for full sized struct

Signed-off-by: Joseph Hemann 
Change-Id: If7d0bfa06529aebd3dfc9f12e8dafa2958812ef7
---
 uefi-sct/SctPkg/CommonGenFramework.sh |   1 +
 uefi-sct/SctPkg/Config/Data/Category.ini  |   7 +
 .../EFI/Protocol/TCG2/BlackBoxTest/Guid.c |  35 +++
 .../EFI/Protocol/TCG2/BlackBoxTest/Guid.h |  43 
 .../TCG2/BlackBoxTest/TCG2ProtocolBBTest.h|  65 ++
 .../TCG2/BlackBoxTest/TCG2ProtocolBBTest.inf  |  51 
 .../TCG2ProtocolBBTestConformance.c   | 221 ++
 .../BlackBoxTest/TCG2ProtocolBBTestMain.c | 102 
 uefi-sct/SctPkg/UEFI/UEFI_SCT.dsc |   1 +
 9 files changed, 526 insertions(+)
 create mode 100644 
uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.c
 create mode 100644 
uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.h
 create mode 100644 
uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTest.h
 create mode 100644 
uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTest.inf
 create mode 100644 
uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTestConformance.c
 create mode 100644 
uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTestMain.c

diff --git a/uefi-sct/SctPkg/CommonGenFramework.sh 
b/uefi-sct/SctPkg/CommonGenFramework.sh
index 779a6a44..997d8ba1 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 af27e362..c239fe4b 100644
--- a/uefi-sct/SctPkg/Config/Data/Category.ini
+++ b/uefi-sct/SctPkg/Config/Data/Category.ini
@@ -1026,3 +1026,10 @@ InterfaceGuid = 8D59D32B-C655-4AE9-9B15-F25904992A43
 Name  = IHV\ConsoleSupportTest\AbsolutePointerProtocolTest
 Description   = Absolute Pointer Protocol Test on IHV Drivers
 
+[Category Data]
+Revision  = 0x0001
+CategoryGuid  = 607f766c-7455-42be-930b-e4d76db2720f
+InterfaceGuid = 607f766c-7455-42be-930b-e4d76db2720f
+Name  = TCG2ProtocolTest
+Description   =
+
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 ..206662ee
--- /dev/null
+++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.c
@@ -0,0 +1,35 @@
+/** @file
+
+  Copyright 2006 - 2013 Unified EFI, Inc.
+  Copyright (c) 2013, Intel Corporation. All rights reserved.
+  Copyright (c) 2021, Arm Inc. All rights reserved.
+
+  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;
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 ..b675756b
--- /dev/null
+++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.h
@@ -0,0 +1,43 @@
+/** @file
+
+  Copyright 2006 - 2016 Unified EFI, Inc.
+  Copyright (c) 2013, Intel Corporation. All rights reserved.
+  Copyrigh

[edk2-devel] [PATCH 1/6] uefi-sct/SctPkg: TCG2 Protocol: add header with TCG2 protocol definitions

2021-10-15 Thread Joseph Hemann
From: Joseph Hemann 

Signed-off-by: Joseph Hemann 
Change-Id: Ib8fafb94c99fbc71f606d23bcdd18963fc7386de
---
 uefi-sct/SctPkg/UEFI/Protocol/TCG2.h | 174 +++
 1 file changed, 174 insertions(+)
 create mode 100644 uefi-sct/SctPkg/UEFI/Protocol/TCG2.h

diff --git a/uefi-sct/SctPkg/UEFI/Protocol/TCG2.h 
b/uefi-sct/SctPkg/UEFI/Protocol/TCG2.h
new file mode 100644
index ..9ece78e0
--- /dev/null
+++ b/uefi-sct/SctPkg/UEFI/Protocol/TCG2.h
@@ -0,0 +1,174 @@
+/** @file
+
+  Copyright 2006 - 2016 Unified EFI, Inc.
+  Copyright (c) 2013 - 2016, Intel Corporation. All rights reserved.
+  Copyright (c) 2021, Arm Inc. All rights reserved.
+
+  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 0x0001
+
+#define EFI_TCG2_BOOT_HASH_ALG_SHA256 0x0002
+
+#define EFI_TCG2_BOOT_HASH_ALG_SHA384 0x0004
+
+#define EFI_TCG2_BOOT_HASH_ALG_SHA512 0x0008
+
+#define EFI_TCG2_BOOT_HASH_ALG_SM3_256 0x0010
+
+#define EFI_TCG2_EVENT_LOG_FORMAT_TCG_1_2 0x0001
+
+#define EFI_TCG2_EVENT_LOG_FORMAT_TCG_2 0x0002
+
+typedef struct _EFI_TCG2_PROTOCOL EFI_TCG2_PROTOCOL;
+
+typedef UINT64 EFI_PHYSICAL_ADDRESS;
+
+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
+);
+
+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;
+
+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.17.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#82146): https://edk2.groups.io/g/dev

[edk2-devel] [PATCH 0/6] Implementation of TCG2 Protocol test

2021-10-15 Thread Joseph Hemann
From: Joseph Hemann 

This patch series implements a set of SCT tests,
for the TCG2 UEFI protocol as defined in the TCG
EFI Protocol Specification. The series implements
the code for the test, and the infrastructure
needed to run the test from the SCT UI.

Patch 1 adds header file with TCG2 protocol definitions.

Patch 2 implements initial infrastructure for the
TCG2 protocol test including updates to .dsc file,
inf file, GUID source files, update to Category.ini.
It also adds initial TCG2 protocol test for GetCapability().

Patch 3 implements TCG2 protocol test for GetActivePcrBanks().

Patch 4 implements a test for HashLogExtendEvent() by hashing,
and extending data in a test buffer to PCR[16].

Patch 5 implements a test for GetEventLog(), by checking for
the event extended in the test in Patch 4.

Patch 6 tests SubmitCommand(), by submitting a simple command
(GetRandom) to the TPM.

Joseph Hemann (6):
  uefi-sct/SctPkg: TCG2 Protocol: add header with TCG2 protocol
definitions
  uefi-sct/SctPkg: TCG2 Protocol: add GetCapability Test
  uefi-sct/SctPkg: TCG2 Protocol: add GetActivePcrBanks  test
  uefi-sct/SctPkg: TCG2 Protocol: add HashLogExtendEvent test
  uefi-sct/SctPkg: TCG2 Protocol: add GetEventLog test
  uefi-sct/SctPkg: TCG2 Protocol: add SubmitCommand test

 uefi-sct/SctPkg/CommonGenFramework.sh |1 +
 uefi-sct/SctPkg/Config/Data/Category.ini  |7 +
 .../EFI/Protocol/TCG2/BlackBoxTest/Guid.c |   59 +
 .../EFI/Protocol/TCG2/BlackBoxTest/Guid.h |  102 ++
 .../TCG2/BlackBoxTest/TCG2ProtocolBBTest.h|  180 +++
 .../TCG2/BlackBoxTest/TCG2ProtocolBBTest.inf  |   51 +
 .../TCG2ProtocolBBTestConformance.c   | 1017 +
 .../BlackBoxTest/TCG2ProtocolBBTestMain.c |  130 +++
 uefi-sct/SctPkg/UEFI/Protocol/TCG2.h  |  219 
 uefi-sct/SctPkg/UEFI/UEFI_SCT.dsc |1 +
 10 files changed, 1767 insertions(+)
 create mode 100644 
uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.c
 create mode 100644 
uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.h
 create mode 100644 
uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTest.h
 create mode 100644 
uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTest.inf
 create mode 100644 
uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTestConformance.c
 create mode 100644 
uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTestMain.c
 create mode 100644 uefi-sct/SctPkg/UEFI/Protocol/TCG2.h

-- 
2.17.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#82147): https://edk2.groups.io/g/devel/message/82147
Mute This Topic: https://groups.io/mt/86343156/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




[edk2-devel] [PATCH 1/1] SecurityPkg/DxeImageVerificationLib: Set Action for failed signed image

2021-10-12 Thread Joseph Hemann
If the image is signed but not allowed by DB and the hash of
image is not found in DB/DBX, then the EFI_IMAGE_INFO_ACTION
of the load of said image should be set to,
EFI_IMAGE_EXECUTION_AUTH_SIG_NOT_FOUND, rather then being left
unset as EFI_IMAGE_EXECUTION_AUTH_UNTESTED.

Cc: Jiewen Yao 
Cc: Jian J Wang 
Cc: Min Xu 

Signed-off-by: Joseph Hemann 
Change-Id: I6b2777bd7aeb57773b8876e44c2179ea7501bc8c
---
 .../Library/DxeImageVerificationLib/DxeImageVerificationLib.c| 1 +
 1 file changed, 1 insertion(+)

diff --git 
a/SecurityPkg/Library/DxeImageVerificationLib/DxeImageVerificationLib.c 
b/SecurityPkg/Library/DxeImageVerificationLib/DxeImageVerificationLib.c
index c48861cd6496..0a804af2162f 100644
--- a/SecurityPkg/Library/DxeImageVerificationLib/DxeImageVerificationLib.c
+++ b/SecurityPkg/Library/DxeImageVerificationLib/DxeImageVerificationLib.c
@@ -1957,6 +1957,7 @@ DxeImageVerificationHandler (
   if (!EFI_ERROR (DbStatus) && IsFound) {
 IsVerified = TRUE;
   } else {
+Action = EFI_IMAGE_EXECUTION_AUTH_SIG_NOT_FOUND;
 DEBUG ((DEBUG_INFO, "DxeImageVerificationLib: Image is signed but 
signature is not allowed by DB and %s hash of image is not found in DB/DBX.\n", 
mHashTypeStr));
   }
 }
-- 
2.17.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#81837): https://edk2.groups.io/g/devel/message/81837
Mute This Topic: https://groups.io/mt/86267146/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




[edk2-devel] [PATCH 1/1] SecurityPkg/DxeImageVerificationLib: Set Action for failed unsigned image

2021-10-12 Thread Joseph Hemann
If the image is not signed and the hash of image is not found
in DB/DBX, then the EFI_IMAGE_INFO_ACTION of the load of said
image should be set to,
EFI_IMAGE_EXECUTION_AUTH_SIG_NOT_FOUND, rather then being left
unset as EFI_IMAGE_EXECUTION_AUTH_UNTESTED.

Cc: Jiewen Yao 
Cc: Jian J Wang 
Cc: Min Xu 

Signed-off-by: Joseph Hemann 
Change-Id: Ia432ebf4ec811e36d67b80bc438a6aff60bc9b67
---
 .../Library/DxeImageVerificationLib/DxeImageVerificationLib.c| 1 +
 1 file changed, 1 insertion(+)

diff --git 
a/SecurityPkg/Library/DxeImageVerificationLib/DxeImageVerificationLib.c 
b/SecurityPkg/Library/DxeImageVerificationLib/DxeImageVerificationLib.c
index 0a804af2162f..e5fae732bb1f 100644
--- a/SecurityPkg/Library/DxeImageVerificationLib/DxeImageVerificationLib.c
+++ b/SecurityPkg/Library/DxeImageVerificationLib/DxeImageVerificationLib.c
@@ -1848,6 +1848,7 @@ DxeImageVerificationHandler (
 //
 // Image Hash is not found in both forbidden and allowed database.
 //
+Action = EFI_IMAGE_EXECUTION_AUTH_SIG_NOT_FOUND;
 DEBUG ((DEBUG_INFO, "DxeImageVerificationLib: Image is not signed and %s 
hash of image is not found in DB/DBX.\n", mHashTypeStr));
 goto Failed;
   }
-- 
2.17.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#81836): https://edk2.groups.io/g/devel/message/81836
Mute This Topic: https://groups.io/mt/86267110/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




[edk2-devel] [PATCH] SecurityPkg/DxeImageVerificationLib: Set Action for failed signed image

2021-10-12 Thread Joseph Hemann
From: Joseph Hemann 

If the image is signed but not allowed by DB and the hash of
image is not found in DB/DBX, then the EFI_IMAGE_INFO_ACTION
of the load of said image should be set to,
EFI_IMAGE_EXECUTION_AUTH_SIG_NOT_FOUND, rather then being left
unset as EFI_IMAGE_EXECUTION_AUTH_UNTESTED.

Cc: Jiewen Yao 
Cc: Jian J Wang 
Cc: Min Xu 

Signed-off-by: Joseph Hemann 
Change-Id: I271fb61384e5b8bb5ac23ccba5de9ba77adb85ad
---
 .../Library/DxeImageVerificationLib/DxeImageVerificationLib.c| 1 +
 1 file changed, 1 insertion(+)

diff --git 
a/SecurityPkg/Library/DxeImageVerificationLib/DxeImageVerificationLib.c 
b/SecurityPkg/Library/DxeImageVerificationLib/DxeImageVerificationLib.c
index c48861cd64..0a804af216 100644
--- a/SecurityPkg/Library/DxeImageVerificationLib/DxeImageVerificationLib.c
+++ b/SecurityPkg/Library/DxeImageVerificationLib/DxeImageVerificationLib.c
@@ -1957,6 +1957,7 @@ DxeImageVerificationHandler (
   if (!EFI_ERROR (DbStatus) && IsFound) {
 IsVerified = TRUE;
   } else {
+Action = EFI_IMAGE_EXECUTION_AUTH_SIG_NOT_FOUND;
 DEBUG ((DEBUG_INFO, "DxeImageVerificationLib: Image is signed but 
signature is not allowed by DB and %s hash of image is not found in DB/DBX.\n", 
mHashTypeStr));
   }
 }
-- 
2.17.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#81829): https://edk2.groups.io/g/devel/message/81829
Mute This Topic: https://groups.io/mt/86261682/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




[edk2-devel] [PATCH] Test comit please ignore this message.

2021-10-11 Thread Joseph Hemann
From: Joseph Hemann 

Signed-off-by: Joseph Hemann 
Change-Id: I11d8af6f1db0206019bd00c53c89b68323a295f7
---
 patchtest | 1 +
 1 file changed, 1 insertion(+)
 create mode 100644 patchtest

diff --git a/patchtest b/patchtest
new file mode 100644
index 00..484c9224ab
--- /dev/null
+++ b/patchtest
@@ -0,0 +1 @@
+Hello this is a test patch please ignore.
-- 
2.17.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#81786): https://edk2.groups.io/g/devel/message/81786
Mute This Topic: https://groups.io/mt/86251420/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




[edk2-devel] [PATCH v1 1/1] uefi-sct/SctPkg: Changed gcc version to be integer

2020-08-26 Thread Joseph Hemann
gcc_version returned by compiler is a string, and needs to be converted
to a integer before testing

Cc: G Edhaya Chandran 
Cc: Eric Jin 
Cc: Irene Park 
Cc: Heinrich Schuchardt 
Cc: Samer El-Haj-Mahmoud 
Signed-off-by: Joseph Hemann 
Change-Id: I24f3f52c12660928b58e6f836fdef86890688d26
---
 uefi-sct/SctPkg/build.sh | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/uefi-sct/SctPkg/build.sh b/uefi-sct/SctPkg/build.sh
index d0c7f16e172c..cad17ccdedc7 100755
--- a/uefi-sct/SctPkg/build.sh
+++ b/uefi-sct/SctPkg/build.sh
@@ -56,8 +56,8 @@ function get_gcc_version
 {
gcc_version=$($1 -dumpversion)
 
-if [ "$gcc_version" -gt "5" ]; then
-gcc_version="5"
+if [ ${gcc_version%%.*} -gt 5 ]; then
+gcc_version=5
 fi
 
case $gcc_version in
-- 
2.17.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#64658): https://edk2.groups.io/g/devel/message/64658
Mute This Topic: https://groups.io/mt/76439007/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-