]> git.proxmox.com Git - mirror_edk2.git/blobdiff - SecurityPkg/Library/SmmTcg2PhysicalPresenceLib/SmmTcg2PhysicalPresenceLib.c
SecurityPkg: Support PP version lower than 1.3
[mirror_edk2.git] / SecurityPkg / Library / SmmTcg2PhysicalPresenceLib / SmmTcg2PhysicalPresenceLib.c
index 606145315b67b10d68967a2d5559297316050137..dfef6c8ca0c8a2e9b1a9894daefe2b628d8e97fe 100644 (file)
@@ -10,7 +10,7 @@
   Tcg2PhysicalPresenceLibSubmitRequestToPreOSFunction() and Tcg2PhysicalPresenceLibGetUserConfirmationStatusFunction()\r
   will receive untrusted input and do validation.\r
 \r
-Copyright (c) 2015 - 2017, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2015 - 2018, Intel Corporation. All rights reserved.<BR>\r
 This program and the accompanying materials \r
 are licensed and made available under the terms and conditions of the BSD License \r
 which accompanies this distribution.  The full text of the license may be found at \r
@@ -27,12 +27,16 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 \r
 #include <Protocol/SmmVariable.h>\r
 \r
+#include <Library/BaseLib.h>\r
 #include <Library/DebugLib.h>\r
 #include <Library/BaseMemoryLib.h>\r
 #include <Library/Tcg2PpVendorLib.h>\r
 #include <Library/SmmServicesTableLib.h>\r
 \r
+#define     PP_INF_VERSION_1_2    "1.2"\r
+\r
 EFI_SMM_VARIABLE_PROTOCOL  *mTcg2PpSmmVariable;\r
+BOOLEAN                    mIsTcg2PPVerLowerThan_1_3 = FALSE;\r
 \r
 /**\r
   The handler for TPM physical presence function:\r
@@ -337,11 +341,22 @@ Tcg2PhysicalPresenceLibGetUserConfirmationStatusFunction (
       break;\r
 \r
     default:\r
-      if (OperationRequest < TCG2_PHYSICAL_PRESENCE_VENDOR_SPECIFIC_OPERATION) {\r
-        //\r
-        // TCG PP spec defined operations that are reserved or un-implemented\r
-        //\r
-        return TCG_PP_GET_USER_CONFIRMATION_NOT_IMPLEMENTED;\r
+      if (mIsTcg2PPVerLowerThan_1_3 == FALSE) {\r
+        if (OperationRequest < TCG2_PHYSICAL_PRESENCE_VENDOR_SPECIFIC_OPERATION) {\r
+          //\r
+          // TCG2 PP1.3 spec defined operations that are reserved or un-implemented\r
+          //\r
+          return TCG_PP_GET_USER_CONFIRMATION_NOT_IMPLEMENTED;\r
+        }\r
+      } else {\r
+       //\r
+       // TCG PP lower than 1.3. (1.0, 1.1, 1.2)\r
+       //\r
+       if (OperationRequest <= TCG2_PHYSICAL_PRESENCE_NO_ACTION_MAX) {\r
+         RequestConfirmed = TRUE;\r
+       } else if (OperationRequest < TCG2_PHYSICAL_PRESENCE_VENDOR_SPECIFIC_OPERATION) {\r
+         return TCG_PP_GET_USER_CONFIRMATION_NOT_IMPLEMENTED;\r
+       }\r
       }\r
       break;\r
   }\r
@@ -377,6 +392,10 @@ Tcg2PhysicalPresenceLibConstructor (
 {\r
   EFI_STATUS  Status;\r
 \r
+  if (AsciiStrnCmp(PP_INF_VERSION_1_2, (CHAR8 *)PcdGetPtr(PcdTcgPhysicalPresenceInterfaceVer), sizeof(PP_INF_VERSION_1_2) - 1) <= 0) {\r
+    mIsTcg2PPVerLowerThan_1_3 = TRUE;\r
+  }\r
+\r
   //\r
   // Locate SmmVariableProtocol.\r
   //\r