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

2024-03-19 Thread G Edhaya Chandran
The patch is upstreamed by the commit:
https://github.com/tianocore/edk2-test/commit/7ec35ffac51d0682c1368041ca1e599189a58223


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




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

2024-03-18 Thread Sunny Wang
Looks good to me.
For others' reference, the change has been already verified by running 
SystemReady SIE (Security Interface extension) tests on multiple SystemReady 
certified Arm systems.
Reviewed-by: Sunny Wang 

-Original Message-
From: devel@edk2.groups.io  On Behalf Of Stuart Yoder via 
groups.io
Sent: Tuesday, January 9, 2024 12:21 PM
To: devel@edk2.groups.io; G Edhaya Chandran ; 
gao...@byosoft.com.cn
Cc: ilias.apalodi...@linaro.org; heinrich.schucha...@canonical.com; Samer 
El-Haj-Mahmoud ; jiewen@intel.com
Subject: [edk2-devel] [PATCH v2 5/6] uefi-sct/SctPkg: TCG2 Protocol: add 
GetEventLog test

From: Joseph Hemann 

-add test for GetEventLog()
  -test for valid and invalid event log format
  -test event log header
  -verify expected event log entry

Signed-off-by: Joseph Hemann 
Signed-off-by: Stuart Yoder 
---
 uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.h
  |  20 ++
 
uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTest.h
|  17 ++
 uefi-sct/SctPkg/UEFI/Protocol/TCG2.h   
  |  46 +
 uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.c
  |   8 +
 
uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTestConformance.c
 | 207 +++-
 5 files changed, 297 insertions(+), 1 deletion(-)

diff --git 
a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.h 
b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.h
index dcfd5919acda..746ff83f899c 100644
--- a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.h
+++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.h
@@ -85,3 +85,23 @@ extern EFI_GUID gTcg2ConformanceTestAssertionGuid011;
 { 0x9cd6d636, 0x603a, 0x4b78, {0x80, 0xa3, 0xa3, 0xb9, 0xcc, 0x6a, 0x0b, 0x08 
}}



 extern EFI_GUID gTcg2ConformanceTestAssertionGuid012;

+

+#define EFI_TEST_TCG2CONFORMANCE_ASSERTION_013_GUID \

+{ 0xfc80408e, 0x9a3c, 0x4054, {0x96, 0xf9, 0x31, 0x23, 0x35, 0xc2, 0x31, 0x35 
}}

+

+extern EFI_GUID gTcg2ConformanceTestAssertionGuid013;

+

+#define EFI_TEST_TCG2CONFORMANCE_ASSERTION_014_GUID \

+{ 0x45fa1a42, 0x912a, 0x5124, {0x84, 0xf4, 0x41, 0x67, 0xab, 0xb5, 0x89, 0x90 
}}

+

+extern EFI_GUID gTcg2ConformanceTestAssertionGuid014;

+

+#define EFI_TEST_TCG2CONFORMANCE_ASSERTION_015_GUID \

+{ 0x1689bc3a, 0x2298, 0xa116, {0x28, 0x4c, 0xc1, 0xdd, 0xaa, 0xd8, 0xef, 0x51 
}}

+

+extern EFI_GUID gTcg2ConformanceTestAssertionGuid015;

+

+#define EFI_TEST_TCG2CONFORMANCE_ASSERTION_016_GUID \

+{ 0x126a789a, 0x1932, 0x3234, {0x21, 0xab, 0x42, 0x64, 0x8a, 0x7b, 0x63, 0x76 
}}

+

+extern EFI_GUID gTcg2ConformanceTestAssertionGuid016;

diff --git 
a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTest.h
 
b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTest.h
index cbbadef4a5c7..5ce275dc6258 100644
--- 
a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTest.h
+++ 
b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTest.h
@@ -43,8 +43,13 @@ Abstract:
 #define EFI_TCG2_PROTOCOL_TEST_ENTRY_GUID0103 \

  {0x907a7878, 0xb294, 0xf147, {0xe9, 0x0a, 0x65, 0x43, 0xab, 0x55, 0x76, 0x46} 
}



+#define EFI_TCG2_PROTOCOL_TEST_ENTRY_GUID0104 \

+ {0x9087ad78, 0x9ad2, 0x4172, {0x9a, 0xbc, 0x98, 0x23, 0x08, 0xf5, 0x6d, 0x26} 
}

