public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Abhimanyu Singh" <Abhi.Singh@arm.com>
To: devel@edk2.groups.io
Cc: Abhi Singh <Abhi.Singh@arm.com>,
	G Edhaya Chandran <edhaya.chandran@arm.com>,
	Barton Gao <gaojie@byosoft.com.cn>,
	Carolyn Gjertsen <carolyn.gjertsen@amd.com>,
	Abhi Singh <abhi.singh@arm.com>,
	Stuart Yoder <stuart.yoder@arm.com>
Subject: [edk2-devel] [PATCH v4 6/6] uefi-sct/SctPkg: TCG MORLOCK Locked with Key State Test
Date: Tue,  5 Mar 2024 17:36:22 -0600	[thread overview]
Message-ID: <20240305233622.747522-7-Abhi.Singh@arm.com> (raw)
In-Reply-To: <20240305233622.747522-1-Abhi.Singh@arm.com>

SCT spec: https://bugzilla.tianocore.org/show_bug.cgi?id=4374

BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=4419

-Implement MemoryOverwriteRequestControlLock Locked with
 Key State test cases
 -Add remaining Assertions 32 - 49 from SCT spec
 -Add Test Case to MemoryOverwriteRequestFunctionTest

Cc: G Edhaya Chandran <edhaya.chandran@arm.com>
Cc: Barton Gao <gaojie@byosoft.com.cn>
Cc: Carolyn Gjertsen <carolyn.gjertsen@amd.com>

Signed-off-by: Abhi Singh <abhi.singh@arm.com>

Reviewed-by: Stuart Yoder <stuart.yoder@arm.com>
---
 uefi-sct/SctPkg/TestCase/UEFI/EFI/RuntimeServices/TCGMemoryOverwriteRequest/BlackBoxTest/Guid.h                                    |  96 ++-
 uefi-sct/SctPkg/TestCase/UEFI/EFI/RuntimeServices/TCGMemoryOverwriteRequest/BlackBoxTest/TCGMemoryOverwriteRequestBBTestMain.h     |  11 +-
 uefi-sct/SctPkg/TestCase/UEFI/EFI/RuntimeServices/TCGMemoryOverwriteRequest/BlackBoxTest/Guid.c                                    |  39 +-
 uefi-sct/SctPkg/TestCase/UEFI/EFI/RuntimeServices/TCGMemoryOverwriteRequest/BlackBoxTest/TCGMemoryOverwriteRequestBBTestFunction.c | 669 ++++++++++++++++++++
 4 files changed, 805 insertions(+), 10 deletions(-)

diff --git a/uefi-sct/SctPkg/TestCase/UEFI/EFI/RuntimeServices/TCGMemoryOverwriteRequest/BlackBoxTest/Guid.h b/uefi-sct/SctPkg/TestCase/UEFI/EFI/RuntimeServices/TCGMemoryOverwriteRequest/BlackBoxTest/Guid.h
index 612e6ee436e0..cf7f3e180f54 100644
--- a/uefi-sct/SctPkg/TestCase/UEFI/EFI/RuntimeServices/TCGMemoryOverwriteRequest/BlackBoxTest/Guid.h
+++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/RuntimeServices/TCGMemoryOverwriteRequest/BlackBoxTest/Guid.h
@@ -85,8 +85,6 @@ Abstract:
 #define EFI_TEST_TCGMORTESTFUNCTION_ASSERTION_020_GUID \
 { 0x2eba284a, 0xf701, 0x4c19, {0xbe, 0x5c, 0x39, 0x27, 0xb0, 0x68, 0x4f, 0xd7 }}
 
-<<<<<<< HEAD
-=======
 #define EFI_TEST_TCGMORTESTFUNCTION_ASSERTION_021_GUID \
 { 0x9a1b44ae, 0x08ce, 0x474c, {0xa5, 0x8e, 0xa6, 0xe2, 0xcf, 0xaf, 0x91, 0x2c }}
 
@@ -120,7 +118,60 @@ Abstract:
 #define EFI_TEST_TCGMORTESTFUNCTION_ASSERTION_031_GUID \
 { 0xe88b22ce, 0x3de6, 0x49b0, {0xb2, 0x46, 0x9e, 0x35, 0x98, 0x2b, 0x9b, 0x1c }}
 
