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