+

 #define EV_POST_CODE 0x01



+#define EV_NO_ACTION 0x03

+

 #define EFI_TCG2_EXTEND_ONLY 0x0001



 #define PE_COFF_IMAGE 0x0010

@@ -103,6 +108,18 @@ BBTestHashLogExtendEventConformanceTestCheckpoint2 (
   IN EFI_TCG2_PROTOCOL *TCG2

   );



+EFI_STATUS

+BBTestGetEventLogConformanceTestCheckpoint1 (

+  IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL*StandardLib,

+  IN EFI_TCG2_PROTOCOL *TCG2

+  );

+

+EFI_STATUS

+BBTestGetEventLogConformanceTestCheckpoint2 (

+  IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL*StandardLib,

+  IN EFI_TCG2_PROTOCOL *TCG2

+  );

+

 EFI_STATUS

 BBTestGetCapabilityConformanceTest (

   IN EFI_BB_TEST_PROTOCOL   *This,

diff --git a/uefi-sct/SctPkg/UEFI/Protocol/TCG2.h 
b/uefi-sct/SctPkg/UEFI/Protocol/TCG2.h
index e62ecd85cbe9..fd31204a9299 100644
--- a/uefi-sct/SctPkg/UEFI/Protocol/TCG2.h
+++ b/uefi-sct/SctPkg/UEFI/Protocol/TCG2.h
@@ -50,6 +50,8 @@ Abstract:


 #define EFI_TCG2_EVENT_LOG_FORMAT_TCG_2 0x0002



+#define HASH_NUMBER 0x04

+

 typedef struct _EFI_TCG2_PROTOCOL EFI_TCG2_PROTOCOL;



 typedef UINT32 EFI_TCG2_EVENT_LOG_BITMAP;

@@ -115,6 +117,50 @@ typedef struct tdEFI_TCG2_EVENT {
   UINT8 Event[];

 } EFI_TCG2_EVENT;



+typedef struct {

+  UINT16 hashAlg;

+  UINT8  digest[];

+} TPMT_HA;

+

+typedef struct tdTPML_DIGEST_VALUES {

+  UINT32 Count;// number of digests

+  TPMT_HA Digests[HASH_N

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

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


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




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

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

-add test for GetEventLog()
  -test for valid and invalid event log format
  -test event log header
  -verify expected event log entry

Signed-off-by: Joseph Hemann 
Signed-off-by: Stuart Yoder 
---
 uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.h
  |  20 ++
 
uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTest.h
|  17 ++
 uefi-sct/SctPkg/UEFI/Protocol/TCG2.h   
  |  46 +
 uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.c
  |   8 +
 
uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTestConformance.c
 | 207 +++-
 5 files changed, 297 insertions(+), 1 deletion(-)

diff --git 
a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.h 
b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.h
index dcfd5919acda..746ff83f899c 100644
--- a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.h
+++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.h
@@ -85,3 +85,23 @@ extern EFI_GUID gTcg2ConformanceTestAssertionGuid011;
 { 0x9cd6d636, 0x603a, 0x4b78, {0x80, 0xa3, 0xa3, 0xb9, 0xcc, 0x6a, 0x0b, 0x08 
}}
 
 extern EFI_GUID gTcg2ConformanceTestAssertionGuid012;
+
+#define EFI_TEST_TCG2CONFORMANCE_ASSERTION_013_GUID \
+{ 0xfc80408e, 0x9a3c, 0x4054, {0x96, 0xf9, 0x31, 0x23, 0x35, 0xc2, 0x31, 0x35 
}}
+
+extern EFI_GUID gTcg2ConformanceTestAssertionGuid013;
+
+#define EFI_TEST_TCG2CONFORMANCE_ASSERTION_014_GUID \
+{ 0x45fa1a42, 0x912a, 0x5124, {0x84, 0xf4, 0x41, 0x67, 0xab, 0xb5, 0x89, 0x90 
}}
+
+extern EFI_GUID gTcg2ConformanceTestAssertionGuid014;
+
+#define EFI_TEST_TCG2CONFORMANCE_ASSERTION_015_GUID \
+{ 0x1689bc3a, 0x2298, 0xa116, {0x28, 0x4c, 0xc1, 0xdd, 0xaa, 0xd8, 0xef, 0x51 
}}
+
+extern EFI_GUID gTcg2ConformanceTestAssertionGuid015;
+
+#define EFI_TEST_TCG2CONFORMANCE_ASSERTION_016_GUID \
+{ 0x126a789a, 0x1932, 0x3234, {0x21, 0xab, 0x42, 0x64, 0x8a, 0x7b, 0x63, 0x76 
}}
+
+extern EFI_GUID gTcg2ConformanceTestAssertionGuid016;
diff --git 
a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTest.h
 
b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTest.h
index cbbadef4a5c7..5ce275dc6258 100644
--- 
a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTest.h
+++ 
b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTest.h
@@ -43,8 +43,13 @@ Abstract:
 #define EFI_TCG2_PROTOCOL_TEST_ENTRY_GUID0103 \
  {0x907a7878, 0xb294, 0xf147, {0xe9, 0x0a, 0x65, 0x43, 0xab, 0x55, 0x76, 0x46} 
}
 
+#define EFI_TCG2_PROTOCOL_TEST_ENTRY_GUID0104 \
+ {0x9087ad78, 0x9ad2, 0x4172, {0x9a, 0xbc, 0x98, 0x23, 0x08, 0xf5, 0x6d, 0x26} 
}
+
 #define EV_POST_CODE 0x01
 
+#define EV_NO_ACTION 0x03
+
 #define EFI_TCG2_EXTEND_ONLY 0x0001
 
 #define PE_COFF_IMAGE 0x0010
@@ -103,6 +108,18 @@ BBTestHashLogExtendEventConformanceTestCheckpoint2 (
   IN EFI_TCG2_PROTOCOL *TCG2
   );
 
+EFI_STATUS
+BBTestGetEventLogConformanceTestCheckpoint1 (
+  IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL*StandardLib,
+  IN EFI_TCG2_PROTOCOL *TCG2
+  );
+
+EFI_STATUS
+BBTestGetEventLogConformanceTestCheckpoint2 (
+  IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL*StandardLib,
+  IN EFI_TCG2_PROTOCOL *TCG2
+  );
+
 EFI_STATUS
 BBTestGetCapabilityConformanceTest (
   IN EFI_BB_TEST_PROTOCOL   *This,
diff --git a/uefi-sct/SctPkg/UEFI/Protocol/TCG2.h 
b/uefi-sct/SctPkg/UEFI/Protocol/TCG2.h
index e62ecd85cbe9..fd31204a9299 100644
--- a/uefi-sct/SctPkg/UEFI/Protocol/TCG2.h
+++ b/uefi-sct/SctPkg/UEFI/Protocol/TCG2.h
@@ -50,6 +50,8 @@ Abstract:
 
 #define EFI_TCG2_EVENT_LOG_FORMAT_TCG_2 0x0002
 
+#define HASH_NUMBER 0x04
+
 typedef struct _EFI_TCG2_PROTOCOL EFI_TCG2_PROTOCOL;
 
 typedef UINT32 EFI_TCG2_EVENT_LOG_BITMAP;
@@ -115,6 +117,50 @@ typedef struct tdEFI_TCG2_EVENT {
   UINT8 Event[];
 } EFI_TCG2_EVENT;
 
+typedef struct {
+  UINT16 hashAlg;
+  UINT8  digest[];
+} TPMT_HA;
+
+typedef struct tdTPML_DIGEST_VALUES {
+  UINT32 Count;// number of digests
+  TPMT_HA Digests[HASH_NUMBER];// Count digests
+} TPML_DIGEST_VALUES;
+
+// This Declaration is for parsing the eventlog header which is defined to be 
20 bytes in TCG EFI Protocol Spec
+typedef UINT8 TCG_DIGEST[20];
+
+typedef struct tdTCG_PCR_EVENT2 {
+  TCG_PCRINDEX PCRIndex;   // PCRIndex event extended to
+  TCG_EVENTTYPE EventType; // Type of event (see [2])
+  TPML_DIGEST_VALUES Digests;  // List of digests extended to //PCRIndex
+  UINT32 EventSize;// Size of the event data
+  UINT8 *Event;// The event data
+} TCG_PCR_EVENT2;
+
+typedef struct tdTCG_PCR_EVENT {
+  UINT32 PCRIndex; // PCRIndex event extended to
+  UINT32 EventType; // Type of event (see EFI specs)
+  T