]> git.proxmox.com Git - mirror_edk2.git/blobdiff - SecurityPkg/VariableAuthenticated/RuntimeDxe/Variable.c
UEFI 2.4 X509 Certificate Hash and RFC3161 Timestamp Verification support for Secure...
[mirror_edk2.git] / SecurityPkg / VariableAuthenticated / RuntimeDxe / Variable.c
index cb0f2baf9d3ff8f79f193406b6cb13d7a2691826..432531f6dfc94087cec5d53f3e69da97250346a1 100644 (file)
@@ -592,14 +592,14 @@ GetEndPointer (
 \r
   Check the PubKeyIndex is a valid key or not.\r
 \r
-  This function will iterate the NV storage to see if this PubKeyIndex is still referenced \r
+  This function will iterate the NV storage to see if this PubKeyIndex is still referenced\r
   by any valid count-based auth variabe.\r
-  \r
+\r
   @param[in]  PubKeyIndex     Index of the public key in public key store.\r
 \r
   @retval     TRUE            The PubKeyIndex is still in use.\r
   @retval     FALSE           The PubKeyIndex is not referenced by any count-based auth variabe.\r
-  \r
+\r
 **/\r
 BOOLEAN\r
 IsValidPubKeyIndex (\r
@@ -617,20 +617,20 @@ IsValidPubKeyIndex (
   VariableStoreEnd = GetEndPointer ((VARIABLE_STORE_HEADER *) (UINTN) mVariableModuleGlobal->VariableGlobal.NonVolatileVariableBase);\r
 \r
   while (IsValidVariableHeader (Variable, VariableStoreEnd)) {\r
-    if ((Variable->State == VAR_ADDED || Variable->State == (VAR_IN_DELETED_TRANSITION & VAR_ADDED)) && \r
+    if ((Variable->State == VAR_ADDED || Variable->State == (VAR_IN_DELETED_TRANSITION & VAR_ADDED)) &&\r
         Variable->PubKeyIndex == PubKeyIndex) {\r
       return TRUE;\r
     }\r
     Variable = GetNextVariablePtr (Variable);\r
   }\r
-  \r
+\r
   return FALSE;\r
 }\r
 \r
 /**\r
 \r
   Get the number of valid public key in PubKeyStore.\r
-  \r
+\r
   @param[in]  PubKeyNumber     Number of the public key in public key store.\r
 \r
   @return     Number of valid public key in PubKeyStore.\r
@@ -645,13 +645,13 @@ GetValidPubKeyNumber (
   UINT32       Counter;\r
 \r
   Counter = 0;\r
-  \r
+\r
   for (PubKeyIndex = 1; PubKeyIndex <= PubKeyNumber; PubKeyIndex++) {\r
     if (IsValidPubKeyIndex (PubKeyIndex)) {\r
       Counter++;\r
     }\r
   }\r
-  \r
+\r
   return Counter;\r
 }\r
 \r
@@ -659,7 +659,7 @@ GetValidPubKeyNumber (
 \r
   Filter the useless key in public key store.\r
 \r
-  This function will find out all valid public keys in public key database, save them in new allocated \r
+  This function will find out all valid public keys in public key database, save them in new allocated\r
   buffer NewPubKeyStore, and give the new PubKeyIndex. The caller is responsible for freeing buffer\r
   NewPubKeyIndex and NewPubKeyStore with FreePool().\r
 \r
@@ -668,10 +668,10 @@ GetValidPubKeyNumber (
   @param[out]  NewPubKeyIndex       Point to an array of new PubKeyIndex corresponds to NewPubKeyStore.\r
   @param[out]  NewPubKeyStore       Saved all valid public keys in PubKeyStore.\r
   @param[out]  NewPubKeySize        Buffer size of the NewPubKeyStore.\r
-  \r
+\r
   @retval  EFI_SUCCESS              Trim operation is complete successfully.\r
   @retval  EFI_OUT_OF_RESOURCES     No enough memory resources, or no useless key in PubKeyStore.\r
-  \r
+\r
 **/\r
 EFI_STATUS\r
 PubKeyStoreFilter (\r
@@ -685,7 +685,7 @@ PubKeyStoreFilter (
   UINT32        PubKeyIndex;\r
   UINT32        CopiedKey;\r
   UINT32        NewPubKeyNumber;\r
-  \r
+\r
   NewPubKeyNumber = GetValidPubKeyNumber (PubKeyNumber);\r
   if (NewPubKeyNumber == PubKeyNumber) {\r
     return EFI_OUT_OF_RESOURCES;\r
@@ -739,7 +739,7 @@ PubKeyStoreFilter (
   @param[in]      NewVariable             Pointer to new variable.\r
   @param[in]      NewVariableSize         New variable size.\r
   @param[in]      ReclaimPubKeyStore      Reclaim for public key database or not.\r
-  \r
+\r
   @return EFI_SUCCESS                  Reclaim operation has finished successfully.\r
   @return EFI_OUT_OF_RESOURCES         No enough memory resources or variable space.\r
   @return EFI_DEVICE_ERROR             The public key database doesn't exist.\r
@@ -873,7 +873,7 @@ Reclaim (
     while (IsValidVariableHeader (Variable, GetEndPointer (VariableStoreHeader))) {\r
       NextVariable = GetNextVariablePtr (Variable);\r
       if (Variable->State == VAR_ADDED || Variable->State == (VAR_IN_DELETED_TRANSITION & VAR_ADDED)) {\r
-        if ((StrCmp (GetVariableNamePtr (Variable), AUTHVAR_KEYDB_NAME) == 0) && \r
+        if ((StrCmp (GetVariableNamePtr (Variable), AUTHVAR_KEYDB_NAME) == 0) &&\r
             (CompareGuid (&Variable->VendorGuid, &gEfiAuthenticatedVariableGuid))) {\r
           //\r
           // Skip the public key database, it will be reinstalled later.\r
@@ -882,7 +882,7 @@ Reclaim (
           Variable = NextVariable;\r
           continue;\r
         }\r
-        \r
+\r
         VariableSize = (UINTN) NextVariable - (UINTN) Variable;\r
         CopyMem (CurrPtr, (UINT8 *) Variable, VariableSize);\r
         ((VARIABLE_HEADER*) CurrPtr)->PubKeyIndex = NewPubKeyIndex[Variable->PubKeyIndex];\r
@@ -909,7 +909,7 @@ Reclaim (
     Variable->DataSize = NewPubKeySize;\r
     StrCpy (GetVariableNamePtr (Variable), GetVariableNamePtr (PubKeyHeader));\r
     CopyMem (GetVariableDataPtr (Variable), NewPubKeyStore, NewPubKeySize);\r
-    CurrPtr = (UINT8*) GetNextVariablePtr (Variable); \r
+    CurrPtr = (UINT8*) GetNextVariablePtr (Variable);\r
     CommonVariableTotalSize += (UINTN) CurrPtr - (UINTN) Variable;\r
   } else {\r
     //\r
@@ -1524,7 +1524,7 @@ VariableGetBestLanguage (
 \r
   @param[in] Attributes         Variable attributes for Variable entries.\r
   @param ...                    The variable argument list with type VARIABLE_ENTRY_CONSISTENCY *.\r
-                                A NULL terminates the list. The VariableSize of \r
+                                A NULL terminates the list. The VariableSize of\r
                                 VARIABLE_ENTRY_CONSISTENCY is the variable data size as input.\r
                                 It will be changed to variable total size as output.\r
 \r
@@ -1803,7 +1803,7 @@ AutoUpdateLangVariable (
         VariableEntry[0].VariableSize = ISO_639_2_ENTRY_SIZE + 1;\r
         VariableEntry[0].Guid = &gEfiGlobalVariableGuid;\r
         VariableEntry[0].Name = EFI_LANG_VARIABLE_NAME;\r
-        \r
+\r
         VariableEntry[1].VariableSize = AsciiStrSize (BestPlatformLang);\r
         VariableEntry[1].Guid = &gEfiGlobalVariableGuid;\r
         VariableEntry[1].Name = EFI_PLATFORM_LANG_VARIABLE_NAME;\r
@@ -2009,7 +2009,7 @@ UpdateVariable (
         Status = EFI_INVALID_PARAMETER;\r
         goto Done;\r
       }\r
-      \r
+\r
       //\r
       // Only variable that have RT attributes can be updated/deleted in Runtime.\r
       //\r
@@ -2103,20 +2103,21 @@ UpdateVariable (
         CopyMem (BufferForMerge, (UINT8 *) ((UINTN) Variable->CurrPtr + DataOffset), Variable->CurrPtr->DataSize);\r
 \r
         //\r
-        // Set Max Common Variable Data Size as default MaxDataSize \r
+        // Set Max Common Variable Data Size as default MaxDataSize\r
         //\r
         MaxDataSize = PcdGet32 (PcdMaxVariableSize) - DataOffset;\r
 \r
         if ((CompareGuid (VendorGuid, &gEfiImageSecurityDatabaseGuid) &&\r
-            ((StrCmp (VariableName, EFI_IMAGE_SECURITY_DATABASE) == 0) || (StrCmp (VariableName, EFI_IMAGE_SECURITY_DATABASE1) == 0))) ||\r
-            (CompareGuid (VendorGuid, &gEfiGlobalVariableGuid) && (StrCmp (VariableName, EFI_KEY_EXCHANGE_KEY_NAME) == 0))) {\r
+            ((StrCmp (VariableName, EFI_IMAGE_SECURITY_DATABASE) == 0) || (StrCmp (VariableName, EFI_IMAGE_SECURITY_DATABASE1) == 0) ||\r
+             (StrCmp (VariableName, EFI_IMAGE_SECURITY_DATABASE2) == 0))) ||\r
+             (CompareGuid (VendorGuid, &gEfiGlobalVariableGuid) && (StrCmp (VariableName, EFI_KEY_EXCHANGE_KEY_NAME) == 0))) {\r
           //\r
           // For variables with formatted as EFI_SIGNATURE_LIST, the driver shall not perform an append of\r
           // EFI_SIGNATURE_DATA values that are already part of the existing variable value.\r
           //\r
           Status = AppendSignatureList (\r
                      BufferForMerge,\r
-                     Variable->CurrPtr->DataSize, \r
+                     Variable->CurrPtr->DataSize,\r
                      MaxDataSize - Variable->CurrPtr->DataSize,\r
                      Data,\r
                      DataSize,\r
@@ -2530,8 +2531,8 @@ Done:
 /**\r
   Check if a Unicode character is a hexadecimal character.\r
 \r
-  This function checks if a Unicode character is a \r
-  hexadecimal character.  The valid hexadecimal character is \r
+  This function checks if a Unicode character is a\r
+  hexadecimal character.  The valid hexadecimal character is\r
   L'0' to L'9', L'a' to L'f', or L'A' to L'F'.\r
 \r
 \r
@@ -2701,7 +2702,7 @@ VariableLockRequestToLock (
 \r
   @retval TRUE      This variable is read-only variable.\r
   @retval FALSE     This variable is NOT read-only variable.\r
-  \r
+\r
 **/\r
 BOOLEAN\r
 IsReadOnlyVariable (\r
@@ -2722,7 +2723,7 @@ IsReadOnlyVariable (
       return TRUE;\r
     }\r
   }\r
-  \r
+\r
   return FALSE;\r
 }\r
 \r
@@ -3077,8 +3078,8 @@ VariableServiceSetVariable (
 \r
   if ((UINTN)(~0) - PayloadSize < StrSize(VariableName)){\r
     //\r
-    // Prevent whole variable size overflow \r
-    // \r
+    // Prevent whole variable size overflow\r
+    //\r
     return EFI_INVALID_PARAMETER;\r
   }\r
 \r
@@ -3184,8 +3185,9 @@ VariableServiceSetVariable (
     Status = ProcessVarWithPk (VariableName, VendorGuid, Data, DataSize, &Variable, Attributes, TRUE);\r
   } else if (CompareGuid (VendorGuid, &gEfiGlobalVariableGuid) && (StrCmp (VariableName, EFI_KEY_EXCHANGE_KEY_NAME) == 0)) {\r
     Status = ProcessVarWithPk (VariableName, VendorGuid, Data, DataSize, &Variable, Attributes, FALSE);\r
-  } else if (CompareGuid (VendorGuid, &gEfiImageSecurityDatabaseGuid) && \r
-          ((StrCmp (VariableName, EFI_IMAGE_SECURITY_DATABASE) == 0) || (StrCmp (VariableName, EFI_IMAGE_SECURITY_DATABASE1) == 0))) {\r
+  } else if (CompareGuid (VendorGuid, &gEfiImageSecurityDatabaseGuid) &&\r
+          ((StrCmp (VariableName, EFI_IMAGE_SECURITY_DATABASE) == 0) || (StrCmp (VariableName, EFI_IMAGE_SECURITY_DATABASE1) == 0))\r
+           || (StrCmp (VariableName, EFI_IMAGE_SECURITY_DATABASE2)) == 0) {\r
     Status = ProcessVarWithPk (VariableName, VendorGuid, Data, DataSize, &Variable, Attributes, FALSE);\r
     if (EFI_ERROR (Status)) {\r
       Status = ProcessVarWithKek (VariableName, VendorGuid, Data, DataSize, &Variable, Attributes);\r
@@ -3937,4 +3939,3 @@ GetFvbInfoByAddress (
 \r
   return Status;\r
 }\r
-\r