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