->>>>>>> 3542bef7c1d2 (uefi-sct/SctPkg: TCG MORLOCK Locked No Key State Test)
+#define EFI_TEST_TCGMORTESTFUNCTION_ASSERTION_032_GUID \
+{ 0xc8894201, 0x7a3a, 0x47d4, {0xa8, 0x8d, 0xdf, 0x4b, 0x03, 0xff, 0xde, 0x4f }}
+
+#define EFI_TEST_TCGMORTESTFUNCTION_ASSERTION_033_GUID \
+{ 0x38a813ac, 0x8eb9, 0x46ce, {0xa8, 0x6b, 0x40, 0x8c, 0x07, 0x5f, 0xc7, 0xed }}
+
+#define EFI_TEST_TCGMORTESTFUNCTION_ASSERTION_034_GUID \
+{ 0x919b8392, 0xcb78, 0x49ff, {0xa3, 0x18, 0x49, 0x78, 0x76, 0xe0, 0xf8, 0xf8 }}
+
+#define EFI_TEST_TCGMORTESTFUNCTION_ASSERTION_035_GUID \
+{ 0x219abaf2, 0x04a9, 0x407c, {0xb5, 0xde, 0xa0, 0x03, 0x6e, 0x65, 0xb0, 0xb9 }}
+
+#define EFI_TEST_TCGMORTESTFUNCTION_ASSERTION_036_GUID \
+{ 0x9a51640a, 0xff14, 0x402b, {0xb0, 0x57, 0xa0, 0xc4, 0xf7, 0x20, 0x8e, 0x44 }}
+
+#define EFI_TEST_TCGMORTESTFUNCTION_ASSERTION_037_GUID \
+{ 0x8ccd0dbb, 0x9b0a, 0x4bfb, {0xa0, 0x7e, 0xc6, 0x06, 0x8b, 0x91, 0x0d, 0xfb }}
+
+#define EFI_TEST_TCGMORTESTFUNCTION_ASSERTION_038_GUID \
+{ 0xde6f4e17, 0xe375, 0x4dcb, {0x8f, 0x07, 0x77, 0x7e, 0x62, 0x49, 0xea, 0x2c }}
+
+#define EFI_TEST_TCGMORTESTFUNCTION_ASSERTION_039_GUID \
+{ 0x4ab6927b, 0x5ee4, 0x4748, {0xa4, 0x9d, 0x2d, 0xf3, 0x70, 0x01, 0x41, 0xd5 }}
+
+#define EFI_TEST_TCGMORTESTFUNCTION_ASSERTION_040_GUID \
+{ 0x33142ecf, 0x0f92, 0x4625, {0xb7, 0xf6, 0x7f, 0x15, 0x25, 0x74, 0xd3, 0x03 }}
+
+#define EFI_TEST_TCGMORTESTFUNCTION_ASSERTION_041_GUID \
+{ 0xf73c04df, 0x2e42, 0x4174, {0x82, 0x18, 0x0f, 0x25, 0x46, 0x4a, 0x55, 0xe9 }}
+
+#define EFI_TEST_TCGMORTESTFUNCTION_ASSERTION_042_GUID \
+{ 0xd4eacf82, 0x55d1, 0x4ba1, {0xbe, 0x89, 0x6a, 0x2e, 0x44, 0x0f, 0xc7, 0xc0 }}
+
+#define EFI_TEST_TCGMORTESTFUNCTION_ASSERTION_043_GUID \
+{ 0xfd88fe63, 0x5ed4, 0x482a, {0x98, 0x44, 0x23, 0x90, 0xf9, 0x09, 0x1c, 0x20 }}
+
+#define EFI_TEST_TCGMORTESTFUNCTION_ASSERTION_044_GUID \
+{ 0x176f16cb, 0xf3a4, 0x4f12, {0x8f, 0x96, 0x4a, 0xc1, 0x8b, 0xdd, 0x6e, 0x3c }}
+
+#define EFI_TEST_TCGMORTESTFUNCTION_ASSERTION_045_GUID \
+{ 0xf0d5e7b3, 0xdc0f, 0x4a18, {0xb9, 0x78, 0x09, 0x3b, 0x15, 0x55, 0x66, 0xbf }}
+
+#define EFI_TEST_TCGMORTESTFUNCTION_ASSERTION_046_GUID \
+{ 0x9bf14c4b, 0x2950, 0x4c4e, {0x8b, 0xa3, 0x06, 0x46, 0xf1, 0x27, 0x8c, 0x05 }}
+
+#define EFI_TEST_TCGMORTESTFUNCTION_ASSERTION_047_GUID \
+{ 0xb0468dee, 0xb1d0, 0x4795, {0x9f, 0xbf, 0xbe, 0x3f, 0x40, 0x2f, 0x3d, 0x6f }}
+
+#define EFI_TEST_TCGMORTESTFUNCTION_ASSERTION_048_GUID \
+{ 0x1f7dd903, 0xcd58, 0x4d6f, {0x80, 0xd6, 0x4f, 0x6d, 0xcb, 0x4a, 0xd6, 0xc9 }}
+
+#define EFI_TEST_TCGMORTESTFUNCTION_ASSERTION_049_GUID \
+{ 0x439179c2, 0x744d, 0x43bc, {0xb0, 0x67, 0x7b, 0x65, 0x60, 0x62, 0x6f, 0x5e }}
+
 extern EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid001;
 
 extern EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid002;
@@ -160,8 +211,6 @@ extern EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid018;
 extern EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid019;
 
 extern EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid020;
-<<<<<<< HEAD
-=======
 
 extern EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid021;
 
@@ -184,4 +233,39 @@ extern EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid029;
 extern EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid030;
 
 extern EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid031;
