]> git.proxmox.com Git - mirror_edk2.git/blob - MdePkg/Include/Protocol/Kms.h
MdePkg: Clean up source files
[mirror_edk2.git] / MdePkg / Include / Protocol / Kms.h
1 /** @file
2 The Key Management Service (KMS) protocol as defined in the UEFI 2.3.1 specification is to
3 provides services to generate, store, retrieve, and manage cryptographic keys.
4 The intention is to specify a simple generic protocol that could be used for many implementations.
5
6 A driver implementing the protocol may need to provide basic key service that consists of a
7 key store and cryptographic key generation capability. It may connect to an external key
8 server over the network, or to a Hardware Security Module (HSM) attached to the system it
9 runs on, or anything else that is capable of providing the key management service.
10
11 Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.<BR>
12 This program and the accompanying materials are licensed and made available under
13 the terms and conditions of the BSD License that accompanies this distribution.
14 The full text of the license may be found at
15 http://opensource.org/licenses/bsd-license.php.
16
17 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
18 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
19
20 **/
21
22 #ifndef __KMS_H__
23 #define __KMS_H__
24
25 #define EFI_KMS_PROTOCOL_GUID \
26 { \
27 0xEC3A978D, 0x7C4E, 0x48FA, {0x9A, 0xBE, 0x6A, 0xD9, 0x1C, 0xC8, 0xF8, 0x11 } \
28 }
29
30 typedef struct _EFI_KMS_PROTOCOL EFI_KMS_PROTOCOL;
31
32 //
33 // Where appropriate, EFI_KMS_DATA_TYPE values may be combined using a bitwise 'OR'
34 // operation to indicate support for multiple data types.
35 //
36 #define EFI_KMS_DATA_TYPE_NONE 0
37 #define EFI_KMS_DATA_TYPE_BINARY 1
38 #define EFI_KMS_DATA_TYPE_ASCII 2
39 #define EFI_KMS_DATA_TYPE_UNICODE 4
40 #define EFI_KMS_DATA_TYPE_UTF8 8
41
42
43 //
44 // The key formats recognized by the KMS protocol are defined by an EFI_GUID which specifies
45 // a (key-algorithm, key-size) pair. The names of these GUIDs are in the format
46 // EFI_KMS_KEY_(key-algorithm)_(key-size)_GUID, where the key-size is expressed in bits.
47 // The key formats recognized fall into three categories, generic (no algorithm), hash algorithms,
48 // and encrypted algorithms.
49 //
50
51 ///
52 /// The following GUIDs define formats that contain generic key data of a specific size in bits,
53 /// but which is not associated with any specific key algorithm(s).
54 ///@{
55 #define EFI_KMS_FORMAT_GENERIC_128_GUID \
56 { \
57 0xec8a3d69, 0x6ddf, 0x4108, {0x94, 0x76, 0x73, 0x37, 0xfc, 0x52, 0x21, 0x36 } \
58 }
59 #define EFI_KMS_FORMAT_GENERIC_160_GUID \
60 { \
61 0xa3b3e6f8, 0xefca, 0x4bc1, {0x88, 0xfb, 0xcb, 0x87, 0x33, 0x9b, 0x25, 0x79 } \
62 }
63 #define EFI_KMS_FORMAT_GENERIC_256_GUID \
64 { \
65 0x70f64793, 0xc323, 0x4261, {0xac, 0x2c, 0xd8, 0x76, 0xf2, 0x7c, 0x53, 0x45 } \
66 }
67 #define EFI_KMS_FORMAT_GENERIC_512_GUID \
68 { \
69 0x978fe043, 0xd7af, 0x422e, {0x8a, 0x92, 0x2b, 0x48, 0xe4, 0x63, 0xbd, 0xe6 } \
70 }
71 #define EFI_KMS_FORMAT_GENERIC_1024_GUID \
72 { \
73 0x43be0b44, 0x874b, 0x4ead, {0xb0, 0x9c, 0x24, 0x1a, 0x4f, 0xbd, 0x7e, 0xb3 } \
74 }
75 #define EFI_KMS_FORMAT_GENERIC_2048_GUID \
76 { \
77 0x40093f23, 0x630c, 0x4626, {0x9c, 0x48, 0x40, 0x37, 0x3b, 0x19, 0xcb, 0xbe } \
78 }
79 #define EFI_KMS_FORMAT_GENERIC_3072_GUID \
80 { \
81 0xb9237513, 0x6c44, 0x4411, {0xa9, 0x90, 0x21, 0xe5, 0x56, 0xe0, 0x5a, 0xde } \
82 }
83 #define EFI_KMS_FORMAT_GENERIC_DYNAMIC_GUID \
84 { \
85 0x2156e996, 0x66de, 0x4b27, {0x9c, 0xc9, 0xb0, 0x9f, 0xac, 0x4d, 0x2, 0xbe } \
86 }
87 ///@}
88
89 ///
90 /// These GUIDS define key data formats that contain data generated by basic hash algorithms
91 /// with no cryptographic properties.
92 ///@{
93 #define EFI_KMS_FORMAT_MD2_128_GUID \
94 { \
95 0x78be11c4, 0xee44, 0x4a22, {0x9f, 0x05, 0x03, 0x85, 0x2e, 0xc5, 0xc9, 0x78 } \
96 }
97 #define EFI_KMS_FORMAT_MDC2_128_GUID \
98 { \
99 0xf7ad60f8, 0xefa8, 0x44a3, {0x91, 0x13, 0x23, 0x1f, 0x39, 0x9e, 0xb4, 0xc7 } \
100 }
101 #define EFI_KMS_FORMAT_MD4_128_GUID \
102 { \
103 0xd1c17aa1, 0xcac5, 0x400f, {0xbe, 0x17, 0xe2, 0xa2, 0xae, 0x06, 0x67, 0x7c } \
104 }
105 #define EFI_KMS_FORMAT_MDC4_128_GUID \
106 { \
107 0x3fa4f847, 0xd8eb, 0x4df4, {0xbd, 0x49, 0x10, 0x3a, 0x0a, 0x84, 0x7b, 0xbc } \
108 }
109 #define EFI_KMS_FORMAT_MD5_128_GUID \
110 { \
111 0xdcbc3662, 0x9cda, 0x4b52, {0xa0, 0x4c, 0x82, 0xeb, 0x1d, 0x23, 0x48, 0xc7 } \
112 }
113 #define EFI_KMS_FORMAT_MD5SHA_128_GUID \
114 { \
115 0x1c178237, 0x6897, 0x459e, {0x9d, 0x36, 0x67, 0xce, 0x8e, 0xf9, 0x4f, 0x76 } \
116 }
117 #define EFI_KMS_FORMAT_SHA1_160_GUID \
118 { \
119 0x453c5e5a, 0x482d, 0x43f0, {0x87, 0xc9, 0x59, 0x41, 0xf3, 0xa3, 0x8a, 0xc2 } \
120 }
121 #define EFI_KMS_FORMAT_SHA256_256_GUID \
122 { \
123 0x6bb4f5cd, 0x8022, 0x448d, {0xbc, 0x6d, 0x77, 0x1b, 0xae, 0x93, 0x5f, 0xc6 } \
124 }
125 #define EFI_KMS_FORMAT_SHA512_512_GUID \
126 { \
127 0x2f240e12, 0xe14d, 0x475c, {0x83, 0xb0, 0xef, 0xff, 0x22, 0xd7, 0x7b, 0xe7 } \
128 }
129 ///@}
130
131 ///
132 /// These GUIDs define key data formats that contain data generated by cryptographic key algorithms.
133 /// There may or may not be a separate data hashing algorithm associated with the key algorithm.
134 ///@{
135 #define EFI_KMS_FORMAT_AESXTS_128_GUID \
136 { \
137 0x4776e33f, 0xdb47, 0x479a, {0xa2, 0x5f, 0xa1, 0xcd, 0x0a, 0xfa, 0xb3, 0x8b } \
138 }
139 #define EFI_KMS_FORMAT_AESXTS_256_GUID \
140 { \
141 0xdc7e8613, 0xc4bb, 0x4db0, {0x84, 0x62, 0x13, 0x51, 0x13, 0x57, 0xab, 0xe2 } \
142 }
143 #define EFI_KMS_FORMAT_AESCBC_128_GUID \
144 { \
145 0xa0e8ee6a, 0x0e92, 0x44d4, {0x86, 0x1b, 0x0e, 0xaa, 0x4a, 0xca, 0x44, 0xa2 } \
146 }
147 #define EFI_KMS_FORMAT_AESCBC_256_GUID \
148 { \
149 0xd7e69789, 0x1f68, 0x45e8, {0x96, 0xef, 0x3b, 0x64, 0x07, 0xa5, 0xb2, 0xdc } \
150 }
151 #define EFI_KMS_FORMAT_RSASHA1_1024_GUID \
152 { \
153 0x56417bed, 0x6bbe, 0x4882, {0x86, 0xa0, 0x3a, 0xe8, 0xbb, 0x17, 0xf8, 0xf9 } \
154 }
155 #define EFI_KMS_FORMAT_RSASHA1_2048_GUID \
156 { \
157 0xf66447d4, 0x75a6, 0x463e, {0xa8, 0x19, 0x07, 0x7f, 0x2d, 0xda, 0x05, 0xe9 } \
158 }
159 #define EFI_KMS_FORMAT_RSASHA256_2048_GUID \
160 { \
161 0xa477af13, 0x877d, 0x4060, {0xba, 0xa1, 0x25, 0xd1, 0xbe, 0xa0, 0x8a, 0xd3 } \
162 }
163 #define EFI_KMS_FORMAT_RSASHA256_3072_GUID \
164 { \
165 0x4e1356c2, 0xeed, 0x463f, {0x81, 0x47, 0x99, 0x33, 0xab, 0xdb, 0xc7, 0xd5 } \
166 }
167 ///@}
168
169 #define EFI_KMS_ATTRIBUTE_TYPE_NONE 0x00
170 #define EFI_KMS_ATTRIBUTE_TYPE_INTEGER 0x01
171 #define EFI_KMS_ATTRIBUTE_TYPE_LONG_INTEGER 0x02
172 #define EFI_KMS_ATTRIBUTE_TYPE_BIG_INTEGER 0x03
173 #define EFI_KMS_ATTRIBUTE_TYPE_ENUMERATION 0x04
174 #define EFI_KMS_ATTRIBUTE_TYPE_BOOLEAN 0x05
175 #define EFI_KMS_ATTRIBUTE_TYPE_BYTE_STRING 0x06
176 #define EFI_KMS_ATTRIBUTE_TYPE_TEXT_STRING 0x07
177 #define EFI_KMS_ATTRIBUTE_TYPE_DATE_TIME 0x08
178 #define EFI_KMS_ATTRIBUTE_TYPE_INTERVAL 0x09
179 #define EFI_KMS_ATTRIBUTE_TYPE_STRUCTURE 0x0A
180 #define EFI_KMS_ATTRIBUTE_TYPE_DYNAMIC 0x0B
181
182 typedef struct {
183 ///
184 /// Length in bytes of the KeyData.
185 ///
186 UINT32 KeySize;
187 ///
188 /// The data of the key.
189 ///
190 UINT8 KeyData[1];
191 } EFI_KMS_FORMAT_GENERIC_DYNAMIC;
192
193 typedef struct {
194 ///
195 /// The size in bytes for the client identifier.
196 ///
197 UINT16 ClientIdSize;
198 ///
199 /// Pointer to a valid client identifier.
200 ///
201 VOID *ClientId;
202 ///
203 /// The client name string type used by this client. The string type set here must be one of
204 /// the string types reported in the ClientNameStringTypes field of the KMS protocol. If the
205 /// KMS does not support client names, this field should be set to EFI_KMS_DATA_TYPE_NONE.
206 ///
207 UINT8 ClientNameType;
208 ///
209 /// The size in characters for the client name. This field will be ignored if
210 /// ClientNameStringType is set to EFI_KMS_DATA_TYPE_NONE. Otherwise, it must contain
211 /// number of characters contained in the ClientName field.
212 ///
213 UINT8 ClientNameCount;
214 ///
215 /// Pointer to a client name. This field will be ignored if ClientNameStringType is set to
216 /// EFI_KMS_DATA_TYPE_NONE. Otherwise, it must point to a valid string of the specified type.
217 ///
218 VOID *ClientName;
219 } EFI_KMS_CLIENT_INFO;
220
221 typedef struct {
222 ///
223 /// The size of the KeyIdentifier field in bytes. This field is limited to the range 0 to 255.
224 ///
225 UINT8 KeyIdentifierSize;
226 ///
227 /// Pointer to an array of KeyIdentifierType elements.
228 ///
229 VOID *KeyIdentifier;
230 ///
231 /// An EFI_GUID which specifies the algorithm and key value size for this key.
232 ///
233 EFI_GUID KeyFormat;
234 ///
235 /// Pointer to a key value for a key specified by the KeyFormat field. A NULL value for this
236 /// field indicates that no key is available.
237 ///
238 VOID *KeyValue;
239 ///
240 /// Specifies the results of KMS operations performed with this descriptor. This field is used
241 /// to indicate the status of individual operations when a KMS function is called with multiple
242 /// EFI_KMS_KEY_DESCRIPTOR structures.
243 /// KeyStatus codes returned for the individual key requests are:
244 /// EFI_SUCCESS Successfully processed this key.
245 /// EFI_WARN_STALE_DATA Successfully processed this key, however, the key's parameters
246 /// exceed internal policies/limits and should be replaced.
247 /// EFI_COMPROMISED_DATA Successfully processed this key, but the key may have been
248 /// compromised and must be replaced.
249 /// EFI_UNSUPPORTED Key format is not supported by the service.
250 /// EFI_OUT_OF_RESOURCES Could not allocate resources for the key processing.
251 /// EFI_TIMEOUT Timed out waiting for device or key server.
252 /// EFI_DEVICE_ERROR Device or key server error.
253 /// EFI_INVALID_PARAMETER KeyFormat is invalid.
254 /// EFI_NOT_FOUND The key does not exist on the KMS.
255 ///
256 EFI_STATUS KeyStatus;
257 } EFI_KMS_KEY_DESCRIPTOR;
258
259 typedef struct {
260 ///
261 /// Part of a tag-type-length triplet that identifies the KeyAttributeData formatting. The
262 /// definition of the value is outside the scope of this standard and may be defined by the KMS.
263 ///
264 UINT16 Tag;
265 ///
266 /// Part of a tag-type-length triplet that identifies the KeyAttributeData formatting. The
267 /// definition of the value is outside the scope of this standard and may be defined by the KMS.
268 ///
269 UINT16 Type;
270 ///
271 /// Length in bytes of the KeyAttributeData.
272 ///
273 UINT32 Length;
274 ///
275 /// An array of bytes to hold the attribute data associated with the KeyAttributeIdentifier.
276 ///
277 UINT8 KeyAttributeData[1];
278 } EFI_KMS_DYNAMIC_FIELD;
279
280 typedef struct {
281 ///
282 /// The number of members in the EFI_KMS_DYNAMIC_ATTRIBUTE structure.
283 ///
284 UINT32 FieldCount;
285 ///
286 /// An array of EFI_KMS_DYNAMIC_FIELD structures.
287 ///
288 EFI_KMS_DYNAMIC_FIELD Field[1];
289 } EFI_KMS_DYNAMIC_ATTRIBUTE;
290
291 typedef struct {
292 ///
293 /// The data type used for the KeyAttributeIdentifier field. Values for this field are defined
294 /// by the EFI_KMS_DATA_TYPE constants, except that EFI_KMS_DATA_TYPE_BINARY is not
295 /// valid for this field.
296 ///
297 UINT8 KeyAttributeIdentifierType;
298 ///
299 /// The length of the KeyAttributeIdentifier field in units defined by KeyAttributeIdentifierType
300 /// field. This field is limited to the range 0 to 255.
301 ///
302 UINT8 KeyAttributeIdentifierCount;
303 ///
304 /// Pointer to an array of KeyAttributeIdentifierType elements. For string types, there must
305 /// not be a null-termination element at the end of the array.
306 ///
307 VOID *KeyAttributeIdentifier;
308 ///
309 /// The instance number of this attribute. If there is only one instance, the value is set to
310 /// one. If this value is set to 0xFFFF (all binary 1's) then this field should be ignored if an
311 /// output or treated as a wild card matching any value if it is an input. If the attribute is
312 /// stored with this field, it will match any attribute request regardless of the setting of the
313 /// field in the request. If set to 0xFFFF in the request, it will match any attribute with the
314 /// same KeyAttributeIdentifier.
315 ///
316 UINT16 KeyAttributeInstance;
317 ///
318 /// The data type of the KeyAttributeValue (e.g. struct, bool, etc.). See the list of
319 /// KeyAttributeType definitions.
320 ///
321 UINT16 KeyAttributeType;
322 ///
323 /// The size in bytes of the KeyAttribute field. A value of zero for this field indicates that no
324 /// key attribute value is available.
325 ///
326 UINT16 KeyAttributeValueSize;
327 ///
328 /// Pointer to a key attribute value for the attribute specified by the KeyAttributeIdentifier
329 /// field. If the KeyAttributeValueSize field is zero, then this field must be NULL.
330 ///
331 VOID *KeyAttributeValue;
332 ///
333 /// KeyAttributeStatusSpecifies the results of KMS operations performed with this attribute.
334 /// This field is used to indicate the status of individual operations when a KMS function is
335 /// called with multiple EFI_KMS_KEY_ATTRIBUTE structures.
336 /// KeyAttributeStatus codes returned for the individual key attribute requests are:
337 /// EFI_SUCCESS Successfully processed this request.
338 /// EFI_WARN_STALE_DATA Successfully processed this request, however, the key's
339 /// parameters exceed internal policies/limits and should be replaced.
340 /// EFI_COMPROMISED_DATA Successfully processed this request, but the key may have been
341 /// compromised and must be replaced.
342 /// EFI_UNSUPPORTED Key attribute format is not supported by the service.
343 /// EFI_OUT_OF_RESOURCES Could not allocate resources for the request processing.
344 /// EFI_TIMEOUT Timed out waiting for device or key server.
345 /// EFI_DEVICE_ERROR Device or key server error.
346 /// EFI_INVALID_PARAMETER A field in the EFI_KMS_KEY_ATTRIBUTE structure is invalid.
347 /// EFI_NOT_FOUND The key attribute does not exist on the KMS.
348 ///
349 EFI_STATUS KeyAttributeStatus;
350 } EFI_KMS_KEY_ATTRIBUTE;
351
352 /**
353 Get the current status of the key management service.
354
355 @param[in] This Pointer to the EFI_KMS_PROTOCOL instance.
356
357 @retval EFI_SUCCESS The KMS is ready for use.
358 @retval EFI_NOT_READY No connection to the KMS is available.
359 @retval EFI_NO_MAPPING No valid connection configuration exists for the KMS.
360 @retval EFI_NO_RESPONSE No response was received from the KMS.
361 @retval EFI_DEVICE_ERROR An error occurred when attempting to access the KMS.
362 @retval EFI_INVALID_PARAMETER This is NULL.
363
364 **/
365 typedef
366 EFI_STATUS
367 (EFIAPI *EFI_KMS_GET_SERVICE_STATUS) (
368 IN EFI_KMS_PROTOCOL *This
369 );
370
371 /**
372 Register client information with the supported KMS.
373
374 @param[in] This Pointer to the EFI_KMS_PROTOCOL instance.
375 @param[in] Client Pointer to a valid EFI_KMS_CLIENT_INFO structure.
376 @param[in, out] ClientDataSize Pointer to the size, in bytes, of an arbitrary block of
377 data specified by the ClientData parameter. This
378 parameter may be NULL, in which case the ClientData
379 parameter will be ignored and no data will be
380 transferred to or from the KMS. If the parameter is
381 not NULL, then ClientData must be a valid pointer.
382 If the value pointed to is 0, no data will be transferred
383 to the KMS, but data may be returned by the KMS.
384 For all non-zero values *ClientData will be transferred
385 to the KMS, which may also return data to the caller.
386 In all cases, the value upon return to the caller will
387 be the size of the data block returned to the caller,
388 which will be zero if no data is returned from the KMS.
389 @param[in, out] ClientData Pointer to a pointer to an arbitrary block of data of
390 *ClientDataSize that is to be passed directly to the
391 KMS if it supports the use of client data. This
392 parameter may be NULL if and only if the
393 ClientDataSize parameter is also NULL. Upon return to
394 the caller, *ClientData points to a block of data of
395 *ClientDataSize that was returned from the KMS.
396 If the returned value for *ClientDataSize is zero,
397 then the returned value for *ClientData must be NULL
398 and should be ignored by the caller. The KMS protocol
399 consumer is responsible for freeing all valid buffers
400 used for client data regardless of whether they are
401 allocated by the caller for input to the function or by
402 the implementation for output back to the caller.
403
404 @retval EFI_SUCCESS The client information has been accepted by the KMS.
405 @retval EFI_NOT_READY No connection to the KMS is available.
406 @retval EFI_NO_RESPONSE There was no response from the device or the key server.
407 @retval EFI_ACCESS_DENIED Access was denied by the device or the key server.
408 @retval EFI_DEVICE_ERROR An error occurred when attempting to access the KMS.
409 @retval EFI_OUT_OF_RESOURCES Required resources were not available to perform the function.
410 @retval EFI_INVALID_PARAMETER This is NULL.
411 @retval EFI_UNSUPPORTED The KMS does not support the use of client identifiers.
412
413 **/
414 typedef
415 EFI_STATUS
416 (EFIAPI *EFI_KMS_REGISTER_CLIENT) (
417 IN EFI_KMS_PROTOCOL *This,
418 IN EFI_KMS_CLIENT_INFO *Client,
419 IN OUT UINTN *ClientDataSize OPTIONAL,
420 IN OUT VOID **ClientData OPTIONAL
421 );
422
423 /**
424 Request that the KMS generate one or more new keys and associate them with key identifiers.
425 The key value(s) is returned to the caller.
426
427 @param[in] This Pointer to the EFI_KMS_PROTOCOL instance.
428 @param[in] Client Pointer to a valid EFI_KMS_CLIENT_INFO structure.
429 @param[in, out] KeyDescriptorCount Pointer to a count of the number of key descriptors to be
430 processed by this operation. On return, this number
431 will be updated with the number of key descriptors
432 successfully processed.
433 @param[in, out] KeyDescriptors Pointer to an array of EFI_KMS_KEY_DESCRIPTOR
434 structures which describe the keys to be generated.
435 On input, the KeyIdentifierSize and the KeyIdentifier
436 may specify an identifier to be used for the key,
437 but this is not required. The KeyFormat field must
438 specify a key format GUID reported as supported by
439 the KeyFormats field of the EFI_KMS_PROTOCOL.
440 The value for this field in the first key descriptor will
441 be considered the default value for subsequent key
442 descriptors requested in this operation if those key
443 descriptors have a NULL GUID in the key format field.
444 On output, the KeyIdentifierSize and KeyIdentifier fields
445 will specify an identifier for the key which will be either
446 the original identifier if one was provided, or an identifier
447 generated either by the KMS or the KMS protocol
448 implementation. The KeyFormat field will be updated
449 with the GUID used to generate the key if it was a
450 NULL GUID, and the KeyValue field will contain a pointer
451 to memory containing the key value for the generated
452 key. Memory for both the KeyIdentifier and the KeyValue
453 fields will be allocated with the BOOT_SERVICES_DATA
454 type and must be freed by the caller when it is no longer
455 needed. Also, the KeyStatus field must reflect the result
456 of the request relative to that key.
457 @param[in, out] ClientDataSize Pointer to the size, in bytes, of an arbitrary block of
458 data specified by the ClientData parameter. This
459 parameter may be NULL, in which case the ClientData
460 parameter will be ignored and no data will be
461 transferred to or from the KMS. If the parameter is
462 not NULL, then ClientData must be a valid pointer.
463 If the value pointed to is 0, no data will be transferred
464 to the KMS, but data may be returned by the KMS.
465 For all non-zero values *ClientData will be transferred
466 to the KMS, which may also return data to the caller.
467 In all cases, the value upon return to the caller will
468 be the size of the data block returned to the caller,
469 which will be zero if no data is returned from the KMS.
470 @param[in, out] ClientData Pointer to a pointer to an arbitrary block of data of
471 *ClientDataSize that is to be passed directly to the
472 KMS if it supports the use of client data. This
473 parameter may be NULL if and only if the
474 ClientDataSize parameter is also NULL. Upon return to
475 the caller, *ClientData points to a block of data of
476 *ClientDataSize that was returned from the KMS.
477 If the returned value for *ClientDataSize is zero,
478 then the returned value for *ClientData must be NULL
479 and should be ignored by the caller. The KMS protocol
480 consumer is responsible for freeing all valid buffers
481 used for client data regardless of whether they are
482 allocated by the caller for input to the function or by
483 the implementation for output back to the caller.
484
485 @retval EFI_SUCCESS Successfully generated and retrieved all requested keys.
486 @retval EFI_UNSUPPORTED This function is not supported by the KMS. --OR--
487 One (or more) of the key requests submitted is not supported by
488 the KMS. Check individual key request(s) to see which ones
489 may have been processed.
490 @retval EFI_OUT_OF_RESOURCES Required resources were not available to perform the function.
491 @retval EFI_TIMEOUT Timed out waiting for device or key server. Check individual key
492 request(s) to see which ones may have been processed.
493 @retval EFI_ACCESS_DENIED Access was denied by the device or the key server; OR a
494 ClientId is required by the server and either no id was
495 provided or an invalid id was provided.
496 @retval EFI_DEVICE_ERROR An error occurred when attempting to access the KMS. Check
497 individual key request(s) to see which ones may have been
498 processed.
499 @retval EFI_INVALID_PARAMETER This is NULL, ClientId is required but it is NULL,
500 KeyDescriptorCount is NULL, or Keys is NULL.
501 @retval EFI_NOT_FOUND One or more EFI_KMS_KEY_DESCRIPTOR structures
502 could not be processed properly. KeyDescriptorCount
503 contains the number of structures which were successfully
504 processed. Individual structures will reflect the status of the
505 processing for that structure.
506
507 **/
508 typedef
509 EFI_STATUS
510 (EFIAPI *EFI_KMS_CREATE_KEY) (
511 IN EFI_KMS_PROTOCOL *This,
512 IN EFI_KMS_CLIENT_INFO *Client,
513 IN OUT UINT16 *KeyDescriptorCount,
514 IN OUT EFI_KMS_KEY_DESCRIPTOR *KeyDescriptors,
515 IN OUT UINTN *ClientDataSize OPTIONAL,
516 IN OUT VOID **ClientData OPTIONAL
517 );
518
519 /**
520 Retrieve an existing key.
521
522 @param[in] This Pointer to the EFI_KMS_PROTOCOL instance.
523 @param[in] Client Pointer to a valid EFI_KMS_CLIENT_INFO structure.
524 @param[in, out] KeyDescriptorCount Pointer to a count of the number of key descriptors to be
525 processed by this operation. On return, this number
526 will be updated with the number of key descriptors
527 successfully processed.
528 @param[in, out] KeyDescriptors Pointer to an array of EFI_KMS_KEY_DESCRIPTOR
529 structures which describe the keys to be retrieved
530 from the KMS.
531 On input, the KeyIdentifierSize and the KeyIdentifier
532 must specify an identifier to be used to retrieve a
533 specific key. All other fields in the descriptor should
534 be NULL.
535 On output, the KeyIdentifierSize and KeyIdentifier fields
536 will be unchanged, while the KeyFormat and KeyValue
537 fields will be updated values associated with this key
538 identifier. Memory for the KeyValue field will be
539 allocated with the BOOT_SERVICES_DATA type and
540 must be freed by the caller when it is no longer needed.
541 Also, the KeyStatus field will reflect the result of the
542 request relative to the individual key descriptor.
543 @param[in, out] ClientDataSize Pointer to the size, in bytes, of an arbitrary block of
544 data specified by the ClientData parameter. This
545 parameter may be NULL, in which case the ClientData
546 parameter will be ignored and no data will be
547 transferred to or from the KMS. If the parameter is
548 not NULL, then ClientData must be a valid pointer.
549 If the value pointed to is 0, no data will be transferred
550 to the KMS, but data may be returned by the KMS.
551 For all non-zero values *ClientData will be transferred
552 to the KMS, which may also return data to the caller.
553 In all cases, the value upon return to the caller will
554 be the size of the data block returned to the caller,
555 which will be zero if no data is returned from the KMS.
556 @param[in, out] ClientData Pointer to a pointer to an arbitrary block of data of
557 *ClientDataSize that is to be passed directly to the
558 KMS if it supports the use of client data. This
559 parameter may be NULL if and only if the
560 ClientDataSize parameter is also NULL. Upon return to
561 the caller, *ClientData points to a block of data of
562 *ClientDataSize that was returned from the KMS.
563 If the returned value for *ClientDataSize is zero,
564 then the returned value for *ClientData must be NULL
565 and should be ignored by the caller. The KMS protocol
566 consumer is responsible for freeing all valid buffers
567 used for client data regardless of whether they are
568 allocated by the caller for input to the function or by
569 the implementation for output back to the caller.
570
571 @retval EFI_SUCCESS Successfully retrieved all requested keys.
572 @retval EFI_OUT_OF_RESOURCES Could not allocate resources for the method processing.
573 @retval EFI_TIMEOUT Timed out waiting for device or key server. Check individual key
574 request(s) to see which ones may have been processed.
575 @retval EFI_BUFFER_TOO_SMALL If multiple keys are associated with a single identifier, and the
576 KeyValue buffer does not contain enough structures
577 (KeyDescriptorCount) to contain all the key data, then
578 the available structures will be filled and
579 KeyDescriptorCount will be updated to indicate the
580 number of keys which could not be processed.
581 @retval EFI_ACCESS_DENIED Access was denied by the device or the key server; OR a
582 ClientId is required by the server and either none or an
583 invalid id was provided.
584 @retval EFI_DEVICE_ERROR Device or key server error. Check individual key request(s) to
585 see which ones may have been processed.
586 @retval EFI_INVALID_PARAMETER This is NULL, ClientId is required but it is NULL,
587 KeyDescriptorCount is NULL, or Keys is NULL.
588 @retval EFI_NOT_FOUND One or more EFI_KMS_KEY_DESCRIPTOR structures
589 could not be processed properly. KeyDescriptorCount
590 contains the number of structures which were successfully
591 processed. Individual structures will reflect the status of the
592 processing for that structure.
593 @retval EFI_UNSUPPORTED The implementation/KMS does not support this function.
594
595 **/
596 typedef
597 EFI_STATUS
598 (EFIAPI *EFI_KMS_GET_KEY) (
599 IN EFI_KMS_PROTOCOL *This,
600 IN EFI_KMS_CLIENT_INFO *Client,
601 IN OUT UINT16 *KeyDescriptorCount,
602 IN OUT EFI_KMS_KEY_DESCRIPTOR *KeyDescriptors,
603 IN OUT UINTN *ClientDataSize OPTIONAL,
604 IN OUT VOID **ClientData OPTIONAL
605 );
606
607 /**
608 Add a new key.
609
610 @param[in] This Pointer to the EFI_KMS_PROTOCOL instance.
611 @param[in] Client Pointer to a valid EFI_KMS_CLIENT_INFO structure.
612 @param[in, out] KeyDescriptorCount Pointer to a count of the number of key descriptors to be
613 processed by this operation. On normal return, this
614 number will be updated with the number of key
615 descriptors successfully processed.
616 @param[in, out] KeyDescriptors Pointer to an array of EFI_KMS_KEY_DESCRIPTOR
617 structures which describe the keys to be added.
618 On input, the KeyId field for first key must contain
619 valid identifier data to be used for adding a key to
620 the KMS. The values for these fields in this key
621 definition will be considered default values for
622 subsequent keys requested in this operation. A value
623 of 0 in any subsequent KeyId field will be replaced
624 with the current default value. The KeyFormat and
625 KeyValue fields for each key to be added must contain
626 consistent values to be associated with the given KeyId.
627 On return, the KeyStatus field will reflect the result
628 of the operation for each key request.
629 @param[in, out] ClientDataSize Pointer to the size, in bytes, of an arbitrary block of
630 data specified by the ClientData parameter. This
631 parameter may be NULL, in which case the ClientData
632 parameter will be ignored and no data will be
633 transferred to or from the KMS. If the parameter is
634 not NULL, then ClientData must be a valid pointer.
635 If the value pointed to is 0, no data will be transferred
636 to the KMS, but data may be returned by the KMS.
637 For all non-zero values *ClientData will be transferred
638 to the KMS, which may also return data to the caller.
639 In all cases, the value upon return to the caller will
640 be the size of the data block returned to the caller,
641 which will be zero if no data is returned from the KMS.
642 @param[in, out] ClientData Pointer to a pointer to an arbitrary block of data of
643 *ClientDataSize that is to be passed directly to the
644 KMS if it supports the use of client data. This
645 parameter may be NULL if and only if the
646 ClientDataSize parameter is also NULL. Upon return to
647 the caller, *ClientData points to a block of data of
648 *ClientDataSize that was returned from the KMS.
649 If the returned value for *ClientDataSize is zero,
650 then the returned value for *ClientData must be NULL
651 and should be ignored by the caller. The KMS protocol
652 consumer is responsible for freeing all valid buffers
653 used for client data regardless of whether they are
654 allocated by the caller for input to the function or by
655 the implementation for output back to the caller.
656
657 @retval EFI_SUCCESS Successfully added all requested keys.
658 @retval EFI_OUT_OF_RESOURCES Could not allocate required resources.
659 @retval EFI_TIMEOUT Timed out waiting for device or key server. Check individual key
660 request(s) to see which ones may have been processed.
661 @retval EFI_BUFFER_TOO_SMALL If multiple keys are associated with a single identifier, and the
662 KeyValue buffer does not contain enough structures
663 (KeyDescriptorCount) to contain all the key data, then
664 the available structures will be filled and
665 KeyDescriptorCount will be updated to indicate the
666 number of keys which could not be processed
667 @retval EFI_ACCESS_DENIED Access was denied by the device or the key server; OR a
668 ClientId is required by the server and either none or an
669 invalid id was provided.
670 @retval EFI_DEVICE_ERROR Device or key server error. Check individual key request(s) to
671 see which ones may have been processed.
672 @retval EFI_INVALID_PARAMETER This is NULL, ClientId is required but it is NULL,
673 KeyDescriptorCount is NULL, or Keys is NULL.
674 @retval EFI_NOT_FOUND One or more EFI_KMS_KEY_DESCRIPTOR structures
675 could not be processed properly. KeyDescriptorCount
676 contains the number of structures which were successfully
677 processed. Individual structures will reflect the status of the
678 processing for that structure.
679 @retval EFI_UNSUPPORTED The implementation/KMS does not support this function.
680
681 **/
682 typedef
683 EFI_STATUS
684 (EFIAPI *EFI_KMS_ADD_KEY) (
685 IN EFI_KMS_PROTOCOL *This,
686 IN EFI_KMS_CLIENT_INFO *Client,
687 IN OUT UINT16 *KeyDescriptorCount,
688 IN OUT EFI_KMS_KEY_DESCRIPTOR *KeyDescriptors,
689 IN OUT UINTN *ClientDataSize OPTIONAL,
690 IN OUT VOID **ClientData OPTIONAL
691 );
692
693 /**
694 Delete an existing key from the KMS database.
695
696 @param[in] This Pointer to the EFI_KMS_PROTOCOL instance.
697 @param[in] Client Pointer to a valid EFI_KMS_CLIENT_INFO structure.
698 @param[in, out] KeyDescriptorCount Pointer to a count of the number of key descriptors to be
699 processed by this operation. On normal return, this
700 number will be updated with the number of key
701 descriptors successfully processed.
702 @param[in, out] KeyDescriptors Pointer to an array of EFI_KMS_KEY_DESCRIPTOR
703 structures which describe the keys to be deleted.
704 On input, the KeyId field for first key must contain
705 valid identifier data to be used for adding a key to
706 the KMS. The values for these fields in this key
707 definition will be considered default values for
708 subsequent keys requested in this operation. A value
709 of 0 in any subsequent KeyId field will be replaced
710 with the current default value. The KeyFormat and
711 KeyValue fields are ignored, but should be 0.
712 On return, the KeyStatus field will reflect the result
713 of the operation for each key request.
714 @param[in, out] ClientDataSize Pointer to the size, in bytes, of an arbitrary block of
715 data specified by the ClientData parameter. This
716 parameter may be NULL, in which case the ClientData
717 parameter will be ignored and no data will be
718 transferred to or from the KMS. If the parameter is
719 not NULL, then ClientData must be a valid pointer.
720 If the value pointed to is 0, no data will be transferred
721 to the KMS, but data may be returned by the KMS.
722 For all non-zero values *ClientData will be transferred
723 to the KMS, which may also return data to the caller.
724 In all cases, the value upon return to the caller will
725 be the size of the data block returned to the caller,
726 which will be zero if no data is returned from the KMS.
727 @param[in, out] ClientData Pointer to a pointer to an arbitrary block of data of
728 *ClientDataSize that is to be passed directly to the
729 KMS if it supports the use of client data. This
730 parameter may be NULL if and only if the
731 ClientDataSize parameter is also NULL. Upon return to
732 the caller, *ClientData points to a block of data of
733 *ClientDataSize that was returned from the KMS.
734 If the returned value for *ClientDataSize is zero,
735 then the returned value for *ClientData must be NULL
736 and should be ignored by the caller. The KMS protocol
737 consumer is responsible for freeing all valid buffers
738 used for client data regardless of whether they are
739 allocated by the caller for input to the function or by
740 the implementation for output back to the caller.
741
742 @retval EFI_SUCCESS Successfully deleted all requested keys.
743 @retval EFI_OUT_OF_RESOURCES Could not allocate required resources.
744 @retval EFI_TIMEOUT Timed out waiting for device or key server. Check individual key
745 request(s) to see which ones may have been processed.
746 @retval EFI_ACCESS_DENIED Access was denied by the device or the key server; OR a
747 ClientId is required by the server and either none or an
748 invalid id was provided.
749 @retval EFI_DEVICE_ERROR Device or key server error. Check individual key request(s) to
750 see which ones may have been processed.
751 @retval EFI_INVALID_PARAMETER This is NULL, ClientId is required but it is NULL,
752 KeyDescriptorCount is NULL, or Keys is NULL.
753 @retval EFI_NOT_FOUND One or more EFI_KMS_KEY_DESCRIPTOR structures
754 could not be processed properly. KeyDescriptorCount
755 contains the number of structures which were successfully
756 processed. Individual structures will reflect the status of the
757 processing for that structure.
758 @retval EFI_UNSUPPORTED The implementation/KMS does not support this function.
759
760 **/
761 typedef
762 EFI_STATUS
763 (EFIAPI *EFI_KMS_DELETE_KEY) (
764 IN EFI_KMS_PROTOCOL *This,
765 IN EFI_KMS_CLIENT_INFO *Client,
766 IN OUT UINT16 *KeyDescriptorCount,
767 IN OUT EFI_KMS_KEY_DESCRIPTOR *KeyDescriptors,
768 IN OUT UINTN *ClientDataSize OPTIONAL,
769 IN OUT VOID **ClientData OPTIONAL
770 );
771
772 /**
773 Get one or more attributes associated with a specified key identifier.
774 If none are found, the returned attributes count contains a value of zero.
775
776 @param[in] This Pointer to the EFI_KMS_PROTOCOL instance.
777 @param[in] Client Pointer to a valid EFI_KMS_CLIENT_INFO structure.
778 @param[in] KeyIdentifierSize Pointer to the size in bytes of the KeyIdentifier variable.
779 @param[in] KeyIdentifier Pointer to the key identifier associated with this key.
780 @param[in, out] KeyAttributesCount Pointer to the number of EFI_KMS_KEY_ATTRIBUTE
781 structures associated with the Key identifier. If none
782 are found, the count value is zero on return.
783 On input this value reflects the number of KeyAttributes
784 that may be returned.
785 On output, the value reflects the number of completed
786 KeyAttributes structures found.
787 @param[in, out] KeyAttributes Pointer to an array of EFI_KMS_KEY_ATTRIBUTE
788 structures associated with the Key Identifier.
789 On input, the fields in the structure should be NULL.
790 On output, the attribute fields will have updated values
791 for attributes associated with this key identifier.
792 @param[in, out] ClientDataSize Pointer to the size, in bytes, of an arbitrary block of
793 data specified by the ClientData parameter. This
794 parameter may be NULL, in which case the ClientData
795 parameter will be ignored and no data will be
796 transferred to or from the KMS. If the parameter is
797 not NULL, then ClientData must be a valid pointer.
798 If the value pointed to is 0, no data will be transferred
799 to the KMS, but data may be returned by the KMS.
800 For all non-zero values *ClientData will be transferred
801 to the KMS, which may also return data to the caller.
802 In all cases, the value upon return to the caller will
803 be the size of the data block returned to the caller,
804 which will be zero if no data is returned from the KMS.
805 @param[in, out] ClientData Pointer to a pointer to an arbitrary block of data of
806 *ClientDataSize that is to be passed directly to the
807 KMS if it supports the use of client data. This
808 parameter may be NULL if and only if the
809 ClientDataSize parameter is also NULL. Upon return to
810 the caller, *ClientData points to a block of data of
811 *ClientDataSize that was returned from the KMS.
812 If the returned value for *ClientDataSize is zero,
813 then the returned value for *ClientData must be NULL
814 and should be ignored by the caller. The KMS protocol
815 consumer is responsible for freeing all valid buffers
816 used for client data regardless of whether they are
817 allocated by the caller for input to the function or by
818 the implementation for output back to the caller.
819
820 @retval EFI_SUCCESS Successfully retrieved all key attributes.
821 @retval EFI_OUT_OF_RESOURCES Could not allocate resources for the method processing.
822 @retval EFI_TIMEOUT Timed out waiting for device or key server. Check individual key
823 attribute request(s) to see which ones may have been
824 processed.
825 @retval EFI_BUFFER_TOO_SMALL If multiple key attributes are associated with a single identifier,
826 and the KeyAttributes buffer does not contain enough
827 structures (KeyAttributesCount) to contain all the key
828 attributes data, then the available structures will be filled and
829 KeyAttributesCount will be updated to indicate the
830 number of key attributes which could not be processed.
831 @retval EFI_ACCESS_DENIED Access was denied by the device or the key server; OR a
832 ClientId is required by the server and either none or an
833 invalid id was provided.
834 @retval EFI_DEVICE_ERROR Device or key server error. Check individual key attribute
835 request(s) (i.e. key attribute status for each) to see which ones
836 may have been processed.
837 @retval EFI_INVALID_PARAMETER This is NULL, ClientId is required but it is NULL,
838 KeyIdentifierSize is NULL , or KeyIdentifier
839 is NULL, or KeyAttributes is NULL, or
840 KeyAttributesSize is NULL.
841 @retval EFI_NOT_FOUND The KeyIdentifier could not be found.
842 KeyAttributesCount contains zero. Individual
843 structures will reflect the status of the processing for that
844 structure.
845 @retval EFI_UNSUPPORTED The implementation/KMS does not support this function.
846
847 **/
848 typedef
849 EFI_STATUS
850 (EFIAPI *EFI_KMS_GET_KEY_ATTRIBUTES) (
851 IN EFI_KMS_PROTOCOL *This,
852 IN EFI_KMS_CLIENT_INFO *Client,
853 IN UINT8 *KeyIdentifierSize,
854 IN CONST VOID *KeyIdentifier,
855 IN OUT UINT16 *KeyAttributesCount,
856 IN OUT EFI_KMS_KEY_ATTRIBUTE *KeyAttributes,
857 IN OUT UINTN *ClientDataSize OPTIONAL,
858 IN OUT VOID **ClientData OPTIONAL
859 );
860
861 /**
862 Add one or more attributes to a key specified by a key identifier.
863
864 @param[in] This Pointer to the EFI_KMS_PROTOCOL instance.
865 @param[in] Client Pointer to a valid EFI_KMS_CLIENT_INFO structure.
866 @param[in] KeyIdentifierSize Pointer to the size in bytes of the KeyIdentifier variable.
867 @param[in] KeyIdentifier Pointer to the key identifier associated with this key.
868 @param[in, out] KeyAttributesCount Pointer to the number of EFI_KMS_KEY_ATTRIBUTE
869 structures to associate with the Key. On normal returns,
870 this number will be updated with the number of key
871 attributes successfully processed.
872 @param[in, out] KeyAttributes Pointer to an array of EFI_KMS_KEY_ATTRIBUTE
873 structures providing the attribute information to
874 associate with the key.
875 On input, the values for the fields in the structure
876 are completely filled in.
877 On return the KeyAttributeStatus field will reflect the
878 result of the operation for each key attribute request.
879 @param[in, out] ClientDataSize Pointer to the size, in bytes, of an arbitrary block of
880 data specified by the ClientData parameter. This
881 parameter may be NULL, in which case the ClientData
882 parameter will be ignored and no data will be
883 transferred to or from the KMS. If the parameter is
884 not NULL, then ClientData must be a valid pointer.
885 If the value pointed to is 0, no data will be transferred
886 to the KMS, but data may be returned by the KMS.
887 For all non-zero values *ClientData will be transferred
888 to the KMS, which may also return data to the caller.
889 In all cases, the value upon return to the caller will
890 be the size of the data block returned to the caller,
891 which will be zero if no data is returned from the KMS.
892 @param[in, out] ClientData Pointer to a pointer to an arbitrary block of data of
893 *ClientDataSize that is to be passed directly to the
894 KMS if it supports the use of client data. This
895 parameter may be NULL if and only if the
896 ClientDataSize parameter is also NULL. Upon return to
897 the caller, *ClientData points to a block of data of
898 *ClientDataSize that was returned from the KMS.
899 If the returned value for *ClientDataSize is zero,
900 then the returned value for *ClientData must be NULL
901 and should be ignored by the caller. The KMS protocol
902 consumer is responsible for freeing all valid buffers
903 used for client data regardless of whether they are
904 allocated by the caller for input to the function or by
905 the implementation for output back to the caller.
906
907 @retval EFI_SUCCESS Successfully added all requested key attributes.
908 @retval EFI_OUT_OF_RESOURCES Could not allocate required resources.
909 @retval EFI_TIMEOUT Timed out waiting for device or key server. Check individual key
910 attribute request(s) to see which ones may have been
911 processed.
912 @retval EFI_BUFFER_TOO_SMALL If multiple keys attributes are associated with a single key
913 identifier, and the attributes buffer does not contain
914 enough structures (KeyAttributesCount) to contain all
915 the data, then the available structures will be filled and
916 KeyAttributesCount will be updated to indicate the
917 number of key attributes which could not be processed. The
918 status of each key attribute is also updated indicating success or
919 failure for that attribute in case there are other errors for those
920 attributes that could be processed.
921 @retval EFI_ACCESS_DENIED Access was denied by the device or the key server; OR a
922 ClientId is required by the server and either none or an
923 invalid id was provided.
924 @retval EFI_DEVICE_ERROR Device or key server error. Check individual key attribute
925 request(s) (i.e. key attribute status for each) to see which ones
926 may have been processed.
927 @retval EFI_INVALID_PARAMETER This is NULL, ClientId is required but it is NULL,
928 KeyAttributesCount is NULL, or KeyAttributes
929 is NULL, or KeyIdentifierSize is NULL, or
930 KeyIdentifer is NULL.
931 @retval EFI_NOT_FOUND The KeyIdentifier could not be found. On return the
932 KeyAttributesCount contains the number of attributes
933 processed. Individual structures will reflect the status of the
934 processing for that structure.
935 @retval EFI_UNSUPPORTED The implementation/KMS does not support this function.
936
937 **/
938 typedef
939 EFI_STATUS
940 (EFIAPI *EFI_KMS_ADD_KEY_ATTRIBUTES) (
941 IN EFI_KMS_PROTOCOL *This,
942 IN EFI_KMS_CLIENT_INFO *Client,
943 IN UINT8 *KeyIdentifierSize,
944 IN CONST VOID *KeyIdentifier,
945 IN OUT UINT16 *KeyAttributesCount,
946 IN OUT EFI_KMS_KEY_ATTRIBUTE *KeyAttributes,
947 IN OUT UINTN *ClientDataSize OPTIONAL,
948 IN OUT VOID **ClientData OPTIONAL
949 );
950
951 /**
952 Delete attributes to a key specified by a key identifier.
953
954 @param[in] This Pointer to the EFI_KMS_PROTOCOL instance.
955 @param[in] Client Pointer to a valid EFI_KMS_CLIENT_INFO structure.
956 @param[in] KeyIdentifierSize Pointer to the size in bytes of the KeyIdentifier variable.
957 @param[in] KeyIdentifier Pointer to the key identifier associated with this key.
958 @param[in, out] KeyAttributesCount Pointer to the number of EFI_KMS_KEY_ATTRIBUTE
959 structures to associate with the Key.
960 On input, the count value is one or more.
961 On normal returns, this number will be updated with
962 the number of key attributes successfully processed.
963 @param[in, out] KeyAttributes Pointer to an array of EFI_KMS_KEY_ATTRIBUTE
964 structures providing the attribute information to
965 associate with the key.
966 On input, the values for the fields in the structure
967 are completely filled in.
968 On return the KeyAttributeStatus field will reflect the
969 result of the operation for each key attribute request.
970 @param[in, out] ClientDataSize Pointer to the size, in bytes, of an arbitrary block of
971 data specified by the ClientData parameter. This
972 parameter may be NULL, in which case the ClientData
973 parameter will be ignored and no data will be
974 transferred to or from the KMS. If the parameter is
975 not NULL, then ClientData must be a valid pointer.
976 If the value pointed to is 0, no data will be transferred
977 to the KMS, but data may be returned by the KMS.
978 For all non-zero values *ClientData will be transferred
979 to the KMS, which may also return data to the caller.
980 In all cases, the value upon return to the caller will
981 be the size of the data block returned to the caller,
982 which will be zero if no data is returned from the KMS.
983 @param[in, out] ClientData Pointer to a pointer to an arbitrary block of data of
984 *ClientDataSize that is to be passed directly to the
985 KMS if it supports the use of client data. This
986 parameter may be NULL if and only if the
987 ClientDataSize parameter is also NULL. Upon return to
988 the caller, *ClientData points to a block of data of
989 *ClientDataSize that was returned from the KMS.
990 If the returned value for *ClientDataSize is zero,
991 then the returned value for *ClientData must be NULL
992 and should be ignored by the caller. The KMS protocol
993 consumer is responsible for freeing all valid buffers
994 used for client data regardless of whether they are
995 allocated by the caller for input to the function or by
996 the implementation for output back to the caller.
997
998 @retval EFI_SUCCESS Successfully deleted all requested key attributes.
999 @retval EFI_OUT_OF_RESOURCES Could not allocate required resources.
1000 @retval EFI_TIMEOUT Timed out waiting for device or key server. Check individual key
1001 attribute request(s) to see which ones may have been
1002 processed.
1003 @retval EFI_ACCESS_DENIED Access was denied by the device or the key server; OR a
1004 ClientId is required by the server and either none or an
1005 invalid id was provided.
1006 @retval EFI_DEVICE_ERROR Device or key server error. Check individual key attribute
1007 request(s) (i.e. key attribute status for each) to see which ones
1008 may have been processed.
1009 @retval EFI_INVALID_PARAMETER This is NULL, ClientId is required but it is NULL,
1010 KeyAttributesCount is NULL, or
1011 KeyAttributes is NULL, or KeyIdentifierSize
1012 is NULL, or KeyIdentifer is NULL.
1013 @retval EFI_NOT_FOUND The KeyIdentifier could not be found or the attribute
1014 could not be found. On return the KeyAttributesCount
1015 contains the number of attributes processed. Individual
1016 structures will reflect the status of the processing for that
1017 structure.
1018 @retval EFI_UNSUPPORTED The implementation/KMS does not support this function.
1019
1020 **/
1021 typedef
1022 EFI_STATUS
1023 (EFIAPI *EFI_KMS_DELETE_KEY_ATTRIBUTES) (
1024 IN EFI_KMS_PROTOCOL *This,
1025 IN EFI_KMS_CLIENT_INFO *Client,
1026 IN UINT8 *KeyIdentifierSize,
1027 IN CONST VOID *KeyIdentifier,
1028 IN OUT UINT16 *KeyAttributesCount,
1029 IN OUT EFI_KMS_KEY_ATTRIBUTE *KeyAttributes,
1030 IN OUT UINTN *ClientDataSize OPTIONAL,
1031 IN OUT VOID **ClientData OPTIONAL
1032 );
1033
1034 /**
1035 Retrieve one or more key that has matched all of the specified key attributes.
1036
1037 @param[in] This Pointer to the EFI_KMS_PROTOCOL instance.
1038 @param[in] Client Pointer to a valid EFI_KMS_CLIENT_INFO structure.
1039 @param[in, out] KeyAttributesCount Pointer to a count of the number of key attribute structures
1040 that must be matched for each returned key descriptor.
1041 On input the count value is one or more.
1042 On normal returns, this number will be updated with
1043 the number of key attributes successfully processed.
1044 @param[in, out] KeyAttributes Pointer to an array of EFI_KMS_KEY_ATTRIBUTE
1045 structure to search for.
1046 On input, the values for the fields in the structure are
1047 completely filled in.
1048 On return the KeyAttributeStatus field will reflect the
1049 result of the operation for each key attribute request.
1050 @param[in, out] KeyDescriptorCount Pointer to a count of the number of key descriptors matched
1051 by this operation.
1052 On entry, this number will be zero.
1053 On return, this number will be updated to the number
1054 of key descriptors successfully found.
1055 @param[in, out] KeyDescriptors Pointer to an array of EFI_KMS_KEY_DESCRIPTOR
1056 structures which describe the keys from the KMS
1057 having the KeyAttribute(s) specified.
1058 On input, this pointer will be NULL.
1059 On output, the array will contain an
1060 EFI_KMS_KEY_DESCRIPTOR structure for each key
1061 meeting the search criteria. Memory for the array
1062 and all KeyValue fields will be allocated with the
1063 EfiBootServicesData type and must be freed by the
1064 caller when it is no longer needed. Also, the KeyStatus
1065 field of each descriptor will reflect the result of the
1066 request relative to that key descriptor.
1067 @param[in, out] ClientDataSize Pointer to the size, in bytes, of an arbitrary block of
1068 data specified by the ClientData parameter. This
1069 parameter may be NULL, in which case the ClientData
1070 parameter will be ignored and no data will be
1071 transferred to or from the KMS. If the parameter is
1072 not NULL, then ClientData must be a valid pointer.
1073 If the value pointed to is 0, no data will be transferred
1074 to the KMS, but data may be returned by the KMS.
1075 For all non-zero values *ClientData will be transferred
1076 to the KMS, which may also return data to the caller.
1077 In all cases, the value upon return to the caller will
1078 be the size of the data block returned to the caller,
1079 which will be zero if no data is returned from the KMS.
1080 @param[in, out] ClientData Pointer to a pointer to an arbitrary block of data of
1081 *ClientDataSize that is to be passed directly to the
1082 KMS if it supports the use of client data. This
1083 parameter may be NULL if and only if the
1084 ClientDataSize parameter is also NULL. Upon return to
1085 the caller, *ClientData points to a block of data of
1086 *ClientDataSize that was returned from the KMS.
1087 If the returned value for *ClientDataSize is zero,
1088 then the returned value for *ClientData must be NULL
1089 and should be ignored by the caller. The KMS protocol
1090 consumer is responsible for freeing all valid buffers
1091 used for client data regardless of whether they are
1092 allocated by the caller for input to the function or by
1093 the implementation for output back to the caller.
1094
1095 @retval EFI_SUCCESS Successfully retrieved all requested keys.
1096 @retval EFI_OUT_OF_RESOURCES Could not allocate required resources.
1097 @retval EFI_TIMEOUT Timed out waiting for device or key server. Check individual key
1098 attribute request(s) to see which ones may have been
1099 processed.
1100 @retval EFI_BUFFER_TOO_SMALL If multiple keys are associated with the attribute(s), and the
1101 KeyValue buffer does not contain enough structures
1102 (KeyDescriptorCount) to contain all the key data, then
1103 the available structures will be filled and
1104 KeyDescriptorCount will be updated to indicate the
1105 number of keys which could not be processed.
1106 @retval EFI_ACCESS_DENIED Access was denied by the device or the key server; OR a
1107 ClientId is required by the server and either none or an
1108 invalid id was provided.
1109 @retval EFI_DEVICE_ERROR Device or key server error. Check individual key attribute
1110 request(s) (i.e. key attribute status for each) to see which ones
1111 may have been processed.
1112 @retval EFI_INVALID_PARAMETER This is NULL, ClientId is required but it is NULL,
1113 KeyDescriptorCount is NULL, or
1114 KeyDescriptors is NULL or KeyAttributes is
1115 NULL, or KeyAttributesCount is NULL.
1116 @retval EFI_NOT_FOUND One or more EFI_KMS_KEY_ATTRIBUTE structures could
1117 not be processed properly. KeyAttributeCount contains
1118 the number of structures which were successfully processed.
1119 Individual structures will reflect the status of the processing for
1120 that structure.
1121 @retval EFI_UNSUPPORTED The implementation/KMS does not support this function.
1122
1123 **/
1124 typedef
1125 EFI_STATUS
1126 (EFIAPI *EFI_KMS_GET_KEY_BY_ATTRIBUTES) (
1127 IN EFI_KMS_PROTOCOL *This,
1128 IN EFI_KMS_CLIENT_INFO *Client,
1129 IN OUT UINTN *KeyAttributeCount,
1130 IN OUT EFI_KMS_KEY_ATTRIBUTE *KeyAttributes,
1131 IN OUT UINTN *KeyDescriptorCount,
1132 IN OUT EFI_KMS_KEY_DESCRIPTOR *KeyDescriptors,
1133 IN OUT UINTN *ClientDataSize OPTIONAL,
1134 IN OUT VOID **ClientData OPTIONAL
1135 );
1136
1137 ///
1138 /// The Key Management Service (KMS) protocol provides services to generate, store, retrieve,
1139 /// and manage cryptographic keys.
1140 ///
1141 struct _EFI_KMS_PROTOCOL {
1142 ///
1143 /// Get the current status of the key management service. If the implementation has not yet
1144 /// connected to the KMS, then a call to this function will initiate a connection. This is the
1145 /// only function that is valid for use prior to the service being marked available.
1146 ///
1147 EFI_KMS_GET_SERVICE_STATUS GetServiceStatus;
1148 ///
1149 /// Register a specific client with the KMS.
1150 ///
1151 EFI_KMS_REGISTER_CLIENT RegisterClient;
1152 ///
1153 /// Request the generation of a new key and retrieve it.
1154 ///
1155 EFI_KMS_CREATE_KEY CreateKey;
1156 ///
1157 /// Retrieve an existing key.
1158 ///
1159 EFI_KMS_GET_KEY GetKey;
1160 ///
1161 /// Add a local key to KMS database. If there is an existing key with this key identifier in the
1162 /// KMS database, it will be replaced with the new key.
1163 ///
1164 EFI_KMS_ADD_KEY AddKey;
1165 ///
1166 /// Delete an existing key from the KMS database.
1167 ///
1168 EFI_KMS_DELETE_KEY DeleteKey;
1169 ///
1170 /// Get attributes for an existing key in the KMS database.
1171 ///
1172 EFI_KMS_GET_KEY_ATTRIBUTES GetKeyAttributes;
1173 ///
1174 /// Add attributes to an existing key in the KMS database.
1175 ///
1176 EFI_KMS_ADD_KEY_ATTRIBUTES AddKeyAttributes;
1177 ///
1178 /// Delete attributes for an existing key in the KMS database.
1179 ///
1180 EFI_KMS_DELETE_KEY_ATTRIBUTES DeleteKeyAttributes;
1181 ///
1182 /// Get existing key(s) with the specified attributes.
1183 ///
1184 EFI_KMS_GET_KEY_BY_ATTRIBUTES GetKeyByAttributes;
1185 ///
1186 /// The version of this EFI_KMS_PROTOCOL structure. This must be set to 0x00020040 for
1187 /// the initial version of this protocol.
1188 ///
1189 UINT32 ProtocolVersion;
1190 ///
1191 /// Optional GUID used to identify a specific KMS. This GUID may be supplied by the provider,
1192 /// by the implementation, or may be null. If is null, then the ServiceName must not be null.
1193 ///
1194 EFI_GUID ServiceId;
1195 ///
1196 /// Optional pointer to a unicode string which may be used to identify the KMS or provide
1197 /// other information about the supplier.
1198 ///
1199 CHAR16 *ServiceName;
1200 ///
1201 /// Optional 32-bit value which may be used to indicate the version of the KMS provided by
1202 /// the supplier.
1203 ///
1204 UINT32 ServiceVersion;
1205 ///
1206 /// TRUE if and only if the service is active and available for use. To avoid unnecessary
1207 /// delays in POST, this protocol may be installed without connecting to the service. In this
1208 /// case, the first call to the GetServiceStatus () function will cause the implementation to
1209 /// connect to the supported service and mark it as available. The capabilities of this service
1210 /// as defined in the reminder of this protocol are not guaranteed to be valid until the service
1211 /// has been marked available.
1212 ///
1213 BOOLEAN ServiceAvailable;
1214 ///
1215 /// TRUE if and only if the service supports client identifiers. Client identifiers may be used
1216 /// for auditing, access control or any other purpose specific to the implementation.
1217 ///
1218 BOOLEAN ClientIdSupported;
1219 ///
1220 /// TRUE if and only if the service requires a client identifier in order to process key requests.
1221 /// FALSE otherwise.
1222 ///
1223 BOOLEAN ClientIdRequired;
1224 ///
1225 /// The maximum size in bytes for the client identifier.
1226 ///
1227 UINT16 ClientIdMaxSize;
1228 ///
1229 /// The client name string type(s) supported by the KMS service. If client names are not
1230 /// supported, this field will be set the EFI_KMS_DATA_TYPE_NONE. Otherwise, it will be set
1231 /// to the inclusive 'OR' of all client name formats supported. Client names may be used for
1232 /// auditing, access control or any other purpose specific to the implementation.
1233 ///
1234 UINT8 ClientNameStringTypes;
1235 ///
1236 /// TRUE if only if the KMS requires a client name to be supplied to the service.
1237 /// FALSE otherwise.
1238 ///
1239 BOOLEAN ClientNameRequired;
1240 ///
1241 /// The maximum number of characters allowed for the client name.
1242 ///
1243 UINT16 ClientNameMaxCount;
1244 ///
1245 /// TRUE if and only if the service supports arbitrary client data requests. The use of client
1246 /// data requires the caller to have specific knowledge of the individual KMS service and
1247 /// should be used only if absolutely necessary.
1248 /// FALSE otherwise.
1249 ///
1250 BOOLEAN ClientDataSupported;
1251 ///
1252 /// The maximum size in bytes for the client data. If the maximum data size is not specified
1253 /// by the KMS or it is not known, then this field must be filled with all ones.
1254 ///
1255 UINTN ClientDataMaxSize;
1256 ///
1257 /// TRUE if variable length key identifiers are supported.
1258 /// FALSE if a fixed length key identifier is supported.
1259 ///
1260 BOOLEAN KeyIdVariableLenSupported;
1261 ///
1262 /// If KeyIdVariableLenSupported is TRUE, this is the maximum supported key identifier length
1263 /// in bytes. Otherwise this is the fixed length of key identifier supported. Key ids shorter
1264 /// than the fixed length will be padded on the right with blanks.
1265 ///
1266 UINTN KeyIdMaxSize;
1267 ///
1268 /// The number of key format/size GUIDs returned in the KeyFormats field.
1269 ///
1270 UINTN KeyFormatsCount;
1271 ///
1272 /// A pointer to an array of EFI_GUID values which specify key formats/sizes supported by
1273 /// this KMS. Each format/size pair will be specified by a separate EFI_GUID. At least one
1274 /// key format/size must be supported. All formats/sizes with the same hashing algorithm
1275 /// must be contiguous in the array, and for each hashing algorithm, the key sizes must be in
1276 /// ascending order. See "Related Definitions" for GUIDs which identify supported key formats/sizes.
1277 /// This list of GUIDs supported by the KMS is not required to be exhaustive, and the KMS
1278 /// may provide support for additional key formats/sizes. Users may request key information
1279 /// using an arbitrary GUID, but any GUID not recognized by the implementation or not
1280 /// supported by the KMS will return an error code of EFI_UNSUPPORTED
1281 ///
1282 EFI_GUID *KeyFormats;
1283 ///
1284 /// TRUE if key attributes are supported.
1285 /// FALSE if key attributes are not supported.
1286 ///
1287 BOOLEAN KeyAttributesSupported;
1288 ///
1289 /// The key attribute identifier string type(s) supported by the KMS service. If key attributes
1290 /// are not supported, this field will be set to EFI_KMS_DATA_TYPE_NONE. Otherwise, it will
1291 /// be set to the inclusive 'OR' of all key attribute identifier string types supported.
1292 /// EFI_KMS_DATA_TYPE_BINARY is not valid for this field.
1293 ///
1294 UINT8 KeyAttributeIdStringTypes;
1295 UINT16 KeyAttributeIdMaxCount;
1296 ///
1297 /// The number of predefined KeyAttributes structures returned in the KeyAttributes
1298 /// parameter. If the KMS does not support predefined key attributes, or if it does not
1299 /// provide a method to obtain predefined key attributes data, then this field must be zero.
1300 ///
1301 UINTN KeyAttributesCount;
1302 ///
1303 /// A pointer to an array of KeyAttributes structures which contains the predefined
1304 /// attributes supported by this KMS. Each structure must contain a valid key attribute
1305 /// identifier and should provide any other information as appropriate for the attribute,
1306 /// including a default value if one exists. This variable must be set to NULL if the
1307 /// KeyAttributesCount variable is zero. It must point to a valid buffer if the
1308 /// KeyAttributesCount variable is non-zero.
1309 /// This list of predefined attributes is not required to be exhaustive, and the KMS may
1310 /// provide additional predefined attributes not enumerated in this list. The implementation
1311 /// does not distinguish between predefined and used defined attributes, and therefore,
1312 /// predefined attributes not enumerated will still be processed to the KMS.
1313 ///
1314 EFI_KMS_KEY_ATTRIBUTE *KeyAttributes;
1315 };
1316
1317 extern EFI_GUID gEfiKmsFormatGeneric128Guid;
1318 extern EFI_GUID gEfiKmsFormatGeneric160Guid;
1319 extern EFI_GUID gEfiKmsFormatGeneric256Guid;
1320 extern EFI_GUID gEfiKmsFormatGeneric512Guid;
1321 extern EFI_GUID gEfiKmsFormatGeneric1024Guid;
1322 extern EFI_GUID gEfiKmsFormatGeneric2048Guid;
1323 extern EFI_GUID gEfiKmsFormatGeneric3072Guid;
1324 extern EFI_GUID gEfiKmsFormatMd2128Guid;
1325 extern EFI_GUID gEfiKmsFormatMdc2128Guid;
1326 extern EFI_GUID gEfiKmsFormatMd4128Guid;
1327 extern EFI_GUID gEfiKmsFormatMdc4128Guid;
1328 extern EFI_GUID gEfiKmsFormatMd5128Guid;
1329 extern EFI_GUID gEfiKmsFormatMd5sha128Guid;
1330 extern EFI_GUID gEfiKmsFormatSha1160Guid;
1331 extern EFI_GUID gEfiKmsFormatSha256256Guid;
1332 extern EFI_GUID gEfiKmsFormatSha512512Guid;
1333 extern EFI_GUID gEfiKmsFormatAesxts128Guid;
1334 extern EFI_GUID gEfiKmsFormatAesxts256Guid;
1335 extern EFI_GUID gEfiKmsFormatAescbc128Guid;
1336 extern EFI_GUID gEfiKmsFormatAescbc256Guid;
1337 extern EFI_GUID gEfiKmsFormatRsasha11024Guid;
1338 extern EFI_GUID gEfiKmsFormatRsasha12048Guid;
1339 extern EFI_GUID gEfiKmsFormatRsasha2562048Guid;
1340 extern EFI_GUID gEfiKmsFormatRsasha2563072Guid;
1341 extern EFI_GUID gEfiKmsProtocolGuid;
1342
1343 #endif