]> git.proxmox.com Git - mirror_edk2.git/blame - SecurityPkg/Library/DxeImageVerificationLib/DxeImageVerificationLib.h
SecurityPkg: Clean up source files
[mirror_edk2.git] / SecurityPkg / Library / DxeImageVerificationLib / DxeImageVerificationLib.h
CommitLineData
0c18794e 1/** @file\r
2 The internal header file includes the common header files, defines\r
3 internal structure and functions used by ImageVerificationLib.\r
4\r
20333c6d
QL
5Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.<BR>\r
6This program and the accompanying materials\r
7are licensed and made available under the terms and conditions of the BSD License\r
8which accompanies this distribution. The full text of the license may be found at\r
0c18794e 9http://opensource.org/licenses/bsd-license.php\r
10\r
20333c6d 11THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
0c18794e 12WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
13\r
14**/\r
15\r
16#ifndef __IMAGEVERIFICATIONLIB_H__\r
17#define __IMAGEVERIFICATIONLIB_H__\r
18\r
19#include <Library/UefiDriverEntryPoint.h>\r
20#include <Library/DebugLib.h>\r
21#include <Library/BaseMemoryLib.h>\r
22#include <Library/UefiBootServicesTableLib.h>\r
23#include <Library/UefiRuntimeServicesTableLib.h>\r
24#include <Library/UefiLib.h>\r
25#include <Library/BaseLib.h>\r
26#include <Library/MemoryAllocationLib.h>\r
27#include <Library/BaseCryptLib.h>\r
28#include <Library/PcdLib.h>\r
29#include <Library/DevicePathLib.h>\r
30#include <Library/SecurityManagementLib.h>\r
28186d45 31#include <Library/PeCoffLib.h>\r
0c18794e 32#include <Protocol/FirmwareVolume2.h>\r
33#include <Protocol/DevicePath.h>\r
34#include <Protocol/BlockIo.h>\r
35#include <Protocol/SimpleFileSystem.h>\r
36#include <Protocol/VariableWrite.h>\r
37#include <Guid/ImageAuthentication.h>\r
beda2356 38#include <Guid/AuthenticatedVariableFormat.h>\r
0c18794e 39#include <IndustryStandard/PeImage.h>\r
40\r
41#define EFI_CERT_TYPE_RSA2048_SHA256_SIZE 256\r
42#define EFI_CERT_TYPE_RSA2048_SIZE 256\r
43#define MAX_NOTIFY_STRING_LEN 64\r
bd0de396 44#define TWO_BYTE_ENCODE 0x82\r
0c18794e 45\r
6de4c35f 46#define ALIGNMENT_SIZE 8\r
47#define ALIGN_SIZE(a) (((a) % ALIGNMENT_SIZE) ? ALIGNMENT_SIZE - ((a) % ALIGNMENT_SIZE) : 0)\r
48\r
0c18794e 49//\r
50// Image type definitions\r
51//\r
52#define IMAGE_UNKNOWN 0x00000000\r
53#define IMAGE_FROM_FV 0x00000001\r
54#define IMAGE_FROM_OPTION_ROM 0x00000002\r
55#define IMAGE_FROM_REMOVABLE_MEDIA 0x00000003\r
56#define IMAGE_FROM_FIXED_MEDIA 0x00000004\r
57\r
58//\r
59// Authorization policy bit definition\r
60//\r
61#define ALWAYS_EXECUTE 0x00000000\r
62#define NEVER_EXECUTE 0x00000001\r
63#define ALLOW_EXECUTE_ON_SECURITY_VIOLATION 0x00000002\r
64#define DEFER_EXECUTE_ON_SECURITY_VIOLATION 0x00000003\r
65#define DENY_EXECUTE_ON_SECURITY_VIOLATION 0x00000004\r
66#define QUERY_USER_ON_SECURITY_VIOLATION 0x00000005\r
67\r
68//\r
69// Support hash types\r
70//\r
71#define HASHALG_SHA1 0x00000000\r
72#define HASHALG_SHA224 0x00000001\r
73#define HASHALG_SHA256 0x00000002\r
74#define HASHALG_SHA384 0x00000003\r
75#define HASHALG_SHA512 0x00000004\r
76#define HASHALG_MAX 0x00000005\r
77\r
78//\r
20333c6d 79// Set max digest size as SHA512 Output (64 bytes) by far\r
0c18794e 80//\r
20333c6d 81#define MAX_DIGEST_SIZE SHA512_DIGEST_SIZE\r
0c18794e 82//\r
83//\r
84// PKCS7 Certificate definition\r
85//\r
86typedef struct {\r
87 WIN_CERTIFICATE Hdr;\r
88 UINT8 CertData[1];\r
89} WIN_CERTIFICATE_EFI_PKCS;\r
90\r
91\r
92/**\r
93 Retrieves the size, in bytes, of the context buffer required for hash operations.\r
94\r
95 @return The size, in bytes, of the context buffer required for hash operations.\r
96\r
97**/\r
98typedef\r
99UINTN\r
100(EFIAPI *HASH_GET_CONTEXT_SIZE)(\r
101 VOID\r
102 );\r
103\r
104/**\r
105 Initializes user-supplied memory pointed by HashContext as hash context for\r
106 subsequent use.\r
107\r
108 If HashContext is NULL, then ASSERT().\r
109\r
110 @param[in, out] HashContext Pointer to Context being initialized.\r
111\r
112 @retval TRUE HASH context initialization succeeded.\r
113 @retval FALSE HASH context initialization failed.\r
114\r
115**/\r
116typedef\r
117BOOLEAN\r
118(EFIAPI *HASH_INIT)(\r
119 IN OUT VOID *HashContext\r
120 );\r
121\r
122\r
123/**\r
124 Performs digest on a data buffer of the specified length. This function can\r
125 be called multiple times to compute the digest of long or discontinuous data streams.\r
126\r
127 If HashContext is NULL, then ASSERT().\r
128\r
129 @param[in, out] HashContext Pointer to the MD5 context.\r
130 @param[in] Data Pointer to the buffer containing the data to be hashed.\r
131 @param[in] DataLength Length of Data buffer in bytes.\r
132\r
133 @retval TRUE HASH data digest succeeded.\r
134 @retval FALSE Invalid HASH context. After HashFinal function has been called, the\r
135 HASH context cannot be reused.\r
136\r
137**/\r
138typedef\r
139BOOLEAN\r
140(EFIAPI *HASH_UPDATE)(\r
141 IN OUT VOID *HashContext,\r
142 IN CONST VOID *Data,\r
143 IN UINTN DataLength\r
144 );\r
145\r
146/**\r
147 Completes hash computation and retrieves the digest value into the specified\r
148 memory. After this function has been called, the context cannot be used again.\r
149\r
150 If HashContext is NULL, then ASSERT().\r
151 If HashValue is NULL, then ASSERT().\r
152\r
153 @param[in, out] HashContext Pointer to the MD5 context\r
154 @param[out] HashValue Pointer to a buffer that receives the HASH digest\r
155 value.\r
156\r
157 @retval TRUE HASH digest computation succeeded.\r
158 @retval FALSE HASH digest computation failed.\r
159\r
160**/\r
161typedef\r
162BOOLEAN\r
163(EFIAPI *HASH_FINAL)(\r
164 IN OUT VOID *HashContext,\r
165 OUT UINT8 *HashValue\r
166 );\r
167\r
168\r
169//\r
170// Hash Algorithm Table\r
171//\r
172typedef struct {\r
173 //\r
174 // Name for Hash Algorithm\r
175 //\r
176 CHAR16 *Name;\r
177 //\r
178 // Digest Length\r
179 //\r
180 UINTN DigestLength;\r
181 //\r
182 // Hash Algorithm OID ASN.1 Value\r
183 //\r
184 UINT8 *OidValue;\r
185 //\r
186 // Length of Hash OID Value\r
187 //\r
188 UINTN OidLength;\r
189 //\r
190 // Pointer to Hash GetContentSize function\r
191 //\r
192 HASH_GET_CONTEXT_SIZE GetContextSize;\r
193 //\r
194 // Pointer to Hash Init function\r
195 //\r
196 HASH_INIT HashInit;\r
197 //\r
198 // Pointer to Hash Update function\r
199 //\r
200 HASH_UPDATE HashUpdate;\r
201 //\r
202 // Pointer to Hash Final function\r
203 //\r
204 HASH_FINAL HashFinal;\r
205} HASH_TABLE;\r
206\r
2e728930 207#endif\r