->>>>>>> 3542bef7c1d2 (uefi-sct/SctPkg: TCG MORLOCK Locked No Key State Test)
+
+extern EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid032;
+
+extern EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid033;
+
+extern EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid034;
+
+extern EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid035;
+
+extern EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid036;
+
+extern EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid037;
+
+extern EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid038;
+
+extern EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid039;
+
+extern EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid040;
+
+extern EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid041;
+
+extern EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid042;
+
+extern EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid043;
+
+extern EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid044;
+
+extern EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid045;
+
+extern EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid046;
+
+extern EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid047;
+
+extern EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid048;
+
+extern EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid049;
diff --git a/uefi-sct/SctPkg/TestCase/UEFI/EFI/RuntimeServices/TCGMemoryOverwriteRequest/BlackBoxTest/TCGMemoryOverwriteRequestBBTestMain.h b/uefi-sct/SctPkg/TestCase/UEFI/EFI/RuntimeServices/TCGMemoryOverwriteRequest/BlackBoxTest/TCGMemoryOverwriteRequestBBTestMain.h
index 94ed476f86ad..76b3c76340cf 100644
--- a/uefi-sct/SctPkg/TestCase/UEFI/EFI/RuntimeServices/TCGMemoryOverwriteRequest/BlackBoxTest/TCGMemoryOverwriteRequestBBTestMain.h
+++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/RuntimeServices/TCGMemoryOverwriteRequest/BlackBoxTest/TCGMemoryOverwriteRequestBBTestMain.h
@@ -50,11 +50,13 @@ typedef struct _RESET_DATA {
 
 #define MOR_LOCK_DATA_UNLOCKED            0x0
 #define MOR_LOCK_DATA_LOCKED_WITHOUT_KEY  0x1
+#define MOR_LOCK_DATA_LOCKED_WITH_KEY     0x2
 
+#define MOR_LOCK_NO_KEY_SIZE              1
 #define MOR_LOCK_WITH_KEY_SIZE            8
 
 #define MOR_LOCK_TEST_KEY                 0x11111111
-
+#define MOR_LOCK_INVALID_TEST_KEY         0x22222222
 
 //
 // TEST GUID for TCG Platform Reset Attack Mitigation MemoryOverwriteRequest (MOR) Test
@@ -118,6 +120,13 @@ TCGMemoryOverwriteRequestControlLockLockedNoKeyState (
   IN RESET_DATA                               *ResetData
   );
 
+EFI_STATUS
+TCGMemoryOverwriteRequestControlLockLockedWithKeyState (
+  IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL       *StandardLib,
+  IN EFI_TEST_RECOVERY_LIBRARY_PROTOCOL       *RecoveryLib,
+  IN RESET_DATA                               *ResetData
+  );
+
 // ****************************************************************************
 //   Entry GUIDs for Test
 // ****************************************************************************
diff --git a/uefi-sct/SctPkg/TestCase/UEFI/EFI/RuntimeServices/TCGMemoryOverwriteRequest/BlackBoxTest/Guid.c b/uefi-sct/SctPkg/TestCase/UEFI/EFI/RuntimeServices/TCGMemoryOverwriteRequest/BlackBoxTest/Guid.c
index 7e00224c325c..6bde8f686a16 100644
--- a/uefi-sct/SctPkg/TestCase/UEFI/EFI/RuntimeServices/TCGMemoryOverwriteRequest/BlackBoxTest/Guid.c
+++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/RuntimeServices/TCGMemoryOverwriteRequest/BlackBoxTest/Guid.c
@@ -67,8 +67,6 @@ EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid018 = EFI_TEST_TCGMO
 EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid019 = EFI_TEST_TCGMORTESTFUNCTION_ASSERTION_019_GUID;
 
 EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid020 = EFI_TEST_TCGMORTESTFUNCTION_ASSERTION_020_GUID;
-<<<<<<< HEAD
-=======
 
 EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid021 = EFI_TEST_TCGMORTESTFUNCTION_ASSERTION_021_GUID;
 
@@ -91,4 +89,39 @@ EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid029 = EFI_TEST_TCGMO
 EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid030 = EFI_TEST_TCGMORTESTFUNCTION_ASSERTION_030_GUID;
 
 EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid031 = EFI_TEST_TCGMORTESTFUNCTION_ASSERTION_031_GUID;
->>>>>>> 3542bef7c1d2 (uefi-sct/SctPkg: TCG MORLOCK Locked No Key State Test)
+
+EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid032 = EFI_TEST_TCGMORTESTFUNCTION_ASSERTION_032_GUID;
+
+EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid033 = EFI_TEST_TCGMORTESTFUNCTION_ASSERTION_033_GUID;
+
+EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid034 = EFI_TEST_TCGMORTESTFUNCTION_ASSERTION_034_GUID;
+
+EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid035 = EFI_TEST_TCGMORTESTFUNCTION_ASSERTION_035_GUID;
+
+EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid036 = EFI_TEST_TCGMORTESTFUNCTION_ASSERTION_036_GUID;
+
+EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid037 = EFI_TEST_TCGMORTESTFUNCTION_ASSERTION_037_GUID;
+
+EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid038 = EFI_TEST_TCGMORTESTFUNCTION_ASSERTION_038_GUID;
+
+EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid039 = EFI_TEST_TCGMORTESTFUNCTION_ASSERTION_039_GUID;
+
+EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid040 = EFI_TEST_TCGMORTESTFUNCTION_ASSERTION_040_GUID;
+
+EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid041 = EFI_TEST_TCGMORTESTFUNCTION_ASSERTION_041_GUID;
+
+EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid042 = EFI_TEST_TCGMORTESTFUNCTION_ASSERTION_042_GUID;
+
+EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid043 = EFI_TEST_TCGMORTESTFUNCTION_ASSERTION_043_GUID;
+
+EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid044 = EFI_TEST_TCGMORTESTFUNCTION_ASSERTION_044_GUID;
+
+EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid045 = EFI_TEST_TCGMORTESTFUNCTION_ASSERTION_045_GUID;
+
+EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid046 = EFI_TEST_TCGMORTESTFUNCTION_ASSERTION_046_GUID;
+
+EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid047 = EFI_TEST_TCGMORTESTFUNCTION_ASSERTION_047_GUID;
+
+EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid048 = EFI_TEST_TCGMORTESTFUNCTION_ASSERTION_048_GUID;
+
+EFI_GUID gTCGMemoryOverwriteRequestTestFunctionAssertionGuid049 = EFI_TEST_TCGMORTESTFUNCTION_ASSERTION_049_GUID;
diff --git a/uefi-sct/SctPkg/TestCase/UEFI/EFI/RuntimeServices/TCGMemoryOverwriteRequest/BlackBoxTest/TCGMemoryOverwriteRequestBBTestFunction.c b/uefi-sct/SctPkg/TestCase/UEFI/EFI/RuntimeServices/TCGMemoryOverwriteRequest/BlackBoxTest/TCGMemoryOverwriteRequestBBTestFunction.c
index 7780b390a5f2..f5418c20d4a5 100644
--- a/uefi-sct/SctPkg/TestCase/UEFI/EFI/RuntimeServices/TCGMemoryOverwriteRequest/BlackBoxTest/TCGMemoryOverwriteRequestBBTestFunction.c
+++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/RuntimeServices/TCGMemoryOverwriteRequest/BlackBoxTest/TCGMemoryOverwriteRequestBBTestFunction.c
@@ -192,6 +192,16 @@ BBTestTCGMemoryOverwriteRequestFunctionTest (
     }
     CheckpointStepMatched = TRUE;
   }
+  if (ResetData->CheckpointStep == LOCK_WITH_KEY_STATE_TEST) {
+    //
+    // Test Checkpoint LOCK_WITH_KEY_STATE_TEST
+    //
+    Status = TCGMemoryOverwriteRequestControlLockLockedWithKeyState (StandardLib, RecoveryLib, ResetData);
+    if(EFI_ERROR(Status)) {
+      return Status;
+    }
+    CheckpointStepMatched = TRUE;
+  }
 
   if (!CheckpointStepMatched) {
     return EFI_INVALID_PARAMETER; // incase of invalid CheckpointStep, return EFI_INVALID_PARAMETER
@@ -1719,3 +1729,662 @@ MORLOCK_LOCKED_STATE:
 
   return EFI_SUCCESS;
 }
