1 /** @file
2   Implements NULL authenticated variable services.
3 
4 Copyright (c) 2015, Intel Corporation. All rights reserved.<BR>
5 This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution.  The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
9 
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
12 
13 **/
14 
15 #include <Library/AuthVariableLib.h>
16 #include <Library/DebugLib.h>
17 
18 /**
19   Initialization for authenticated varibale services.
20   If this initialization returns error status, other APIs will not work
21   and expect to be not called then.
22 
23   @param[in]  AuthVarLibContextIn   Pointer to input auth variable lib context.
24   @param[out] AuthVarLibContextOut  Pointer to output auth variable lib context.
25 
26   @retval EFI_SUCCESS               Function successfully executed.
27   @retval EFI_INVALID_PARAMETER     If AuthVarLibContextIn == NULL or AuthVarLibContextOut == NULL.
28   @retval EFI_OUT_OF_RESOURCES      Fail to allocate enough resource.
29   @retval EFI_UNSUPPORTED           Unsupported to process authenticated variable.
30 
31 **/
32 EFI_STATUS
33 EFIAPI
AuthVariableLibInitialize(IN AUTH_VAR_LIB_CONTEXT_IN * AuthVarLibContextIn,OUT AUTH_VAR_LIB_CONTEXT_OUT * AuthVarLibContextOut)34 AuthVariableLibInitialize (
35   IN  AUTH_VAR_LIB_CONTEXT_IN   *AuthVarLibContextIn,
36   OUT AUTH_VAR_LIB_CONTEXT_OUT  *AuthVarLibContextOut
37   )
38 {
39   //
40   // Do nothing, just return EFI_UNSUPPORTED.
41   //
42   return EFI_UNSUPPORTED;
43 }
44 
45 /**
46   Process variable with EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS/EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS set.
47 
48   @param[in] VariableName           Name of the variable.
49   @param[in] VendorGuid             Variable vendor GUID.
50   @param[in] Data                   Data pointer.
51   @param[in] DataSize               Size of Data.
52   @param[in] Attributes             Attribute value of the variable.
53 
54   @retval EFI_SUCCESS               The firmware has successfully stored the variable and its data as
55                                     defined by the Attributes.
56   @retval EFI_INVALID_PARAMETER     Invalid parameter.
57   @retval EFI_WRITE_PROTECTED       Variable is write-protected.
58   @retval EFI_OUT_OF_RESOURCES      There is not enough resource.
59   @retval EFI_SECURITY_VIOLATION    The variable is with EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS
60                                     or EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACESS
61                                     set, but the AuthInfo does NOT pass the validation
62                                     check carried out by the firmware.
63   @retval EFI_UNSUPPORTED           Unsupported to process authenticated variable.
64 
65 **/
66 EFI_STATUS
67 EFIAPI
AuthVariableLibProcessVariable(IN CHAR16 * VariableName,IN EFI_GUID * VendorGuid,IN VOID * Data,IN UINTN DataSize,IN UINT32 Attributes)68 AuthVariableLibProcessVariable (
69   IN CHAR16         *VariableName,
70   IN EFI_GUID       *VendorGuid,
71   IN VOID           *Data,
72   IN UINTN          DataSize,
73   IN UINT32         Attributes
74   )
75 {
76   ASSERT (FALSE);
77   return EFI_UNSUPPORTED;
78 }
79