From b6477d820b783d08c56a444905d1681de5c698b2 Mon Sep 17 00:00:00 2001 From: Star Zeng Date: Wed, 1 Jul 2015 03:04:18 +0000 Subject: MdeModulePkg: Add AuthVariableLib LibraryClass What to do: 1. Add AuthVariableLib LibraryClass definitions. 2. Implement a NULL AuthVariableLib library instance. 3. Add VARIABLE_ENTRY_PROPERTY definition to VarCheck.h. 4. Add VARIABLE_ENTRY_CONSISTENCY and variable attribute combinations definitions to VariableFormat.h. Why to do: 1. Share code. 1.1. Separate auth variable service from Auth Variable driver in SecurityPkg to AuthVariableLib. Then the AuthVariableLib could benefit and be used by different implementation of Auth Variable drivers. 1.2 The VARIABLE_ENTRY_PROPERTY definition to VarCheck.h, VARIABLE_ENTRY_CONSISTENCY and variable attribute combinations definitions to VariableFormat.h will be shared by merged Variable driver and AuthVariableLib. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Star Zeng Reviewed-by: Jiewen Yao Reviewed-by: Liming Gao git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@17757 6f19259b-4bc3-4df7-8a09-765794883524 --- .../AuthVariableLibNull/AuthVariableLibNull.c | 78 +++++++++++++++++++++ .../AuthVariableLibNull/AuthVariableLibNull.inf | 40 +++++++++++ .../AuthVariableLibNull/AuthVariableLibNull.uni | Bin 0 -> 1710 bytes 3 files changed, 118 insertions(+) create mode 100644 MdeModulePkg/Library/AuthVariableLibNull/AuthVariableLibNull.c create mode 100644 MdeModulePkg/Library/AuthVariableLibNull/AuthVariableLibNull.inf create mode 100644 MdeModulePkg/Library/AuthVariableLibNull/AuthVariableLibNull.uni (limited to 'MdeModulePkg/Library') diff --git a/MdeModulePkg/Library/AuthVariableLibNull/AuthVariableLibNull.c b/MdeModulePkg/Library/AuthVariableLibNull/AuthVariableLibNull.c new file mode 100644 index 0000000..054131f --- /dev/null +++ b/MdeModulePkg/Library/AuthVariableLibNull/AuthVariableLibNull.c @@ -0,0 +1,78 @@ +/** @file + Implements NULL authenticated variable services. + +Copyright (c) 2015, Intel Corporation. All rights reserved.
+This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#include +#include + +/** + Initialization for authenticated varibale services. + If this initialization returns error status, other APIs will not work + and expect to be not called then. + + @param[in] AuthVarLibContextIn Pointer to input auth variable lib context. + @param[out] AuthVarLibContextOut Pointer to output auth variable lib context. + + @retval EFI_SUCCESS Function successfully executed. + @retval EFI_INVALID_PARAMETER If AuthVarLibContextIn == NULL or AuthVarLibContextOut == NULL. + @retval EFI_OUT_OF_RESOURCES Fail to allocate enough resource. + @retval EFI_UNSUPPORTED Unsupported to process authenticated variable. + +**/ +EFI_STATUS +EFIAPI +AuthVariableLibInitialize ( + IN AUTH_VAR_LIB_CONTEXT_IN *AuthVarLibContextIn, + OUT AUTH_VAR_LIB_CONTEXT_OUT *AuthVarLibContextOut + ) +{ + // + // Do nothing, just return EFI_UNSUPPORTED. + // + return EFI_UNSUPPORTED; +} + +/** + Process variable with EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS/EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS set. + + @param[in] VariableName Name of the variable. + @param[in] VendorGuid Variable vendor GUID. + @param[in] Data Data pointer. + @param[in] DataSize Size of Data. + @param[in] Attributes Attribute value of the variable. + + @retval EFI_SUCCESS The firmware has successfully stored the variable and its data as + defined by the Attributes. + @retval EFI_INVALID_PARAMETER Invalid parameter. + @retval EFI_WRITE_PROTECTED Variable is write-protected. + @retval EFI_OUT_OF_RESOURCES There is not enough resource. + @retval EFI_SECURITY_VIOLATION The variable is with EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS + or EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACESS + set, but the AuthInfo does NOT pass the validation + check carried out by the firmware. + @retval EFI_UNSUPPORTED Unsupported to process authenticated variable. + +**/ +EFI_STATUS +EFIAPI +AuthVariableLibProcessVariable ( + IN CHAR16 *VariableName, + IN EFI_GUID *VendorGuid, + IN VOID *Data, + IN UINTN DataSize, + IN UINT32 Attributes + ) +{ + ASSERT (FALSE); + return EFI_UNSUPPORTED; +} diff --git a/MdeModulePkg/Library/AuthVariableLibNull/AuthVariableLibNull.inf b/MdeModulePkg/Library/AuthVariableLibNull/AuthVariableLibNull.inf new file mode 100644 index 0000000..900fef5 --- /dev/null +++ b/MdeModulePkg/Library/AuthVariableLibNull/AuthVariableLibNull.inf @@ -0,0 +1,40 @@ +## @file +# Provides NULL authenticated variable services. +# +# Copyright (c) 2015, Intel Corporation. All rights reserved.
+# +# This program and the accompanying materials +# are licensed and made available under the terms and conditions +# of the BSD License which accompanies this distribution. The +# full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = AuthVariableLibNull + MODULE_UNI_FILE = AuthVariableLibNull.uni + FILE_GUID = 435CB0E4-7C9A-4BB7-9907-8FD4643E978A + MODULE_TYPE = DXE_RUNTIME_DRIVER + VERSION_STRING = 1.0 + LIBRARY_CLASS = AuthVariableLib|DXE_RUNTIME_DRIVER DXE_SMM_DRIVER + +# +# The following information is for reference only and not required by the build tools. +# +# VALID_ARCHITECTURES = IA32 X64 +# + +[Sources] + AuthVariableLibNull.c + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + +[LibraryClasses] + DebugLib diff --git a/MdeModulePkg/Library/AuthVariableLibNull/AuthVariableLibNull.uni b/MdeModulePkg/Library/AuthVariableLibNull/AuthVariableLibNull.uni new file mode 100644 index 0000000..02237ff Binary files /dev/null and b/MdeModulePkg/Library/AuthVariableLibNull/AuthVariableLibNull.uni differ -- cgit v1.1