+
+
+/**
+ *  MemoryOverwriteRequestControlLock in locked-with-key state test
+ *  When unlocked, a valid SetVariable() with an 8 byte key must return EFI_SUCCESS
+ *  and the lock value must be 0x02 (MOR_LOCK_DATA_LOCKED_WITH_KEY), in order to
+ *  unlock, the same 8 byte key must be passed.
+ *
+ *  When locked with an 8 byte key, SetVariable() with the same 8 byte key
+ *  must return EFI_SUCCESS and the Lock value must be 0x00 or MOR_LOCK_DATA_UNLOCKED.
+ *
+ *  When locked with an 8 byte Key, SetVariable() with DataSize != 8 and
+ *  Data = 0x01 (MOR_LOCK_DATA_LOCKED_WITHOUT_KEY) or 0x00 (MOR_LOCK_DATA_UNLOCKED)
+ *  must return EFI_ACCESS_DENIED
+ *  and value must still equal to 0x02 (MOR_LOCK_DATA_LOCKED_WITH_KEY).
+ *
+ *  When locked with an 8 byte Key, SetVariable() with 8 byte key != key used to set
+ *  the lock, in this case 0x11111111 (MOR_LOCK_TEST_KEY), must return EFI_ACCESS_DENIED
+ *  and lock value must be updated to 0x01 (MOR_LOCK_DATA_LOCKED_WITHOUT_KEY)
+ *  to prevent dictonary attack.
+ *
+ *  @param StandardLib    A pointer to EFI_STANDARD_TEST_LIBRARY_PROTOCOL
+ *                        instance.
+ *  @param RecoveryLib    A pointer to EFI_TEST_RECOVERY_LIBRARY_PROTOCOL
+ *                        instance.
+ *  @param ResetData      A pointer to the ResetData Buffer which is used throughout
+ *                        the test
+ *  @return EFI_SUCCESS   Successfully.
+ *  @return Other value   Something failed.
+ */
+EFI_STATUS
+TCGMemoryOverwriteRequestControlLockLockedWithKeyState (
+  IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL       *StandardLib,
+  IN EFI_TEST_RECOVERY_LIBRARY_PROTOCOL       *RecoveryLib,
+  IN RESET_DATA                               *ResetData
+  )
+{
+  EFI_STATUS                           Status;
+  EFI_TEST_ASSERTION                   Result;
+  UINTN                                DataSize;
+  UINT8                                MemoryOverwriteRequestControlLockData;
+  UINTN                                MemoryOverwriteControlLockKeyValue;
+  UINT8                                MemoryOverwriteRequestControlData;
+  UINT8                                MemoryOverwriteRequestControlDataCached;
+  UINT32                               Attributes;
+
+  //
+  // Check Step to see which part of test remains to be executed
+  //
+  switch (ResetData->Step) {
+    case 0:
+      goto INITIAL_RESET;
+    case 1:
+      goto MORLOCK_LOCKED_KEY_STATE;
+    default:
+      return EFI_INVALID_PARAMETER;
+  }
+
+INITIAL_RESET:
+  //
+  // Reset MORLOCK variable by performing a cold reset
+  //
+
+  ResetData->Step = 1;
+  ResetData->CheckpointStep = LOCK_WITH_KEY_STATE_TEST;
+  Status = RecoveryLib->WriteResetRecord (
+                  RecoveryLib,
+                  sizeof (RESET_DATA),
+                  (UINT8*)ResetData
+                  );
+  if (EFI_ERROR(Status)) {
+    StandardLib->RecordAssertion (
+                  StandardLib,
+                  EFI_TEST_ASSERTION_FAILED,
+                  gTestGenericFailureGuid,
+                  L"TestRecoveryLib - WriteResetRecord",
+                  L"%a:%d:Status - %r",
+                  __FILE__,
+                  (UINTN)__LINE__,
+                  Status
+                  );
+    return Status;
+  }
+
+  SctPrint (L"System will cold reset after 1 second and test will be resumed after reboot.");
+  Status = gtBS->Stall(1000000);
+  if (EFI_ERROR(Status)) {
+      // Handle stall error
+      SctPrint(L"Error: Failed to stall the system.\n");
+      return Status;
+  }
+  gtRT->ResetSystem (
+                  EfiResetCold,
+                  EFI_SUCCESS,
+                  0,
+                  NULL
+                  );
+  SctPrint(L"Error: Failed to perform a cold reset.\n");
+  return EFI_DEVICE_ERROR;
+
+MORLOCK_LOCKED_KEY_STATE:
+  //
+  // MORLOCK Reboot system to clear lock, and invoke SetVariable() with valid 8 byte key
+  // In this case = 0x11111111, must return EFI_SUCCESS and GetVariable() value must = 0x02
+  //
+
+  DataSize = MOR_LOCK_WITH_KEY_SIZE;
+  Attributes = TCG_MOR_VARIABLE_ATTRIBUTES;
+  MemoryOverwriteControlLockKeyValue = MOR_LOCK_TEST_KEY;
+
+  Status = gtRT->SetVariable (
+                  L"MemoryOverwriteRequestControlLock",        // VariableName
+                  &gEfiMemoryOverwriteRequestControlLockGuid,  // VendorGuid
+                  Attributes,                                  // Attributes
+                  DataSize,                                    // DataSize
+                  &MemoryOverwriteControlLockKeyValue          // Data
+                  );
+  if (Status == EFI_SUCCESS) {
+    Result = EFI_TEST_ASSERTION_PASSED;
+  } else {
+    Result = EFI_TEST_ASSERTION_FAILED;
+  }
+
+  StandardLib->RecordAssertion (
+                  StandardLib,
+                  Result,
+                  gTCGMemoryOverwriteRequestTestFunctionAssertionGuid032,
+                  L"MemoryOverwriteRequestControlLock - Setting to locked-with-key using key value = 0x11111111 when unlocked returns EFI_SUCCESS",
+                  L"%a:%d:Status - %r",
+                  __FILE__,
+                  (UINTN)__LINE__,
+                  Status
+                  );
+
+  DataSize = sizeof(MemoryOverwriteRequestControlLockData);
+  Attributes = TCG_MOR_VARIABLE_ATTRIBUTES;
+
+  Status = gtRT->GetVariable (
+                  L"MemoryOverwriteRequestControlLock",        // VariableName
+                  &gEfiMemoryOverwriteRequestControlLockGuid,  // VendorGuid
+                  &Attributes,                                 // Attributes
+                  &DataSize,                                   // DataSize
+                  &MemoryOverwriteRequestControlLockData       // Data
+                  );
+  if (EFI_ERROR (Status) || (MemoryOverwriteRequestControlLockData != MOR_LOCK_DATA_LOCKED_WITH_KEY)) {
+    Result = EFI_TEST_ASSERTION_FAILED;
+  } else {
+    Result = EFI_TEST_ASSERTION_PASSED;
+  }
+
+  StandardLib->RecordAssertion (
+                  StandardLib,
+                  Result,
+                  gTCGMemoryOverwriteRequestTestFunctionAssertionGuid033,
+                  L"MemoryOverwriteRequestControlLock - Lock state is now locked-with-key with key value = 0x11111111",
+                  L"%a:%d:Status - %r",
+                  __FILE__,
+                  (UINTN)__LINE__,
+                  Status
+                  );
+
+  //
+  // Currently locked-with-key, invoke SetVariable() with the same valid 8 byte key used to lock
+  // In this case = 0x11111111, must return EFI_SUCCESS and GetVariable() value must = 0x00
+  //
+  DataSize = MOR_LOCK_WITH_KEY_SIZE;
+  Attributes = TCG_MOR_VARIABLE_ATTRIBUTES;
+  MemoryOverwriteControlLockKeyValue = MOR_LOCK_TEST_KEY;
+
+  Status = gtRT->SetVariable (
+                  L"MemoryOverwriteRequestControlLock",        // VariableName
+                  &gEfiMemoryOverwriteRequestControlLockGuid,  // VendorGuid
+                  Attributes,                                  // Attributes
+                  DataSize,                                    // DataSize
+                  &MemoryOverwriteControlLockKeyValue          // Data
+                  );
+  if (Status == EFI_SUCCESS) {
+    Result = EFI_TEST_ASSERTION_PASSED;
+  } else {
+    Result = EFI_TEST_ASSERTION_FAILED;
+  }
+
+  StandardLib->RecordAssertion (
+                  StandardLib,
+                  Result,
+                  gTCGMemoryOverwriteRequestTestFunctionAssertionGuid034,
+                  L"MemoryOverwriteRequestControlLock - Unlocking the lock using key value = 0x11111111 when locked with the same key returns EFI_SUCCESS",
+                  L"%a:%d:Status - %r",
+                  __FILE__,
+                  (UINTN)__LINE__,
+                  Status
+                  );
+
+  DataSize = sizeof(MemoryOverwriteRequestControlLockData);
+  Attributes = TCG_MOR_VARIABLE_ATTRIBUTES;
+
+  Status = gtRT->GetVariable (
+                  L"MemoryOverwriteRequestControlLock",        // VariableName
+                  &gEfiMemoryOverwriteRequestControlLockGuid,  // VendorGuid
+                  &Attributes,                                 // Attributes
+                  &DataSize,                                   // DataSize
+                  &MemoryOverwriteRequestControlLockData       // Data
+                  );
+  if (EFI_ERROR (Status) || (MemoryOverwriteRequestControlLockData != MOR_LOCK_DATA_UNLOCKED)) {
+    Result = EFI_TEST_ASSERTION_FAILED;
+  } else {
+    Result = EFI_TEST_ASSERTION_PASSED;
+  }
+
+  StandardLib->RecordAssertion (
+                  StandardLib,
+                  Result,
+                  gTCGMemoryOverwriteRequestTestFunctionAssertionGuid035,
+                  L"MemoryOverwriteRequestControlLock - Lock state is now unlocked",
+                  L"%a:%d:Status - %r",
+                  __FILE__,
+                  (UINTN)__LINE__,
+                  Status
+                  );
+
+  //
+  // Lock with same 8 byte key again, verify EFI_SUCCESS is returned
+  // unlock attempt: invoke SetVariable() with the same valid 8 byte
+  // key used to lock = 0x11111111, but with invalid DataSize == 1
+  // must return EFI_ACCESS_DENIED and GetVariable() value must remain = 0x02
+  //
+  DataSize = MOR_LOCK_WITH_KEY_SIZE;
+  Attributes = TCG_MOR_VARIABLE_ATTRIBUTES;
+  MemoryOverwriteControlLockKeyValue = MOR_LOCK_TEST_KEY;
+
+  Status = gtRT->SetVariable (
+                  L"MemoryOverwriteRequestControlLock",        // VariableName
+                  &gEfiMemoryOverwriteRequestControlLockGuid,  // VendorGuid
+                  Attributes,                                  // Attributes
+                  DataSize,                                    // DataSize
+                  &MemoryOverwriteControlLockKeyValue          // Data
+                  );
+  if (Status == EFI_SUCCESS) {
+    Result = EFI_TEST_ASSERTION_PASSED;
+  } else {
+    Result = EFI_TEST_ASSERTION_FAILED;
+  }
+
+  StandardLib->RecordAssertion (
+                  StandardLib,
+                  Result,
+                  gTCGMemoryOverwriteRequestTestFunctionAssertionGuid036,
+                  L"MemoryOverwriteRequestControlLock - Setting to locked-with-key using key value = 0x11111111 when unlocked returns EFI_SUCCESS",
+                  L"%a:%d:Status - %r",
+                  __FILE__,
+                  (UINTN)__LINE__,
+                  Status
+                  );
+
+  DataSize = MOR_LOCK_NO_KEY_SIZE; // invalid datasize == 1
+  Attributes = TCG_MOR_VARIABLE_ATTRIBUTES;
+  MemoryOverwriteControlLockKeyValue = MOR_LOCK_TEST_KEY;
+
+  Status = gtRT->SetVariable (
+                  L"MemoryOverwriteRequestControlLock",        // VariableName
+                  &gEfiMemoryOverwriteRequestControlLockGuid,  // VendorGuid
+                  Attributes,                                  // Attributes
+                  DataSize,                                    // DataSize
+                  &MemoryOverwriteControlLockKeyValue          // Data
+                  );
+  if (Status == EFI_ACCESS_DENIED) {
+    Result = EFI_TEST_ASSERTION_PASSED;
+  } else {
+    Result = EFI_TEST_ASSERTION_FAILED;
+  }
+
+  StandardLib->RecordAssertion (
+                  StandardLib,
+                  Result,
+                  gTCGMemoryOverwriteRequestTestFunctionAssertionGuid037,
+                  L"MemoryOverwriteRequestControlLock - Attempting to unlock by passing an invalid DataSize returns EFI_ACCESS_DENIED",
+                  L"%a:%d:Status - %r",
+                  __FILE__,
+                  (UINTN)__LINE__,
+                  Status
+                  );
+
+  DataSize = sizeof(MemoryOverwriteRequestControlLockData);
+  Attributes = TCG_MOR_VARIABLE_ATTRIBUTES;
+
+  Status = gtRT->GetVariable (
+                  L"MemoryOverwriteRequestControlLock",        // VariableName
+                  &gEfiMemoryOverwriteRequestControlLockGuid,  // VendorGuid
+                  &Attributes,                                 // Attributes
+                  &DataSize,                                   // DataSize
+                  &MemoryOverwriteRequestControlLockData       // Data
+                  );
+  if (EFI_ERROR (Status) || (MemoryOverwriteRequestControlLockData != MOR_LOCK_DATA_LOCKED_WITH_KEY)) {
+    Result = EFI_TEST_ASSERTION_FAILED;
+  } else {
+    Result = EFI_TEST_ASSERTION_PASSED;
+  }
+
+  StandardLib->RecordAssertion (
+                  StandardLib,
+                  Result,
+                  gTCGMemoryOverwriteRequestTestFunctionAssertionGuid038,
+                  L"MemoryOverwriteRequestControlLock - Lock state is still locked-with-key with key value = 0x11111111",
+                  L"%a:%d:Status - %r",
+                  __FILE__,
+                  (UINTN)__LINE__,
+                  Status
+                  );
+
+  //
+  // invoke MORLOCK SetVariable() with Data value = 0x00 to change to unlocked
+  // must return EFI_ACCESS_DENIED and GetVariable() value must still = 0x02
+  //
+  DataSize = sizeof(MemoryOverwriteRequestControlLockData);
+  Attributes = TCG_MOR_VARIABLE_ATTRIBUTES;
+  MemoryOverwriteRequestControlLockData = MOR_LOCK_DATA_UNLOCKED;
+
+  Status = gtRT->SetVariable (
+                  L"MemoryOverwriteRequestControlLock",        // VariableName
+                  &gEfiMemoryOverwriteRequestControlLockGuid,  // VendorGuid
+                  Attributes,                                  // Attributes
+                  DataSize,                                    // DataSize
+                  &MemoryOverwriteRequestControlLockData       // Data
+                  );
+  if (Status == EFI_ACCESS_DENIED) {
+    Result = EFI_TEST_ASSERTION_PASSED;
+  } else {
+    Result = EFI_TEST_ASSERTION_FAILED;
+  }
+
+  StandardLib->RecordAssertion (
+                  StandardLib,
+                  Result,
+                  gTCGMemoryOverwriteRequestTestFunctionAssertionGuid039,
+                  L"MemoryOverwriteRequestControlLock - Setting to unlocked when locked-with-key returns EFI_ACCESS_DENIED",
+                  L"%a:%d:Status - %r",
+                  __FILE__,
+                  (UINTN)__LINE__,
+                  Status
+                  );
+
+  DataSize = sizeof(MemoryOverwriteRequestControlLockData);
+  Attributes = TCG_MOR_VARIABLE_ATTRIBUTES;
+
+  Status = gtRT->GetVariable (
+                  L"MemoryOverwriteRequestControlLock",        // VariableName
+                  &gEfiMemoryOverwriteRequestControlLockGuid,  // VendorGuid
+                  &Attributes,                                 // Attributes
+                  &DataSize,                                   // DataSize
+                  &MemoryOverwriteRequestControlLockData       // Data
+                  );
+  if (EFI_ERROR (Status) || (MemoryOverwriteRequestControlLockData != MOR_LOCK_DATA_LOCKED_WITH_KEY)) {
+    Result = EFI_TEST_ASSERTION_FAILED;
+  } else {
+    Result = EFI_TEST_ASSERTION_PASSED;
+  }
+
+  StandardLib->RecordAssertion (
+                  StandardLib,
+                  Result,
+                  gTCGMemoryOverwriteRequestTestFunctionAssertionGuid040,
+                  L"MemoryOverwriteRequestControlLock - Lock state is still locked-with-key with key value = 0x11111111",
+                  L"%a:%d:Status - %r",
+                  __FILE__,
+                  (UINTN)__LINE__,
+                  Status
+                  );
+
+  //
+  // invoke MORLOCK SetVariable() with Data value = 0x01 to change to locked-without-key
+  // must return EFI_ACCESS_DENIED and GetVariable() value must still = 0x02
+  //
+  DataSize = sizeof(MemoryOverwriteRequestControlLockData);
+  Attributes = TCG_MOR_VARIABLE_ATTRIBUTES;
+  MemoryOverwriteRequestControlLockData = MOR_LOCK_DATA_LOCKED_WITHOUT_KEY;
+
+  Status = gtRT->SetVariable (
+                  L"MemoryOverwriteRequestControlLock",        // VariableName
+                  &gEfiMemoryOverwriteRequestControlLockGuid,  // VendorGuid
+                  Attributes,                                  // Attributes
+                  DataSize,                                    // DataSize
+                  &MemoryOverwriteRequestControlLockData       // Data
+                  );
+  if (Status == EFI_ACCESS_DENIED) {
+    Result = EFI_TEST_ASSERTION_PASSED;
+  } else {
+    Result = EFI_TEST_ASSERTION_FAILED;
+  }
+
+  StandardLib->RecordAssertion (
+                  StandardLib,
+                  Result,
+                  gTCGMemoryOverwriteRequestTestFunctionAssertionGuid041,
+                  L"MemoryOverwriteRequestControlLock - Setting to locked-without-key when locked-with-key returns EFI_ACCESS_DENIED",
+                  L"%a:%d:Status - %r",
+                  __FILE__,
+                  (UINTN)__LINE__,
+                  Status
+                  );
+
+  DataSize = sizeof(MemoryOverwriteRequestControlLockData);
+  Attributes = TCG_MOR_VARIABLE_ATTRIBUTES;
+
+  Status = gtRT->GetVariable (
+                  L"MemoryOverwriteRequestControlLock",        // VariableName
+                  &gEfiMemoryOverwriteRequestControlLockGuid,  // VendorGuid
+                  &Attributes,                                 // Attributes
+                  &DataSize,                                   // DataSize
+                  &MemoryOverwriteRequestControlLockData       // Data
+                  );
+  if (EFI_ERROR (Status) || (MemoryOverwriteRequestControlLockData != MOR_LOCK_DATA_LOCKED_WITH_KEY)) {
+    Result = EFI_TEST_ASSERTION_FAILED;
+  } else {
+    Result = EFI_TEST_ASSERTION_PASSED;
+  }
+
+  StandardLib->RecordAssertion (
+                  StandardLib,
+                  Result,
+                  gTCGMemoryOverwriteRequestTestFunctionAssertionGuid042,
+                  L"MemoryOverwriteRequestControlLock - Lock state is still locked-with-key with key value = 0x11111111",
+                  L"%a:%d:Status - %r",
+                  __FILE__,
+                  (UINTN)__LINE__,
+                  Status
+                  );
+
+  //
+  // Once locked-with-key, MOR SetVariable() call to set MOR bit 0 must return EFI_ACCESS_DENIED
+  // and MOR value must not change
+  //
+  DataSize = sizeof(MemoryOverwriteRequestControlData);
+  Attributes = TCG_MOR_VARIABLE_ATTRIBUTES;
+  // getting current MOR value that will be used to check that the variable is unchanged
+  Status = gtRT->GetVariable (
+                  L"MemoryOverwriteRequestControl",     // VariableName
+                  &gEfiMemoryOverwriteControlDataGuid,  // VendorGuid
+                  &Attributes,                          // Attributes
+                  &DataSize,                            // DataSize
+                  &MemoryOverwriteRequestControlData    // Data
+                  );
+  if (EFI_ERROR (Status)) {
+    return Status;
+  }
+
+  // caching MOR and setting the bit 0
+  MemoryOverwriteRequestControlDataCached = MemoryOverwriteRequestControlData;
+  MemoryOverwriteRequestControlData |= MOR_BIT_HIGH << MOR_CLEAR_MEMORY_BIT_OFFSET;
+
+  DataSize = sizeof(MemoryOverwriteRequestControlData);
+  Attributes = TCG_MOR_VARIABLE_ATTRIBUTES;
+
+  Status = gtRT->SetVariable (
+                  L"MemoryOverwriteRequestControl",     // VariableName
+                  &gEfiMemoryOverwriteControlDataGuid,  // VendorGuid
+                  Attributes,                           // Attributes
+                  DataSize,                             // DataSize
+                  &MemoryOverwriteRequestControlData    // Data
+                  );
+  if (Status == EFI_ACCESS_DENIED) {
+    Result = EFI_TEST_ASSERTION_PASSED;
+  } else {
+    Result = EFI_TEST_ASSERTION_FAILED;
+  }
+
+  StandardLib->RecordAssertion (
+                  StandardLib,
+                  Result,
+                  gTCGMemoryOverwriteRequestTestFunctionAssertionGuid043,
+                  L"MemoryOverwriteRequestControl - SetVariable() returns EFI_ACCESS_DENIED when MORLOCK is locked-with-key",
+                  L"%a:%d:Status - %r",
+                  __FILE__,
+                  (UINTN)__LINE__,
+                  Status
+                  );
+
+  DataSize = sizeof(MemoryOverwriteRequestControlData);
+  Attributes = TCG_MOR_VARIABLE_ATTRIBUTES;
+
+  Status = gtRT->GetVariable (
+                  L"MemoryOverwriteRequestControl",     // VariableName
+                  &gEfiMemoryOverwriteControlDataGuid,  // VendorGuid
+                  &Attributes,                          // Attributes
+                  &DataSize,                            // DataSize
+                  &MemoryOverwriteRequestControlData    // Data
+                  );
+
+  // verifying that the variable has not been modified with SetVariable()
+  if (MemoryOverwriteRequestControlDataCached == MemoryOverwriteRequestControlData) {
+    Result = EFI_TEST_ASSERTION_PASSED;
+  } else {
+    Result = EFI_TEST_ASSERTION_FAILED;
+  }
+
+  StandardLib->RecordAssertion (
+                  StandardLib,
+                  Result,
+                  gTCGMemoryOverwriteRequestTestFunctionAssertionGuid044,
+                  L"MemoryOverwriteRequestControl - After SetVariable(), MOR value remains unchanged when MORLOCK is locked-with-key",
+                  L"%a:%d:Status - %r",
+                  __FILE__,
+                  (UINTN)__LINE__,
+                  Status
+                  );
+
+  //
+  // Once locked-with-key, MOR cannot be deleted
+  // SetVariable() call to set MOR with DataSize == 0 must return EFI_ACCESS_DENIED
+  // MemoryOverwriteControlData is a don't care in this case
+  DataSize = 0;
+  Attributes = TCG_MOR_VARIABLE_ATTRIBUTES;
+
+  Status = gtRT->SetVariable (
+                  L"MemoryOverwriteRequestControl",     // VariableName
+                  &gEfiMemoryOverwriteControlDataGuid,  // VendorGuid
+                  Attributes,                           // Attributes
+                  DataSize,                             // DataSize
+                  &MemoryOverwriteRequestControlData    // Data
+                  );
+  if (Status == EFI_ACCESS_DENIED || EFI_INVALID_PARAMETER) {
+    Result = EFI_TEST_ASSERTION_PASSED;
+  } else {
+    Result = EFI_TEST_ASSERTION_FAILED;
+  }
+
+  StandardLib->RecordAssertion (
+                  StandardLib,
+                  Result,
+                  gTCGMemoryOverwriteRequestTestFunctionAssertionGuid045,
+                  L"MemoryOverwriteRequestControl - When MORLOCK is locked-with-key, an attempt to delete the MOR variable must return either EFI_ACCESS_DENIED or EFI_INVALID_PARAMETER",
+                  L"%a:%d:Status - %r",
+                  __FILE__,
+                  (UINTN)__LINE__,
+                  Status
+                  );
+
+  //
+  // When locked-with-key, in this case key = 0x11111111,
+  // SetVariable() with an invalid 8 byte key != 0x11111111, must return EFI_ACCESS_DENIED
+  // and lock must be updated to Locked without key (Data value = 0x01) to prevent dictonary attack
+  // The invalid key to be used to attempt unlock is = 0x22222222
+  //
+  DataSize = MOR_LOCK_WITH_KEY_SIZE;
+  Attributes = TCG_MOR_VARIABLE_ATTRIBUTES;
+  MemoryOverwriteControlLockKeyValue = MOR_LOCK_INVALID_TEST_KEY;
+
+  Status = gtRT->SetVariable (
+                  L"MemoryOverwriteRequestControlLock",        // VariableName
+                  &gEfiMemoryOverwriteRequestControlLockGuid,  // VendorGuid
+                  Attributes,                                  // Attributes
+                  DataSize,                                    // DataSize
+                  &MemoryOverwriteControlLockKeyValue          // Data
+                  );
+  if (Status == EFI_ACCESS_DENIED) {
+    Result = EFI_TEST_ASSERTION_PASSED;
+  } else {
+    Result = EFI_TEST_ASSERTION_FAILED;
+  }
+
+  StandardLib->RecordAssertion (
+                  StandardLib,
+                  Result,
+                  gTCGMemoryOverwriteRequestTestFunctionAssertionGuid046,
+                  L"MemoryOverwriteRequestControlLock - Unlocking lock with invalid key != 0x11111111 returns EFI_ACCESS_DENIED",
+                  L"%a:%d:Status - %r",
+                  __FILE__,
+                  (UINTN)__LINE__,
+                  Status
+                  );
+
+  DataSize = sizeof(MemoryOverwriteRequestControlLockData);
+  Attributes = TCG_MOR_VARIABLE_ATTRIBUTES;
+
+  Status = gtRT->GetVariable (
+                  L"MemoryOverwriteRequestControlLock",        // VariableName
+                  &gEfiMemoryOverwriteRequestControlLockGuid,  // VendorGuid
+                  &Attributes,                                 // Attributes
+                  &DataSize,                                   // DataSize
+                  &MemoryOverwriteRequestControlLockData       // Data
+                  );
+  if (EFI_ERROR (Status) || (MemoryOverwriteRequestControlLockData != MOR_LOCK_DATA_LOCKED_WITHOUT_KEY)) {
+    Result = EFI_TEST_ASSERTION_FAILED;
+  } else {
+    Result = EFI_TEST_ASSERTION_PASSED;
+  }
+
+  StandardLib->RecordAssertion (
+                  StandardLib,
+                  Result,
+                  gTCGMemoryOverwriteRequestTestFunctionAssertionGuid047,
+                  L"MemoryOverwriteRequestControlLock - Lock state is now locked-without-key",
+                  L"%a:%d:Status - %r",
+                  __FILE__,
+                  (UINTN)__LINE__,
+                  Status
+                  );
+
+  //
+  // MORLOCK has been updated to locked-without-key (Data value = 0x01) to prevent dictonary attack
+  // Now check to see if the lock can still be unlocked with the initial key used to set to lock-with-key state
+  // The key to be used to attempt unlock is = 0x11111111
+  //
+  DataSize = MOR_LOCK_WITH_KEY_SIZE;
+  Attributes = TCG_MOR_VARIABLE_ATTRIBUTES;
+  MemoryOverwriteControlLockKeyValue = MOR_LOCK_TEST_KEY;
+
+  Status = gtRT->SetVariable (
+                  L"MemoryOverwriteRequestControlLock",        // VariableName
+                  &gEfiMemoryOverwriteRequestControlLockGuid,  // VendorGuid
+                  Attributes,                                  // Attributes
+                  DataSize,                                    // DataSize
+                  &MemoryOverwriteControlLockKeyValue          // Data
+                  );
+  if (Status == EFI_ACCESS_DENIED) {
+    Result = EFI_TEST_ASSERTION_PASSED;
+  } else {
+    Result = EFI_TEST_ASSERTION_FAILED;
+  }
+
+  StandardLib->RecordAssertion (
+                  StandardLib,
+                  Result,
+                  gTCGMemoryOverwriteRequestTestFunctionAssertionGuid048,
+                  L"MemoryOverwriteRequestControlLock - Attempt to unlock after dictionary attack mitigation returns EFI_ACCESS_DENIED",
+                  L"%a:%d:Status - %r",
+                  __FILE__,
+                  (UINTN)__LINE__,
+                  Status
+                  );
+
+  DataSize = sizeof(MemoryOverwriteRequestControlLockData);
+  Attributes = TCG_MOR_VARIABLE_ATTRIBUTES;
+
+  Status = gtRT->GetVariable (
+                  L"MemoryOverwriteRequestControlLock",        // VariableName
+                  &gEfiMemoryOverwriteRequestControlLockGuid,  // VendorGuid
+                  &Attributes,                                 // Attributes
+                  &DataSize,                                   // DataSize
+                  &MemoryOverwriteRequestControlLockData       // Data
+                  );
+  if (EFI_ERROR (Status) || (MemoryOverwriteRequestControlLockData != MOR_LOCK_DATA_LOCKED_WITHOUT_KEY)) {
+    Result = EFI_TEST_ASSERTION_FAILED;
+  } else {
+    Result = EFI_TEST_ASSERTION_PASSED;
+  }
+
+  StandardLib->RecordAssertion (
+                  StandardLib,
+                  Result,
+                  gTCGMemoryOverwriteRequestTestFunctionAssertionGuid049,
+                  L"MemoryOverwriteRequestControlLock - Lock state is still locked-without-key",
+                  L"%a:%d:Status - %r",
+                  __FILE__,
+                  (UINTN)__LINE__,
+                  Status
+                  );
+
+  return EFI_SUCCESS;
+}
-- 
2.34.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#116412): https://edk2.groups.io/g/devel/message/116412
Mute This Topic: https://groups.io/mt/104756657/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-



  parent reply	other threads:[~2024-03-05 23:36 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-05 23:36 [edk2-devel] [PATCH v4 0/6] EDK2-TEST TCG MOR Tests Abhimanyu Singh
2024-03-05 23:36 ` [edk2-devel] [PATCH v4 1/6] uefi-sct/SctPkg: TCG Platform Reset Check Test Abhimanyu Singh
2024-03-21 11:30   ` G Edhaya Chandran
2024-03-21 11:33     ` G Edhaya Chandran
2024-03-05 23:36 ` [edk2-devel] [PATCH v4 2/6] uefi-sct/SctPkg: TCG MOR SetVariable Test Abhimanyu Singh
2024-03-21 11:30   ` G Edhaya Chandran
2024-03-05 23:36 ` [edk2-devel] [PATCH v4 3/6] uefi-sct/SctPkg: TCG MORLOCK " Abhimanyu Singh
2024-03-21 11:31   ` G Edhaya Chandran
2024-03-05 23:36 ` [edk2-devel] [PATCH v4 4/6] uefi-sct/SctPkg: TCG MORLOCK Unlocked State Test Abhimanyu Singh
2024-03-21 11:31   ` G Edhaya Chandran
2024-03-05 23:36 ` [edk2-devel] [PATCH v4 5/6] uefi-sct/SctPkg: TCG MORLOCK Locked No Key " Abhimanyu Singh
2024-03-21 11:32   ` G Edhaya Chandran
2024-03-05 23:36 ` Abhimanyu Singh [this message]
2024-03-21 11:32   ` [edk2-devel] [PATCH v4 6/6] uefi-sct/SctPkg: TCG MORLOCK Locked with " G Edhaya Chandran
2024-04-04 16:49 ` [edk2-devel] [PATCH v4 0/6] EDK2-TEST TCG MOR Tests Sunny Wang

Reply instructions:

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

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

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

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

  git send-email \
    --in-reply-to=20240305233622.747522-7-Abhi.Singh@arm.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

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

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