]> git.proxmox.com Git - mirror_edk2.git/blobdiff - SecurityPkg/Library/DxeTcg2PhysicalPresenceLib/DxeTcg2PhysicalPresenceLib.c
SecurityPkg: Clean up source files
[mirror_edk2.git] / SecurityPkg / Library / DxeTcg2PhysicalPresenceLib / DxeTcg2PhysicalPresenceLib.c
index 5ece8e513abc5921095c583b326d587c013ed2a9..a271c813887f8e5864aa88e348429aad55143c53 100644 (file)
@@ -7,13 +7,13 @@
 \r
   Tpm2ExecutePendingTpmRequest() will receive untrusted input and do validation.\r
 \r
-Copyright (c) 2013 - 2016, 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
+Copyright (c) 2013 - 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
 http://opensource.org/licenses/bsd-license.php\r
 \r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
 \r
 **/\r
@@ -109,7 +109,7 @@ Done:
   Change EPS.\r
 \r
   @param[in]  PlatformAuth      platform auth value. NULL means no platform auth change.\r
-  \r
+\r
   @retval EFI_SUCCESS Operation completed successfully.\r
 **/\r
 EFI_STATUS\r
@@ -145,9 +145,9 @@ Tpm2CommandChangeEps (
   @param[in]      CommandCode         Physical presence operation value.\r
   @param[in]      CommandParameter    Physical presence operation parameter.\r
   @param[in, out] PpiFlags            The physical presence interface flags.\r
-  \r
+\r
   @retval TCG_PP_OPERATION_RESPONSE_BIOS_FAILURE   Unknown physical presence operation.\r
-  @retval TCG_PP_OPERATION_RESPONSE_BIOS_FAILURE   Error occurred during sending command to TPM or \r
+  @retval TCG_PP_OPERATION_RESPONSE_BIOS_FAILURE   Error occurred during sending command to TPM or\r
                                                    receiving response from TPM.\r
   @retval Others                                   Return code from the TPM device after command execution.\r
 **/\r
@@ -274,8 +274,8 @@ Tcg2ReadUserKey (
   EFI_STATUS                        Status;\r
   EFI_INPUT_KEY                     Key;\r
   UINT16                            InputKey;\r
-      \r
-  InputKey = 0; \r
+\r
+  InputKey = 0;\r
   do {\r
     Status = gBS->CheckEvent (gST->ConIn->WaitForKey);\r
     if (!EFI_ERROR (Status)) {\r
@@ -289,13 +289,13 @@ Tcg2ReadUserKey (
       if ((Key.ScanCode == SCAN_F12) && CautionKey) {\r
         InputKey = Key.ScanCode;\r
       }\r
-    }      \r
+    }\r
   } while (InputKey == 0);\r
 \r
   if (InputKey != SCAN_ESC) {\r
     return TRUE;\r
   }\r
-  \r
+\r
   return FALSE;\r
 }\r
 \r
@@ -364,7 +364,7 @@ Tcg2UserConfirm (
 {\r
   CHAR16                            *ConfirmText;\r
   CHAR16                            *TmpStr1;\r
-  CHAR16                            *TmpStr2; \r
+  CHAR16                            *TmpStr2;\r
   UINTN                             BufSize;\r
   BOOLEAN                           CautionKey;\r
   BOOLEAN                           NoPpiInfo;\r
@@ -376,7 +376,7 @@ Tcg2UserConfirm (
   EFI_TCG2_BOOT_SERVICE_CAPABILITY  ProtocolCapability;\r
   UINT32                            CurrentPCRBanks;\r
   EFI_STATUS                        Status;\r
-  \r
+\r
   TmpStr2     = NULL;\r
   CautionKey  = FALSE;\r
   NoPpiInfo   = FALSE;\r
@@ -403,7 +403,7 @@ Tcg2UserConfirm (
       TmpStr1 = Tcg2PhysicalPresenceGetStringById (STRING_TOKEN (TPM_WARNING_CLEAR));\r
       StrnCatS (ConfirmText, BufSize / sizeof (CHAR16), TmpStr1, (BufSize / sizeof (CHAR16)) - StrLen (ConfirmText) - 1);\r
       StrnCatS (ConfirmText, BufSize / sizeof (CHAR16), L" \n\n", (BufSize / sizeof (CHAR16)) - StrLen (ConfirmText) - 1);\r
-      FreePool (TmpStr1);      \r
+      FreePool (TmpStr1);\r
 \r
       break;\r
 \r
@@ -423,7 +423,7 @@ Tcg2UserConfirm (
       TmpStr1 = Tcg2PhysicalPresenceGetStringById (STRING_TOKEN (TPM_WARNING_CLEAR));\r
       StrnCatS (ConfirmText, BufSize / sizeof (CHAR16), TmpStr1, (BufSize / sizeof (CHAR16)) - StrLen (ConfirmText) - 1);\r
       StrnCatS (ConfirmText, BufSize / sizeof (CHAR16), L" \n\n", (BufSize / sizeof (CHAR16)) - StrLen (ConfirmText) - 1);\r
-      FreePool (TmpStr1); \r
+      FreePool (TmpStr1);\r
 \r
       break;\r
 \r
@@ -453,11 +453,11 @@ Tcg2UserConfirm (
 \r
       TmpStr1 = Tcg2PhysicalPresenceGetStringById (STRING_TOKEN (TPM_WARNING_SET_PCR_BANKS_1));\r
       StrnCatS (ConfirmText, BufSize / sizeof (CHAR16), TmpStr1, (BufSize / sizeof (CHAR16)) - StrLen (ConfirmText) - 1);\r
-      FreePool (TmpStr1);      \r
+      FreePool (TmpStr1);\r
 \r
       TmpStr1 = Tcg2PhysicalPresenceGetStringById (STRING_TOKEN (TPM_WARNING_SET_PCR_BANKS_2));\r
       StrnCatS (ConfirmText, BufSize / sizeof (CHAR16), TmpStr1, (BufSize / sizeof (CHAR16)) - StrLen (ConfirmText) - 1);\r
-      FreePool (TmpStr1);      \r
+      FreePool (TmpStr1);\r
 \r
       Tcg2FillBufferWithBootHashAlg (TempBuffer, sizeof(TempBuffer), TpmPpCommandParameter);\r
       Tcg2FillBufferWithBootHashAlg (TempBuffer2, sizeof(TempBuffer2), CurrentPCRBanks);\r
@@ -468,7 +468,7 @@ Tcg2UserConfirm (
 \r
       StrnCatS (ConfirmText, BufSize / sizeof (CHAR16), TmpStr1, (BufSize / sizeof (CHAR16)) - StrLen (ConfirmText) - 1);\r
       StrnCatS (ConfirmText, BufSize / sizeof (CHAR16), L" \n", (BufSize / sizeof (CHAR16)) - StrLen (ConfirmText) - 1);\r
-      FreePool (TmpStr1);      \r
+      FreePool (TmpStr1);\r
 \r
       break;\r
 \r
@@ -482,11 +482,11 @@ Tcg2UserConfirm (
 \r
       TmpStr1 = Tcg2PhysicalPresenceGetStringById (STRING_TOKEN (TPM_WARNING_CHANGE_EPS_1));\r
       StrnCatS (ConfirmText, BufSize / sizeof (CHAR16), TmpStr1, (BufSize / sizeof (CHAR16)) - StrLen (ConfirmText) - 1);\r
-      FreePool (TmpStr1);      \r
-      \r
+      FreePool (TmpStr1);\r
+\r
       TmpStr1 = Tcg2PhysicalPresenceGetStringById (STRING_TOKEN (TPM_WARNING_CHANGE_EPS_2));\r
       StrnCatS (ConfirmText, BufSize / sizeof (CHAR16), TmpStr1, (BufSize / sizeof (CHAR16)) - StrLen (ConfirmText) - 1);\r
-      FreePool (TmpStr1);      \r
+      FreePool (TmpStr1);\r
 \r
       break;\r
 \r
@@ -571,10 +571,10 @@ Tcg2UserConfirm (
 \r
   DstStr[80] = L'\0';\r
   for (Index = 0; Index < StrLen (ConfirmText); Index += 80) {\r
-    StrnCpyS (DstStr, sizeof (DstStr) / sizeof (CHAR16), ConfirmText + Index, sizeof (DstStr) / sizeof (CHAR16) - 1);    \r
-    Print (DstStr);    \r
+    StrnCpyS (DstStr, sizeof (DstStr) / sizeof (CHAR16), ConfirmText + Index, sizeof (DstStr) / sizeof (CHAR16) - 1);\r
+    Print (DstStr);\r
   }\r
-  \r
+\r
   FreePool (TmpStr1);\r
   FreePool (TmpStr2);\r
   FreePool (ConfirmText);\r
@@ -584,17 +584,17 @@ Tcg2UserConfirm (
     return TRUE;\r
   }\r
 \r
-  return FALSE;  \r
+  return FALSE;\r
 }\r
 \r
 /**\r
-  Check if there is a valid physical presence command request. Also updates parameter value \r
+  Check if there is a valid physical presence command request. Also updates parameter value\r
   to whether the requested physical presence command already confirmed by user\r
\r
-   @param[in]  TcgPpData                 EFI Tcg2 Physical Presence request data. \r
+\r
+   @param[in]  TcgPpData                 EFI Tcg2 Physical Presence request data.\r
    @param[in]  Flags                     The physical presence interface flags.\r
    @param[out] RequestConfirmed          If the physical presence operation command required user confirm from UI.\r
-                                           True, it indicates the command doesn't require user confirm, or already confirmed \r
+                                           True, it indicates the command doesn't require user confirm, or already confirmed\r
                                                  in last boot cycle by user.\r
                                            False, it indicates the command need user confirm from UI.\r
 \r
@@ -657,7 +657,7 @@ Tcg2HaveValidTpmRequest  (
         *RequestConfirmed = TRUE;\r
       }\r
       break;\r
-      \r
+\r
     case TCG2_PHYSICAL_PRESENCE_LOG_ALL_DIGESTS:\r
       *RequestConfirmed = TRUE;\r
       break;\r
@@ -778,7 +778,7 @@ Tcg2ExecutePendingTpmRequest (
   } else {\r
     if (!RequestConfirmed) {\r
       //\r
-      // Print confirm text and wait for approval. \r
+      // Print confirm text and wait for approval.\r
       //\r
       RequestConfirmed = Tcg2UserConfirm (TcgPpData->PPRequest, TcgPpData->PPRequestParameter);\r
     }\r
@@ -791,8 +791,8 @@ Tcg2ExecutePendingTpmRequest (
     if (RequestConfirmed) {\r
       TcgPpData->PPResponse = Tcg2ExecutePhysicalPresence (\r
                                 PlatformAuth,\r
-                                TcgPpData->PPRequest, \r
-                                TcgPpData->PPRequestParameter, \r
+                                TcgPpData->PPRequest,\r
+                                TcgPpData->PPRequestParameter,\r
                                 &NewFlags\r
                                 );\r
     }\r
@@ -809,7 +809,7 @@ Tcg2ExecutePendingTpmRequest (
                       EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,\r
                       sizeof (EFI_TCG2_PHYSICAL_PRESENCE_FLAGS),\r
                       &NewFlags\r
-                      ); \r
+                      );\r
   }\r
 \r
   //\r
@@ -817,7 +817,7 @@ Tcg2ExecutePendingTpmRequest (
   //\r
   if ((NewFlags.PPFlags & TCG2_LIB_PP_FLAG_RESET_TRACK) == 0) {\r
     TcgPpData->LastPPRequest = TcgPpData->PPRequest;\r
-    TcgPpData->PPRequest = TCG2_PHYSICAL_PRESENCE_NO_ACTION;    \r
+    TcgPpData->PPRequest = TCG2_PHYSICAL_PRESENCE_NO_ACTION;\r
     TcgPpData->PPRequestParameter = 0;\r
   }\r
 \r
@@ -879,19 +879,19 @@ Tcg2ExecutePendingTpmRequest (
 \r
   Print (L"Rebooting system to make TPM2 settings in effect\n");\r
   gRT->ResetSystem (EfiResetCold, EFI_SUCCESS, 0, NULL);\r
-  ASSERT (FALSE);  \r
+  ASSERT (FALSE);\r
 }\r
 \r
 /**\r
   Check and execute the pending TPM request.\r
 \r
-  The TPM request may come from OS or BIOS. This API will display request information and wait \r
+  The TPM request may come from OS or BIOS. This API will display request information and wait\r
   for user confirmation if TPM request exists. The TPM request will be sent to TPM device after\r
-  the TPM request is confirmed, and one or more reset may be required to make TPM request to \r
+  the TPM request is confirmed, and one or more reset may be required to make TPM request to\r
   take effect.\r
-  \r
+\r
   This API should be invoked after console in and console out are all ready as they are required\r
-  to display request information and get user input to confirm the request.  \r
+  to display request information and get user input to confirm the request.\r
 \r
   @param[in]  PlatformAuth                   platform auth value. NULL means no platform auth change.\r
 **/\r
@@ -908,7 +908,7 @@ Tcg2PhysicalPresenceLibProcessRequest (
   EFI_TCG2_PHYSICAL_PRESENCE_FLAGS  PpiFlags;\r
 \r
   //\r
-  // This flags variable controls whether physical presence is required for TPM command. \r
+  // This flags variable controls whether physical presence is required for TPM command.\r
   // It should be protected from malicious software. We set it as read-only variable here.\r
   //\r
   Status = gBS->LocateProtocol (&gEdkiiVariableLockProtocolGuid, NULL, (VOID **)&VariableLockProtocol);\r
@@ -923,7 +923,7 @@ Tcg2PhysicalPresenceLibProcessRequest (
       ASSERT_EFI_ERROR (Status);\r
     }\r
   }\r
-  \r
+\r
   //\r
   // Check S4 resume\r
   //\r
@@ -958,7 +958,7 @@ Tcg2PhysicalPresenceLibProcessRequest (
     }\r
     DEBUG((DEBUG_INFO, "[TPM2] Initial physical presence flags value is 0x%x\n", PpiFlags.PPFlags));\r
   }\r
-  \r
+\r
   //\r
   // Initialize physical presence variable.\r
   //\r
@@ -990,7 +990,7 @@ Tcg2PhysicalPresenceLibProcessRequest (
 \r
   //\r
   // Execute pending TPM request.\r
-  //  \r
+  //\r
   Tcg2ExecutePendingTpmRequest (PlatformAuth, &TcgPpData, &PpiFlags);\r
   DEBUG ((EFI_D_INFO, "[TPM2] PPResponse = %x (LastPPRequest=%x, Flags=%x)\n", TcgPpData.PPResponse, TcgPpData.LastPPRequest, PpiFlags.PPFlags));\r
 \r
@@ -1001,7 +1001,7 @@ Tcg2PhysicalPresenceLibProcessRequest (
 \r
   The TPM request may come from OS. This API will check if TPM request exists and need user\r
   input to confirmation.\r
-  \r
+\r
   @retval    TRUE        TPM needs input to confirm user physical presence.\r
   @retval    FALSE       TPM doesn't need input to confirm user physical presence.\r
 \r
@@ -1052,7 +1052,7 @@ Tcg2PhysicalPresenceLibNeedUserConfirm(
   if (EFI_ERROR (Status)) {\r
     return FALSE;\r
   }\r
-  \r
+\r
   if (TcgPpData.PPRequest == TCG2_PHYSICAL_PRESENCE_NO_ACTION) {\r
     //\r
     // No operation request\r
@@ -1097,7 +1097,7 @@ Tcg2PhysicalPresenceLibReturnOperationResponseToOsFunction (
   EFI_STATUS                        Status;\r
   UINTN                             DataSize;\r
   EFI_TCG2_PHYSICAL_PRESENCE        PpData;\r
-  \r
+\r
   DEBUG ((EFI_D_INFO, "[TPM2] ReturnOperationResponseToOsFunction\n"));\r
 \r
   //\r
@@ -1117,7 +1117,7 @@ Tcg2PhysicalPresenceLibReturnOperationResponseToOsFunction (
     DEBUG ((EFI_D_ERROR, "[TPM2] Get PP variable failure! Status = %r\n", Status));\r
     return TCG_PP_RETURN_TPM_OPERATION_RESPONSE_FAILURE;\r
   }\r
-  \r
+\r
   *MostRecentRequest = PpData.LastPPRequest;\r
   *Response          = PpData.PPResponse;\r
 \r
@@ -1130,7 +1130,7 @@ Tcg2PhysicalPresenceLibReturnOperationResponseToOsFunction (
   Submit TPM Operation Request to Pre-OS Environment 2.\r
 \r
   Caution: This function may receive untrusted input.\r
-  \r
+\r
   @param[in]      OperationRequest TPM physical presence operation request.\r
   @param[in]      RequestParameter TPM physical presence operation request parameter.\r
 \r
@@ -1148,9 +1148,9 @@ Tcg2PhysicalPresenceLibSubmitRequestToPreOSFunction (
   UINTN                             DataSize;\r
   EFI_TCG2_PHYSICAL_PRESENCE        PpData;\r
   EFI_TCG2_PHYSICAL_PRESENCE_FLAGS  Flags;\r
-  \r
+\r
   DEBUG ((EFI_D_INFO, "[TPM2] SubmitRequestToPreOSFunction, Request = %x, %x\n", OperationRequest, RequestParameter));\r
-  \r
+\r
   //\r
   // Get the Physical Presence variable\r
   //\r
@@ -1184,7 +1184,7 @@ Tcg2PhysicalPresenceLibSubmitRequestToPreOSFunction (
                     DataSize,\r
                     &PpData\r
                     );\r
-    if (EFI_ERROR (Status)) { \r
+    if (EFI_ERROR (Status)) {\r
       DEBUG ((EFI_D_ERROR, "[TPM2] Set PP variable failure! Status = %r\n", Status));\r
       return TCG_PP_SUBMIT_REQUEST_TO_PREOS_GENERAL_FAILURE;\r
     }\r