SecurityPkg: Support PP version lower than 1.3
authorZhang, Chao B <chao.b.zhang@intel.com>
Fri, 2 Feb 2018 08:16:05 +0000 (16:16 +0800)
committerZhang, Chao B <chao.b.zhang@intel.com>
Tue, 6 Feb 2018 04:59:15 +0000 (12:59 +0800)
TCG PP 1.2 & PP 1.3 spec defined different Opcodes.
Update code to support both.

Cc: Long Qin <qin.long@intel.com>
Cc: Yao Jiewen <jiewen.yao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Chao Zhang <chao.b.zhang@intel.com>
Reviewed-by: Long Qin <qin.long@intel.com>
Reviewed-by: Yao Jiewen <jiewen.yao@intel.com>
SecurityPkg/Library/SmmTcg2PhysicalPresenceLib/SmmTcg2PhysicalPresenceLib.c
SecurityPkg/Library/SmmTcg2PhysicalPresenceLib/SmmTcg2PhysicalPresenceLib.inf

index 6061453..dfef6c8 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
index 5fa84b1..8367097 100644 (file)
@@ -7,7 +7,7 @@
 #  This driver will have external input - variable.\r
 #  This external input must be validated carefully to avoid security issue.\r
 #\r
-# Copyright (c) 2015, 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
@@ -52,6 +52,9 @@
   ## SOMETIMES_CONSUMES ## Variable:L"PhysicalPresence"\r
   ## SOMETIMES_CONSUMES ## Variable:L"PhysicalPresenceFlags"\r
   gEfiTcg2PhysicalPresenceGuid\r
-  \r
+\r
+[Pcd]\r
+  gEfiSecurityPkgTokenSpaceGuid.PcdTcgPhysicalPresenceInterfaceVer  ## CONSUMES\r
+\r
 [Depex]\r
   gEfiSmmVariableProtocolGuid
\ No newline at end of file