iPXE
ImageAuthentication.h
Go to the documentation of this file.
1/** @file
2 Image signature database are defined for the signed image validation.
3
4 Copyright (c) 2009 - 2024, Intel Corporation. All rights reserved.<BR>
5 SPDX-License-Identifier: BSD-2-Clause-Patent
6
7 @par Revision Reference:
8 GUIDs defined in UEFI 2.5 spec.
9**/
10
11#pragma once
12
13FILE_LICENCE ( BSD2_PATENT );
14FILE_SECBOOT ( PERMITTED );
15
18
19#define EFI_IMAGE_SECURITY_DATABASE_GUID \
20 { \
21 0xd719b2cb, 0x3d3a, 0x4596, { 0xa3, 0xbc, 0xda, 0xd0, 0xe, 0x67, 0x65, 0x6f } \
22 }
23
24///
25/// Varialbe name with guid EFI_IMAGE_SECURITY_DATABASE_GUID
26/// for the authorized signature database.
27///
28#define EFI_IMAGE_SECURITY_DATABASE L"db"
29///
30/// Varialbe name with guid EFI_IMAGE_SECURITY_DATABASE_GUID
31/// for the forbidden signature database.
32///
33#define EFI_IMAGE_SECURITY_DATABASE1 L"dbx"
34///
35/// Variable name with guid EFI_IMAGE_SECURITY_DATABASE_GUID
36/// for the timestamp signature database.
37///
38#define EFI_IMAGE_SECURITY_DATABASE2 L"dbt"
39
40#define SECURE_BOOT_MODE_ENABLE 1
41#define SECURE_BOOT_MODE_DISABLE 0
42
43#define SETUP_MODE 1
44#define USER_MODE 0
45
46#define DEVICE_AUTH_BOOT_MODE_ENABLE 1
47#define DEVICE_AUTH_BOOT_MODE_DISABLE 0
48
49// ***********************************************************************
50// Signature Database
51// ***********************************************************************
52///
53/// The format of a signature database.
54///
55#pragma pack(1)
56
57typedef struct {
58 ///
59 /// An identifier which identifies the agent which added the signature to the list.
60 ///
62 ///
63 /// The format of the signature is defined by the SignatureType.
64 ///
67
68typedef struct {
69 ///
70 /// Type of the signature. GUID signature types are defined in below.
71 ///
73 ///
74 /// Total size of the signature list, including this header.
75 ///
77 ///
78 /// Size of the signature header which precedes the array of signatures.
79 ///
81 ///
82 /// Size of each signature.
83 ///
85 ///
86 /// Header before the array of signatures. The format of this header is specified
87 /// by the SignatureType.
88 /// UINT8 SignatureHeader[SignatureHeaderSize];
89 ///
90 /// An array of signatures. Each signature is SignatureSize bytes in length.
91 /// EFI_SIGNATURE_DATA Signatures[][SignatureSize];
92 ///
94
95typedef struct {
96 ///
97 /// The SHA256 hash of an X.509 certificate's To-Be-Signed contents.
98 ///
100 ///
101 /// The time that the certificate shall be considered to be revoked.
102 ///
105
106typedef struct {
107 ///
108 /// The SHA384 hash of an X.509 certificate's To-Be-Signed contents.
109 ///
111 ///
112 /// The time that the certificate shall be considered to be revoked.
113 ///
116
117typedef struct {
118 ///
119 /// The SHA512 hash of an X.509 certificate's To-Be-Signed contents.
120 ///
122 ///
123 /// The time that the certificate shall be considered to be revoked.
124 ///
127
128typedef UINT8 EFI_SM3_HASH[32];
129
130typedef struct {
131 ///
132 /// The SM3 hash of an X.509 certificate's To-Be-Signed contents.
133 ///
135 ///
136 /// The time that the certificate shall be considered to be revoked.
137 ///
140
141#pragma pack()
142
143///
144/// This identifies a signature containing a SHA-256 hash. The SignatureHeader size shall
145/// always be 0. The SignatureSize shall always be 16 (size of SignatureOwner component) +
146/// 32 bytes.
147///
148#define EFI_CERT_SHA256_GUID \
149 { \
150 0xc1c41626, 0x504c, 0x4092, {0xac, 0xa9, 0x41, 0xf9, 0x36, 0x93, 0x43, 0x28} \
151 }
152
153///
154/// This identifies a signature containing an RSA-2048 key. The key (only the modulus
155/// since the public key exponent is known to be 0x10001) shall be stored in big-endian
156/// order.
157/// The SignatureHeader size shall always be 0. The SignatureSize shall always be 16 (size
158/// of SignatureOwner component) + 256 bytes.
159///
160#define EFI_CERT_RSA2048_GUID \
161 { \
162 0x3c5766e8, 0x269c, 0x4e34, {0xaa, 0x14, 0xed, 0x77, 0x6e, 0x85, 0xb3, 0xb6} \
163 }
164
165///
166/// This identifies a signature containing a RSA-2048 signature of a SHA-256 hash. The
167/// SignatureHeader size shall always be 0. The SignatureSize shall always be 16 (size of
168/// SignatureOwner component) + 256 bytes.
169///
170#define EFI_CERT_RSA2048_SHA256_GUID \
171 { \
172 0xe2b36190, 0x879b, 0x4a3d, {0xad, 0x8d, 0xf2, 0xe7, 0xbb, 0xa3, 0x27, 0x84} \
173 }
174
175///
176/// This identifies a signature containing a SHA-1 hash. The SignatureSize shall always
177/// be 16 (size of SignatureOwner component) + 20 bytes.
178///
179#define EFI_CERT_SHA1_GUID \
180 { \
181 0x826ca512, 0xcf10, 0x4ac9, {0xb1, 0x87, 0xbe, 0x1, 0x49, 0x66, 0x31, 0xbd} \
182 }
183
184///
185/// This identifies a signature containing a SM3 hash. The SignatureSize shall always
186/// be 16 (size of SignatureOwner component) + 32 bytes.
187///
188#define EFI_CERT_SM3_GUID \
189 { \
190 0x57347f87, 0x7a9b, 0x403a, { 0xb9, 0x3c, 0xdc, 0x4a, 0xfb, 0x7a, 0xe, 0xbc } \
191 }
192
193///
194/// TThis identifies a signature containing a RSA-2048 signature of a SHA-1 hash. The
195/// SignatureHeader size shall always be 0. The SignatureSize shall always be 16 (size of
196/// SignatureOwner component) + 256 bytes.
197///
198#define EFI_CERT_RSA2048_SHA1_GUID \
199 { \
200 0x67f8444f, 0x8743, 0x48f1, {0xa3, 0x28, 0x1e, 0xaa, 0xb8, 0x73, 0x60, 0x80} \
201 }
202
203///
204/// This identifies a signature based on an X.509 certificate. If the signature is an X.509
205/// certificate then verification of the signature of an image should validate the public
206/// key certificate in the image using certificate path verification, up to this X.509
207/// certificate as a trusted root. The SignatureHeader size shall always be 0. The
208/// SignatureSize may vary but shall always be 16 (size of the SignatureOwner component) +
209/// the size of the certificate itself.
210/// Note: This means that each certificate will normally be in a separate EFI_SIGNATURE_LIST.
211///
212#define EFI_CERT_X509_GUID \
213 { \
214 0xa5c059a1, 0x94e4, 0x4aa7, {0x87, 0xb5, 0xab, 0x15, 0x5c, 0x2b, 0xf0, 0x72} \
215 }
216
217///
218/// This identifies a signature containing the SM3 hash of an X.509 certificate's To-Be-Signed
219/// contents, and a time of revocation. The SignatureHeader size shall always be 0. The
220/// SignatureSize shall always be 16 (size of the SignatureOwner component) + 32 bytes for
221/// an EFI_CERT_X509_SM3 structure. If the TimeOfRevocation is non-zero, the certificate should
222/// be considered to be revoked from that time and onwards, and otherwise the certificate shall
223/// be considered to always be revoked.
224///
225#define EFI_CERT_X509_SM3_GUID \
226 { \
227 0x60d807e5, 0x10b4, 0x49a9, {0x93, 0x31, 0xe4, 0x4, 0x37, 0x88, 0x8d, 0x37 } \
228 }
229
230///
231/// This identifies a signature containing a SHA-224 hash. The SignatureHeader size shall
232/// always be 0. The SignatureSize shall always be 16 (size of SignatureOwner component) +
233/// 28 bytes.
234///
235#define EFI_CERT_SHA224_GUID \
236 { \
237 0xb6e5233, 0xa65c, 0x44c9, {0x94, 0x7, 0xd9, 0xab, 0x83, 0xbf, 0xc8, 0xbd} \
238 }
239
240///
241/// This identifies a signature containing a SHA-384 hash. The SignatureHeader size shall
242/// always be 0. The SignatureSize shall always be 16 (size of SignatureOwner component) +
243/// 48 bytes.
244///
245#define EFI_CERT_SHA384_GUID \
246 { \
247 0xff3e5307, 0x9fd0, 0x48c9, {0x85, 0xf1, 0x8a, 0xd5, 0x6c, 0x70, 0x1e, 0x1} \
248 }
249
250///
251/// This identifies a signature containing a SHA-512 hash. The SignatureHeader size shall
252/// always be 0. The SignatureSize shall always be 16 (size of SignatureOwner component) +
253/// 64 bytes.
254///
255#define EFI_CERT_SHA512_GUID \
256 { \
257 0x93e0fae, 0xa6c4, 0x4f50, {0x9f, 0x1b, 0xd4, 0x1e, 0x2b, 0x89, 0xc1, 0x9a} \
258 }
259
260///
261/// This identifies a signature containing the SHA256 hash of an X.509 certificate's
262/// To-Be-Signed contents, and a time of revocation. The SignatureHeader size shall
263/// always be 0. The SignatureSize shall always be 16 (size of the SignatureOwner component)
264/// + 48 bytes for an EFI_CERT_X509_SHA256 structure. If the TimeOfRevocation is non-zero,
265/// the certificate should be considered to be revoked from that time and onwards, and
266/// otherwise the certificate shall be considered to always be revoked.
267///
268#define EFI_CERT_X509_SHA256_GUID \
269 { \
270 0x3bd2a492, 0x96c0, 0x4079, {0xb4, 0x20, 0xfc, 0xf9, 0x8e, 0xf1, 0x03, 0xed } \
271 }
272
273///
274/// This identifies a signature containing the SHA384 hash of an X.509 certificate's
275/// To-Be-Signed contents, and a time of revocation. The SignatureHeader size shall
276/// always be 0. The SignatureSize shall always be 16 (size of the SignatureOwner component)
277/// + 64 bytes for an EFI_CERT_X509_SHA384 structure. If the TimeOfRevocation is non-zero,
278/// the certificate should be considered to be revoked from that time and onwards, and
279/// otherwise the certificate shall be considered to always be revoked.
280///
281#define EFI_CERT_X509_SHA384_GUID \
282 { \
283 0x7076876e, 0x80c2, 0x4ee6, {0xaa, 0xd2, 0x28, 0xb3, 0x49, 0xa6, 0x86, 0x5b } \
284 }
285
286///
287/// This identifies a signature containing the SHA512 hash of an X.509 certificate's
288/// To-Be-Signed contents, and a time of revocation. The SignatureHeader size shall
289/// always be 0. The SignatureSize shall always be 16 (size of the SignatureOwner component)
290/// + 80 bytes for an EFI_CERT_X509_SHA512 structure. If the TimeOfRevocation is non-zero,
291/// the certificate should be considered to be revoked from that time and onwards, and
292/// otherwise the certificate shall be considered to always be revoked.
293///
294#define EFI_CERT_X509_SHA512_GUID \
295 { \
296 0x446dbf63, 0x2502, 0x4cda, {0xbc, 0xfa, 0x24, 0x65, 0xd2, 0xb0, 0xfe, 0x9d } \
297 }
298
299///
300/// This identifies a signature containing a DER-encoded PKCS #7 version 1.5 [RFC2315]
301/// SignedData value.
302///
303#define EFI_CERT_TYPE_PKCS7_GUID \
304 { \
305 0x4aafd29d, 0x68df, 0x49ee, {0x8a, 0xa9, 0x34, 0x7d, 0x37, 0x56, 0x65, 0xa7} \
306 }
307
308// ***********************************************************************
309// Image Execution Information Table Definition
310// ***********************************************************************
312
313#define EFI_IMAGE_EXECUTION_AUTHENTICATION 0x00000007
314#define EFI_IMAGE_EXECUTION_AUTH_UNTESTED 0x00000000
315#define EFI_IMAGE_EXECUTION_AUTH_SIG_FAILED 0x00000001
316#define EFI_IMAGE_EXECUTION_AUTH_SIG_PASSED 0x00000002
317#define EFI_IMAGE_EXECUTION_AUTH_SIG_NOT_FOUND 0x00000003
318#define EFI_IMAGE_EXECUTION_AUTH_SIG_FOUND 0x00000004
319#define EFI_IMAGE_EXECUTION_POLICY_FAILED 0x00000005
320#define EFI_IMAGE_EXECUTION_INITIALIZED 0x00000008
321
322//
323// EFI_IMAGE_EXECUTION_INFO is added to EFI System Configuration Table
324// and assigned the GUID EFI_IMAGE_SECURITY_DATABASE_GUID.
325//
326typedef struct {
327 ///
328 /// Describes the action taken by the firmware regarding this image.
329 ///
331 ///
332 /// Size of all of the entire structure.
333 ///
335 ///
336 /// If this image was a UEFI device driver (for option ROM, for example) this is the
337 /// null-terminated, user-friendly name for the device. If the image was for an application,
338 /// then this is the name of the application. If this cannot be determined, then a simple
339 /// NULL character should be put in this position.
340 /// CHAR16 Name[];
341 ///
342
343 ///
344 /// For device drivers, this is the device path of the device for which this device driver
345 /// was intended. In some cases, the driver itself may be stored as part of the system
346 /// firmware, but this field should record the device's path, not the firmware path. For
347 /// applications, this is the device path of the application. If this cannot be determined,
348 /// a simple end-of-path device node should be put in this position.
349 /// EFI_DEVICE_PATH_PROTOCOL DevicePath;
350 ///
351
352 ///
353 /// Zero or more image signatures. If the image contained no signatures,
354 /// then this field is empty.
355 /// EFI_SIGNATURE_LIST Signature;
356 ///
358
359typedef struct {
360 ///
361 /// Number of EFI_IMAGE_EXECUTION_INFO structures.
362 ///
364 ///
365 /// Number of image instances of EFI_IMAGE_EXECUTION_INFO structures.
366 ///
367 // EFI_IMAGE_EXECUTION_INFO InformationInfo[]
369
UINT64 UINTN
Unsigned value of native width.
unsigned char UINT8
1-byte unsigned value.
unsigned int UINT32
4-byte unsigned value.
GUID for EFI (NVRAM) Variables.
EFI_HASH_SERVICE_BINDING_PROTOCOL as defined in UEFI 2.0.
UINT8 EFI_SHA256_HASH[32]
Definition Hash.h:83
UINT8 EFI_SHA512_HASH[64]
Definition Hash.h:85
UINT8 EFI_SHA384_HASH[48]
Definition Hash.h:84
EFI_GUID gEfiCertX509Sha256Guid
EFI_GUID gEfiCertX509Sm3Guid
EFI_GUID gEfiCertX509Sha512Guid
EFI_GUID gEfiCertSha384Guid
EFI_GUID gEfiCertRsa2048Sha1Guid
UINT32 EFI_IMAGE_EXECUTION_ACTION
EFI_GUID gEfiCertX509Sha384Guid
EFI_GUID gEfiCertRsa2048Guid
EFI_GUID gEfiCertSha1Guid
EFI_GUID gEfiCertSha224Guid
UINT8 EFI_SM3_HASH[32]
EFI_GUID gEfiCertRsa2048Sha256Guid
EFI_GUID gEfiCertX509Guid
EFI_GUID gEfiCertSm3Guid
EFI_GUID gEfiImageSecurityDatabaseGuid
EFI_GUID gEfiCertSha512Guid
EFI_GUID gEfiCertSha256Guid
EFI_GUID gEfiCertPkcs7Guid
GUID EFI_GUID
128-bit buffer containing a unique identifier value.
#define FILE_LICENCE(_licence)
Declare a particular licence as applying to a file.
Definition compiler.h:921
#define FILE_SECBOOT(_status)
Declare a file's UEFI Secure Boot permission status.
Definition compiler.h:951
EFI_SHA256_HASH ToBeSignedHash
The SHA256 hash of an X.509 certificate's To-Be-Signed contents.
EFI_TIME TimeOfRevocation
The time that the certificate shall be considered to be revoked.
EFI_SHA384_HASH ToBeSignedHash
The SHA384 hash of an X.509 certificate's To-Be-Signed contents.
EFI_TIME TimeOfRevocation
The time that the certificate shall be considered to be revoked.
EFI_SHA512_HASH ToBeSignedHash
The SHA512 hash of an X.509 certificate's To-Be-Signed contents.
EFI_TIME TimeOfRevocation
The time that the certificate shall be considered to be revoked.
EFI_TIME TimeOfRevocation
The time that the certificate shall be considered to be revoked.
EFI_SM3_HASH ToBeSignedHash
The SM3 hash of an X.509 certificate's To-Be-Signed contents.
UINTN NumberOfImages
Number of EFI_IMAGE_EXECUTION_INFO structures.
EFI_IMAGE_EXECUTION_ACTION Action
Describes the action taken by the firmware regarding this image.
UINT32 InfoSize
Size of all of the entire structure.
The format of a signature database.
EFI_GUID SignatureOwner
An identifier which identifies the agent which added the signature to the list.
UINT8 SignatureData[1]
The format of the signature is defined by the SignatureType.
UINT32 SignatureHeaderSize
Size of the signature header which precedes the array of signatures.
EFI_GUID SignatureType
Type of the signature.
UINT32 SignatureListSize
Total size of the signature list, including this header.
UINT32 SignatureSize
Size of each signature.
EFI Time Abstraction: Year: 1900 - 9999 Month: 1 - 12 Day: 1 - 31 Hour: 0 - 23 Minute: 0 - 59 Second:...