]>
Commit | Line | Data |
---|---|---|
bb806a6e GB |
1 | /** @file\r |
2 | Provides a helper functions for creating variable authenticated\r | |
3 | payloads, signature lists related to secure boot keys.\r | |
4 | \r | |
5 | Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.<BR>\r | |
6 | (C) Copyright 2018 Hewlett Packard Enterprise Development LP<BR>\r | |
7 | Copyright (c) 2021, ARM Ltd. All rights reserved.<BR>\r | |
8 | Copyright (c) 2021, Semihalf All rights reserved.<BR>\r | |
56c717aa | 9 | Copyright (c) Microsoft Corporation.\r |
bb806a6e GB |
10 | SPDX-License-Identifier: BSD-2-Clause-Patent\r |
11 | \r | |
12 | **/\r | |
13 | \r | |
14 | #ifndef SECURE_BOOT_VARIABLE_LIB_H_\r | |
15 | #define SECURE_BOOT_VARIABLE_LIB_H_\r | |
16 | \r | |
17 | /**\r | |
18 | Set the platform secure boot mode into "Custom" or "Standard" mode.\r | |
19 | \r | |
20 | @param[in] SecureBootMode New secure boot mode: STANDARD_SECURE_BOOT_MODE or\r | |
21 | CUSTOM_SECURE_BOOT_MODE.\r | |
22 | \r | |
23 | @return EFI_SUCCESS The platform has switched to the special mode successfully.\r | |
24 | @return other Fail to operate the secure boot mode.\r | |
25 | \r | |
26 | --*/\r | |
27 | EFI_STATUS\r | |
56c717aa | 28 | EFIAPI\r |
bb806a6e GB |
29 | SetSecureBootMode (\r |
30 | IN UINT8 SecureBootMode\r | |
c411b485 | 31 | );\r |
bb806a6e GB |
32 | \r |
33 | /**\r | |
34 | Fetches the value of SetupMode variable.\r | |
35 | \r | |
36 | @param[out] SetupMode Pointer to UINT8 for SetupMode output\r | |
37 | \r | |
38 | @retval other Error codes from GetVariable.\r | |
39 | --*/\r | |
40 | EFI_STATUS\r | |
41 | EFIAPI\r | |
42 | GetSetupMode (\r | |
c411b485 MK |
43 | OUT UINT8 *SetupMode\r |
44 | );\r | |
bb806a6e GB |
45 | \r |
46 | /**\r | |
6de7c084 | 47 | Create a EFI Signature List with data supplied from input argument.\r |
48 | The input certificates from KeyInfo parameter should be DER-encoded\r | |
49 | format.\r | |
bb806a6e | 50 | \r |
bb806a6e | 51 | @param[out] SigListsSize A pointer to size of signature list\r |
6de7c084 | 52 | @param[out] SigListOut A pointer to a callee-allocated buffer with signature lists\r |
53 | @param[in] KeyInfoCount The number of certificate pointer and size pairs inside KeyInfo.\r | |
54 | @param[in] KeyInfo A pointer to all certificates, in the format of DER-encoded,\r | |
55 | to be concatenated into signature lists.\r | |
bb806a6e | 56 | \r |
6de7c084 | 57 | @retval EFI_SUCCESS Created signature list from payload successfully.\r |
bb806a6e | 58 | @retval EFI_NOT_FOUND Section with key has not been found.\r |
6de7c084 | 59 | @retval EFI_INVALID_PARAMETER Embedded key has a wrong format or input pointers are NULL.\r |
bb806a6e GB |
60 | @retval Others Unexpected error happens.\r |
61 | \r | |
62 | --*/\r | |
63 | EFI_STATUS\r | |
6de7c084 | 64 | EFIAPI\r |
65 | SecureBootCreateDataFromInput (\r | |
66 | OUT UINTN *SigListsSize,\r | |
67 | OUT EFI_SIGNATURE_LIST **SigListOut,\r | |
68 | IN UINTN KeyInfoCount,\r | |
69 | IN CONST SECURE_BOOT_CERTIFICATE_INFO *KeyInfo\r | |
c411b485 | 70 | );\r |
bb806a6e GB |
71 | \r |
72 | /**\r | |
73 | Create a time based data payload by concatenating the EFI_VARIABLE_AUTHENTICATION_2\r | |
74 | descriptor with the input data. NO authentication is required in this function.\r | |
75 | \r | |
76 | @param[in, out] DataSize On input, the size of Data buffer in bytes.\r | |
77 | On output, the size of data returned in Data\r | |
78 | buffer in bytes.\r | |
79 | @param[in, out] Data On input, Pointer to data buffer to be wrapped or\r | |
80 | pointer to NULL to wrap an empty payload.\r | |
81 | On output, Pointer to the new payload date buffer allocated from pool,\r | |
82 | it's caller's responsibility to free the memory when finish using it.\r | |
56c717aa | 83 | @param[in] Time Pointer to time information to created time based payload.\r |
bb806a6e GB |
84 | \r |
85 | @retval EFI_SUCCESS Create time based payload successfully.\r | |
86 | @retval EFI_OUT_OF_RESOURCES There are not enough memory resources to create time based payload.\r | |
87 | @retval EFI_INVALID_PARAMETER The parameter is invalid.\r | |
88 | @retval Others Unexpected error happens.\r | |
89 | \r | |
90 | --*/\r | |
91 | EFI_STATUS\r | |
56c717aa | 92 | EFIAPI\r |
bb806a6e | 93 | CreateTimeBasedPayload (\r |
56c717aa KQ |
94 | IN OUT UINTN *DataSize,\r |
95 | IN OUT UINT8 **Data,\r | |
96 | IN EFI_TIME *Time\r | |
c411b485 | 97 | );\r |
bb806a6e GB |
98 | \r |
99 | /**\r | |
100 | Clears the content of the 'db' variable.\r | |
101 | \r | |
102 | @retval EFI_OUT_OF_RESOURCES If memory allocation for EFI_VARIABLE_AUTHENTICATION_2 fails\r | |
103 | while VendorGuid is NULL.\r | |
104 | @retval other Errors from GetVariable2(), GetTime() and SetVariable()\r | |
105 | --*/\r | |
106 | EFI_STATUS\r | |
107 | EFIAPI\r | |
108 | DeleteDb (\r | |
109 | VOID\r | |
c411b485 | 110 | );\r |
bb806a6e GB |
111 | \r |
112 | /**\r | |
113 | Clears the content of the 'dbx' variable.\r | |
114 | \r | |
115 | @retval EFI_OUT_OF_RESOURCES If memory allocation for EFI_VARIABLE_AUTHENTICATION_2 fails\r | |
116 | while VendorGuid is NULL.\r | |
117 | @retval other Errors from GetVariable2(), GetTime() and SetVariable()\r | |
118 | --*/\r | |
119 | EFI_STATUS\r | |
120 | EFIAPI\r | |
121 | DeleteDbx (\r | |
122 | VOID\r | |
c411b485 | 123 | );\r |
bb806a6e GB |
124 | \r |
125 | /**\r | |
126 | Clears the content of the 'dbt' variable.\r | |
127 | \r | |
128 | @retval EFI_OUT_OF_RESOURCES If memory allocation for EFI_VARIABLE_AUTHENTICATION_2 fails\r | |
129 | while VendorGuid is NULL.\r | |
130 | @retval other Errors from GetVariable2(), GetTime() and SetVariable()\r | |
131 | --*/\r | |
132 | EFI_STATUS\r | |
133 | EFIAPI\r | |
134 | DeleteDbt (\r | |
135 | VOID\r | |
c411b485 | 136 | );\r |
bb806a6e GB |
137 | \r |
138 | /**\r | |
139 | Clears the content of the 'KEK' variable.\r | |
140 | \r | |
141 | @retval EFI_OUT_OF_RESOURCES If memory allocation for EFI_VARIABLE_AUTHENTICATION_2 fails\r | |
142 | while VendorGuid is NULL.\r | |
143 | @retval other Errors from GetVariable2(), GetTime() and SetVariable()\r | |
144 | --*/\r | |
145 | EFI_STATUS\r | |
146 | EFIAPI\r | |
147 | DeleteKEK (\r | |
148 | VOID\r | |
c411b485 | 149 | );\r |
bb806a6e GB |
150 | \r |
151 | /**\r | |
152 | Clears the content of the 'PK' variable.\r | |
153 | \r | |
154 | @retval EFI_OUT_OF_RESOURCES If memory allocation for EFI_VARIABLE_AUTHENTICATION_2 fails\r | |
155 | while VendorGuid is NULL.\r | |
156 | @retval other Errors from GetVariable2(), GetTime() and SetVariable()\r | |
157 | --*/\r | |
158 | EFI_STATUS\r | |
159 | EFIAPI\r | |
160 | DeletePlatformKey (\r | |
161 | VOID\r | |
c411b485 MK |
162 | );\r |
163 | \r | |
bb806a6e | 164 | #endif\r |