]> git.proxmox.com Git - mirror_edk2.git/blobdiff - SecurityPkg/Library/AuthVariableLib/AuthVariableLib.c
SecurityPkg: AuthVariableLib: Add new cert database for volatile time based Auth...
[mirror_edk2.git] / SecurityPkg / Library / AuthVariableLib / AuthVariableLib.c
index bf60bf54e5cb97936f0573829ecd4aa4c608f7cf..6467c0695c6cdaf476b16d7832ef1c44a98007de 100644 (file)
@@ -11,7 +11,7 @@
   may not be modified without authorization. If platform fails to protect these resources,\r
   the authentication service provided in this driver will be broken, and the behavior is undefined.\r
 \r
-Copyright (c) 2015, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2015 - 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
@@ -98,6 +98,17 @@ VARIABLE_ENTRY_PROPERTY mAuthVarEntry[] = {
       MAX_UINTN\r
     }\r
   },\r
+  {\r
+    &gEfiCertDbGuid,\r
+    EFI_CERT_DB_VOLATILE_NAME,\r
+    {\r
+      VAR_CHECK_VARIABLE_PROPERTY_REVISION,\r
+      VAR_CHECK_VARIABLE_PROPERTY_READ_ONLY,\r
+      VARIABLE_ATTRIBUTE_BS_RT_AT,\r
+      sizeof (UINT32),\r
+      MAX_UINTN\r
+    }\r
+  },\r
   {\r
     &gEdkiiSecureBootModeGuid,\r
     L"SecureBootMode",\r
@@ -172,8 +183,9 @@ AuthVariableLibInitialize (
 \r
   //\r
   // Reserve runtime buffer for certificate database. The size excludes variable header and name size.\r
+  // Use EFI_CERT_DB_VOLATILE_NAME size since it is longer.\r
   //\r
-  mMaxCertDbSize = (UINT32) (mAuthVarLibContextIn->MaxAuthVariableSize - sizeof (EFI_CERT_DB_NAME));\r
+  mMaxCertDbSize = (UINT32) (mAuthVarLibContextIn->MaxAuthVariableSize - sizeof (EFI_CERT_DB_VOLATILE_NAME));\r
   mCertDbStore   = AllocateRuntimePool (mMaxCertDbSize);\r
   if (mCertDbStore == NULL) {\r
     return EFI_OUT_OF_RESOURCES;\r
@@ -288,6 +300,22 @@ AuthVariableLibInitialize (
     }\r
   }\r
 \r
+  //\r
+  // Create "certdbv" variable with RT+BS+AT set.\r
+  //\r
+  VarAttr  = EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS;\r
+  ListSize = sizeof (UINT32);\r
+  Status   = AuthServiceInternalUpdateVariable (\r
+               EFI_CERT_DB_VOLATILE_NAME,\r
+               &gEfiCertDbGuid,\r
+               &ListSize,\r
+               sizeof (UINT32),\r
+               VarAttr\r
+               );\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+\r
   //\r
   // Check "VendorKeysNv" variable's existence and create "VendorKeys" variable accordingly.\r
   //\r