]> git.proxmox.com Git - mirror_edk2.git/commitdiff
SecurityPkg: add null version of VariableKeyLib
authorJian J Wang <jian.j.wang@intel.com>
Thu, 12 Mar 2020 05:44:41 +0000 (13:44 +0800)
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Fri, 27 Mar 2020 16:41:05 +0000 (16:41 +0000)
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2594

Add null version of VariableKeyLib instance. The full version should be
provided by platforms which supports key generator.

Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Chao Zhang <chao.b.zhang@intel.com>
Cc: Nishant C Mistry <nishant.c.mistry@intel.com>
Signed-off-by: Jian J Wang <jian.j.wang@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
Reviewed-by: Michael Kubacki <michael.kubacki@microsoft.com>
SecurityPkg/Library/VariableKeyLibNull/VariableKeyLibNull.c [new file with mode: 0644]
SecurityPkg/Library/VariableKeyLibNull/VariableKeyLibNull.inf [new file with mode: 0644]
SecurityPkg/SecurityPkg.dsc

diff --git a/SecurityPkg/Library/VariableKeyLibNull/VariableKeyLibNull.c b/SecurityPkg/Library/VariableKeyLibNull/VariableKeyLibNull.c
new file mode 100644 (file)
index 0000000..3ddb37c
--- /dev/null
@@ -0,0 +1,67 @@
+/** @file\r
+  Null version of VariableKeyLib for build purpose. Don't use it in real product.\r
+\r
+Copyright (c) 2020, Intel Corporation. All rights reserved.<BR>\r
+SPDX-License-Identifier: BSD-2-Clause-Patent\r
+\r
+**/\r
+#include <Library/DebugLib.h>\r
+#include <Library/VariableKeyLib.h>\r
+\r
+/**\r
+  Retrieves the key for integrity and/or confidentiality of variables.\r
+\r
+  @param[out]     VariableKey         A pointer to pointer for the variable key buffer.\r
+  @param[in,out]  VariableKeySize     The size in bytes of the variable key.\r
+\r
+  @retval       EFI_SUCCESS             The variable key was returned.\r
+  @retval       EFI_DEVICE_ERROR        An error occurred while attempting to get the variable key.\r
+  @retval       EFI_ACCESS_DENIED       The function was invoked after locking the key interface.\r
+  @retval       EFI_UNSUPPORTED         The variable key is not supported in the current boot configuration.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+GetVariableKey (\r
+      OUT VOID    **VariableKey,\r
+  IN  OUT UINTN   *VariableKeySize\r
+  )\r
+{\r
+  ASSERT (FALSE);\r
+  return EFI_UNSUPPORTED;\r
+}\r
+\r
+/**\r
+  Regenerates the variable key.\r
+\r
+  @retval       EFI_SUCCESS             The variable key was regenerated successfully.\r
+  @retval       EFI_DEVICE_ERROR        An error occurred while attempting to regenerate the key.\r
+  @retval       EFI_ACCESS_DENIED       The function was invoked after locking the key interface.\r
+  @retval       EFI_UNSUPPORTED         Key regeneration is not supported in the current boot configuration.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+RegenerateVariableKey (\r
+  VOID\r
+  )\r
+{\r
+  ASSERT (FALSE);\r
+  return EFI_UNSUPPORTED;\r
+}\r
+\r
+/**\r
+  Locks the regenerate key interface.\r
+\r
+  @retval       EFI_SUCCESS             The key interface was locked successfully.\r
+  @retval       EFI_UNSUPPORTED         Locking the key interface is not supported in the current boot configuration.\r
+  @retval       Others                  An error occurred while attempting to lock the key interface.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+LockVariableKeyInterface (\r
+  VOID\r
+  )\r
+{\r
+  ASSERT (FALSE);\r
+  return EFI_UNSUPPORTED;\r
+}\r
+\r
diff --git a/SecurityPkg/Library/VariableKeyLibNull/VariableKeyLibNull.inf b/SecurityPkg/Library/VariableKeyLibNull/VariableKeyLibNull.inf
new file mode 100644 (file)
index 0000000..ea74e38
--- /dev/null
@@ -0,0 +1,33 @@
+## @file\r
+#  Provides Null version of VariableKeyLib for build only.\r
+#\r
+#  Copyright (c) 2020, Intel Corporation. All rights reserved.<BR>\r
+#  SPDX-License-Identifier: BSD-2-Clause-Patent\r
+#\r
+##\r
+\r
+[Defines]\r
+  INF_VERSION                    = 0x00010029\r
+  BASE_NAME                      = VariableKeyLibNull\r
+  FILE_GUID                      = 2B640ED8-1E6A-4516-9F1D-25910E59BC4A\r
+  MODULE_TYPE                    = BASE\r
+  VERSION_STRING                 = 1.0\r
+  LIBRARY_CLASS                  = VariableKeyLib\r
+\r
+#\r
+# The following information is for reference only and not required by the build tools.\r
+#\r
+#  VALID_ARCHITECTURES           = IA32 X64 Arm AArch64\r
+#\r
+\r
+[Sources]\r
+  VariableKeyLibNull.c\r
+\r
+[Packages]\r
+  MdePkg/MdePkg.dec\r
+  SecurityPkg/SecurityPkg.dec\r
+\r
+[LibraryClasses]\r
+  BaseLib\r
+  DebugLib\r
+\r
index 97e0e7ed6edaa12f1f3f029007d16e1e48938a01..4b85f77b02143b38196401ae87c819fed02b7803 100644 (file)
@@ -64,6 +64,7 @@
   TcgStorageCoreLib|SecurityPkg/Library/TcgStorageCoreLib/TcgStorageCoreLib.inf\r
   TcgStorageOpalLib|SecurityPkg/Library/TcgStorageOpalLib/TcgStorageOpalLib.inf\r
   ResetSystemLib|MdeModulePkg/Library/BaseResetSystemLibNull/BaseResetSystemLibNull.inf\r
+  VariableKeyLib|SecurityPkg/Library/VariableKeyLibNull/VariableKeyLibNull.inf\r
   RpmcLib|SecurityPkg/Library/RpmcLibNull/RpmcLibNull.inf\r
 \r
 [LibraryClasses.ARM]\r
   #\r
   # Variable Confidentiality & Integrity\r
   #\r
+  SecurityPkg/Library/VariableKeyLibNull/VariableKeyLibNull.inf\r
   SecurityPkg/Library/RpmcLibNull/RpmcLibNull.inf\r
 \r
   #\r