]> git.proxmox.com Git - mirror_edk2.git/blob - MdePkg/Include/Protocol/Bis.h
UefiCpuPkg: Move AsmRelocateApLoopStart from Mpfuncs.nasm to AmdSev.nasm
[mirror_edk2.git] / MdePkg / Include / Protocol / Bis.h
1 /** @file
2 The EFI_BIS_PROTOCOL is used to check a digital signature of a data block
3 against a digital certificate for the purpose of an integrity and authorization check.
4
5 Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
6 SPDX-License-Identifier: BSD-2-Clause-Patent
7
8 @par Revision Reference:
9 This Protocol is introduced in EFI Specification 1.10.
10
11 **/
12
13 #ifndef __BIS_H__
14 #define __BIS_H__
15
16 #define EFI_BIS_PROTOCOL_GUID \
17 { \
18 0x0b64aab0, 0x5429, 0x11d4, {0x98, 0x16, 0x00, 0xa0, 0xc9, 0x1f, 0xad, 0xcf } \
19 }
20
21 //
22 // X-Intel-BIS-ParameterSet
23 // Attribute value
24 // Binary Value of X-Intel-BIS-ParameterSet Attribute.
25 // (Value is Base-64 encoded in actual signed manifest).
26 //
27 #define BOOT_OBJECT_AUTHORIZATION_PARMSET_GUID \
28 { \
29 0xedd35e31, 0x7b9, 0x11d2, { 0x83,0xa3,0x0,0xa0,0xc9,0x1f,0xad,0xcf } \
30 }
31
32 typedef struct _EFI_BIS_PROTOCOL EFI_BIS_PROTOCOL;
33
34 //
35 // Basic types
36 //
37 typedef VOID *BIS_APPLICATION_HANDLE;
38 typedef UINT16 BIS_ALG_ID;
39 typedef UINT32 BIS_CERT_ID;
40
41 ///
42 /// EFI_BIS_DATA instances obtained from BIS must be freed by calling Free( ).
43 ///
44 typedef struct {
45 UINT32 Length; ///< The length of Data in 8 bit bytes.
46 UINT8 *Data; ///< 32 Bit Flat Address of data.
47 } EFI_BIS_DATA;
48
49 ///
50 /// EFI_BIS_VERSION type.
51 ///
52 typedef struct {
53 UINT32 Major; ///< The major BIS version number.
54 UINT32 Minor; ///< A minor BIS version number.
55 } EFI_BIS_VERSION;
56
57 //
58 // ----------------------------------------------------//
59 // Use these values to initialize EFI_BIS_VERSION.Major
60 // and to interpret results of Initialize.
61 // ----------------------------------------------------//
62 //
63 #define BIS_CURRENT_VERSION_MAJOR BIS_VERSION_1
64 #define BIS_VERSION_1 1
65
66 ///
67 /// EFI_BIS_SIGNATURE_INFO type.
68 ///
69 typedef struct {
70 BIS_CERT_ID CertificateID; ///< Truncated hash of platform Boot Object
71 BIS_ALG_ID AlgorithmID; ///< A signature algorithm number.
72 UINT16 KeyLength; ///< The length of alg. keys in bits.
73 } EFI_BIS_SIGNATURE_INFO;
74
75 ///
76 /// values for EFI_BIS_SIGNATURE_INFO.AlgorithmID.
77 /// The exact numeric values come from the
78 /// "Common Data Security Architecture (CDSA) Specification".
79 ///
80 #define BIS_ALG_DSA (41) // CSSM_ALGID_DSA
81 #define BIS_ALG_RSA_MD5 (42) // CSSM_ALGID_MD5_WITH_RSA
82 ///
83 /// values for EFI_BIS_SIGNATURE_INFO.CertificateId.
84 ///
85 #define BIS_CERT_ID_DSA BIS_ALG_DSA // CSSM_ALGID_DSA
86 #define BIS_CERT_ID_RSA_MD5 BIS_ALG_RSA_MD5 // CSSM_ALGID_MD5_WITH_RSA
87 ///
88 /// The mask value that gets applied to the truncated hash of a
89 /// platform Boot Object Authorization Certificate to create the certificateID.
90 /// A certificateID must not have any bits set to the value 1 other than bits in
91 /// this mask.
92 ///
93 #define BIS_CERT_ID_MASK (0xFF7F7FFF)
94
95 ///
96 /// Macros for dealing with the EFI_BIS_DATA object obtained
97 /// from BIS_GetSignatureInfo().
98 /// BIS_GET_SIGINFO_COUNT - tells how many EFI_BIS_SIGNATURE_INFO
99 /// elements are contained in a EFI_BIS_DATA struct pointed to
100 /// by the provided EFI_BIS_DATA*.
101 ///
102 #define BIS_GET_SIGINFO_COUNT(BisDataPtr) ((BisDataPtr)->Length / sizeof (EFI_BIS_SIGNATURE_INFO))
103
104 ///
105 /// BIS_GET_SIGINFO_ARRAY - produces a EFI_BIS_SIGNATURE_INFO*
106 /// from a given EFI_BIS_DATA*.
107 ///
108 #define BIS_GET_SIGINFO_ARRAY(BisDataPtr) ((EFI_BIS_SIGNATURE_INFO *) (BisDataPtr)->Data)
109
110 ///
111 /// Support an old name for backward compatibility.
112 ///
113 #define BOOT_OBJECT_AUTHORIZATION_PARMSET_GUIDVALUE \
114 BOOT_OBJECT_AUTHORIZATION_PARMSET_GUID
115
116 /**
117 Initializes the BIS service, checking that it is compatible with the version requested by the caller.
118 After this call, other BIS functions may be invoked.
119
120 @param This A pointer to the EFI_BIS_PROTOCOL object.
121 @param AppHandle The function writes the new BIS_APPLICATION_HANDLE if
122 successful, otherwise it writes NULL. The caller must eventually
123 destroy this handle by calling Shutdown().
124 @param InterfaceVersion On input, the caller supplies the major version number of the
125 interface version desired.
126 On output, both the major and minor
127 version numbers are updated with the major and minor version
128 numbers of the interface. This update is done whether or not the
129 initialization was successful.
130 @param TargetAddress Indicates a network or device address of the BIS platform to connect to.
131
132 @retval EFI_SUCCESS The function completed successfully.
133 @retval EFI_INCOMPATIBLE_VERSION The InterfaceVersion.Major requested by the
134 caller was not compatible with the interface version of the
135 implementation. The InterfaceVersion.Major has
136 been updated with the current interface version.
137 @retval EFI_UNSUPPORTED This is a local-platform implementation and
138 TargetAddress.Data was not NULL, or
139 TargetAddress.Data was any other value that was not
140 supported by the implementation.
141 @retval EFI_OUT_OF_RESOURCES The function failed due to lack of memory or other resources.
142 @retval EFI_DEVICE_ERROR One of the following device errors:
143 * The function encountered an unexpected internal failure while initializing a cryptographic software module
144 * No cryptographic software module with compatible version was found
145 found
146 * A resource limitation was encountered while using a cryptographic software module.
147 @retval EFI_INVALID_PARAMETER The This parameter supplied by the caller is NULL or does not
148 reference a valid EFI_BIS_PROTOCOL object. Or,
149 the AppHandle parameter supplied by the caller is NULL or
150 an invalid memory reference. Or,
151 the InterfaceVersion parameter supplied by the caller
152 is NULL or an invalid memory reference. Or,
153 the TargetAddress parameter supplied by the caller is
154 NULL or an invalid memory reference.
155
156 **/
157 typedef
158 EFI_STATUS
159 (EFIAPI *EFI_BIS_INITIALIZE)(
160 IN EFI_BIS_PROTOCOL *This,
161 OUT BIS_APPLICATION_HANDLE *AppHandle,
162 IN OUT EFI_BIS_VERSION *InterfaceVersion,
163 IN EFI_BIS_DATA *TargetAddress
164 );
165
166 /**
167 Frees memory structures allocated and returned by other functions in the EFI_BIS protocol.
168
169 @param AppHandle An opaque handle that identifies the caller's instance of initialization
170 of the BIS service.
171 @param ToFree An EFI_BIS_DATA* and associated memory block to be freed.
172 This EFI_BIS_DATA* must have been allocated by one of the other BIS functions.
173
174 @retval EFI_SUCCESS The function completed successfully.
175 @retval EFI_NO_MAPPING The AppHandle parameter is not or is no longer a valid
176 application instance handle associated with the EFI_BIS protocol.
177 @retval EFI_OUT_OF_RESOURCES The function failed due to lack of memory or other resources.
178 @retval EFI_INVALID_PARAMETER The ToFree parameter is not or is no longer a memory resource
179 associated with this AppHandle.
180
181 **/
182 typedef
183 EFI_STATUS
184 (EFIAPI *EFI_BIS_FREE)(
185 IN BIS_APPLICATION_HANDLE AppHandle,
186 IN EFI_BIS_DATA *ToFree
187 );
188
189 /**
190 Shuts down an application's instance of the BIS service, invalidating the application handle. After
191 this call, other BIS functions may no longer be invoked using the application handle value.
192
193 @param AppHandle An opaque handle that identifies the caller's instance of initialization
194 of the BIS service.
195
196 @retval EFI_SUCCESS The function completed successfully.
197 @retval EFI_NO_MAPPING The AppHandle parameter is not, or is no longer, a valid
198 application instance handle associated with the EFI_BIS protocol.
199 @retval EFI_OUT_OF_RESOURCES The function failed due to lack of memory or other resources.
200 @retval EFI_DEVICE_ERROR The function encountered an unexpected internal failure while
201 returning resources associated with a cryptographic software module, or
202 while trying to shut down a cryptographic software module.
203 **/
204 typedef
205 EFI_STATUS
206 (EFIAPI *EFI_BIS_SHUTDOWN)(
207 IN BIS_APPLICATION_HANDLE AppHandle
208 );
209
210 /**
211 Retrieves the certificate that has been configured as the identity of the organization designated as
212 the source of authorization for signatures of boot objects.
213
214 @param AppHandle An opaque handle that identifies the caller's instance of initialization
215 of the BIS service.
216 @param Certificate The function writes an allocated EFI_BIS_DATA* containing the Boot
217 Object Authorization Certificate object. The caller must
218 eventually free the memory allocated by this function using the function Free().
219
220 @retval EFI_SUCCESS The function completed successfully.
221 @retval EFI_NO_MAPPING The AppHandle parameter is not or is no longer a valid
222 application instance handle associated with the EFI_BIS protocol.
223 @retval EFI_NOT_FOUND There is no Boot Object Authorization Certificate currently installed.
224 @retval EFI_OUT_OF_RESOURCES The function failed due to lack of memory or other resources.
225 @retval EFI_INVALID_PARAMETER The Certificate parameter supplied by the caller is NULL or
226 an invalid memory reference.
227
228 **/
229 typedef
230 EFI_STATUS
231 (EFIAPI *EFI_BIS_GET_BOOT_OBJECT_AUTHORIZATION_CERTIFICATE)(
232 IN BIS_APPLICATION_HANDLE AppHandle,
233 OUT EFI_BIS_DATA **Certificate
234 );
235
236 /**
237 Verifies the integrity and authorization of the indicated data object according to the
238 indicated credentials.
239
240 @param AppHandle An opaque handle that identifies the caller's instance of initialization
241 of the BIS service.
242 @param Credentials A Signed Manifest containing verification information for the indicated
243 data object.
244 @param DataObject An in-memory copy of the raw data object to be verified.
245 @param IsVerified The function writes TRUE if the verification succeeded, otherwise
246 FALSE.
247
248 @retval EFI_SUCCESS The function completed successfully.
249 @retval EFI_NO_MAPPING The AppHandle parameter is not or is no longer a valid
250 application instance handle associated with the EFI_BIS protocol.
251 @retval EFI_OUT_OF_RESOURCES The function failed due to lack of memory or other resources.
252 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
253 @retval EFI_SECURITY_VIOLATION The signed manifest supplied as the Credentials parameter
254 was invalid (could not be parsed) or Platform-specific authorization failed, etc.
255 @retval EFI_DEVICE_ERROR An unexpected internal error occurred.
256
257 **/
258 typedef
259 EFI_STATUS
260 (EFIAPI *EFI_BIS_VERIFY_BOOT_OBJECT)(
261 IN BIS_APPLICATION_HANDLE AppHandle,
262 IN EFI_BIS_DATA *Credentials,
263 IN EFI_BIS_DATA *DataObject,
264 OUT BOOLEAN *IsVerified
265 );
266
267 /**
268 Retrieves the current status of the Boot Authorization Check Flag.
269
270 @param AppHandle An opaque handle that identifies the caller's instance of initialization
271 of the BIS service.
272 @param CheckIsRequired The function writes the value TRUE if a Boot Authorization Check is
273 currently required on this platform, otherwise the function writes
274 FALSE.
275
276 @retval EFI_SUCCESS The function completed successfully.
277 @retval EFI_NO_MAPPING The AppHandle parameter is not or is no longer a valid
278 application instance handle associated with the EFI_BIS protocol.
279 @retval EFI_OUT_OF_RESOURCES The function failed due to lack of memory or other resources.
280 @retval EFI_INVALID_PARAMETER The CheckIsRequired parameter supplied by the caller is
281 NULL or an invalid memory reference.
282
283 **/
284 typedef
285 EFI_STATUS
286 (EFIAPI *EFI_BIS_GET_BOOT_OBJECT_AUTHORIZATION_CHECKFLAG)(
287 IN BIS_APPLICATION_HANDLE AppHandle,
288 OUT BOOLEAN *CheckIsRequired
289 );
290
291 /**
292 Retrieves a unique token value to be included in the request credential for the next update of any
293 parameter in the Boot Object Authorization set
294
295 @param AppHandle An opaque handle that identifies the caller's
296 instance of initialization of the BIS service.
297 @param UpdateToken The function writes an allocated EFI_BIS_DATA*
298 containing the newunique update token value.
299 The caller musteventually free the memory allocated
300 by this function using the function Free().
301
302 @retval EFI_SUCCESS The function completed successfully.
303 @retval EFI_NO_MAPPING The AppHandle parameter is not or is no longer a valid
304 application instance handle associated with the EFI_BIS protocol.
305 @retval EFI_OUT_OF_RESOURCES The function failed due to lack of memory or other resources.
306 @retval EFI_INVALID_PARAMETER The UpdateToken parameter supplied by the caller is NULL or
307 an invalid memory reference.
308 @retval EFI_DEVICE_ERROR An unexpected internal error occurred.
309
310 **/
311 typedef
312 EFI_STATUS
313 (EFIAPI *EFI_BIS_GET_BOOT_OBJECT_AUTHORIZATION_UPDATE_TOKEN)(
314 IN BIS_APPLICATION_HANDLE AppHandle,
315 OUT EFI_BIS_DATA **UpdateToken
316 );
317
318 /**
319 Updates one of the configurable parameters of the Boot Object Authorization set.
320
321 @param AppHandle An opaque handle that identifies the caller's
322 instance of initialization of the BIS service.
323 @param RequestCredential This is a Signed Manifest with embedded attributes
324 that carry the details of the requested update.
325 @param NewUpdateToken The function writes an allocated EFI_BIS_DATA*
326 containing the new unique update token value.
327 The caller must eventually free the memory allocated
328 by this function using the function Free().
329
330 @retval EFI_SUCCESS The function completed successfully.
331 @retval EFI_NO_MAPPING The AppHandle parameter is not or is no longer a valid
332 application instance handle associated with the EFI_BIS protocol.
333 @retval EFI_OUT_OF_RESOURCES The function failed due to lack of memory or other resources.
334 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
335 @retval EFI_SECURITY_VIOLATION The signed manifest supplied as the RequestCredential parameter
336 was invalid (could not be parsed) or Platform-specific authorization failed, etc.
337 @retval EFI_DEVICE_ERROR An unexpected internal error occurred while analyzing the new
338 certificate's key algorithm, or while attempting to retrieve
339 the public key algorithm of the manifest's signer's certificate,
340 or An unexpected internal error occurred in a cryptographic software module.
341
342 **/
343 typedef
344 EFI_STATUS
345 (EFIAPI *EFI_BIS_UPDATE_BOOT_OBJECT_AUTHORIZATION)(
346 IN BIS_APPLICATION_HANDLE AppHandle,
347 IN EFI_BIS_DATA *RequestCredential,
348 OUT EFI_BIS_DATA **NewUpdateToken
349 );
350
351 /**
352 Verifies the integrity and authorization of the indicated data object according to the indicated
353 credentials and authority certificate.
354
355 @param AppHandle An opaque handle that identifies the caller's instance of initialization
356 of the BIS service.
357 @param Credentials A Signed Manifest containing verification information for the
358 indicated data object.
359 @param DataObject An in-memory copy of the raw data object to be verified.
360 @param SectionName An ASCII string giving the section name in the
361 manifest holding the verification information (in other words,
362 hash value) that corresponds to DataObject.
363 @param AuthorityCertificate A digital certificate whose public key must match the signer's
364 public key which is found in the credentials.
365 @param IsVerified The function writes TRUE if the verification was successful.
366 Otherwise, the function writes FALSE.
367
368 @retval EFI_SUCCESS The function completed successfully.
369 @retval EFI_NO_MAPPING The AppHandle parameter is not or is no longer a valid
370 application instance handle associated with the EFI_BIS protocol.
371 @retval EFI_OUT_OF_RESOURCES The function failed due to lack of memory or other resources.
372 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
373 @retval EFI_SECURITY_VIOLATION The Credentials.Data supplied by the caller is NULL,
374 or the AuthorityCertificate supplied by the caller was
375 invalid (could not be parsed),
376 or Platform-specific authorization failed, etc.
377 @retval EFI_DEVICE_ERROR An unexpected internal error occurred while attempting to retrieve
378 the public key algorithm of the manifest's signer's certificate,
379 or An unexpected internal error occurred in a cryptographic software module.
380 **/
381 typedef
382 EFI_STATUS
383 (EFIAPI *EFI_BIS_VERIFY_OBJECT_WITH_CREDENTIAL)(
384 IN BIS_APPLICATION_HANDLE AppHandle,
385 IN EFI_BIS_DATA *Credentials,
386 IN EFI_BIS_DATA *DataObject,
387 IN EFI_BIS_DATA *SectionName,
388 IN EFI_BIS_DATA *AuthorityCertificate,
389 OUT BOOLEAN *IsVerified
390 );
391
392 /**
393 Retrieves a list of digital certificate identifier, digital signature algorithm, hash algorithm, and keylength
394 combinations that the platform supports.
395
396 @param AppHandle An opaque handle that identifies the caller's instance of initialization
397 of the BIS service.
398 @param SignatureInfo The function writes an allocated EFI_BIS_DATA* containing the array
399 of EFI_BIS_SIGNATURE_INFO structures representing the supported
400 digital certificate identifier, algorithm, and key length combinations.
401 The caller must eventually free the memory allocated by this function using the function Free().
402
403 @retval EFI_SUCCESS The function completed successfully.
404 @retval EFI_NO_MAPPING The AppHandle parameter is not or is no longer a valid
405 application instance handle associated with the EFI_BIS protocol.
406 @retval EFI_OUT_OF_RESOURCES The function failed due to lack of memory or other resources.
407 @retval EFI_INVALID_PARAMETER The SignatureInfo parameter supplied by the caller is NULL
408 or an invalid memory reference.
409 @retval EFI_DEVICE_ERROR An unexpected internal error occurred in a
410 cryptographic software module, or
411 The function encountered an unexpected internal consistency check
412 failure (possible corruption of stored Boot Object Authorization Certificate).
413
414 **/
415 typedef
416 EFI_STATUS
417 (EFIAPI *EFI_BIS_GET_SIGNATURE_INFO)(
418 IN BIS_APPLICATION_HANDLE AppHandle,
419 OUT EFI_BIS_DATA **SignatureInfo
420 );
421
422 ///
423 /// The EFI_BIS_PROTOCOL is used to check a digital signature of a data block against a digital
424 /// certificate for the purpose of an integrity and authorization check.
425 ///
426 struct _EFI_BIS_PROTOCOL {
427 EFI_BIS_INITIALIZE Initialize;
428 EFI_BIS_SHUTDOWN Shutdown;
429 EFI_BIS_FREE Free;
430 EFI_BIS_GET_BOOT_OBJECT_AUTHORIZATION_CERTIFICATE GetBootObjectAuthorizationCertificate;
431 EFI_BIS_GET_BOOT_OBJECT_AUTHORIZATION_CHECKFLAG GetBootObjectAuthorizationCheckFlag;
432 EFI_BIS_GET_BOOT_OBJECT_AUTHORIZATION_UPDATE_TOKEN GetBootObjectAuthorizationUpdateToken;
433 EFI_BIS_GET_SIGNATURE_INFO GetSignatureInfo;
434 EFI_BIS_UPDATE_BOOT_OBJECT_AUTHORIZATION UpdateBootObjectAuthorization;
435 EFI_BIS_VERIFY_BOOT_OBJECT VerifyBootObject;
436 EFI_BIS_VERIFY_OBJECT_WITH_CREDENTIAL VerifyObjectWithCredential;
437 };
438
439 extern EFI_GUID gEfiBisProtocolGuid;
440 extern EFI_GUID gBootObjectAuthorizationParmsetGuid;
441
442 #endif