]> git.proxmox.com Git - mirror_edk2.git/blame_incremental - SecurityPkg/Library/DxeImageVerificationLib/DxeImageVerificationLib.h
Add security package to repository.
[mirror_edk2.git] / SecurityPkg / Library / DxeImageVerificationLib / DxeImageVerificationLib.h
... / ...
CommitLineData
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
5Copyright (c) 2009 - 2011, 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
9http://opensource.org/licenses/bsd-license.php\r
10\r
11THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
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
31#include <Protocol/FirmwareVolume2.h>\r
32#include <Protocol/DevicePath.h>\r
33#include <Protocol/BlockIo.h>\r
34#include <Protocol/SimpleFileSystem.h>\r
35#include <Protocol/VariableWrite.h>\r
36#include <Guid/ImageAuthentication.h>\r
37#include <IndustryStandard/PeImage.h>\r
38\r
39#define EFI_CERT_TYPE_RSA2048_SHA256_SIZE 256\r
40#define EFI_CERT_TYPE_RSA2048_SIZE 256\r
41#define MAX_NOTIFY_STRING_LEN 64\r
42\r
43//\r
44// Image type definitions\r
45//\r
46#define IMAGE_UNKNOWN 0x00000000\r
47#define IMAGE_FROM_FV 0x00000001\r
48#define IMAGE_FROM_OPTION_ROM 0x00000002\r
49#define IMAGE_FROM_REMOVABLE_MEDIA 0x00000003\r
50#define IMAGE_FROM_FIXED_MEDIA 0x00000004\r
51\r
52//\r
53// Authorization policy bit definition\r
54//\r
55#define ALWAYS_EXECUTE 0x00000000\r
56#define NEVER_EXECUTE 0x00000001\r
57#define ALLOW_EXECUTE_ON_SECURITY_VIOLATION 0x00000002\r
58#define DEFER_EXECUTE_ON_SECURITY_VIOLATION 0x00000003\r
59#define DENY_EXECUTE_ON_SECURITY_VIOLATION 0x00000004\r
60#define QUERY_USER_ON_SECURITY_VIOLATION 0x00000005\r
61\r
62//\r
63// Support hash types\r
64//\r
65#define HASHALG_SHA1 0x00000000\r
66#define HASHALG_SHA224 0x00000001\r
67#define HASHALG_SHA256 0x00000002\r
68#define HASHALG_SHA384 0x00000003\r
69#define HASHALG_SHA512 0x00000004\r
70#define HASHALG_MAX 0x00000005\r
71\r
72//\r
73// Set max digest size as SHA256 Output (32 bytes) by far\r
74//\r
75#define MAX_DIGEST_SIZE SHA256_DIGEST_SIZE \r
76//\r
77//\r
78// PKCS7 Certificate definition\r
79//\r
80typedef struct {\r
81 WIN_CERTIFICATE Hdr;\r
82 UINT8 CertData[1];\r
83} WIN_CERTIFICATE_EFI_PKCS;\r
84\r
85\r
86/**\r
87 Retrieves the size, in bytes, of the context buffer required for hash operations.\r
88\r
89 @return The size, in bytes, of the context buffer required for hash operations.\r
90\r
91**/\r
92typedef\r
93UINTN\r
94(EFIAPI *HASH_GET_CONTEXT_SIZE)(\r
95 VOID\r
96 );\r
97\r
98/**\r
99 Initializes user-supplied memory pointed by HashContext as hash context for\r
100 subsequent use.\r
101\r
102 If HashContext is NULL, then ASSERT().\r
103\r
104 @param[in, out] HashContext Pointer to Context being initialized.\r
105\r
106 @retval TRUE HASH context initialization succeeded.\r
107 @retval FALSE HASH context initialization failed.\r
108\r
109**/\r
110typedef\r
111BOOLEAN\r
112(EFIAPI *HASH_INIT)(\r
113 IN OUT VOID *HashContext\r
114 );\r
115\r
116\r
117/**\r
118 Performs digest on a data buffer of the specified length. This function can\r
119 be called multiple times to compute the digest of long or discontinuous data streams.\r
120\r
121 If HashContext is NULL, then ASSERT().\r
122\r
123 @param[in, out] HashContext Pointer to the MD5 context.\r
124 @param[in] Data Pointer to the buffer containing the data to be hashed.\r
125 @param[in] DataLength Length of Data buffer in bytes.\r
126\r
127 @retval TRUE HASH data digest succeeded.\r
128 @retval FALSE Invalid HASH context. After HashFinal function has been called, the\r
129 HASH context cannot be reused.\r
130\r
131**/\r
132typedef\r
133BOOLEAN\r
134(EFIAPI *HASH_UPDATE)(\r
135 IN OUT VOID *HashContext,\r
136 IN CONST VOID *Data,\r
137 IN UINTN DataLength\r
138 );\r
139\r
140/**\r
141 Completes hash computation and retrieves the digest value into the specified\r
142 memory. After this function has been called, the context cannot be used again.\r
143\r
144 If HashContext is NULL, then ASSERT().\r
145 If HashValue is NULL, then ASSERT().\r
146\r
147 @param[in, out] HashContext Pointer to the MD5 context\r
148 @param[out] HashValue Pointer to a buffer that receives the HASH digest\r
149 value.\r
150\r
151 @retval TRUE HASH digest computation succeeded.\r
152 @retval FALSE HASH digest computation failed.\r
153\r
154**/\r
155typedef\r
156BOOLEAN\r
157(EFIAPI *HASH_FINAL)(\r
158 IN OUT VOID *HashContext,\r
159 OUT UINT8 *HashValue\r
160 );\r
161\r
162\r
163//\r
164// Hash Algorithm Table\r
165//\r
166typedef struct {\r
167 //\r
168 // Name for Hash Algorithm\r
169 //\r
170 CHAR16 *Name;\r
171 //\r
172 // Digest Length\r
173 //\r
174 UINTN DigestLength;\r
175 //\r
176 // Hash Algorithm OID ASN.1 Value\r
177 //\r
178 UINT8 *OidValue;\r
179 //\r
180 // Length of Hash OID Value\r
181 //\r
182 UINTN OidLength;\r
183 //\r
184 // Pointer to Hash GetContentSize function\r
185 //\r
186 HASH_GET_CONTEXT_SIZE GetContextSize;\r
187 //\r
188 // Pointer to Hash Init function\r
189 //\r
190 HASH_INIT HashInit;\r
191 //\r
192 // Pointer to Hash Update function\r
193 //\r
194 HASH_UPDATE HashUpdate;\r
195 //\r
196 // Pointer to Hash Final function\r
197 //\r
198 HASH_FINAL HashFinal;\r
199} HASH_TABLE;\r
200\r
201#endif\r