]>
Commit | Line | Data |
---|---|---|
3b0e0430 MK |
1 | /** @file\r |
2 | This Protocol provides Crypto services to DXE modules\r | |
3 | \r | |
4 | Copyright (C) Microsoft Corporation. All rights reserved.\r | |
5 | SPDX-License-Identifier: BSD-2-Clause-Patent\r | |
6 | \r | |
7 | **/\r | |
8 | \r | |
9 | #ifndef __EDKII_CRYPTO_PROTOCOL_H__\r | |
10 | #define __EDKII_CRYPTO_PROTOCOL_H__\r | |
11 | \r | |
12 | #include <Base.h>\r | |
13 | #include <Library/BaseCryptLib.h>\r | |
14 | #include <Library/PcdLib.h>\r | |
15 | \r | |
16 | ///\r | |
17 | /// The version of the EDK II Crypto Protocol.\r | |
18 | /// As APIs are added to BaseCryptLib, the EDK II Crypto Protocol is extended\r | |
19 | /// with new APIs at the end of the EDK II Crypto Protocol structure. Each time\r | |
20 | /// the EDK II Crypto Protocol is extended, this version define must be\r | |
21 | /// increased.\r | |
22 | ///\r | |
23 | #define EDKII_CRYPTO_VERSION 6\r | |
24 | \r | |
25 | ///\r | |
26 | /// EDK II Crypto Protocol forward declaration\r | |
27 | ///\r | |
28 | typedef struct _EDKII_CRYPTO_PROTOCOL EDKII_CRYPTO_PROTOCOL;\r | |
29 | \r | |
30 | /**\r | |
31 | Returns the version of the EDK II Crypto Protocol.\r | |
32 | \r | |
33 | @return The version of the EDK II Crypto Protocol.\r | |
34 | \r | |
35 | **/\r | |
36 | typedef\r | |
37 | UINTN\r | |
38 | (EFIAPI *EDKII_CRYPTO_GET_VERSION) (\r | |
39 | VOID\r | |
40 | );\r | |
41 | \r | |
42 | //=====================================================================================\r | |
43 | // MAC (Message Authentication Code) Primitive\r | |
44 | //=====================================================================================\r | |
45 | /**\r | |
46 | Allocates and initializes one HMAC_CTX context for subsequent HMAC-MD5 use.\r | |
47 | \r | |
48 | If this interface is not supported, then return NULL.\r | |
49 | \r | |
50 | @return Pointer to the HMAC_CTX context that has been initialized.\r | |
51 | If the allocations fails, HmacMd5New() returns NULL.\r | |
52 | @retval NULL This interface is not supported.\r | |
53 | \r | |
54 | **/\r | |
55 | typedef\r | |
56 | VOID*\r | |
57 | (EFIAPI *EDKII_CRYPTO_HMAC_MD5_NEW) (\r | |
58 | VOID\r | |
59 | );\r | |
60 | \r | |
61 | /**\r | |
62 | Release the specified HMAC_CTX context.\r | |
63 | \r | |
64 | If this interface is not supported, then do nothing.\r | |
65 | \r | |
66 | @param[in] HmacMd5Ctx Pointer to the HMAC_CTX context to be released.\r | |
67 | \r | |
68 | **/\r | |
69 | typedef\r | |
70 | VOID\r | |
71 | (EFIAPI *EDKII_CRYPTO_HMAC_MD5_FREE) (\r | |
72 | IN VOID *HmacMd5Ctx\r | |
73 | );\r | |
74 | \r | |
75 | /**\r | |
76 | Set user-supplied key for subsequent use. It must be done before any\r | |
77 | calling to HmacMd5Update().\r | |
78 | \r | |
79 | If HmacMd5Context is NULL, then return FALSE.\r | |
80 | If this interface is not supported, then return FALSE.\r | |
81 | \r | |
82 | @param[out] HmacMd5Context Pointer to HMAC-MD5 context.\r | |
83 | @param[in] Key Pointer to the user-supplied key.\r | |
84 | @param[in] KeySize Key size in bytes.\r | |
85 | \r | |
86 | @retval TRUE HMAC-MD5 context initialization succeeded.\r | |
87 | @retval FALSE HMAC-MD5 context initialization failed.\r | |
88 | @retval FALSE This interface is not supported.\r | |
89 | \r | |
90 | **/\r | |
91 | typedef\r | |
92 | BOOLEAN\r | |
93 | (EFIAPI *EDKII_CRYPTO_HMAC_MD5_SET_KEY) (\r | |
94 | OUT VOID *HmacMd5Context,\r | |
95 | IN CONST UINT8 *Key,\r | |
96 | IN UINTN KeySize\r | |
97 | );\r | |
98 | \r | |
99 | /**\r | |
100 | Makes a copy of an existing HMAC-MD5 context.\r | |
101 | \r | |
102 | If HmacMd5Context is NULL, then return FALSE.\r | |
103 | If NewHmacMd5Context is NULL, then return FALSE.\r | |
104 | If this interface is not supported, then return FALSE.\r | |
105 | \r | |
106 | @param[in] HmacMd5Context Pointer to HMAC-MD5 context being copied.\r | |
107 | @param[out] NewHmacMd5Context Pointer to new HMAC-MD5 context.\r | |
108 | \r | |
109 | @retval TRUE HMAC-MD5 context copy succeeded.\r | |
110 | @retval FALSE HMAC-MD5 context copy failed.\r | |
111 | @retval FALSE This interface is not supported.\r | |
112 | \r | |
113 | **/\r | |
114 | typedef\r | |
115 | BOOLEAN\r | |
116 | (EFIAPI *EDKII_CRYPTO_HMAC_MD5_DUPLICATE) (\r | |
117 | IN CONST VOID *HmacMd5Context,\r | |
118 | OUT VOID *NewHmacMd5Context\r | |
119 | );\r | |
120 | \r | |
121 | /**\r | |
122 | Digests the input data and updates HMAC-MD5 context.\r | |
123 | \r | |
124 | This function performs HMAC-MD5 digest on a data buffer of the specified size.\r | |
125 | It can be called multiple times to compute the digest of long or discontinuous data streams.\r | |
126 | HMAC-MD5 context should be initialized by HmacMd5New(), and should not be finalized by\r | |
127 | HmacMd5Final(). Behavior with invalid context is undefined.\r | |
128 | \r | |
129 | If HmacMd5Context is NULL, then return FALSE.\r | |
130 | If this interface is not supported, then return FALSE.\r | |
131 | \r | |
132 | @param[in, out] HmacMd5Context Pointer to the HMAC-MD5 context.\r | |
133 | @param[in] Data Pointer to the buffer containing the data to be digested.\r | |
134 | @param[in] DataSize Size of Data buffer in bytes.\r | |
135 | \r | |
136 | @retval TRUE HMAC-MD5 data digest succeeded.\r | |
137 | @retval FALSE HMAC-MD5 data digest failed.\r | |
138 | @retval FALSE This interface is not supported.\r | |
139 | \r | |
140 | **/\r | |
141 | typedef\r | |
142 | BOOLEAN\r | |
143 | (EFIAPI *EDKII_CRYPTO_HMAC_MD5_UPDATE) (\r | |
144 | IN OUT VOID *HmacMd5Context,\r | |
145 | IN CONST VOID *Data,\r | |
146 | IN UINTN DataSize\r | |
147 | );\r | |
148 | \r | |
149 | \r | |
150 | /**\r | |
151 | Completes computation of the HMAC-MD5 digest value.\r | |
152 | \r | |
153 | This function completes HMAC-MD5 hash computation and retrieves the digest value into\r | |
154 | the specified memory. After this function has been called, the HMAC-MD5 context cannot\r | |
155 | be used again.\r | |
156 | HMAC-MD5 context should be initialized by HmacMd5New(), and should not be finalized by\r | |
157 | HmacMd5Final(). Behavior with invalid HMAC-MD5 context is undefined.\r | |
158 | \r | |
159 | If HmacMd5Context is NULL, then return FALSE.\r | |
160 | If HmacValue is NULL, then return FALSE.\r | |
161 | If this interface is not supported, then return FALSE.\r | |
162 | \r | |
163 | @param[in, out] HmacMd5Context Pointer to the HMAC-MD5 context.\r | |
164 | @param[out] HmacValue Pointer to a buffer that receives the HMAC-MD5 digest\r | |
165 | value (16 bytes).\r | |
166 | \r | |
167 | @retval TRUE HMAC-MD5 digest computation succeeded.\r | |
168 | @retval FALSE HMAC-MD5 digest computation failed.\r | |
169 | @retval FALSE This interface is not supported.\r | |
170 | \r | |
171 | **/\r | |
172 | typedef\r | |
173 | BOOLEAN\r | |
174 | (EFIAPI *EDKII_CRYPTO_HMAC_MD5_FINAL) (\r | |
175 | IN OUT VOID *HmacMd5Context,\r | |
176 | OUT UINT8 *HmacValue\r | |
177 | );\r | |
178 | \r | |
179 | \r | |
180 | /**\r | |
181 | Allocates and initializes one HMAC_CTX context for subsequent HMAC-SHA1 use.\r | |
182 | \r | |
183 | If this interface is not supported, then return NULL.\r | |
184 | \r | |
185 | @return Pointer to the HMAC_CTX context that has been initialized.\r | |
186 | If the allocations fails, HmacSha1New() returns NULL.\r | |
187 | @return NULL This interface is not supported.\r | |
188 | \r | |
189 | **/\r | |
190 | typedef\r | |
191 | VOID*\r | |
192 | (EFIAPI *EDKII_CRYPTO_HMAC_SHA1_NEW) (\r | |
193 | VOID\r | |
194 | );\r | |
195 | \r | |
196 | /**\r | |
197 | Release the specified HMAC_CTX context.\r | |
198 | \r | |
199 | If this interface is not supported, then do nothing.\r | |
200 | \r | |
201 | @param[in] HmacSha1Ctx Pointer to the HMAC_CTX context to be released.\r | |
202 | \r | |
203 | **/\r | |
204 | typedef\r | |
205 | VOID\r | |
206 | (EFIAPI *EDKII_CRYPTO_HMAC_SHA1_FREE) (\r | |
207 | IN VOID *HmacSha1Ctx\r | |
208 | );\r | |
209 | \r | |
210 | \r | |
211 | /**\r | |
212 | Set user-supplied key for subsequent use. It must be done before any\r | |
213 | calling to HmacSha1Update().\r | |
214 | \r | |
215 | If HmacSha1Context is NULL, then return FALSE.\r | |
216 | If this interface is not supported, then return FALSE.\r | |
217 | \r | |
218 | @param[out] HmacSha1Context Pointer to HMAC-SHA1 context.\r | |
219 | @param[in] Key Pointer to the user-supplied key.\r | |
220 | @param[in] KeySize Key size in bytes.\r | |
221 | \r | |
222 | @retval TRUE The Key is set successfully.\r | |
223 | @retval FALSE The Key is set unsuccessfully.\r | |
224 | @retval FALSE This interface is not supported.\r | |
225 | \r | |
226 | **/\r | |
227 | typedef\r | |
228 | BOOLEAN\r | |
229 | (EFIAPI *EDKII_CRYPTO_HMAC_SHA1_SET_KEY) (\r | |
230 | OUT VOID *HmacSha1Context,\r | |
231 | IN CONST UINT8 *Key,\r | |
232 | IN UINTN KeySize\r | |
233 | );\r | |
234 | \r | |
235 | \r | |
236 | /**\r | |
237 | Makes a copy of an existing HMAC-SHA1 context.\r | |
238 | \r | |
239 | If HmacSha1Context is NULL, then return FALSE.\r | |
240 | If NewHmacSha1Context is NULL, then return FALSE.\r | |
241 | If this interface is not supported, then return FALSE.\r | |
242 | \r | |
243 | @param[in] HmacSha1Context Pointer to HMAC-SHA1 context being copied.\r | |
244 | @param[out] NewHmacSha1Context Pointer to new HMAC-SHA1 context.\r | |
245 | \r | |
246 | @retval TRUE HMAC-SHA1 context copy succeeded.\r | |
247 | @retval FALSE HMAC-SHA1 context copy failed.\r | |
248 | @retval FALSE This interface is not supported.\r | |
249 | \r | |
250 | **/\r | |
251 | typedef\r | |
252 | BOOLEAN\r | |
253 | (EFIAPI *EDKII_CRYPTO_HMAC_SHA1_DUPLICATE) (\r | |
254 | IN CONST VOID *HmacSha1Context,\r | |
255 | OUT VOID *NewHmacSha1Context\r | |
256 | );\r | |
257 | \r | |
258 | \r | |
259 | /**\r | |
260 | Digests the input data and updates HMAC-SHA1 context.\r | |
261 | \r | |
262 | This function performs HMAC-SHA1 digest on a data buffer of the specified size.\r | |
263 | It can be called multiple times to compute the digest of long or discontinuous data streams.\r | |
264 | HMAC-SHA1 context should be initialized by HmacSha1New(), and should not be finalized by\r | |
265 | HmacSha1Final(). Behavior with invalid context is undefined.\r | |
266 | \r | |
267 | If HmacSha1Context is NULL, then return FALSE.\r | |
268 | If this interface is not supported, then return FALSE.\r | |
269 | \r | |
270 | @param[in, out] HmacSha1Context Pointer to the HMAC-SHA1 context.\r | |
271 | @param[in] Data Pointer to the buffer containing the data to be digested.\r | |
272 | @param[in] DataSize Size of Data buffer in bytes.\r | |
273 | \r | |
274 | @retval TRUE HMAC-SHA1 data digest succeeded.\r | |
275 | @retval FALSE HMAC-SHA1 data digest failed.\r | |
276 | @retval FALSE This interface is not supported.\r | |
277 | \r | |
278 | **/\r | |
279 | typedef\r | |
280 | BOOLEAN\r | |
281 | (EFIAPI *EDKII_CRYPTO_HMAC_SHA1_UPDATE) (\r | |
282 | IN OUT VOID *HmacSha1Context,\r | |
283 | IN CONST VOID *Data,\r | |
284 | IN UINTN DataSize\r | |
285 | );\r | |
286 | \r | |
287 | \r | |
288 | /**\r | |
289 | Completes computation of the HMAC-SHA1 digest value.\r | |
290 | \r | |
291 | This function completes HMAC-SHA1 hash computation and retrieves the digest value into\r | |
292 | the specified memory. After this function has been called, the HMAC-SHA1 context cannot\r | |
293 | be used again.\r | |
294 | HMAC-SHA1 context should be initialized by HmacSha1New(), and should not be finalized\r | |
295 | by HmacSha1Final(). Behavior with invalid HMAC-SHA1 context is undefined.\r | |
296 | \r | |
297 | If HmacSha1Context is NULL, then return FALSE.\r | |
298 | If HmacValue is NULL, then return FALSE.\r | |
299 | If this interface is not supported, then return FALSE.\r | |
300 | \r | |
301 | @param[in, out] HmacSha1Context Pointer to the HMAC-SHA1 context.\r | |
302 | @param[out] HmacValue Pointer to a buffer that receives the HMAC-SHA1 digest\r | |
303 | value (20 bytes).\r | |
304 | \r | |
305 | @retval TRUE HMAC-SHA1 digest computation succeeded.\r | |
306 | @retval FALSE HMAC-SHA1 digest computation failed.\r | |
307 | @retval FALSE This interface is not supported.\r | |
308 | \r | |
309 | **/\r | |
310 | typedef\r | |
311 | BOOLEAN\r | |
312 | (EFIAPI *EDKII_CRYPTO_HMAC_SHA1_FINAL) (\r | |
313 | IN OUT VOID *HmacSha1Context,\r | |
314 | OUT UINT8 *HmacValue\r | |
315 | );\r | |
316 | \r | |
317 | \r | |
318 | /**\r | |
319 | Allocates and initializes one HMAC_CTX context for subsequent HMAC-SHA256 use.\r | |
320 | \r | |
321 | @return Pointer to the HMAC_CTX context that has been initialized.\r | |
322 | If the allocations fails, HmacSha256New() returns NULL.\r | |
323 | \r | |
324 | **/\r | |
325 | typedef\r | |
326 | VOID *\r | |
327 | (EFIAPI *EDKII_CRYPTO_HMAC_SHA256_NEW) (\r | |
328 | VOID\r | |
329 | );\r | |
330 | \r | |
331 | /**\r | |
332 | Release the specified HMAC_CTX context.\r | |
333 | \r | |
334 | @param[in] HmacSha256Ctx Pointer to the HMAC_CTX context to be released.\r | |
335 | \r | |
336 | **/\r | |
337 | typedef\r | |
338 | VOID\r | |
339 | (EFIAPI *EDKII_CRYPTO_HMAC_SHA256_FREE) (\r | |
340 | IN VOID *HmacSha256Ctx\r | |
341 | );\r | |
342 | \r | |
343 | \r | |
344 | /**\r | |
345 | Set user-supplied key for subsequent use. It must be done before any\r | |
346 | calling to HmacSha256Update().\r | |
347 | \r | |
348 | If HmacSha256Context is NULL, then return FALSE.\r | |
349 | If this interface is not supported, then return FALSE.\r | |
350 | \r | |
351 | @param[out] HmacSha256Context Pointer to HMAC-SHA256 context.\r | |
352 | @param[in] Key Pointer to the user-supplied key.\r | |
353 | @param[in] KeySize Key size in bytes.\r | |
354 | \r | |
355 | @retval TRUE The Key is set successfully.\r | |
356 | @retval FALSE The Key is set unsuccessfully.\r | |
357 | @retval FALSE This interface is not supported.\r | |
358 | \r | |
359 | **/\r | |
360 | typedef\r | |
361 | BOOLEAN\r | |
362 | (EFIAPI *EDKII_CRYPTO_HMAC_SHA256_SET_KEY) (\r | |
363 | OUT VOID *HmacSha256Context,\r | |
364 | IN CONST UINT8 *Key,\r | |
365 | IN UINTN KeySize\r | |
366 | );\r | |
367 | \r | |
368 | /**\r | |
369 | Makes a copy of an existing HMAC-SHA256 context.\r | |
370 | \r | |
371 | If HmacSha256Context is NULL, then return FALSE.\r | |
372 | If NewHmacSha256Context is NULL, then return FALSE.\r | |
373 | If this interface is not supported, then return FALSE.\r | |
374 | \r | |
375 | @param[in] HmacSha256Context Pointer to HMAC-SHA256 context being copied.\r | |
376 | @param[out] NewHmacSha256Context Pointer to new HMAC-SHA256 context.\r | |
377 | \r | |
378 | @retval TRUE HMAC-SHA256 context copy succeeded.\r | |
379 | @retval FALSE HMAC-SHA256 context copy failed.\r | |
380 | @retval FALSE This interface is not supported.\r | |
381 | \r | |
382 | **/\r | |
383 | typedef\r | |
384 | BOOLEAN\r | |
385 | (EFIAPI *EDKII_CRYPTO_HMAC_SHA256_DUPLICATE) (\r | |
386 | IN CONST VOID *HmacSha256Context,\r | |
387 | OUT VOID *NewHmacSha256Context\r | |
388 | );\r | |
389 | \r | |
390 | \r | |
391 | /**\r | |
392 | Digests the input data and updates HMAC-SHA256 context.\r | |
393 | \r | |
394 | This function performs HMAC-SHA256 digest on a data buffer of the specified size.\r | |
395 | It can be called multiple times to compute the digest of long or discontinuous data streams.\r | |
396 | HMAC-SHA256 context should be initialized by HmacSha256New(), and should not be finalized\r | |
397 | by HmacSha256Final(). Behavior with invalid context is undefined.\r | |
398 | \r | |
399 | If HmacSha256Context is NULL, then return FALSE.\r | |
400 | If this interface is not supported, then return FALSE.\r | |
401 | \r | |
402 | @param[in, out] HmacSha256Context Pointer to the HMAC-SHA256 context.\r | |
403 | @param[in] Data Pointer to the buffer containing the data to be digested.\r | |
404 | @param[in] DataSize Size of Data buffer in bytes.\r | |
405 | \r | |
406 | @retval TRUE HMAC-SHA256 data digest succeeded.\r | |
407 | @retval FALSE HMAC-SHA256 data digest failed.\r | |
408 | @retval FALSE This interface is not supported.\r | |
409 | \r | |
410 | **/\r | |
411 | typedef\r | |
412 | BOOLEAN\r | |
413 | (EFIAPI *EDKII_CRYPTO_HMAC_SHA256_UPDATE) (\r | |
414 | IN OUT VOID *HmacSha256Context,\r | |
415 | IN CONST VOID *Data,\r | |
416 | IN UINTN DataSize\r | |
417 | );\r | |
418 | \r | |
419 | /**\r | |
420 | Completes computation of the HMAC-SHA256 digest value.\r | |
421 | \r | |
422 | This function completes HMAC-SHA256 hash computation and retrieves the digest value into\r | |
423 | the specified memory. After this function has been called, the HMAC-SHA256 context cannot\r | |
424 | be used again.\r | |
425 | HMAC-SHA256 context should be initialized by HmacSha256New(), and should not be finalized\r | |
426 | by HmacSha256Final(). Behavior with invalid HMAC-SHA256 context is undefined.\r | |
427 | \r | |
428 | If HmacSha256Context is NULL, then return FALSE.\r | |
429 | If HmacValue is NULL, then return FALSE.\r | |
430 | If this interface is not supported, then return FALSE.\r | |
431 | \r | |
432 | @param[in, out] HmacSha256Context Pointer to the HMAC-SHA256 context.\r | |
433 | @param[out] HmacValue Pointer to a buffer that receives the HMAC-SHA256 digest\r | |
434 | value (32 bytes).\r | |
435 | \r | |
436 | @retval TRUE HMAC-SHA256 digest computation succeeded.\r | |
437 | @retval FALSE HMAC-SHA256 digest computation failed.\r | |
438 | @retval FALSE This interface is not supported.\r | |
439 | \r | |
440 | **/\r | |
441 | typedef\r | |
442 | BOOLEAN\r | |
443 | (EFIAPI *EDKII_CRYPTO_HMAC_SHA256_FINAL) (\r | |
444 | IN OUT VOID *HmacSha256Context,\r | |
445 | OUT UINT8 *HmacValue\r | |
446 | );\r | |
447 | \r | |
448 | \r | |
449 | //=====================================================================================\r | |
450 | // One-Way Cryptographic Hash Primitives\r | |
451 | //=====================================================================================\r | |
452 | \r | |
453 | /**\r | |
0a6fc3d0 ZG |
454 | MD4 is deprecated and unsupported any longer.\r |
455 | Keep the function field for binary compability.\r | |
3b0e0430 MK |
456 | \r |
457 | **/\r | |
458 | typedef\r | |
459 | UINTN\r | |
0a6fc3d0 | 460 | (EFIAPI *DEPRECATED_EDKII_CRYPTO_MD4_GET_CONTEXT_SIZE) (\r |
3b0e0430 MK |
461 | VOID\r |
462 | );\r | |
463 | \r | |
464 | \r | |
3b0e0430 MK |
465 | typedef\r |
466 | BOOLEAN\r | |
0a6fc3d0 | 467 | (EFIAPI *DEPRECATED_EDKII_CRYPTO_MD4_INIT) (\r |
3b0e0430 MK |
468 | OUT VOID *Md4Context\r |
469 | );\r | |
470 | \r | |
471 | \r | |
3b0e0430 MK |
472 | typedef\r |
473 | BOOLEAN\r | |
0a6fc3d0 | 474 | (EFIAPI *DEPRECATED_EDKII_CRYPTO_MD4_DUPLICATE) (\r |
3b0e0430 MK |
475 | IN CONST VOID *Md4Context,\r |
476 | OUT VOID *NewMd4Context\r | |
477 | );\r | |
478 | \r | |
479 | \r | |
3b0e0430 MK |
480 | typedef\r |
481 | BOOLEAN\r | |
0a6fc3d0 | 482 | (EFIAPI *DEPRECATED_EDKII_CRYPTO_MD4_UPDATE) (\r |
3b0e0430 MK |
483 | IN OUT VOID *Md4Context,\r |
484 | IN CONST VOID *Data,\r | |
485 | IN UINTN DataSize\r | |
486 | );\r | |
487 | \r | |
488 | \r | |
3b0e0430 MK |
489 | typedef\r |
490 | BOOLEAN\r | |
0a6fc3d0 | 491 | (EFIAPI *DEPRECATED_EDKII_CRYPTO_MD4_FINAL) (\r |
3b0e0430 MK |
492 | IN OUT VOID *Md4Context,\r |
493 | OUT UINT8 *HashValue\r | |
494 | );\r | |
495 | \r | |
496 | \r | |
3b0e0430 MK |
497 | typedef\r |
498 | BOOLEAN\r | |
0a6fc3d0 | 499 | (EFIAPI *DEPRECATED_EDKII_CRYPTO_MD4_HASH_ALL) (\r |
3b0e0430 MK |
500 | IN CONST VOID *Data,\r |
501 | IN UINTN DataSize,\r | |
502 | OUT UINT8 *HashValue\r | |
503 | );\r | |
504 | \r | |
505 | // ----------------------------------------------------------------------------\r | |
506 | \r | |
507 | /**\r | |
508 | Retrieves the size, in bytes, of the context buffer required for MD5 hash operations.\r | |
509 | \r | |
510 | If this interface is not supported, then return zero.\r | |
511 | \r | |
512 | @return The size, in bytes, of the context buffer required for MD5 hash operations.\r | |
513 | @retval 0 This interface is not supported.\r | |
514 | \r | |
515 | **/\r | |
516 | typedef\r | |
517 | UINTN\r | |
518 | (EFIAPI* EDKII_CRYPTO_MD5_GET_CONTEXT_SIZE)(\r | |
519 | VOID\r | |
520 | );\r | |
521 | \r | |
522 | /**\r | |
523 | Initializes user-supplied memory pointed by Md5Context as MD5 hash context for\r | |
524 | subsequent use.\r | |
525 | \r | |
526 | If Md5Context is NULL, then return FALSE.\r | |
527 | If this interface is not supported, then return FALSE.\r | |
528 | \r | |
529 | @param[out] Md5Context Pointer to MD5 context being initialized.\r | |
530 | \r | |
531 | @retval TRUE MD5 context initialization succeeded.\r | |
532 | @retval FALSE MD5 context initialization failed.\r | |
533 | @retval FALSE This interface is not supported.\r | |
534 | \r | |
535 | **/\r | |
536 | typedef\r | |
537 | BOOLEAN\r | |
538 | (EFIAPI* EDKII_CRYPTO_MD5_INIT)(\r | |
539 | OUT VOID *Md5Context);\r | |
540 | \r | |
541 | /**\r | |
542 | Makes a copy of an existing MD5 context.\r | |
543 | \r | |
544 | If Md5Context is NULL, then return FALSE.\r | |
545 | If NewMd5Context is NULL, then return FALSE.\r | |
546 | If this interface is not supported, then return FALSE.\r | |
547 | \r | |
548 | @param[in] Md5Context Pointer to MD5 context being copied.\r | |
549 | @param[out] NewMd5Context Pointer to new MD5 context.\r | |
550 | \r | |
551 | @retval TRUE MD5 context copy succeeded.\r | |
552 | @retval FALSE MD5 context copy failed.\r | |
553 | @retval FALSE This interface is not supported.\r | |
554 | \r | |
555 | **/\r | |
556 | typedef\r | |
557 | BOOLEAN\r | |
558 | (EFIAPI* EDKII_CRYPTO_MD5_DUPLICATE) (\r | |
559 | IN CONST VOID *Md5Context,\r | |
560 | OUT VOID *NewMd5Context);\r | |
561 | \r | |
562 | \r | |
563 | /**\r | |
564 | Digests the input data and updates MD5 context.\r | |
565 | \r | |
566 | This function performs MD5 digest on a data buffer of the specified size.\r | |
567 | It can be called multiple times to compute the digest of long or discontinuous data streams.\r | |
568 | MD5 context should be already correctly initialized by Md5Init(), and should not be finalized\r | |
569 | by Md5Final(). Behavior with invalid context is undefined.\r | |
570 | \r | |
571 | If Md5Context is NULL, then return FALSE.\r | |
572 | If this interface is not supported, then return FALSE.\r | |
573 | \r | |
574 | @param[in, out] Md5Context Pointer to the MD5 context.\r | |
575 | @param[in] Data Pointer to the buffer containing the data to be hashed.\r | |
576 | @param[in] DataSize Size of Data buffer in bytes.\r | |
577 | \r | |
578 | @retval TRUE MD5 data digest succeeded.\r | |
579 | @retval FALSE MD5 data digest failed.\r | |
580 | @retval FALSE This interface is not supported.\r | |
581 | \r | |
582 | **/\r | |
583 | typedef\r | |
584 | BOOLEAN\r | |
585 | (EFIAPI* EDKII_CRYPTO_MD5_UPDATE)(\r | |
586 | IN OUT VOID *Md5Context,\r | |
587 | IN CONST VOID *Data,\r | |
588 | IN UINTN DataSize);\r | |
589 | \r | |
590 | \r | |
591 | /**\r | |
592 | Completes computation of the MD5 digest value.\r | |
593 | \r | |
594 | This function completes MD5 hash computation and retrieves the digest value into\r | |
595 | the specified memory. After this function has been called, the MD5 context cannot\r | |
596 | be used again.\r | |
597 | MD5 context should be already correctly initialized by Md5Init(), and should not be\r | |
598 | finalized by Md5Final(). Behavior with invalid MD5 context is undefined.\r | |
599 | \r | |
600 | If Md5Context is NULL, then return FALSE.\r | |
601 | If HashValue is NULL, then return FALSE.\r | |
602 | If this interface is not supported, then return FALSE.\r | |
603 | \r | |
604 | @param[in, out] Md5Context Pointer to the MD5 context.\r | |
605 | @param[out] HashValue Pointer to a buffer that receives the MD5 digest\r | |
606 | value (16 bytes).\r | |
607 | \r | |
608 | @retval TRUE MD5 digest computation succeeded.\r | |
609 | @retval FALSE MD5 digest computation failed.\r | |
610 | @retval FALSE This interface is not supported.\r | |
611 | \r | |
612 | **/\r | |
613 | typedef\r | |
614 | BOOLEAN\r | |
615 | (EFIAPI* EDKII_CRYPTO_MD5_FINAL)(\r | |
616 | IN OUT VOID *Md5Context,\r | |
617 | OUT UINT8 *HashValue);\r | |
618 | \r | |
619 | \r | |
620 | /**\r | |
621 | Computes the MD5 message digest of a input data buffer.\r | |
622 | \r | |
623 | This function performs the MD5 message digest of a given data buffer, and places\r | |
624 | the digest value into the specified memory.\r | |
625 | \r | |
626 | If this interface is not supported, then return FALSE.\r | |
627 | \r | |
628 | @param[in] Data Pointer to the buffer containing the data to be hashed.\r | |
629 | @param[in] DataSize Size of Data buffer in bytes.\r | |
630 | @param[out] HashValue Pointer to a buffer that receives the MD5 digest\r | |
631 | value (16 bytes).\r | |
632 | \r | |
633 | @retval TRUE MD5 digest computation succeeded.\r | |
634 | @retval FALSE MD5 digest computation failed.\r | |
635 | @retval FALSE This interface is not supported.\r | |
636 | \r | |
637 | **/\r | |
638 | typedef\r | |
639 | BOOLEAN\r | |
640 | (EFIAPI* EDKII_CRYPTO_MD5_HASH_ALL)(\r | |
641 | IN CONST VOID *Data,\r | |
642 | IN UINTN DataSize,\r | |
643 | OUT UINT8 *HashValue);\r | |
644 | \r | |
645 | \r | |
646 | //=====================================================================================\r | |
647 | // PKCS\r | |
648 | //=====================================================================================\r | |
649 | \r | |
650 | \r | |
651 | /**\r | |
652 | Encrypts a blob using PKCS1v2 (RSAES-OAEP) schema. On success, will return the encrypted message in\r | |
653 | in a newly allocated buffer.\r | |
654 | \r | |
655 | Things that can cause a failure include:\r | |
656 | - X509 key size does not match any known key size.\r | |
657 | - Fail to parse X509 certificate.\r | |
658 | - Fail to allocate an intermediate buffer.\r | |
659 | - NULL pointer provided for a non-optional parameter.\r | |
660 | - Data size is too large for the provided key size (max size is a function of key size and hash digest size).\r | |
661 | \r | |
662 | @param[in] PublicKey A pointer to the DER-encoded X509 certificate that will be used to encrypt the data.\r | |
663 | @param[in] PublicKeySize Size of the X509 cert buffer.\r | |
664 | @param[in] InData Data to be encrypted.\r | |
665 | @param[in] InDataSize Size of the data buffer.\r | |
666 | @param[in] PrngSeed [Optional] If provided, a pointer to a random seed buffer to be used when initializing the PRNG. NULL otherwise.\r | |
667 | @param[in] PrngSeedSize [Optional] If provided, size of the random seed buffer. 0 otherwise.\r | |
668 | @param[out] EncryptedData Pointer to an allocated buffer containing the encrypted message.\r | |
669 | @param[out] EncryptedDataSize Size of the encrypted message buffer.\r | |
670 | \r | |
671 | @retval TRUE Encryption was successful.\r | |
672 | @retval FALSE Encryption failed.\r | |
673 | \r | |
674 | **/\r | |
675 | typedef\r | |
676 | BOOLEAN\r | |
677 | (EFIAPI *EDKII_CRYPTO_PKCS1_ENCRYPT_V2) (\r | |
678 | IN CONST UINT8 *PublicKey,\r | |
679 | IN UINTN PublicKeySize,\r | |
680 | IN UINT8 *InData,\r | |
681 | IN UINTN InDataSize,\r | |
682 | IN CONST UINT8 *PrngSeed OPTIONAL,\r | |
683 | IN UINTN PrngSeedSize OPTIONAL,\r | |
684 | OUT UINT8 **EncryptedData,\r | |
685 | OUT UINTN *EncryptedDataSize\r | |
686 | );\r | |
687 | \r | |
688 | \r | |
689 | \r | |
690 | \r | |
691 | // ---------------------------------------------\r | |
692 | // PKCS5\r | |
693 | \r | |
694 | /**\r | |
695 | Derives a key from a password using a salt and iteration count, based on PKCS#5 v2.0\r | |
696 | password based encryption key derivation function PBKDF2, as specified in RFC 2898.\r | |
697 | \r | |
698 | If Password or Salt or OutKey is NULL, then return FALSE.\r | |
699 | If the hash algorithm could not be determined, then return FALSE.\r | |
700 | If this interface is not supported, then return FALSE.\r | |
701 | \r | |
702 | @param[in] PasswordLength Length of input password in bytes.\r | |
703 | @param[in] Password Pointer to the array for the password.\r | |
704 | @param[in] SaltLength Size of the Salt in bytes.\r | |
705 | @param[in] Salt Pointer to the Salt.\r | |
706 | @param[in] IterationCount Number of iterations to perform. Its value should be\r | |
707 | greater than or equal to 1.\r | |
708 | @param[in] DigestSize Size of the message digest to be used (eg. SHA256_DIGEST_SIZE).\r | |
709 | NOTE: DigestSize will be used to determine the hash algorithm.\r | |
710 | Only SHA1_DIGEST_SIZE or SHA256_DIGEST_SIZE is supported.\r | |
711 | @param[in] KeyLength Size of the derived key buffer in bytes.\r | |
712 | @param[out] OutKey Pointer to the output derived key buffer.\r | |
713 | \r | |
714 | @retval TRUE A key was derived successfully.\r | |
715 | @retval FALSE One of the pointers was NULL or one of the sizes was too large.\r | |
716 | @retval FALSE The hash algorithm could not be determined from the digest size.\r | |
717 | @retval FALSE The key derivation operation failed.\r | |
718 | @retval FALSE This interface is not supported.\r | |
719 | \r | |
720 | **/\r | |
721 | typedef\r | |
722 | BOOLEAN\r | |
723 | (EFIAPI *EDKII_CRYPTO_PKCS5_PW_HASH) (\r | |
724 | IN UINTN PasswordSize,\r | |
725 | IN CONST CHAR8 *Password,\r | |
726 | IN UINTN SaltSize,\r | |
727 | IN CONST UINT8 *Salt,\r | |
728 | IN UINTN IterationCount,\r | |
729 | IN UINTN DigestSize,\r | |
730 | IN UINTN OutputSize,\r | |
731 | OUT UINT8 *Output\r | |
732 | );\r | |
733 | \r | |
734 | \r | |
735 | \r | |
736 | // ---------------------------------------------\r | |
737 | // PKCS7\r | |
738 | \r | |
739 | /**\r | |
740 | Verifies the validity of a PKCS#7 signed data as described in "PKCS #7:\r | |
741 | Cryptographic Message Syntax Standard". The input signed data could be wrapped\r | |
742 | in a ContentInfo structure.\r | |
743 | \r | |
744 | If P7Data, TrustedCert or InData is NULL, then return FALSE.\r | |
745 | If P7Length, CertLength or DataLength overflow, then return FALSE.\r | |
746 | If this interface is not supported, then return FALSE.\r | |
747 | \r | |
748 | @param[in] P7Data Pointer to the PKCS#7 message to verify.\r | |
749 | @param[in] P7Length Length of the PKCS#7 message in bytes.\r | |
750 | @param[in] TrustedCert Pointer to a trusted/root certificate encoded in DER, which\r | |
751 | is used for certificate chain verification.\r | |
752 | @param[in] CertLength Length of the trusted certificate in bytes.\r | |
753 | @param[in] InData Pointer to the content to be verified.\r | |
754 | @param[in] DataLength Length of InData in bytes.\r | |
755 | \r | |
756 | @retval TRUE The specified PKCS#7 signed data is valid.\r | |
757 | @retval FALSE Invalid PKCS#7 signed data.\r | |
758 | @retval FALSE This interface is not supported.\r | |
759 | \r | |
760 | **/\r | |
761 | typedef\r | |
762 | BOOLEAN\r | |
763 | (EFIAPI *EDKII_CRYPTO_PKCS7_VERIFY) (\r | |
764 | IN CONST UINT8 *P7Data,\r | |
765 | IN UINTN P7DataLength,\r | |
766 | IN CONST UINT8 *TrustedCert,\r | |
767 | IN UINTN TrustedCertLength,\r | |
768 | IN CONST UINT8 *Data,\r | |
769 | IN UINTN DataLength\r | |
770 | );\r | |
771 | \r | |
772 | /**\r | |
773 | VerifyEKUsInPkcs7Signature()\r | |
774 | \r | |
775 | This function receives a PKCS7 formatted signature, and then verifies that\r | |
776 | the specified Enhanced or Extended Key Usages (EKU's) are present in the end-entity\r | |
777 | leaf signing certificate.\r | |
778 | \r | |
779 | Note that this function does not validate the certificate chain.\r | |
780 | \r | |
781 | Applications for custom EKU's are quite flexible. For example, a policy EKU\r | |
782 | may be present in an Issuing Certificate Authority (CA), and any sub-ordinate\r | |
783 | certificate issued might also contain this EKU, thus constraining the\r | |
784 | sub-ordinate certificate. Other applications might allow a certificate\r | |
785 | embedded in a device to specify that other Object Identifiers (OIDs) are\r | |
786 | present which contains binary data specifying custom capabilities that\r | |
787 | the device is able to do.\r | |
788 | \r | |
789 | @param[in] Pkcs7Signature - The PKCS#7 signed information content block. An array\r | |
790 | containing the content block with both the signature,\r | |
791 | the signer's certificate, and any necessary intermediate\r | |
792 | certificates.\r | |
793 | \r | |
794 | @param[in] Pkcs7SignatureSize - Number of bytes in Pkcs7Signature.\r | |
795 | \r | |
796 | @param[in] RequiredEKUs - Array of null-terminated strings listing OIDs of\r | |
797 | required EKUs that must be present in the signature.\r | |
798 | \r | |
799 | @param[in] RequiredEKUsSize - Number of elements in the RequiredEKUs string array.\r | |
800 | \r | |
801 | @param[in] RequireAllPresent - If this is TRUE, then all of the specified EKU's\r | |
802 | must be present in the leaf signer. If it is\r | |
803 | FALSE, then we will succeed if we find any\r | |
804 | of the specified EKU's.\r | |
805 | \r | |
806 | @retval EFI_SUCCESS - The required EKUs were found in the signature.\r | |
807 | @retval EFI_INVALID_PARAMETER - A parameter was invalid.\r | |
808 | @retval EFI_NOT_FOUND - One or more EKU's were not found in the signature.\r | |
809 | \r | |
810 | **/\r | |
811 | typedef\r | |
812 | EFI_STATUS\r | |
813 | (EFIAPI *EDKII_CRYPTO_PKCS7_VERIFY_EKU) (\r | |
814 | IN CONST UINT8 *Pkcs7Signature,\r | |
815 | IN CONST UINT32 SignatureSize,\r | |
816 | IN CONST CHAR8 *RequiredEKUs[],\r | |
817 | IN CONST UINT32 RequiredEKUsSize,\r | |
818 | IN BOOLEAN RequireAllPresent\r | |
819 | );\r | |
820 | \r | |
821 | /**\r | |
822 | Get the signer's certificates from PKCS#7 signed data as described in "PKCS #7:\r | |
823 | Cryptographic Message Syntax Standard". The input signed data could be wrapped\r | |
824 | in a ContentInfo structure.\r | |
825 | \r | |
826 | If P7Data, CertStack, StackLength, TrustedCert or CertLength is NULL, then\r | |
827 | return FALSE. If P7Length overflow, then return FALSE.\r | |
828 | If this interface is not supported, then return FALSE.\r | |
829 | \r | |
830 | @param[in] P7Data Pointer to the PKCS#7 message to verify.\r | |
831 | @param[in] P7Length Length of the PKCS#7 message in bytes.\r | |
832 | @param[out] CertStack Pointer to Signer's certificates retrieved from P7Data.\r | |
833 | It's caller's responsibility to free the buffer with\r | |
834 | Pkcs7FreeSigners().\r | |
835 | This data structure is EFI_CERT_STACK type.\r | |
836 | @param[out] StackLength Length of signer's certificates in bytes.\r | |
837 | @param[out] TrustedCert Pointer to a trusted certificate from Signer's certificates.\r | |
838 | It's caller's responsibility to free the buffer with\r | |
839 | Pkcs7FreeSigners().\r | |
840 | @param[out] CertLength Length of the trusted certificate in bytes.\r | |
841 | \r | |
842 | @retval TRUE The operation is finished successfully.\r | |
843 | @retval FALSE Error occurs during the operation.\r | |
844 | @retval FALSE This interface is not supported.\r | |
845 | \r | |
846 | **/\r | |
847 | typedef\r | |
848 | BOOLEAN\r | |
849 | (EFIAPI *EDKII_CRYPTO_PKCS7_GET_SIGNERS) (\r | |
850 | IN CONST UINT8 *P7Data,\r | |
851 | IN UINTN P7Length,\r | |
852 | OUT UINT8 **CertStack,\r | |
853 | OUT UINTN *StackLength,\r | |
854 | OUT UINT8 **TrustedCert,\r | |
855 | OUT UINTN *CertLength\r | |
856 | );\r | |
857 | \r | |
858 | /**\r | |
859 | Wrap function to use free() to free allocated memory for certificates.\r | |
860 | \r | |
861 | If this interface is not supported, then ASSERT().\r | |
862 | \r | |
863 | @param[in] Certs Pointer to the certificates to be freed.\r | |
864 | \r | |
865 | **/\r | |
866 | typedef\r | |
867 | VOID\r | |
868 | (EFIAPI *EDKII_CRYPTO_PKCS7_FREE_SIGNERS) (\r | |
869 | IN UINT8 *Certs\r | |
870 | );\r | |
871 | \r | |
872 | /**\r | |
873 | Creates a PKCS#7 signedData as described in "PKCS #7: Cryptographic Message\r | |
874 | Syntax Standard, version 1.5". This interface is only intended to be used for\r | |
875 | application to perform PKCS#7 functionality validation.\r | |
876 | \r | |
877 | If this interface is not supported, then return FALSE.\r | |
878 | \r | |
879 | @param[in] PrivateKey Pointer to the PEM-formatted private key data for\r | |
880 | data signing.\r | |
881 | @param[in] PrivateKeySize Size of the PEM private key data in bytes.\r | |
882 | @param[in] KeyPassword NULL-terminated passphrase used for encrypted PEM\r | |
883 | key data.\r | |
884 | @param[in] InData Pointer to the content to be signed.\r | |
885 | @param[in] InDataSize Size of InData in bytes.\r | |
886 | @param[in] SignCert Pointer to signer's DER-encoded certificate to sign with.\r | |
887 | @param[in] OtherCerts Pointer to an optional additional set of certificates to\r | |
888 | include in the PKCS#7 signedData (e.g. any intermediate\r | |
889 | CAs in the chain).\r | |
890 | @param[out] SignedData Pointer to output PKCS#7 signedData. It's caller's\r | |
891 | responsibility to free the buffer with FreePool().\r | |
892 | @param[out] SignedDataSize Size of SignedData in bytes.\r | |
893 | \r | |
894 | @retval TRUE PKCS#7 data signing succeeded.\r | |
895 | @retval FALSE PKCS#7 data signing failed.\r | |
896 | @retval FALSE This interface is not supported.\r | |
897 | \r | |
898 | **/\r | |
899 | typedef\r | |
900 | BOOLEAN\r | |
901 | (EFIAPI *EDKII_CRYPTO_PKCS7_SIGN) (\r | |
902 | IN CONST UINT8 *PrivateKey,\r | |
903 | IN UINTN PrivateKeySize,\r | |
904 | IN CONST UINT8 *KeyPassword,\r | |
905 | IN UINT8 *InData,\r | |
906 | IN UINTN InDataSize,\r | |
907 | IN UINT8 *SignCert,\r | |
908 | IN UINT8 *OtherCerts OPTIONAL,\r | |
909 | OUT UINT8 **SignedData,\r | |
910 | OUT UINTN *SignedDataSize\r | |
911 | );\r | |
912 | \r | |
913 | /**\r | |
914 | Extracts the attached content from a PKCS#7 signed data if existed. The input signed\r | |
915 | data could be wrapped in a ContentInfo structure.\r | |
916 | \r | |
917 | If P7Data, Content, or ContentSize is NULL, then return FALSE. If P7Length overflow,\r | |
918 | then return FALSE. If the P7Data is not correctly formatted, then return FALSE.\r | |
919 | \r | |
920 | Caution: This function may receive untrusted input. So this function will do\r | |
921 | basic check for PKCS#7 data structure.\r | |
922 | \r | |
923 | @param[in] P7Data Pointer to the PKCS#7 signed data to process.\r | |
924 | @param[in] P7Length Length of the PKCS#7 signed data in bytes.\r | |
925 | @param[out] Content Pointer to the extracted content from the PKCS#7 signedData.\r | |
926 | It's caller's responsibility to free the buffer with FreePool().\r | |
927 | @param[out] ContentSize The size of the extracted content in bytes.\r | |
928 | \r | |
929 | @retval TRUE The P7Data was correctly formatted for processing.\r | |
930 | @retval FALSE The P7Data was not correctly formatted for processing.\r | |
931 | \r | |
932 | \r | |
933 | **/\r | |
934 | typedef\r | |
935 | BOOLEAN\r | |
936 | (EFIAPI *EDKII_CRYPTO_PKCS7_GET_ATTACHED_CONTENT) (\r | |
937 | IN CONST UINT8 *P7Data,\r | |
938 | IN UINTN P7Length,\r | |
939 | OUT VOID **Content,\r | |
940 | OUT UINTN *ContentSize\r | |
941 | );\r | |
942 | \r | |
943 | /**\r | |
944 | Retrieves all embedded certificates from PKCS#7 signed data as described in "PKCS #7:\r | |
945 | Cryptographic Message Syntax Standard", and outputs two certificate lists chained and\r | |
946 | unchained to the signer's certificates.\r | |
947 | The input signed data could be wrapped in a ContentInfo structure.\r | |
948 | \r | |
949 | @param[in] P7Data Pointer to the PKCS#7 message.\r | |
950 | @param[in] P7Length Length of the PKCS#7 message in bytes.\r | |
951 | @param[out] SignerChainCerts Pointer to the certificates list chained to signer's\r | |
952 | certificate. It's caller's responsibility to free the buffer\r | |
953 | with Pkcs7FreeSigners().\r | |
954 | This data structure is EFI_CERT_STACK type.\r | |
955 | @param[out] ChainLength Length of the chained certificates list buffer in bytes.\r | |
956 | @param[out] UnchainCerts Pointer to the unchained certificates lists. It's caller's\r | |
957 | responsibility to free the buffer with Pkcs7FreeSigners().\r | |
958 | This data structure is EFI_CERT_STACK type.\r | |
959 | @param[out] UnchainLength Length of the unchained certificates list buffer in bytes.\r | |
960 | \r | |
961 | @retval TRUE The operation is finished successfully.\r | |
962 | @retval FALSE Error occurs during the operation.\r | |
963 | \r | |
964 | **/\r | |
965 | typedef\r | |
966 | BOOLEAN\r | |
967 | (EFIAPI *EDKII_CRYPTO_PKCS7_GET_CERTIFICATES_LIST) (\r | |
968 | IN CONST UINT8 *P7Data,\r | |
969 | IN UINTN P7Length,\r | |
970 | OUT UINT8 **SignerChainCerts,\r | |
971 | OUT UINTN *ChainLength,\r | |
972 | OUT UINT8 **UnchainCerts,\r | |
973 | OUT UINTN *UnchainLength\r | |
974 | );\r | |
975 | \r | |
976 | /**\r | |
977 | Verifies the validity of a PE/COFF Authenticode Signature as described in "Windows\r | |
978 | Authenticode Portable Executable Signature Format".\r | |
979 | \r | |
980 | If AuthData is NULL, then return FALSE.\r | |
981 | If ImageHash is NULL, then return FALSE.\r | |
982 | If this interface is not supported, then return FALSE.\r | |
983 | \r | |
984 | @param[in] AuthData Pointer to the Authenticode Signature retrieved from signed\r | |
985 | PE/COFF image to be verified.\r | |
986 | @param[in] DataSize Size of the Authenticode Signature in bytes.\r | |
987 | @param[in] TrustedCert Pointer to a trusted/root certificate encoded in DER, which\r | |
988 | is used for certificate chain verification.\r | |
989 | @param[in] CertSize Size of the trusted certificate in bytes.\r | |
990 | @param[in] ImageHash Pointer to the original image file hash value. The procedure\r | |
991 | for calculating the image hash value is described in Authenticode\r | |
992 | specification.\r | |
993 | @param[in] HashSize Size of Image hash value in bytes.\r | |
994 | \r | |
995 | @retval TRUE The specified Authenticode Signature is valid.\r | |
996 | @retval FALSE Invalid Authenticode Signature.\r | |
997 | @retval FALSE This interface is not supported.\r | |
998 | \r | |
999 | **/\r | |
1000 | typedef\r | |
1001 | BOOLEAN\r | |
1002 | (EFIAPI *EDKII_CRYPTO_AUTHENTICODE_VERIFY) (\r | |
1003 | IN CONST UINT8 *AuthData,\r | |
1004 | IN UINTN DataSize,\r | |
1005 | IN CONST UINT8 *TrustedCert,\r | |
1006 | IN UINTN CertSize,\r | |
1007 | IN CONST UINT8 *ImageHash,\r | |
1008 | IN UINTN HashSize\r | |
1009 | );\r | |
1010 | \r | |
1011 | /**\r | |
1012 | Verifies the validity of a RFC3161 Timestamp CounterSignature embedded in PE/COFF Authenticode\r | |
1013 | signature.\r | |
1014 | \r | |
1015 | If AuthData is NULL, then return FALSE.\r | |
1016 | If this interface is not supported, then return FALSE.\r | |
1017 | \r | |
1018 | @param[in] AuthData Pointer to the Authenticode Signature retrieved from signed\r | |
1019 | PE/COFF image to be verified.\r | |
1020 | @param[in] DataSize Size of the Authenticode Signature in bytes.\r | |
1021 | @param[in] TsaCert Pointer to a trusted/root TSA certificate encoded in DER, which\r | |
1022 | is used for TSA certificate chain verification.\r | |
1023 | @param[in] CertSize Size of the trusted certificate in bytes.\r | |
1024 | @param[out] SigningTime Return the time of timestamp generation time if the timestamp\r | |
1025 | signature is valid.\r | |
1026 | \r | |
1027 | @retval TRUE The specified Authenticode includes a valid RFC3161 Timestamp CounterSignature.\r | |
1028 | @retval FALSE No valid RFC3161 Timestamp CounterSignature in the specified Authenticode data.\r | |
1029 | \r | |
1030 | **/\r | |
1031 | typedef\r | |
1032 | BOOLEAN\r | |
1033 | (EFIAPI *EDKII_CRYPTO_IMAGE_TIMESTAMP_VERIFY) (\r | |
1034 | IN CONST UINT8 *AuthData,\r | |
1035 | IN UINTN DataSize,\r | |
1036 | IN CONST UINT8 *TsaCert,\r | |
1037 | IN UINTN CertSize,\r | |
1038 | OUT EFI_TIME *SigningTime\r | |
1039 | );\r | |
1040 | \r | |
1041 | \r | |
1042 | //=====================================================================================\r | |
1043 | // DH Key Exchange Primitive\r | |
1044 | //=====================================================================================\r | |
1045 | \r | |
1046 | /**\r | |
1047 | Allocates and Initializes one Diffie-Hellman Context for subsequent use.\r | |
1048 | \r | |
1049 | @return Pointer to the Diffie-Hellman Context that has been initialized.\r | |
1050 | If the allocations fails, DhNew() returns NULL.\r | |
1051 | If the interface is not supported, DhNew() returns NULL.\r | |
1052 | \r | |
1053 | **/\r | |
1054 | typedef\r | |
1055 | VOID*\r | |
1056 | (EFIAPI *EDKII_CRYPTO_DH_NEW) (\r | |
1057 | VOID\r | |
1058 | );\r | |
1059 | \r | |
1060 | /**\r | |
1061 | Release the specified DH context.\r | |
1062 | \r | |
1063 | If the interface is not supported, then ASSERT().\r | |
1064 | \r | |
1065 | @param[in] DhContext Pointer to the DH context to be released.\r | |
1066 | \r | |
1067 | **/\r | |
1068 | typedef\r | |
1069 | VOID\r | |
1070 | (EFIAPI *EDKII_CRYPTO_DH_FREE) (\r | |
1071 | IN VOID *DhContext\r | |
1072 | );\r | |
1073 | \r | |
1074 | /**\r | |
1075 | Generates DH parameter.\r | |
1076 | \r | |
1077 | Given generator g, and length of prime number p in bits, this function generates p,\r | |
1078 | and sets DH context according to value of g and p.\r | |
1079 | \r | |
1080 | Before this function can be invoked, pseudorandom number generator must be correctly\r | |
1081 | initialized by RandomSeed().\r | |
1082 | \r | |
1083 | If DhContext is NULL, then return FALSE.\r | |
1084 | If Prime is NULL, then return FALSE.\r | |
1085 | If this interface is not supported, then return FALSE.\r | |
1086 | \r | |
1087 | @param[in, out] DhContext Pointer to the DH context.\r | |
1088 | @param[in] Generator Value of generator.\r | |
1089 | @param[in] PrimeLength Length in bits of prime to be generated.\r | |
1090 | @param[out] Prime Pointer to the buffer to receive the generated prime number.\r | |
1091 | \r | |
1092 | @retval TRUE DH parameter generation succeeded.\r | |
1093 | @retval FALSE Value of Generator is not supported.\r | |
1094 | @retval FALSE PRNG fails to generate random prime number with PrimeLength.\r | |
1095 | @retval FALSE This interface is not supported.\r | |
1096 | \r | |
1097 | **/\r | |
1098 | typedef\r | |
1099 | BOOLEAN\r | |
1100 | (EFIAPI *EDKII_CRYPTO_DH_GENERATE_PARAMETER) (\r | |
1101 | IN OUT VOID *DhContext,\r | |
1102 | IN UINTN Generator,\r | |
1103 | IN UINTN PrimeLength,\r | |
1104 | OUT UINT8 *Prime\r | |
1105 | );\r | |
1106 | \r | |
1107 | /**\r | |
1108 | Sets generator and prime parameters for DH.\r | |
1109 | \r | |
1110 | Given generator g, and prime number p, this function and sets DH\r | |
1111 | context accordingly.\r | |
1112 | \r | |
1113 | If DhContext is NULL, then return FALSE.\r | |
1114 | If Prime is NULL, then return FALSE.\r | |
1115 | If this interface is not supported, then return FALSE.\r | |
1116 | \r | |
1117 | @param[in, out] DhContext Pointer to the DH context.\r | |
1118 | @param[in] Generator Value of generator.\r | |
1119 | @param[in] PrimeLength Length in bits of prime to be generated.\r | |
1120 | @param[in] Prime Pointer to the prime number.\r | |
1121 | \r | |
1122 | @retval TRUE DH parameter setting succeeded.\r | |
1123 | @retval FALSE Value of Generator is not supported.\r | |
1124 | @retval FALSE Value of Generator is not suitable for the Prime.\r | |
1125 | @retval FALSE Value of Prime is not a prime number.\r | |
1126 | @retval FALSE Value of Prime is not a safe prime number.\r | |
1127 | @retval FALSE This interface is not supported.\r | |
1128 | \r | |
1129 | **/\r | |
1130 | typedef\r | |
1131 | BOOLEAN\r | |
1132 | (EFIAPI *EDKII_CRYPTO_DH_SET_PARAMETER) (\r | |
1133 | IN OUT VOID *DhContext,\r | |
1134 | IN UINTN Generator,\r | |
1135 | IN UINTN PrimeLength,\r | |
1136 | IN CONST UINT8 *Prime\r | |
1137 | );\r | |
1138 | \r | |
1139 | /**\r | |
1140 | Generates DH public key.\r | |
1141 | \r | |
1142 | This function generates random secret exponent, and computes the public key, which is\r | |
1143 | returned via parameter PublicKey and PublicKeySize. DH context is updated accordingly.\r | |
1144 | If the PublicKey buffer is too small to hold the public key, FALSE is returned and\r | |
1145 | PublicKeySize is set to the required buffer size to obtain the public key.\r | |
1146 | \r | |
1147 | If DhContext is NULL, then return FALSE.\r | |
1148 | If PublicKeySize is NULL, then return FALSE.\r | |
1149 | If PublicKeySize is large enough but PublicKey is NULL, then return FALSE.\r | |
1150 | If this interface is not supported, then return FALSE.\r | |
1151 | \r | |
1152 | @param[in, out] DhContext Pointer to the DH context.\r | |
1153 | @param[out] PublicKey Pointer to the buffer to receive generated public key.\r | |
1154 | @param[in, out] PublicKeySize On input, the size of PublicKey buffer in bytes.\r | |
1155 | On output, the size of data returned in PublicKey buffer in bytes.\r | |
1156 | \r | |
1157 | @retval TRUE DH public key generation succeeded.\r | |
1158 | @retval FALSE DH public key generation failed.\r | |
1159 | @retval FALSE PublicKeySize is not large enough.\r | |
1160 | @retval FALSE This interface is not supported.\r | |
1161 | \r | |
1162 | **/\r | |
1163 | typedef\r | |
1164 | BOOLEAN\r | |
1165 | (EFIAPI *EDKII_CRYPTO_DH_GENERATE_KEY) (\r | |
1166 | IN OUT VOID *DhContext,\r | |
1167 | OUT UINT8 *PublicKey,\r | |
1168 | IN OUT UINTN *PublicKeySize\r | |
1169 | );\r | |
1170 | \r | |
1171 | /**\r | |
1172 | Computes exchanged common key.\r | |
1173 | \r | |
1174 | Given peer's public key, this function computes the exchanged common key, based on its own\r | |
1175 | context including value of prime modulus and random secret exponent.\r | |
1176 | \r | |
1177 | If DhContext is NULL, then return FALSE.\r | |
1178 | If PeerPublicKey is NULL, then return FALSE.\r | |
1179 | If KeySize is NULL, then return FALSE.\r | |
1180 | If Key is NULL, then return FALSE.\r | |
1181 | If KeySize is not large enough, then return FALSE.\r | |
1182 | If this interface is not supported, then return FALSE.\r | |
1183 | \r | |
1184 | @param[in, out] DhContext Pointer to the DH context.\r | |
1185 | @param[in] PeerPublicKey Pointer to the peer's public key.\r | |
1186 | @param[in] PeerPublicKeySize Size of peer's public key in bytes.\r | |
1187 | @param[out] Key Pointer to the buffer to receive generated key.\r | |
1188 | @param[in, out] KeySize On input, the size of Key buffer in bytes.\r | |
1189 | On output, the size of data returned in Key buffer in bytes.\r | |
1190 | \r | |
1191 | @retval TRUE DH exchanged key generation succeeded.\r | |
1192 | @retval FALSE DH exchanged key generation failed.\r | |
1193 | @retval FALSE KeySize is not large enough.\r | |
1194 | @retval FALSE This interface is not supported.\r | |
1195 | \r | |
1196 | **/\r | |
1197 | typedef\r | |
1198 | BOOLEAN\r | |
1199 | (EFIAPI *EDKII_CRYPTO_DH_COMPUTE_KEY) (\r | |
1200 | IN OUT VOID *DhContext,\r | |
1201 | IN CONST UINT8 *PeerPublicKey,\r | |
1202 | IN UINTN PeerPublicKeySize,\r | |
1203 | OUT UINT8 *Key,\r | |
1204 | IN OUT UINTN *KeySize\r | |
1205 | );\r | |
1206 | \r | |
1207 | //=====================================================================================\r | |
1208 | // Pseudo-Random Generation Primitive\r | |
1209 | //=====================================================================================\r | |
1210 | \r | |
1211 | /**\r | |
1212 | Sets up the seed value for the pseudorandom number generator.\r | |
1213 | \r | |
1214 | This function sets up the seed value for the pseudorandom number generator.\r | |
1215 | If Seed is not NULL, then the seed passed in is used.\r | |
1216 | If Seed is NULL, then default seed is used.\r | |
1217 | If this interface is not supported, then return FALSE.\r | |
1218 | \r | |
1219 | @param[in] Seed Pointer to seed value.\r | |
1220 | If NULL, default seed is used.\r | |
1221 | @param[in] SeedSize Size of seed value.\r | |
1222 | If Seed is NULL, this parameter is ignored.\r | |
1223 | \r | |
1224 | @retval TRUE Pseudorandom number generator has enough entropy for random generation.\r | |
1225 | @retval FALSE Pseudorandom number generator does not have enough entropy for random generation.\r | |
1226 | @retval FALSE This interface is not supported.\r | |
1227 | \r | |
1228 | **/\r | |
1229 | typedef\r | |
1230 | BOOLEAN\r | |
1231 | (EFIAPI *EDKII_CRYPTO_RANDOM_SEED) (\r | |
1232 | IN CONST UINT8 *Seed OPTIONAL,\r | |
1233 | IN UINTN SeedSize\r | |
1234 | );\r | |
1235 | \r | |
1236 | /**\r | |
1237 | Generates a pseudorandom byte stream of the specified size.\r | |
1238 | \r | |
1239 | If Output is NULL, then return FALSE.\r | |
1240 | If this interface is not supported, then return FALSE.\r | |
1241 | \r | |
1242 | @param[out] Output Pointer to buffer to receive random value.\r | |
1243 | @param[in] Size Size of random bytes to generate.\r | |
1244 | \r | |
1245 | @retval TRUE Pseudorandom byte stream generated successfully.\r | |
1246 | @retval FALSE Pseudorandom number generator fails to generate due to lack of entropy.\r | |
1247 | @retval FALSE This interface is not supported.\r | |
1248 | \r | |
1249 | **/\r | |
1250 | typedef\r | |
1251 | BOOLEAN\r | |
1252 | (EFIAPI *EDKII_CRYPTO_RANDOM_BYTES) (\r | |
1253 | OUT UINT8 *Output,\r | |
1254 | IN UINTN Size\r | |
1255 | );\r | |
1256 | \r | |
1257 | /**\r | |
1258 | Verifies the RSA-SSA signature with EMSA-PKCS1-v1_5 encoding scheme defined in\r | |
1259 | RSA PKCS#1.\r | |
1260 | \r | |
1261 | If RsaContext is NULL, then return FALSE.\r | |
1262 | If MessageHash is NULL, then return FALSE.\r | |
1263 | If Signature is NULL, then return FALSE.\r | |
1264 | If HashSize is not equal to the size of MD5, SHA-1, SHA-256 digest, then return FALSE.\r | |
1265 | \r | |
1266 | @param[in] RsaContext Pointer to RSA context for signature verification.\r | |
1267 | @param[in] MessageHash Pointer to octet message hash to be checked.\r | |
1268 | @param[in] HashSize Size of the message hash in bytes.\r | |
1269 | @param[in] Signature Pointer to RSA PKCS1-v1_5 signature to be verified.\r | |
1270 | @param[in] SigSize Size of signature in bytes.\r | |
1271 | \r | |
1272 | @retval TRUE Valid signature encoded in PKCS1-v1_5.\r | |
1273 | @retval FALSE Invalid signature or invalid RSA context.\r | |
1274 | \r | |
1275 | **/\r | |
1276 | typedef\r | |
1277 | BOOLEAN\r | |
1278 | (EFIAPI *EDKII_CRYPTO_RSA_VERIFY_PKCS1) (\r | |
1279 | IN VOID *RsaContext,\r | |
1280 | IN CONST UINT8 *MessageHash,\r | |
1281 | IN UINTN HashSize,\r | |
1282 | IN CONST UINT8 *Signature,\r | |
1283 | IN UINTN SigSize\r | |
1284 | );\r | |
1285 | \r | |
1286 | /**\r | |
1287 | Retrieve the RSA Public Key from one DER-encoded X509 certificate.\r | |
1288 | \r | |
1289 | If Cert is NULL, then return FALSE.\r | |
1290 | If RsaContext is NULL, then return FALSE.\r | |
1291 | If this interface is not supported, then return FALSE.\r | |
1292 | \r | |
1293 | @param[in] Cert Pointer to the DER-encoded X509 certificate.\r | |
1294 | @param[in] CertSize Size of the X509 certificate in bytes.\r | |
1295 | @param[out] RsaContext Pointer to new-generated RSA context which contain the retrieved\r | |
1296 | RSA public key component. Use RsaFree() function to free the\r | |
1297 | resource.\r | |
1298 | \r | |
1299 | @retval TRUE RSA Public Key was retrieved successfully.\r | |
1300 | @retval FALSE Fail to retrieve RSA public key from X509 certificate.\r | |
1301 | @retval FALSE This interface is not supported.\r | |
1302 | \r | |
1303 | **/\r | |
1304 | typedef\r | |
1305 | BOOLEAN\r | |
1306 | (EFIAPI *EDKII_CRYPTO_RSA_GET_PUBLIC_KEY_FROM_X509) (\r | |
1307 | IN CONST UINT8 *Cert,\r | |
1308 | IN UINTN CertSize,\r | |
1309 | OUT VOID **RsaContext\r | |
1310 | );\r | |
1311 | \r | |
1312 | /**\r | |
1313 | Allocates and initializes one RSA context for subsequent use.\r | |
1314 | \r | |
1315 | @return Pointer to the RSA context that has been initialized.\r | |
1316 | If the allocations fails, RsaNew() returns NULL.\r | |
1317 | \r | |
1318 | **/\r | |
1319 | typedef\r | |
1320 | VOID*\r | |
1321 | (EFIAPI *EDKII_CRYPTO_RSA_NEW) (\r | |
1322 | VOID\r | |
1323 | );\r | |
1324 | \r | |
1325 | /**\r | |
1326 | Release the specified RSA context.\r | |
1327 | \r | |
1328 | If RsaContext is NULL, then return FALSE.\r | |
1329 | \r | |
1330 | @param[in] RsaContext Pointer to the RSA context to be released.\r | |
1331 | \r | |
1332 | **/\r | |
1333 | typedef\r | |
1334 | VOID\r | |
1335 | (EFIAPI *EDKII_CRYPTO_RSA_FREE) (\r | |
1336 | IN VOID *RsaContext\r | |
1337 | );\r | |
1338 | \r | |
1339 | /**\r | |
1340 | Sets the tag-designated key component into the established RSA context.\r | |
1341 | \r | |
1342 | This function sets the tag-designated RSA key component into the established\r | |
1343 | RSA context from the user-specified non-negative integer (octet string format\r | |
1344 | represented in RSA PKCS#1).\r | |
1345 | If BigNumber is NULL, then the specified key component in RSA context is cleared.\r | |
1346 | \r | |
1347 | If RsaContext is NULL, then return FALSE.\r | |
1348 | \r | |
1349 | @param[in, out] RsaContext Pointer to RSA context being set.\r | |
1350 | @param[in] KeyTag Tag of RSA key component being set.\r | |
1351 | @param[in] BigNumber Pointer to octet integer buffer.\r | |
1352 | If NULL, then the specified key component in RSA\r | |
1353 | context is cleared.\r | |
1354 | @param[in] BnSize Size of big number buffer in bytes.\r | |
1355 | If BigNumber is NULL, then it is ignored.\r | |
1356 | \r | |
1357 | @retval TRUE RSA key component was set successfully.\r | |
1358 | @retval FALSE Invalid RSA key component tag.\r | |
1359 | \r | |
1360 | **/\r | |
1361 | typedef\r | |
1362 | BOOLEAN\r | |
1363 | (EFIAPI *EDKII_CRYPTO_RSA_SET_KEY) (\r | |
1364 | IN OUT VOID *RsaContext,\r | |
1365 | IN RSA_KEY_TAG KeyTag,\r | |
1366 | IN CONST UINT8 *BigNumber,\r | |
1367 | IN UINTN BnSize\r | |
1368 | );\r | |
1369 | \r | |
1370 | /**\r | |
1371 | Gets the tag-designated RSA key component from the established RSA context.\r | |
1372 | \r | |
1373 | This function retrieves the tag-designated RSA key component from the\r | |
1374 | established RSA context as a non-negative integer (octet string format\r | |
1375 | represented in RSA PKCS#1).\r | |
1376 | If specified key component has not been set or has been cleared, then returned\r | |
1377 | BnSize is set to 0.\r | |
1378 | If the BigNumber buffer is too small to hold the contents of the key, FALSE\r | |
1379 | is returned and BnSize is set to the required buffer size to obtain the key.\r | |
1380 | \r | |
1381 | If RsaContext is NULL, then return FALSE.\r | |
1382 | If BnSize is NULL, then return FALSE.\r | |
1383 | If BnSize is large enough but BigNumber is NULL, then return FALSE.\r | |
1384 | If this interface is not supported, then return FALSE.\r | |
1385 | \r | |
1386 | @param[in, out] RsaContext Pointer to RSA context being set.\r | |
1387 | @param[in] KeyTag Tag of RSA key component being set.\r | |
1388 | @param[out] BigNumber Pointer to octet integer buffer.\r | |
1389 | @param[in, out] BnSize On input, the size of big number buffer in bytes.\r | |
1390 | On output, the size of data returned in big number buffer in bytes.\r | |
1391 | \r | |
1392 | @retval TRUE RSA key component was retrieved successfully.\r | |
1393 | @retval FALSE Invalid RSA key component tag.\r | |
1394 | @retval FALSE BnSize is too small.\r | |
1395 | @retval FALSE This interface is not supported.\r | |
1396 | \r | |
1397 | **/\r | |
1398 | typedef\r | |
1399 | BOOLEAN\r | |
1400 | (EFIAPI *EDKII_CRYPTO_RSA_GET_KEY) (\r | |
1401 | IN OUT VOID *RsaContext,\r | |
1402 | IN RSA_KEY_TAG KeyTag,\r | |
1403 | OUT UINT8 *BigNumber,\r | |
1404 | IN OUT UINTN *BnSize\r | |
1405 | );\r | |
1406 | \r | |
1407 | /**\r | |
1408 | Generates RSA key components.\r | |
1409 | \r | |
1410 | This function generates RSA key components. It takes RSA public exponent E and\r | |
1411 | length in bits of RSA modulus N as input, and generates all key components.\r | |
1412 | If PublicExponent is NULL, the default RSA public exponent (0x10001) will be used.\r | |
1413 | \r | |
1414 | Before this function can be invoked, pseudorandom number generator must be correctly\r | |
1415 | initialized by RandomSeed().\r | |
1416 | \r | |
1417 | If RsaContext is NULL, then return FALSE.\r | |
1418 | If this interface is not supported, then return FALSE.\r | |
1419 | \r | |
1420 | @param[in, out] RsaContext Pointer to RSA context being set.\r | |
1421 | @param[in] ModulusLength Length of RSA modulus N in bits.\r | |
1422 | @param[in] PublicExponent Pointer to RSA public exponent.\r | |
1423 | @param[in] PublicExponentSize Size of RSA public exponent buffer in bytes.\r | |
1424 | \r | |
1425 | @retval TRUE RSA key component was generated successfully.\r | |
1426 | @retval FALSE Invalid RSA key component tag.\r | |
1427 | @retval FALSE This interface is not supported.\r | |
1428 | \r | |
1429 | **/\r | |
1430 | typedef\r | |
1431 | BOOLEAN\r | |
1432 | (EFIAPI *EDKII_CRYPTO_RSA_GENERATE_KEY) (\r | |
1433 | IN OUT VOID *RsaContext,\r | |
1434 | IN UINTN ModulusLength,\r | |
1435 | IN CONST UINT8 *PublicExponent,\r | |
1436 | IN UINTN PublicExponentSize\r | |
1437 | );\r | |
1438 | \r | |
1439 | /**\r | |
1440 | Validates key components of RSA context.\r | |
1441 | NOTE: This function performs integrity checks on all the RSA key material, so\r | |
1442 | the RSA key structure must contain all the private key data.\r | |
1443 | \r | |
1444 | This function validates key components of RSA context in following aspects:\r | |
1445 | - Whether p is a prime\r | |
1446 | - Whether q is a prime\r | |
1447 | - Whether n = p * q\r | |
1448 | - Whether d*e = 1 mod lcm(p-1,q-1)\r | |
1449 | \r | |
1450 | If RsaContext is NULL, then return FALSE.\r | |
1451 | If this interface is not supported, then return FALSE.\r | |
1452 | \r | |
1453 | @param[in] RsaContext Pointer to RSA context to check.\r | |
1454 | \r | |
1455 | @retval TRUE RSA key components are valid.\r | |
1456 | @retval FALSE RSA key components are not valid.\r | |
1457 | @retval FALSE This interface is not supported.\r | |
1458 | \r | |
1459 | **/\r | |
1460 | typedef\r | |
1461 | BOOLEAN\r | |
1462 | (EFIAPI *EDKII_CRYPTO_RSA_CHECK_KEY) (\r | |
1463 | IN VOID *RsaContext\r | |
1464 | );\r | |
1465 | \r | |
1466 | /**\r | |
1467 | Carries out the RSA-SSA signature generation with EMSA-PKCS1-v1_5 encoding scheme.\r | |
1468 | \r | |
1469 | This function carries out the RSA-SSA signature generation with EMSA-PKCS1-v1_5 encoding scheme defined in\r | |
1470 | RSA PKCS#1.\r | |
1471 | If the Signature buffer is too small to hold the contents of signature, FALSE\r | |
1472 | is returned and SigSize is set to the required buffer size to obtain the signature.\r | |
1473 | \r | |
1474 | If RsaContext is NULL, then return FALSE.\r | |
1475 | If MessageHash is NULL, then return FALSE.\r | |
1476 | If HashSize is not equal to the size of MD5, SHA-1 or SHA-256 digest, then return FALSE.\r | |
1477 | If SigSize is large enough but Signature is NULL, then return FALSE.\r | |
1478 | If this interface is not supported, then return FALSE.\r | |
1479 | \r | |
1480 | @param[in] RsaContext Pointer to RSA context for signature generation.\r | |
1481 | @param[in] MessageHash Pointer to octet message hash to be signed.\r | |
1482 | @param[in] HashSize Size of the message hash in bytes.\r | |
1483 | @param[out] Signature Pointer to buffer to receive RSA PKCS1-v1_5 signature.\r | |
1484 | @param[in, out] SigSize On input, the size of Signature buffer in bytes.\r | |
1485 | On output, the size of data returned in Signature buffer in bytes.\r | |
1486 | \r | |
1487 | @retval TRUE Signature successfully generated in PKCS1-v1_5.\r | |
1488 | @retval FALSE Signature generation failed.\r | |
1489 | @retval FALSE SigSize is too small.\r | |
1490 | @retval FALSE This interface is not supported.\r | |
1491 | \r | |
1492 | **/\r | |
1493 | typedef\r | |
1494 | BOOLEAN\r | |
1495 | (EFIAPI *EDKII_CRYPTO_RSA_PKCS1_SIGN) (\r | |
1496 | IN VOID *RsaContext,\r | |
1497 | IN CONST UINT8 *MessageHash,\r | |
1498 | IN UINTN HashSize,\r | |
1499 | OUT UINT8 *Signature,\r | |
1500 | IN OUT UINTN *SigSize\r | |
1501 | );\r | |
1502 | \r | |
1503 | /**\r | |
1504 | Verifies the RSA-SSA signature with EMSA-PKCS1-v1_5 encoding scheme defined in\r | |
1505 | RSA PKCS#1.\r | |
1506 | \r | |
1507 | If RsaContext is NULL, then return FALSE.\r | |
1508 | If MessageHash is NULL, then return FALSE.\r | |
1509 | If Signature is NULL, then return FALSE.\r | |
1510 | If HashSize is not equal to the size of MD5, SHA-1, SHA-256 digest, then return FALSE.\r | |
1511 | \r | |
1512 | @param[in] RsaContext Pointer to RSA context for signature verification.\r | |
1513 | @param[in] MessageHash Pointer to octet message hash to be checked.\r | |
1514 | @param[in] HashSize Size of the message hash in bytes.\r | |
1515 | @param[in] Signature Pointer to RSA PKCS1-v1_5 signature to be verified.\r | |
1516 | @param[in] SigSize Size of signature in bytes.\r | |
1517 | \r | |
1518 | @retval TRUE Valid signature encoded in PKCS1-v1_5.\r | |
1519 | @retval FALSE Invalid signature or invalid RSA context.\r | |
1520 | \r | |
1521 | **/\r | |
1522 | typedef\r | |
1523 | BOOLEAN\r | |
1524 | (EFIAPI *EDKII_CRYPTO_RSA_PKCS1_VERIFY) (\r | |
1525 | IN VOID *RsaContext,\r | |
1526 | IN CONST UINT8 *MessageHash,\r | |
1527 | IN UINTN HashSize,\r | |
1528 | IN CONST UINT8 *Signature,\r | |
1529 | IN UINTN SigSize\r | |
1530 | );\r | |
1531 | \r | |
1532 | /**\r | |
1533 | Retrieve the RSA Private Key from the password-protected PEM key data.\r | |
1534 | \r | |
1535 | If PemData is NULL, then return FALSE.\r | |
1536 | If RsaContext is NULL, then return FALSE.\r | |
1537 | If this interface is not supported, then return FALSE.\r | |
1538 | \r | |
1539 | @param[in] PemData Pointer to the PEM-encoded key data to be retrieved.\r | |
1540 | @param[in] PemSize Size of the PEM key data in bytes.\r | |
1541 | @param[in] Password NULL-terminated passphrase used for encrypted PEM key data.\r | |
1542 | @param[out] RsaContext Pointer to new-generated RSA context which contain the retrieved\r | |
1543 | RSA private key component. Use RsaFree() function to free the\r | |
1544 | resource.\r | |
1545 | \r | |
1546 | @retval TRUE RSA Private Key was retrieved successfully.\r | |
1547 | @retval FALSE Invalid PEM key data or incorrect password.\r | |
1548 | @retval FALSE This interface is not supported.\r | |
1549 | \r | |
1550 | **/\r | |
1551 | typedef\r | |
1552 | BOOLEAN\r | |
1553 | (EFIAPI *EDKII_CRYPTO_RSA_GET_PRIVATE_KEY_FROM_PEM) (\r | |
1554 | IN CONST UINT8 *PemData,\r | |
1555 | IN UINTN PemSize,\r | |
1556 | IN CONST CHAR8 *Password,\r | |
1557 | OUT VOID **RsaContext\r | |
1558 | );\r | |
1559 | \r | |
1560 | /**\r | |
1561 | Retrieve the RSA Public Key from one DER-encoded X509 certificate.\r | |
1562 | \r | |
1563 | If Cert is NULL, then return FALSE.\r | |
1564 | If RsaContext is NULL, then return FALSE.\r | |
1565 | If this interface is not supported, then return FALSE.\r | |
1566 | \r | |
1567 | @param[in] Cert Pointer to the DER-encoded X509 certificate.\r | |
1568 | @param[in] CertSize Size of the X509 certificate in bytes.\r | |
1569 | @param[out] RsaContext Pointer to new-generated RSA context which contain the retrieved\r | |
1570 | RSA public key component. Use RsaFree() function to free the\r | |
1571 | resource.\r | |
1572 | \r | |
1573 | @retval TRUE RSA Public Key was retrieved successfully.\r | |
1574 | @retval FALSE Fail to retrieve RSA public key from X509 certificate.\r | |
1575 | @retval FALSE This interface is not supported.\r | |
1576 | \r | |
1577 | **/\r | |
1578 | typedef\r | |
1579 | BOOLEAN\r | |
1580 | (EFIAPI *EDKII_CRYPTO_RSA_GET_PUBLIC_KEY_FROM_X509) (\r | |
1581 | IN CONST UINT8 *Cert,\r | |
1582 | IN UINTN CertSize,\r | |
1583 | OUT VOID **RsaContext\r | |
1584 | );\r | |
1585 | \r | |
1586 | //----------------------------------------\r | |
1587 | // SHA\r | |
1588 | //----------------------------------------\r | |
1589 | \r | |
1590 | /**\r | |
1591 | Retrieves the size, in bytes, of the context buffer required for SHA-1 hash operations.\r | |
1592 | \r | |
1593 | If this interface is not supported, then return zero.\r | |
1594 | \r | |
1595 | @return The size, in bytes, of the context buffer required for SHA-1 hash operations.\r | |
1596 | @retval 0 This interface is not supported.\r | |
1597 | \r | |
1598 | **/\r | |
1599 | typedef\r | |
1600 | UINTN\r | |
1601 | (EFIAPI *EDKII_CRYPTO_SHA1_GET_CONTEXT_SIZE ) (\r | |
1602 | VOID\r | |
1603 | );\r | |
1604 | \r | |
1605 | /**\r | |
1606 | Initializes user-supplied memory pointed by Sha1Context as SHA-1 hash context for\r | |
1607 | subsequent use.\r | |
1608 | \r | |
1609 | If Sha1Context is NULL, then return FALSE.\r | |
1610 | If this interface is not supported, then return FALSE.\r | |
1611 | \r | |
1612 | @param[out] Sha1Context Pointer to SHA-1 context being initialized.\r | |
1613 | \r | |
1614 | @retval TRUE SHA-1 context initialization succeeded.\r | |
1615 | @retval FALSE SHA-1 context initialization failed.\r | |
1616 | @retval FALSE This interface is not supported.\r | |
1617 | \r | |
1618 | **/\r | |
1619 | typedef\r | |
1620 | BOOLEAN\r | |
1621 | (EFIAPI *EDKII_CRYPTO_SHA1_INIT ) (\r | |
1622 | OUT VOID *Sha1Context\r | |
1623 | );\r | |
1624 | \r | |
1625 | /**\r | |
1626 | Makes a copy of an existing SHA-1 context.\r | |
1627 | \r | |
1628 | If Sha1Context is NULL, then return FALSE.\r | |
1629 | If NewSha1Context is NULL, then return FALSE.\r | |
1630 | If this interface is not supported, then return FALSE.\r | |
1631 | \r | |
1632 | @param[in] Sha1Context Pointer to SHA-1 context being copied.\r | |
1633 | @param[out] NewSha1Context Pointer to new SHA-1 context.\r | |
1634 | \r | |
1635 | @retval TRUE SHA-1 context copy succeeded.\r | |
1636 | @retval FALSE SHA-1 context copy failed.\r | |
1637 | @retval FALSE This interface is not supported.\r | |
1638 | \r | |
1639 | **/\r | |
1640 | typedef\r | |
1641 | BOOLEAN\r | |
1642 | (EFIAPI *EDKII_CRYPTO_SHA1_DUPLICATE ) (\r | |
1643 | IN CONST VOID *Sha1Context,\r | |
1644 | OUT VOID *NewSha1Context\r | |
1645 | );\r | |
1646 | \r | |
1647 | /**\r | |
1648 | Digests the input data and updates SHA-1 context.\r | |
1649 | \r | |
1650 | This function performs SHA-1 digest on a data buffer of the specified size.\r | |
1651 | It can be called multiple times to compute the digest of long or discontinuous data streams.\r | |
1652 | SHA-1 context should be already correctly initialized by Sha1Init(), and should not be finalized\r | |
1653 | by Sha1Final(). Behavior with invalid context is undefined.\r | |
1654 | \r | |
1655 | If Sha1Context is NULL, then return FALSE.\r | |
1656 | If this interface is not supported, then return FALSE.\r | |
1657 | \r | |
1658 | @param[in, out] Sha1Context Pointer to the SHA-1 context.\r | |
1659 | @param[in] Data Pointer to the buffer containing the data to be hashed.\r | |
1660 | @param[in] DataSize Size of Data buffer in bytes.\r | |
1661 | \r | |
1662 | @retval TRUE SHA-1 data digest succeeded.\r | |
1663 | @retval FALSE SHA-1 data digest failed.\r | |
1664 | @retval FALSE This interface is not supported.\r | |
1665 | \r | |
1666 | **/\r | |
1667 | typedef\r | |
1668 | BOOLEAN\r | |
1669 | (EFIAPI *EDKII_CRYPTO_SHA1_UPDATE ) (\r | |
1670 | IN OUT VOID *Sha1Context,\r | |
1671 | IN CONST VOID *Data,\r | |
1672 | IN UINTN DataSize\r | |
1673 | );\r | |
1674 | \r | |
1675 | /**\r | |
1676 | Completes computation of the SHA-1 digest value.\r | |
1677 | \r | |
1678 | This function completes SHA-1 hash computation and retrieves the digest value into\r | |
1679 | the specified memory. After this function has been called, the SHA-1 context cannot\r | |
1680 | be used again.\r | |
1681 | SHA-1 context should be already correctly initialized by Sha1Init(), and should not be\r | |
1682 | finalized by Sha1Final(). Behavior with invalid SHA-1 context is undefined.\r | |
1683 | \r | |
1684 | If Sha1Context is NULL, then return FALSE.\r | |
1685 | If HashValue is NULL, then return FALSE.\r | |
1686 | If this interface is not supported, then return FALSE.\r | |
1687 | \r | |
1688 | @param[in, out] Sha1Context Pointer to the SHA-1 context.\r | |
1689 | @param[out] HashValue Pointer to a buffer that receives the SHA-1 digest\r | |
1690 | value (20 bytes).\r | |
1691 | \r | |
1692 | @retval TRUE SHA-1 digest computation succeeded.\r | |
1693 | @retval FALSE SHA-1 digest computation failed.\r | |
1694 | @retval FALSE This interface is not supported.\r | |
1695 | \r | |
1696 | **/\r | |
1697 | typedef\r | |
1698 | BOOLEAN\r | |
1699 | (EFIAPI *EDKII_CRYPTO_SHA1_FINAL ) (\r | |
1700 | IN OUT VOID *Sha1Context,\r | |
1701 | OUT UINT8 *HashValue\r | |
1702 | );\r | |
1703 | \r | |
1704 | /**\r | |
1705 | Computes the SHA-1 message digest of a input data buffer.\r | |
1706 | \r | |
1707 | This function performs the SHA-1 message digest of a given data buffer, and places\r | |
1708 | the digest value into the specified memory.\r | |
1709 | \r | |
1710 | If this interface is not supported, then return FALSE.\r | |
1711 | \r | |
1712 | @param[in] Data Pointer to the buffer containing the data to be hashed.\r | |
1713 | @param[in] DataSize Size of Data buffer in bytes.\r | |
1714 | @param[out] HashValue Pointer to a buffer that receives the SHA-1 digest\r | |
1715 | value (20 bytes).\r | |
1716 | \r | |
1717 | @retval TRUE SHA-1 digest computation succeeded.\r | |
1718 | @retval FALSE SHA-1 digest computation failed.\r | |
1719 | @retval FALSE This interface is not supported.\r | |
1720 | \r | |
1721 | **/\r | |
1722 | typedef\r | |
1723 | BOOLEAN\r | |
1724 | (EFIAPI *EDKII_CRYPTO_SHA1_HASH_ALL ) (\r | |
1725 | IN CONST VOID *Data,\r | |
1726 | IN UINTN DataSize,\r | |
1727 | OUT UINT8 *HashValue\r | |
1728 | );\r | |
1729 | \r | |
1730 | /**\r | |
1731 | Retrieves the size, in bytes, of the context buffer required for SHA-256 hash operations.\r | |
1732 | \r | |
1733 | @return The size, in bytes, of the context buffer required for SHA-256 hash operations.\r | |
1734 | \r | |
1735 | **/\r | |
1736 | typedef\r | |
1737 | UINTN\r | |
1738 | (EFIAPI *EDKII_CRYPTO_SHA256_GET_CONTEXT_SIZE ) (\r | |
1739 | VOID\r | |
1740 | );\r | |
1741 | \r | |
1742 | /**\r | |
1743 | Initializes user-supplied memory pointed by Sha256Context as SHA-256 hash context for\r | |
1744 | subsequent use.\r | |
1745 | \r | |
1746 | If Sha256Context is NULL, then return FALSE.\r | |
1747 | \r | |
1748 | @param[out] Sha256Context Pointer to SHA-256 context being initialized.\r | |
1749 | \r | |
1750 | @retval TRUE SHA-256 context initialization succeeded.\r | |
1751 | @retval FALSE SHA-256 context initialization failed.\r | |
1752 | \r | |
1753 | **/\r | |
1754 | typedef\r | |
1755 | BOOLEAN\r | |
1756 | (EFIAPI *EDKII_CRYPTO_SHA256_INIT ) (\r | |
1757 | OUT VOID *Sha256Context\r | |
1758 | );\r | |
1759 | \r | |
1760 | /**\r | |
1761 | Makes a copy of an existing SHA-256 context.\r | |
1762 | \r | |
1763 | If Sha256Context is NULL, then return FALSE.\r | |
1764 | If NewSha256Context is NULL, then return FALSE.\r | |
1765 | If this interface is not supported, then return FALSE.\r | |
1766 | \r | |
1767 | @param[in] Sha256Context Pointer to SHA-256 context being copied.\r | |
1768 | @param[out] NewSha256Context Pointer to new SHA-256 context.\r | |
1769 | \r | |
1770 | @retval TRUE SHA-256 context copy succeeded.\r | |
1771 | @retval FALSE SHA-256 context copy failed.\r | |
1772 | @retval FALSE This interface is not supported.\r | |
1773 | \r | |
1774 | **/\r | |
1775 | typedef\r | |
1776 | BOOLEAN\r | |
1777 | (EFIAPI *EDKII_CRYPTO_SHA256_DUPLICATE ) (\r | |
1778 | IN CONST VOID *Sha256Context,\r | |
1779 | OUT VOID *NewSha256Context\r | |
1780 | );\r | |
1781 | \r | |
1782 | /**\r | |
1783 | Digests the input data and updates SHA-256 context.\r | |
1784 | \r | |
1785 | This function performs SHA-256 digest on a data buffer of the specified size.\r | |
1786 | It can be called multiple times to compute the digest of long or discontinuous data streams.\r | |
1787 | SHA-256 context should be already correctly initialized by Sha256Init(), and should not be finalized\r | |
1788 | by Sha256Final(). Behavior with invalid context is undefined.\r | |
1789 | \r | |
1790 | If Sha256Context is NULL, then return FALSE.\r | |
1791 | \r | |
1792 | @param[in, out] Sha256Context Pointer to the SHA-256 context.\r | |
1793 | @param[in] Data Pointer to the buffer containing the data to be hashed.\r | |
1794 | @param[in] DataSize Size of Data buffer in bytes.\r | |
1795 | \r | |
1796 | @retval TRUE SHA-256 data digest succeeded.\r | |
1797 | @retval FALSE SHA-256 data digest failed.\r | |
1798 | \r | |
1799 | **/\r | |
1800 | typedef\r | |
1801 | BOOLEAN\r | |
1802 | (EFIAPI *EDKII_CRYPTO_SHA256_UPDATE ) (\r | |
1803 | IN OUT VOID *Sha256Context,\r | |
1804 | IN CONST VOID *Data,\r | |
1805 | IN UINTN DataSize\r | |
1806 | );\r | |
1807 | \r | |
1808 | /**\r | |
1809 | Completes computation of the SHA-256 digest value.\r | |
1810 | \r | |
1811 | This function completes SHA-256 hash computation and retrieves the digest value into\r | |
1812 | the specified memory. After this function has been called, the SHA-256 context cannot\r | |
1813 | be used again.\r | |
1814 | SHA-256 context should be already correctly initialized by Sha256Init(), and should not be\r | |
1815 | finalized by Sha256Final(). Behavior with invalid SHA-256 context is undefined.\r | |
1816 | \r | |
1817 | If Sha256Context is NULL, then return FALSE.\r | |
1818 | If HashValue is NULL, then return FALSE.\r | |
1819 | \r | |
1820 | @param[in, out] Sha256Context Pointer to the SHA-256 context.\r | |
1821 | @param[out] HashValue Pointer to a buffer that receives the SHA-256 digest\r | |
1822 | value (32 bytes).\r | |
1823 | \r | |
1824 | @retval TRUE SHA-256 digest computation succeeded.\r | |
1825 | @retval FALSE SHA-256 digest computation failed.\r | |
1826 | \r | |
1827 | **/\r | |
1828 | typedef\r | |
1829 | BOOLEAN\r | |
1830 | (EFIAPI *EDKII_CRYPTO_SHA256_FINAL ) (\r | |
1831 | IN OUT VOID *Sha256Context,\r | |
1832 | OUT UINT8 *HashValue\r | |
1833 | );\r | |
1834 | \r | |
1835 | /**\r | |
1836 | Computes the SHA-256 message digest of a input data buffer.\r | |
1837 | \r | |
1838 | This function performs the SHA-256 message digest of a given data buffer, and places\r | |
1839 | the digest value into the specified memory.\r | |
1840 | \r | |
1841 | If this interface is not supported, then return FALSE.\r | |
1842 | \r | |
1843 | @param[in] Data Pointer to the buffer containing the data to be hashed.\r | |
1844 | @param[in] DataSize Size of Data buffer in bytes.\r | |
1845 | @param[out] HashValue Pointer to a buffer that receives the SHA-256 digest\r | |
1846 | value (32 bytes).\r | |
1847 | \r | |
1848 | @retval TRUE SHA-256 digest computation succeeded.\r | |
1849 | @retval FALSE SHA-256 digest computation failed.\r | |
1850 | @retval FALSE This interface is not supported.\r | |
1851 | \r | |
1852 | **/\r | |
1853 | typedef\r | |
1854 | BOOLEAN\r | |
1855 | (EFIAPI *EDKII_CRYPTO_SHA256_HASH_ALL ) (\r | |
1856 | IN CONST VOID *Data,\r | |
1857 | IN UINTN DataSize,\r | |
1858 | OUT UINT8 *HashValue\r | |
1859 | );\r | |
1860 | \r | |
1861 | \r | |
1862 | /**\r | |
1863 | Retrieves the size, in bytes, of the context buffer required for SHA-384 hash operations.\r | |
1864 | If this interface is not supported, then return zero.\r | |
1865 | \r | |
1866 | @return The size, in bytes, of the context buffer required for SHA-384 hash operations.\r | |
1867 | @retval 0 This interface is not supported.\r | |
1868 | \r | |
1869 | **/\r | |
1870 | typedef\r | |
1871 | UINTN\r | |
1872 | (EFIAPI *EDKII_CRYPTO_SHA384_GET_CONTEXT_SIZE) (\r | |
1873 | VOID\r | |
1874 | );\r | |
1875 | \r | |
1876 | \r | |
1877 | /**\r | |
1878 | Initializes user-supplied memory pointed by Sha384Context as SHA-384 hash context for\r | |
1879 | subsequent use.\r | |
1880 | \r | |
1881 | If Sha384Context is NULL, then return FALSE.\r | |
1882 | \r | |
1883 | @param[out] Sha384Context Pointer to SHA-384 context being initialized.\r | |
1884 | \r | |
1885 | @retval TRUE SHA-384 context initialization succeeded.\r | |
1886 | @retval FALSE SHA-384 context initialization failed.\r | |
1887 | \r | |
1888 | **/\r | |
1889 | typedef\r | |
1890 | BOOLEAN\r | |
1891 | (EFIAPI *EDKII_CRYPTO_SHA384_INIT) (\r | |
1892 | OUT VOID *Sha384Context\r | |
1893 | );\r | |
1894 | \r | |
1895 | \r | |
1896 | /**\r | |
1897 | Makes a copy of an existing SHA-384 context.\r | |
1898 | \r | |
1899 | If Sha384Context is NULL, then return FALSE.\r | |
1900 | If NewSha384Context is NULL, then return FALSE.\r | |
1901 | If this interface is not supported, then return FALSE.\r | |
1902 | \r | |
1903 | @param[in] Sha384Context Pointer to SHA-384 context being copied.\r | |
1904 | @param[out] NewSha384Context Pointer to new SHA-384 context.\r | |
1905 | \r | |
1906 | @retval TRUE SHA-384 context copy succeeded.\r | |
1907 | @retval FALSE SHA-384 context copy failed.\r | |
1908 | @retval FALSE This interface is not supported.\r | |
1909 | \r | |
1910 | **/\r | |
1911 | typedef\r | |
1912 | BOOLEAN\r | |
1913 | (EFIAPI *EDKII_CRYPTO_SHA384_DUPLICATE) (\r | |
1914 | IN CONST VOID *Sha384Context,\r | |
1915 | OUT VOID *NewSha384Context\r | |
1916 | );\r | |
1917 | \r | |
1918 | \r | |
1919 | /**\r | |
1920 | Digests the input data and updates SHA-384 context.\r | |
1921 | \r | |
1922 | This function performs SHA-384 digest on a data buffer of the specified size.\r | |
1923 | It can be called multiple times to compute the digest of long or discontinuous data streams.\r | |
1924 | SHA-384 context should be already correctly initialized by Sha384Init(), and should not be finalized\r | |
1925 | by Sha384Final(). Behavior with invalid context is undefined.\r | |
1926 | \r | |
1927 | If Sha384Context is NULL, then return FALSE.\r | |
1928 | \r | |
1929 | @param[in, out] Sha384Context Pointer to the SHA-384 context.\r | |
1930 | @param[in] Data Pointer to the buffer containing the data to be hashed.\r | |
1931 | @param[in] DataSize Size of Data buffer in bytes.\r | |
1932 | \r | |
1933 | @retval TRUE SHA-384 data digest succeeded.\r | |
1934 | @retval FALSE SHA-384 data digest failed.\r | |
1935 | \r | |
1936 | **/\r | |
1937 | typedef\r | |
1938 | BOOLEAN\r | |
1939 | (EFIAPI *EDKII_CRYPTO_SHA384_UPDATE) (\r | |
1940 | IN OUT VOID *Sha384Context,\r | |
1941 | IN CONST VOID *Data,\r | |
1942 | IN UINTN DataSize\r | |
1943 | );\r | |
1944 | \r | |
1945 | \r | |
1946 | /**\r | |
1947 | Completes computation of the SHA-384 digest value.\r | |
1948 | \r | |
1949 | This function completes SHA-384 hash computation and retrieves the digest value into\r | |
1950 | the specified memory. After this function has been called, the SHA-384 context cannot\r | |
1951 | be used again.\r | |
1952 | SHA-384 context should be already correctly initialized by Sha384Init(), and should not be\r | |
1953 | finalized by Sha384Final(). Behavior with invalid SHA-384 context is undefined.\r | |
1954 | \r | |
1955 | If Sha384Context is NULL, then return FALSE.\r | |
1956 | If HashValue is NULL, then return FALSE.\r | |
1957 | \r | |
1958 | @param[in, out] Sha384Context Pointer to the SHA-384 context.\r | |
1959 | @param[out] HashValue Pointer to a buffer that receives the SHA-384 digest\r | |
1960 | value (48 bytes).\r | |
1961 | \r | |
1962 | @retval TRUE SHA-384 digest computation succeeded.\r | |
1963 | @retval FALSE SHA-384 digest computation failed.\r | |
1964 | \r | |
1965 | **/\r | |
1966 | typedef\r | |
1967 | BOOLEAN\r | |
1968 | (EFIAPI *EDKII_CRYPTO_SHA384_FINAL) (\r | |
1969 | IN OUT VOID *Sha384Context,\r | |
1970 | OUT UINT8 *HashValue\r | |
1971 | );\r | |
1972 | \r | |
1973 | \r | |
1974 | /**\r | |
1975 | Computes the SHA-384 message digest of a input data buffer.\r | |
1976 | \r | |
1977 | This function performs the SHA-384 message digest of a given data buffer, and places\r | |
1978 | the digest value into the specified memory.\r | |
1979 | \r | |
1980 | If this interface is not supported, then return FALSE.\r | |
1981 | \r | |
1982 | @param[in] Data Pointer to the buffer containing the data to be hashed.\r | |
1983 | @param[in] DataSize Size of Data buffer in bytes.\r | |
1984 | @param[out] HashValue Pointer to a buffer that receives the SHA-384 digest\r | |
1985 | value (48 bytes).\r | |
1986 | \r | |
1987 | @retval TRUE SHA-384 digest computation succeeded.\r | |
1988 | @retval FALSE SHA-384 digest computation failed.\r | |
1989 | @retval FALSE This interface is not supported.\r | |
1990 | \r | |
1991 | **/\r | |
1992 | typedef\r | |
1993 | BOOLEAN\r | |
1994 | (EFIAPI *EDKII_CRYPTO_SHA384_HASH_ALL) (\r | |
1995 | IN CONST VOID *Data,\r | |
1996 | IN UINTN DataSize,\r | |
1997 | OUT UINT8 *HashValue\r | |
1998 | );\r | |
1999 | \r | |
2000 | /**\r | |
2001 | Retrieves the size, in bytes, of the context buffer required for SHA-512 hash operations.\r | |
2002 | \r | |
2003 | @return The size, in bytes, of the context buffer required for SHA-512 hash operations.\r | |
2004 | \r | |
2005 | **/\r | |
2006 | typedef\r | |
2007 | UINTN\r | |
2008 | (EFIAPI *EDKII_CRYPTO_SHA512_GET_CONTEXT_SIZE) (\r | |
2009 | VOID\r | |
2010 | );\r | |
2011 | \r | |
2012 | \r | |
2013 | /**\r | |
2014 | Initializes user-supplied memory pointed by Sha512Context as SHA-512 hash context for\r | |
2015 | subsequent use.\r | |
2016 | \r | |
2017 | If Sha512Context is NULL, then return FALSE.\r | |
2018 | \r | |
2019 | @param[out] Sha512Context Pointer to SHA-512 context being initialized.\r | |
2020 | \r | |
2021 | @retval TRUE SHA-512 context initialization succeeded.\r | |
2022 | @retval FALSE SHA-512 context initialization failed.\r | |
2023 | \r | |
2024 | **/\r | |
2025 | typedef\r | |
2026 | BOOLEAN\r | |
2027 | (EFIAPI *EDKII_CRYPTO_SHA512_INIT) (\r | |
2028 | OUT VOID *Sha512Context\r | |
2029 | );\r | |
2030 | \r | |
2031 | \r | |
2032 | /**\r | |
2033 | Makes a copy of an existing SHA-512 context.\r | |
2034 | \r | |
2035 | If Sha512Context is NULL, then return FALSE.\r | |
2036 | If NewSha512Context is NULL, then return FALSE.\r | |
2037 | If this interface is not supported, then return FALSE.\r | |
2038 | \r | |
2039 | @param[in] Sha512Context Pointer to SHA-512 context being copied.\r | |
2040 | @param[out] NewSha512Context Pointer to new SHA-512 context.\r | |
2041 | \r | |
2042 | @retval TRUE SHA-512 context copy succeeded.\r | |
2043 | @retval FALSE SHA-512 context copy failed.\r | |
2044 | @retval FALSE This interface is not supported.\r | |
2045 | \r | |
2046 | **/\r | |
2047 | typedef\r | |
2048 | BOOLEAN\r | |
2049 | (EFIAPI *EDKII_CRYPTO_SHA512_DUPLICATE) (\r | |
2050 | IN CONST VOID *Sha512Context,\r | |
2051 | OUT VOID *NewSha512Context\r | |
2052 | );\r | |
2053 | \r | |
2054 | /**\r | |
2055 | Digests the input data and updates SHA-512 context.\r | |
2056 | \r | |
2057 | This function performs SHA-512 digest on a data buffer of the specified size.\r | |
2058 | It can be called multiple times to compute the digest of long or discontinuous data streams.\r | |
2059 | SHA-512 context should be already correctly initialized by Sha512Init(), and should not be finalized\r | |
2060 | by Sha512Final(). Behavior with invalid context is undefined.\r | |
2061 | \r | |
2062 | If Sha512Context is NULL, then return FALSE.\r | |
2063 | \r | |
2064 | @param[in, out] Sha512Context Pointer to the SHA-512 context.\r | |
2065 | @param[in] Data Pointer to the buffer containing the data to be hashed.\r | |
2066 | @param[in] DataSize Size of Data buffer in bytes.\r | |
2067 | \r | |
2068 | @retval TRUE SHA-512 data digest succeeded.\r | |
2069 | @retval FALSE SHA-512 data digest failed.\r | |
2070 | \r | |
2071 | **/\r | |
2072 | typedef\r | |
2073 | BOOLEAN\r | |
2074 | (EFIAPI *EDKII_CRYPTO_SHA512_UPDATE) (\r | |
2075 | IN OUT VOID *Sha512Context,\r | |
2076 | IN CONST VOID *Data,\r | |
2077 | IN UINTN DataSize\r | |
2078 | );\r | |
2079 | \r | |
2080 | \r | |
2081 | /**\r | |
2082 | Completes computation of the SHA-512 digest value.\r | |
2083 | \r | |
2084 | This function completes SHA-512 hash computation and retrieves the digest value into\r | |
2085 | the specified memory. After this function has been called, the SHA-512 context cannot\r | |
2086 | be used again.\r | |
2087 | SHA-512 context should be already correctly initialized by Sha512Init(), and should not be\r | |
2088 | finalized by Sha512Final(). Behavior with invalid SHA-512 context is undefined.\r | |
2089 | \r | |
2090 | If Sha512Context is NULL, then return FALSE.\r | |
2091 | If HashValue is NULL, then return FALSE.\r | |
2092 | \r | |
2093 | @param[in, out] Sha512Context Pointer to the SHA-512 context.\r | |
2094 | @param[out] HashValue Pointer to a buffer that receives the SHA-512 digest\r | |
2095 | value (64 bytes).\r | |
2096 | \r | |
2097 | @retval TRUE SHA-512 digest computation succeeded.\r | |
2098 | @retval FALSE SHA-512 digest computation failed.\r | |
2099 | \r | |
2100 | **/\r | |
2101 | typedef\r | |
2102 | BOOLEAN\r | |
2103 | (EFIAPI *EDKII_CRYPTO_SHA512_FINAL) (\r | |
2104 | IN OUT VOID *Sha512Context,\r | |
2105 | OUT UINT8 *HashValue\r | |
2106 | );\r | |
2107 | \r | |
2108 | /**\r | |
2109 | Computes the SHA-512 message digest of a input data buffer.\r | |
2110 | \r | |
2111 | This function performs the SHA-512 message digest of a given data buffer, and places\r | |
2112 | the digest value into the specified memory.\r | |
2113 | \r | |
2114 | If this interface is not supported, then return FALSE.\r | |
2115 | \r | |
2116 | @param[in] Data Pointer to the buffer containing the data to be hashed.\r | |
2117 | @param[in] DataSize Size of Data buffer in bytes.\r | |
2118 | @param[out] HashValue Pointer to a buffer that receives the SHA-512 digest\r | |
2119 | value (64 bytes).\r | |
2120 | \r | |
2121 | @retval TRUE SHA-512 digest computation succeeded.\r | |
2122 | @retval FALSE SHA-512 digest computation failed.\r | |
2123 | @retval FALSE This interface is not supported.\r | |
2124 | \r | |
2125 | **/\r | |
2126 | typedef\r | |
2127 | BOOLEAN\r | |
2128 | (EFIAPI *EDKII_CRYPTO_SHA512_HASH_ALL) (\r | |
2129 | IN CONST VOID *Data,\r | |
2130 | IN UINTN DataSize,\r | |
2131 | OUT UINT8 *HashValue\r | |
2132 | );\r | |
2133 | \r | |
2134 | //----------------------------------------------------------------------------\r | |
2135 | // X509\r | |
2136 | //----------------------------------------------------------------------------\r | |
2137 | \r | |
2138 | /**\r | |
2139 | Retrieve the subject bytes from one X.509 certificate.\r | |
2140 | \r | |
2141 | If Cert is NULL, then return FALSE.\r | |
2142 | If SubjectSize is NULL, then return FALSE.\r | |
2143 | If this interface is not supported, then return FALSE.\r | |
2144 | \r | |
2145 | @param[in] Cert Pointer to the DER-encoded X509 certificate.\r | |
2146 | @param[in] CertSize Size of the X509 certificate in bytes.\r | |
2147 | @param[out] CertSubject Pointer to the retrieved certificate subject bytes.\r | |
2148 | @param[in, out] SubjectSize The size in bytes of the CertSubject buffer on input,\r | |
2149 | and the size of buffer returned CertSubject on output.\r | |
2150 | \r | |
2151 | @retval TRUE The certificate subject retrieved successfully.\r | |
2152 | @retval FALSE Invalid certificate, or the SubjectSize is too small for the result.\r | |
2153 | The SubjectSize will be updated with the required size.\r | |
2154 | @retval FALSE This interface is not supported.\r | |
2155 | \r | |
2156 | **/\r | |
2157 | typedef\r | |
2158 | BOOLEAN\r | |
2159 | (EFIAPI *EDKII_CRYPTO_X509_GET_SUBJECT_NAME) (\r | |
2160 | IN CONST UINT8 *Cert,\r | |
2161 | IN UINTN CertSize,\r | |
2162 | OUT UINT8 *CertSubject,\r | |
2163 | IN OUT UINTN *SubjectSize\r | |
2164 | );\r | |
2165 | \r | |
2166 | /**\r | |
2167 | Retrieve the common name (CN) string from one X.509 certificate.\r | |
2168 | \r | |
2169 | @param[in] Cert Pointer to the DER-encoded X509 certificate.\r | |
2170 | @param[in] CertSize Size of the X509 certificate in bytes.\r | |
2171 | @param[out] CommonName Buffer to contain the retrieved certificate common\r | |
2172 | name string (UTF8). At most CommonNameSize bytes will be\r | |
2173 | written and the string will be null terminated. May be\r | |
2174 | NULL in order to determine the size buffer needed.\r | |
2175 | @param[in,out] CommonNameSize The size in bytes of the CommonName buffer on input,\r | |
2176 | and the size of buffer returned CommonName on output.\r | |
2177 | If CommonName is NULL then the amount of space needed\r | |
2178 | in buffer (including the final null) is returned.\r | |
2179 | \r | |
2180 | @retval RETURN_SUCCESS The certificate CommonName retrieved successfully.\r | |
2181 | @retval RETURN_INVALID_PARAMETER If Cert is NULL.\r | |
2182 | If CommonNameSize is NULL.\r | |
2183 | If CommonName is not NULL and *CommonNameSize is 0.\r | |
2184 | If Certificate is invalid.\r | |
2185 | @retval RETURN_NOT_FOUND If no CommonName entry exists.\r | |
2186 | @retval RETURN_BUFFER_TOO_SMALL If the CommonName is NULL. The required buffer size\r | |
2187 | (including the final null) is returned in the\r | |
2188 | CommonNameSize parameter.\r | |
2189 | @retval RETURN_UNSUPPORTED The operation is not supported.\r | |
2190 | \r | |
2191 | **/\r | |
2192 | typedef\r | |
2193 | EFI_STATUS\r | |
2194 | (EFIAPI *EDKII_CRYPTO_X509_GET_COMMON_NAME) (\r | |
2195 | IN CONST UINT8 *Cert,\r | |
2196 | IN UINTN CertSize,\r | |
2197 | OUT CHAR8 *CommonName, OPTIONAL\r | |
2198 | IN OUT UINTN *CommonNameSize\r | |
2199 | );\r | |
2200 | \r | |
2201 | /**\r | |
2202 | Retrieve the organization name (O) string from one X.509 certificate.\r | |
2203 | \r | |
2204 | @param[in] Cert Pointer to the DER-encoded X509 certificate.\r | |
2205 | @param[in] CertSize Size of the X509 certificate in bytes.\r | |
2206 | @param[out] NameBuffer Buffer to contain the retrieved certificate organization\r | |
2207 | name string. At most NameBufferSize bytes will be\r | |
2208 | written and the string will be null terminated. May be\r | |
2209 | NULL in order to determine the size buffer needed.\r | |
2210 | @param[in,out] NameBufferSiz e The size in bytes of the Name buffer on input,\r | |
2211 | and the size of buffer returned Name on output.\r | |
2212 | If NameBuffer is NULL then the amount of space needed\r | |
2213 | in buffer (including the final null) is returned.\r | |
2214 | \r | |
2215 | @retval RETURN_SUCCESS The certificate Organization Name retrieved successfully.\r | |
2216 | @retval RETURN_INVALID_PARAMETER If Cert is NULL.\r | |
2217 | If NameBufferSize is NULL.\r | |
2218 | If NameBuffer is not NULL and *CommonNameSize is 0.\r | |
2219 | If Certificate is invalid.\r | |
2220 | @retval RETURN_NOT_FOUND If no Organization Name entry exists.\r | |
2221 | @retval RETURN_BUFFER_TOO_SMALL If the NameBuffer is NULL. The required buffer size\r | |
2222 | (including the final null) is returned in the\r | |
2223 | CommonNameSize parameter.\r | |
2224 | @retval RETURN_UNSUPPORTED The operation is not supported.\r | |
2225 | \r | |
2226 | **/\r | |
2227 | typedef\r | |
2228 | EFI_STATUS\r | |
2229 | (EFIAPI *EDKII_CRYPTO_X509_GET_ORGANIZATION_NAME) (\r | |
2230 | IN CONST UINT8 *Cert,\r | |
2231 | IN UINTN CertSize,\r | |
2232 | OUT CHAR8 *NameBuffer, OPTIONAL\r | |
2233 | IN OUT UINTN *NameBufferSize\r | |
2234 | );\r | |
2235 | \r | |
2236 | /**\r | |
2237 | Verify one X509 certificate was issued by the trusted CA.\r | |
2238 | \r | |
2239 | If Cert is NULL, then return FALSE.\r | |
2240 | If CACert is NULL, then return FALSE.\r | |
2241 | If this interface is not supported, then return FALSE.\r | |
2242 | \r | |
2243 | @param[in] Cert Pointer to the DER-encoded X509 certificate to be verified.\r | |
2244 | @param[in] CertSize Size of the X509 certificate in bytes.\r | |
2245 | @param[in] CACert Pointer to the DER-encoded trusted CA certificate.\r | |
2246 | @param[in] CACertSize Size of the CA Certificate in bytes.\r | |
2247 | \r | |
2248 | @retval TRUE The certificate was issued by the trusted CA.\r | |
2249 | @retval FALSE Invalid certificate or the certificate was not issued by the given\r | |
2250 | trusted CA.\r | |
2251 | @retval FALSE This interface is not supported.\r | |
2252 | \r | |
2253 | **/\r | |
2254 | typedef\r | |
2255 | BOOLEAN\r | |
2256 | (EFIAPI *EDKII_CRYPTO_X509_VERIFY_CERT) (\r | |
2257 | IN CONST UINT8 *Cert,\r | |
2258 | IN UINTN CertSize,\r | |
2259 | IN CONST UINT8 *CACert,\r | |
2260 | IN UINTN CACertSize\r | |
2261 | );\r | |
2262 | \r | |
2263 | /**\r | |
2264 | Construct a X509 object from DER-encoded certificate data.\r | |
2265 | \r | |
2266 | If Cert is NULL, then return FALSE.\r | |
2267 | If SingleX509Cert is NULL, then return FALSE.\r | |
2268 | If this interface is not supported, then return FALSE.\r | |
2269 | \r | |
2270 | @param[in] Cert Pointer to the DER-encoded certificate data.\r | |
2271 | @param[in] CertSize The size of certificate data in bytes.\r | |
2272 | @param[out] SingleX509Cert The generated X509 object.\r | |
2273 | \r | |
2274 | @retval TRUE The X509 object generation succeeded.\r | |
2275 | @retval FALSE The operation failed.\r | |
2276 | @retval FALSE This interface is not supported.\r | |
2277 | \r | |
2278 | **/\r | |
2279 | typedef\r | |
2280 | BOOLEAN\r | |
2281 | (EFIAPI *EDKII_CRYPTO_X509_CONSTRUCT_CERTIFICATE) (\r | |
2282 | IN CONST UINT8 *Cert,\r | |
2283 | IN UINTN CertSize,\r | |
2284 | OUT UINT8 **SingleX509Cert\r | |
2285 | );\r | |
2286 | \r | |
2287 | /**\r | |
2288 | Construct a X509 stack object from a list of DER-encoded certificate data.\r | |
2289 | \r | |
2290 | If X509Stack is NULL, then return FALSE.\r | |
2291 | If this interface is not supported, then return FALSE.\r | |
2292 | \r | |
2293 | @param[in, out] X509Stack On input, pointer to an existing or NULL X509 stack object.\r | |
2294 | On output, pointer to the X509 stack object with new\r | |
2295 | inserted X509 certificate.\r | |
2296 | @param ... A list of DER-encoded single certificate data followed\r | |
2297 | by certificate size. A NULL terminates the list. The\r | |
2298 | pairs are the arguments to X509ConstructCertificate().\r | |
2299 | \r | |
2300 | @retval TRUE The X509 stack construction succeeded.\r | |
2301 | @retval FALSE The construction operation failed.\r | |
2302 | @retval FALSE This interface is not supported.\r | |
2303 | \r | |
2304 | **/\r | |
2305 | typedef\r | |
2306 | BOOLEAN\r | |
2307 | (EFIAPI *EDKII_CRYPTO_X509_CONSTRUCT_CERTIFICATE_STACK) (\r | |
2308 | IN OUT UINT8 **X509Stack,\r | |
2309 | ...\r | |
2310 | );\r | |
2311 | \r | |
2312 | /**\r | |
2313 | Construct a X509 stack object from a list of DER-encoded certificate data.\r | |
2314 | \r | |
2315 | If X509Stack is NULL, then return FALSE.\r | |
2316 | If this interface is not supported, then return FALSE.\r | |
2317 | \r | |
2318 | @param[in, out] X509Stack On input, pointer to an existing or NULL X509 stack object.\r | |
2319 | On output, pointer to the X509 stack object with new\r | |
2320 | inserted X509 certificate.\r | |
2321 | @param[in] Args VA_LIST marker for the variable argument list.\r | |
2322 | A list of DER-encoded single certificate data followed\r | |
2323 | by certificate size. A NULL terminates the list. The\r | |
2324 | pairs are the arguments to X509ConstructCertificate().\r | |
2325 | \r | |
2326 | @retval TRUE The X509 stack construction succeeded.\r | |
2327 | @retval FALSE The construction operation failed.\r | |
2328 | @retval FALSE This interface is not supported.\r | |
2329 | \r | |
2330 | **/\r | |
2331 | typedef\r | |
2332 | BOOLEAN\r | |
2333 | (EFIAPI *EDKII_CRYPTO_X509_CONSTRUCT_CERTIFICATE_STACK_V) (\r | |
2334 | IN OUT UINT8 **X509Stack,\r | |
2335 | IN VA_LIST Args\r | |
2336 | );\r | |
2337 | \r | |
2338 | /**\r | |
2339 | Release the specified X509 object.\r | |
2340 | \r | |
2341 | If the interface is not supported, then ASSERT().\r | |
2342 | \r | |
2343 | @param[in] X509Cert Pointer to the X509 object to be released.\r | |
2344 | \r | |
2345 | **/\r | |
2346 | typedef\r | |
2347 | VOID\r | |
2348 | (EFIAPI *EDKII_CRYPTO_X509_FREE) (\r | |
2349 | IN VOID *X509Cert\r | |
2350 | );\r | |
2351 | \r | |
2352 | /**\r | |
2353 | Release the specified X509 stack object.\r | |
2354 | \r | |
2355 | If the interface is not supported, then ASSERT().\r | |
2356 | \r | |
2357 | @param[in] X509Stack Pointer to the X509 stack object to be released.\r | |
2358 | \r | |
2359 | **/\r | |
2360 | typedef\r | |
2361 | VOID\r | |
2362 | (EFIAPI *EDKII_CRYPTO_X509_STACK_FREE) (\r | |
2363 | IN VOID *X509Stack\r | |
2364 | );\r | |
2365 | \r | |
2366 | /**\r | |
2367 | Retrieve the TBSCertificate from one given X.509 certificate.\r | |
2368 | \r | |
2369 | @param[in] Cert Pointer to the given DER-encoded X509 certificate.\r | |
2370 | @param[in] CertSize Size of the X509 certificate in bytes.\r | |
2371 | @param[out] TBSCert DER-Encoded To-Be-Signed certificate.\r | |
2372 | @param[out] TBSCertSize Size of the TBS certificate in bytes.\r | |
2373 | \r | |
2374 | If Cert is NULL, then return FALSE.\r | |
2375 | If TBSCert is NULL, then return FALSE.\r | |
2376 | If TBSCertSize is NULL, then return FALSE.\r | |
2377 | If this interface is not supported, then return FALSE.\r | |
2378 | \r | |
2379 | @retval TRUE The TBSCertificate was retrieved successfully.\r | |
2380 | @retval FALSE Invalid X.509 certificate.\r | |
2381 | \r | |
2382 | **/\r | |
2383 | typedef\r | |
2384 | BOOLEAN\r | |
2385 | (EFIAPI *EDKII_CRYPTO_X509_GET_TBS_CERT) (\r | |
2386 | IN CONST UINT8 *Cert,\r | |
2387 | IN UINTN CertSize,\r | |
2388 | OUT UINT8 **TBSCert,\r | |
2389 | OUT UINTN *TBSCertSize\r | |
2390 | );\r | |
2391 | \r | |
2392 | \r | |
2393 | \r | |
2394 | //=====================================================================================\r | |
2395 | // Symmetric Cryptography Primitive\r | |
2396 | //=====================================================================================\r | |
2397 | \r | |
2398 | /**\r | |
2399 | Retrieves the size, in bytes, of the context buffer required for TDES operations.\r | |
2400 | \r | |
2401 | If this interface is not supported, then return zero.\r | |
2402 | \r | |
2403 | @return The size, in bytes, of the context buffer required for TDES operations.\r | |
2404 | @retval 0 This interface is not supported.\r | |
2405 | \r | |
2406 | **/\r | |
2407 | typedef\r | |
2408 | UINTN\r | |
2409 | (EFIAPI *EDKII_CRYPTO_TDES_GET_CONTEXT_SIZE) (\r | |
2410 | VOID\r | |
2411 | );\r | |
2412 | \r | |
2413 | /**\r | |
2414 | Initializes user-supplied memory as TDES context for subsequent use.\r | |
2415 | \r | |
2416 | This function initializes user-supplied memory pointed by TdesContext as TDES context.\r | |
2417 | In addition, it sets up all TDES key materials for subsequent encryption and decryption\r | |
2418 | operations.\r | |
2419 | There are 3 key options as follows:\r | |
2420 | KeyLength = 64, Keying option 1: K1 == K2 == K3 (Backward compatibility with DES)\r | |
2421 | KeyLength = 128, Keying option 2: K1 != K2 and K3 = K1 (Less Security)\r | |
2422 | KeyLength = 192 Keying option 3: K1 != K2 != K3 (Strongest)\r | |
2423 | \r | |
2424 | If TdesContext is NULL, then return FALSE.\r | |
2425 | If Key is NULL, then return FALSE.\r | |
2426 | If KeyLength is not valid, then return FALSE.\r | |
2427 | If this interface is not supported, then return FALSE.\r | |
2428 | \r | |
2429 | @param[out] TdesContext Pointer to TDES context being initialized.\r | |
2430 | @param[in] Key Pointer to the user-supplied TDES key.\r | |
2431 | @param[in] KeyLength Length of TDES key in bits.\r | |
2432 | \r | |
2433 | @retval TRUE TDES context initialization succeeded.\r | |
2434 | @retval FALSE TDES context initialization failed.\r | |
2435 | @retval FALSE This interface is not supported.\r | |
2436 | \r | |
2437 | **/\r | |
2438 | typedef\r | |
2439 | BOOLEAN\r | |
2440 | (EFIAPI *EDKII_CRYPTO_TDES_INIT) (\r | |
2441 | OUT VOID *TdesContext,\r | |
2442 | IN CONST UINT8 *Key,\r | |
2443 | IN UINTN KeyLength\r | |
2444 | );\r | |
2445 | \r | |
2446 | /**\r | |
2447 | Performs TDES encryption on a data buffer of the specified size in ECB mode.\r | |
2448 | \r | |
2449 | This function performs TDES encryption on data buffer pointed by Input, of specified\r | |
2450 | size of InputSize, in ECB mode.\r | |
2451 | InputSize must be multiple of block size (8 bytes). This function does not perform\r | |
2452 | padding. Caller must perform padding, if necessary, to ensure valid input data size.\r | |
2453 | TdesContext should be already correctly initialized by TdesInit(). Behavior with\r | |
2454 | invalid TDES context is undefined.\r | |
2455 | \r | |
2456 | If TdesContext is NULL, then return FALSE.\r | |
2457 | If Input is NULL, then return FALSE.\r | |
2458 | If InputSize is not multiple of block size (8 bytes), then return FALSE.\r | |
2459 | If Output is NULL, then return FALSE.\r | |
2460 | If this interface is not supported, then return FALSE.\r | |
2461 | \r | |
2462 | @param[in] TdesContext Pointer to the TDES context.\r | |
2463 | @param[in] Input Pointer to the buffer containing the data to be encrypted.\r | |
2464 | @param[in] InputSize Size of the Input buffer in bytes.\r | |
2465 | @param[out] Output Pointer to a buffer that receives the TDES encryption output.\r | |
2466 | \r | |
2467 | @retval TRUE TDES encryption succeeded.\r | |
2468 | @retval FALSE TDES encryption failed.\r | |
2469 | @retval FALSE This interface is not supported.\r | |
2470 | \r | |
2471 | **/\r | |
2472 | typedef\r | |
2473 | BOOLEAN\r | |
2474 | (EFIAPI *EDKII_CRYPTO_TDES_ECB_ENCRYPT) (\r | |
2475 | IN VOID *TdesContext,\r | |
2476 | IN CONST UINT8 *Input,\r | |
2477 | IN UINTN InputSize,\r | |
2478 | OUT UINT8 *Output\r | |
2479 | );\r | |
2480 | \r | |
2481 | /**\r | |
2482 | Performs TDES decryption on a data buffer of the specified size in ECB mode.\r | |
2483 | \r | |
2484 | This function performs TDES decryption on data buffer pointed by Input, of specified\r | |
2485 | size of InputSize, in ECB mode.\r | |
2486 | InputSize must be multiple of block size (8 bytes). This function does not perform\r | |
2487 | padding. Caller must perform padding, if necessary, to ensure valid input data size.\r | |
2488 | TdesContext should be already correctly initialized by TdesInit(). Behavior with\r | |
2489 | invalid TDES context is undefined.\r | |
2490 | \r | |
2491 | If TdesContext is NULL, then return FALSE.\r | |
2492 | If Input is NULL, then return FALSE.\r | |
2493 | If InputSize is not multiple of block size (8 bytes), then return FALSE.\r | |
2494 | If Output is NULL, then return FALSE.\r | |
2495 | If this interface is not supported, then return FALSE.\r | |
2496 | \r | |
2497 | @param[in] TdesContext Pointer to the TDES context.\r | |
2498 | @param[in] Input Pointer to the buffer containing the data to be decrypted.\r | |
2499 | @param[in] InputSize Size of the Input buffer in bytes.\r | |
2500 | @param[out] Output Pointer to a buffer that receives the TDES decryption output.\r | |
2501 | \r | |
2502 | @retval TRUE TDES decryption succeeded.\r | |
2503 | @retval FALSE TDES decryption failed.\r | |
2504 | @retval FALSE This interface is not supported.\r | |
2505 | \r | |
2506 | **/\r | |
2507 | typedef\r | |
2508 | BOOLEAN\r | |
2509 | (EFIAPI *EDKII_CRYPTO_TDES_ECB_DECRYPT) (\r | |
2510 | IN VOID *TdesContext,\r | |
2511 | IN CONST UINT8 *Input,\r | |
2512 | IN UINTN InputSize,\r | |
2513 | OUT UINT8 *Output\r | |
2514 | );\r | |
2515 | \r | |
2516 | /**\r | |
2517 | Performs TDES encryption on a data buffer of the specified size in CBC mode.\r | |
2518 | \r | |
2519 | This function performs TDES encryption on data buffer pointed by Input, of specified\r | |
2520 | size of InputSize, in CBC mode.\r | |
2521 | InputSize must be multiple of block size (8 bytes). This function does not perform\r | |
2522 | padding. Caller must perform padding, if necessary, to ensure valid input data size.\r | |
2523 | Initialization vector should be one block size (8 bytes).\r | |
2524 | TdesContext should be already correctly initialized by TdesInit(). Behavior with\r | |
2525 | invalid TDES context is undefined.\r | |
2526 | \r | |
2527 | If TdesContext is NULL, then return FALSE.\r | |
2528 | If Input is NULL, then return FALSE.\r | |
2529 | If InputSize is not multiple of block size (8 bytes), then return FALSE.\r | |
2530 | If Ivec is NULL, then return FALSE.\r | |
2531 | If Output is NULL, then return FALSE.\r | |
2532 | If this interface is not supported, then return FALSE.\r | |
2533 | \r | |
2534 | @param[in] TdesContext Pointer to the TDES context.\r | |
2535 | @param[in] Input Pointer to the buffer containing the data to be encrypted.\r | |
2536 | @param[in] InputSize Size of the Input buffer in bytes.\r | |
2537 | @param[in] Ivec Pointer to initialization vector.\r | |
2538 | @param[out] Output Pointer to a buffer that receives the TDES encryption output.\r | |
2539 | \r | |
2540 | @retval TRUE TDES encryption succeeded.\r | |
2541 | @retval FALSE TDES encryption failed.\r | |
2542 | @retval FALSE This interface is not supported.\r | |
2543 | \r | |
2544 | **/\r | |
2545 | typedef\r | |
2546 | BOOLEAN\r | |
2547 | (EFIAPI *EDKII_CRYPTO_TDES_CBC_ENCRYPT) (\r | |
2548 | IN VOID *TdesContext,\r | |
2549 | IN CONST UINT8 *Input,\r | |
2550 | IN UINTN InputSize,\r | |
2551 | IN CONST UINT8 *Ivec,\r | |
2552 | OUT UINT8 *Output\r | |
2553 | );\r | |
2554 | \r | |
2555 | /**\r | |
2556 | Performs TDES decryption on a data buffer of the specified size in CBC mode.\r | |
2557 | \r | |
2558 | This function performs TDES decryption on data buffer pointed by Input, of specified\r | |
2559 | size of InputSize, in CBC mode.\r | |
2560 | InputSize must be multiple of block size (8 bytes). This function does not perform\r | |
2561 | padding. Caller must perform padding, if necessary, to ensure valid input data size.\r | |
2562 | Initialization vector should be one block size (8 bytes).\r | |
2563 | TdesContext should be already correctly initialized by TdesInit(). Behavior with\r | |
2564 | invalid TDES context is undefined.\r | |
2565 | \r | |
2566 | If TdesContext is NULL, then return FALSE.\r | |
2567 | If Input is NULL, then return FALSE.\r | |
2568 | If InputSize is not multiple of block size (8 bytes), then return FALSE.\r | |
2569 | If Ivec is NULL, then return FALSE.\r | |
2570 | If Output is NULL, then return FALSE.\r | |
2571 | If this interface is not supported, then return FALSE.\r | |
2572 | \r | |
2573 | @param[in] TdesContext Pointer to the TDES context.\r | |
2574 | @param[in] Input Pointer to the buffer containing the data to be encrypted.\r | |
2575 | @param[in] InputSize Size of the Input buffer in bytes.\r | |
2576 | @param[in] Ivec Pointer to initialization vector.\r | |
2577 | @param[out] Output Pointer to a buffer that receives the TDES encryption output.\r | |
2578 | \r | |
2579 | @retval TRUE TDES decryption succeeded.\r | |
2580 | @retval FALSE TDES decryption failed.\r | |
2581 | @retval FALSE This interface is not supported.\r | |
2582 | \r | |
2583 | **/\r | |
2584 | typedef\r | |
2585 | BOOLEAN\r | |
2586 | (EFIAPI *EDKII_CRYPTO_TDES_CBC_DECRYPT) (\r | |
2587 | IN VOID *TdesContext,\r | |
2588 | IN CONST UINT8 *Input,\r | |
2589 | IN UINTN InputSize,\r | |
2590 | IN CONST UINT8 *Ivec,\r | |
2591 | OUT UINT8 *Output\r | |
2592 | );\r | |
2593 | \r | |
2594 | /**\r | |
2595 | Retrieves the size, in bytes, of the context buffer required for AES operations.\r | |
2596 | \r | |
2597 | If this interface is not supported, then return zero.\r | |
2598 | \r | |
2599 | @return The size, in bytes, of the context buffer required for AES operations.\r | |
2600 | @retval 0 This interface is not supported.\r | |
2601 | \r | |
2602 | **/\r | |
2603 | typedef\r | |
2604 | UINTN\r | |
2605 | (EFIAPI *EDKII_CRYPTO_AES_GET_CONTEXT_SIZE) (\r | |
2606 | VOID\r | |
2607 | );\r | |
2608 | \r | |
2609 | /**\r | |
2610 | Initializes user-supplied memory as AES context for subsequent use.\r | |
2611 | \r | |
2612 | This function initializes user-supplied memory pointed by AesContext as AES context.\r | |
2613 | In addition, it sets up all AES key materials for subsequent encryption and decryption\r | |
2614 | operations.\r | |
2615 | There are 3 options for key length, 128 bits, 192 bits, and 256 bits.\r | |
2616 | \r | |
2617 | If AesContext is NULL, then return FALSE.\r | |
2618 | If Key is NULL, then return FALSE.\r | |
2619 | If KeyLength is not valid, then return FALSE.\r | |
2620 | If this interface is not supported, then return FALSE.\r | |
2621 | \r | |
2622 | @param[out] AesContext Pointer to AES context being initialized.\r | |
2623 | @param[in] Key Pointer to the user-supplied AES key.\r | |
2624 | @param[in] KeyLength Length of AES key in bits.\r | |
2625 | \r | |
2626 | @retval TRUE AES context initialization succeeded.\r | |
2627 | @retval FALSE AES context initialization failed.\r | |
2628 | @retval FALSE This interface is not supported.\r | |
2629 | \r | |
2630 | **/\r | |
2631 | typedef\r | |
2632 | BOOLEAN\r | |
2633 | (EFIAPI *EDKII_CRYPTO_AES_INIT) (\r | |
2634 | OUT VOID *AesContext,\r | |
2635 | IN CONST UINT8 *Key,\r | |
2636 | IN UINTN KeyLength\r | |
2637 | );\r | |
2638 | \r | |
2639 | /**\r | |
2640 | Performs AES encryption on a data buffer of the specified size in ECB mode.\r | |
2641 | \r | |
2642 | This function performs AES encryption on data buffer pointed by Input, of specified\r | |
2643 | size of InputSize, in ECB mode.\r | |
2644 | InputSize must be multiple of block size (16 bytes). This function does not perform\r | |
2645 | padding. Caller must perform padding, if necessary, to ensure valid input data size.\r | |
2646 | AesContext should be already correctly initialized by AesInit(). Behavior with\r | |
2647 | invalid AES context is undefined.\r | |
2648 | \r | |
2649 | If AesContext is NULL, then return FALSE.\r | |
2650 | If Input is NULL, then return FALSE.\r | |
2651 | If InputSize is not multiple of block size (16 bytes), then return FALSE.\r | |
2652 | If Output is NULL, then return FALSE.\r | |
2653 | If this interface is not supported, then return FALSE.\r | |
2654 | \r | |
2655 | @param[in] AesContext Pointer to the AES context.\r | |
2656 | @param[in] Input Pointer to the buffer containing the data to be encrypted.\r | |
2657 | @param[in] InputSize Size of the Input buffer in bytes.\r | |
2658 | @param[out] Output Pointer to a buffer that receives the AES encryption output.\r | |
2659 | \r | |
2660 | @retval TRUE AES encryption succeeded.\r | |
2661 | @retval FALSE AES encryption failed.\r | |
2662 | @retval FALSE This interface is not supported.\r | |
2663 | \r | |
2664 | **/\r | |
2665 | typedef\r | |
2666 | BOOLEAN\r | |
2667 | (EFIAPI *EDKII_CRYPTO_AES_ECB_ENCRYPT) (\r | |
2668 | IN VOID *AesContext,\r | |
2669 | IN CONST UINT8 *Input,\r | |
2670 | IN UINTN InputSize,\r | |
2671 | OUT UINT8 *Output\r | |
2672 | );\r | |
2673 | \r | |
2674 | /**\r | |
2675 | Performs AES decryption on a data buffer of the specified size in ECB mode.\r | |
2676 | \r | |
2677 | This function performs AES decryption on data buffer pointed by Input, of specified\r | |
2678 | size of InputSize, in ECB mode.\r | |
2679 | InputSize must be multiple of block size (16 bytes). This function does not perform\r | |
2680 | padding. Caller must perform padding, if necessary, to ensure valid input data size.\r | |
2681 | AesContext should be already correctly initialized by AesInit(). Behavior with\r | |
2682 | invalid AES context is undefined.\r | |
2683 | \r | |
2684 | If AesContext is NULL, then return FALSE.\r | |
2685 | If Input is NULL, then return FALSE.\r | |
2686 | If InputSize is not multiple of block size (16 bytes), then return FALSE.\r | |
2687 | If Output is NULL, then return FALSE.\r | |
2688 | If this interface is not supported, then return FALSE.\r | |
2689 | \r | |
2690 | @param[in] AesContext Pointer to the AES context.\r | |
2691 | @param[in] Input Pointer to the buffer containing the data to be decrypted.\r | |
2692 | @param[in] InputSize Size of the Input buffer in bytes.\r | |
2693 | @param[out] Output Pointer to a buffer that receives the AES decryption output.\r | |
2694 | \r | |
2695 | @retval TRUE AES decryption succeeded.\r | |
2696 | @retval FALSE AES decryption failed.\r | |
2697 | @retval FALSE This interface is not supported.\r | |
2698 | \r | |
2699 | **/\r | |
2700 | typedef\r | |
2701 | BOOLEAN\r | |
2702 | (EFIAPI *EDKII_CRYPTO_AES_ECB_DECRYPT) (\r | |
2703 | IN VOID *AesContext,\r | |
2704 | IN CONST UINT8 *Input,\r | |
2705 | IN UINTN InputSize,\r | |
2706 | OUT UINT8 *Output\r | |
2707 | );\r | |
2708 | \r | |
2709 | /**\r | |
2710 | Performs AES encryption on a data buffer of the specified size in CBC mode.\r | |
2711 | \r | |
2712 | This function performs AES encryption on data buffer pointed by Input, of specified\r | |
2713 | size of InputSize, in CBC mode.\r | |
2714 | InputSize must be multiple of block size (16 bytes). This function does not perform\r | |
2715 | padding. Caller must perform padding, if necessary, to ensure valid input data size.\r | |
2716 | Initialization vector should be one block size (16 bytes).\r | |
2717 | AesContext should be already correctly initialized by AesInit(). Behavior with\r | |
2718 | invalid AES context is undefined.\r | |
2719 | \r | |
2720 | If AesContext is NULL, then return FALSE.\r | |
2721 | If Input is NULL, then return FALSE.\r | |
2722 | If InputSize is not multiple of block size (16 bytes), then return FALSE.\r | |
2723 | If Ivec is NULL, then return FALSE.\r | |
2724 | If Output is NULL, then return FALSE.\r | |
2725 | If this interface is not supported, then return FALSE.\r | |
2726 | \r | |
2727 | @param[in] AesContext Pointer to the AES context.\r | |
2728 | @param[in] Input Pointer to the buffer containing the data to be encrypted.\r | |
2729 | @param[in] InputSize Size of the Input buffer in bytes.\r | |
2730 | @param[in] Ivec Pointer to initialization vector.\r | |
2731 | @param[out] Output Pointer to a buffer that receives the AES encryption output.\r | |
2732 | \r | |
2733 | @retval TRUE AES encryption succeeded.\r | |
2734 | @retval FALSE AES encryption failed.\r | |
2735 | @retval FALSE This interface is not supported.\r | |
2736 | \r | |
2737 | **/\r | |
2738 | typedef\r | |
2739 | BOOLEAN\r | |
2740 | (EFIAPI *EDKII_CRYPTO_AES_CBC_ENCRYPT) (\r | |
2741 | IN VOID *AesContext,\r | |
2742 | IN CONST UINT8 *Input,\r | |
2743 | IN UINTN InputSize,\r | |
2744 | IN CONST UINT8 *Ivec,\r | |
2745 | OUT UINT8 *Output\r | |
2746 | );\r | |
2747 | \r | |
2748 | /**\r | |
2749 | Performs AES decryption on a data buffer of the specified size in CBC mode.\r | |
2750 | \r | |
2751 | This function performs AES decryption on data buffer pointed by Input, of specified\r | |
2752 | size of InputSize, in CBC mode.\r | |
2753 | InputSize must be multiple of block size (16 bytes). This function does not perform\r | |
2754 | padding. Caller must perform padding, if necessary, to ensure valid input data size.\r | |
2755 | Initialization vector should be one block size (16 bytes).\r | |
2756 | AesContext should be already correctly initialized by AesInit(). Behavior with\r | |
2757 | invalid AES context is undefined.\r | |
2758 | \r | |
2759 | If AesContext is NULL, then return FALSE.\r | |
2760 | If Input is NULL, then return FALSE.\r | |
2761 | If InputSize is not multiple of block size (16 bytes), then return FALSE.\r | |
2762 | If Ivec is NULL, then return FALSE.\r | |
2763 | If Output is NULL, then return FALSE.\r | |
2764 | If this interface is not supported, then return FALSE.\r | |
2765 | \r | |
2766 | @param[in] AesContext Pointer to the AES context.\r | |
2767 | @param[in] Input Pointer to the buffer containing the data to be encrypted.\r | |
2768 | @param[in] InputSize Size of the Input buffer in bytes.\r | |
2769 | @param[in] Ivec Pointer to initialization vector.\r | |
2770 | @param[out] Output Pointer to a buffer that receives the AES encryption output.\r | |
2771 | \r | |
2772 | @retval TRUE AES decryption succeeded.\r | |
2773 | @retval FALSE AES decryption failed.\r | |
2774 | @retval FALSE This interface is not supported.\r | |
2775 | \r | |
2776 | **/\r | |
2777 | typedef\r | |
2778 | BOOLEAN\r | |
2779 | (EFIAPI *EDKII_CRYPTO_AES_CBC_DECRYPT) (\r | |
2780 | IN VOID *AesContext,\r | |
2781 | IN CONST UINT8 *Input,\r | |
2782 | IN UINTN InputSize,\r | |
2783 | IN CONST UINT8 *Ivec,\r | |
2784 | OUT UINT8 *Output\r | |
2785 | );\r | |
2786 | \r | |
2787 | /**\r | |
2788 | Retrieves the size, in bytes, of the context buffer required for ARC4 operations.\r | |
2789 | \r | |
2790 | If this interface is not supported, then return zero.\r | |
2791 | \r | |
2792 | @return The size, in bytes, of the context buffer required for ARC4 operations.\r | |
2793 | @retval 0 This interface is not supported.\r | |
2794 | \r | |
2795 | **/\r | |
2796 | typedef\r | |
2797 | UINTN\r | |
2798 | (EFIAPI *EDKII_CRYPTO_ARC4_GET_CONTEXT_SIZE) (\r | |
2799 | VOID\r | |
2800 | );\r | |
2801 | \r | |
2802 | /**\r | |
2803 | Initializes user-supplied memory as ARC4 context for subsequent use.\r | |
2804 | \r | |
2805 | This function initializes user-supplied memory pointed by Arc4Context as ARC4 context.\r | |
2806 | In addition, it sets up all ARC4 key materials for subsequent encryption and decryption\r | |
2807 | operations.\r | |
2808 | \r | |
2809 | If Arc4Context is NULL, then return FALSE.\r | |
2810 | If Key is NULL, then return FALSE.\r | |
2811 | If KeySize does not in the range of [5, 256] bytes, then return FALSE.\r | |
2812 | If this interface is not supported, then return FALSE.\r | |
2813 | \r | |
2814 | @param[out] Arc4Context Pointer to ARC4 context being initialized.\r | |
2815 | @param[in] Key Pointer to the user-supplied ARC4 key.\r | |
2816 | @param[in] KeySize Size of ARC4 key in bytes.\r | |
2817 | \r | |
2818 | @retval TRUE ARC4 context initialization succeeded.\r | |
2819 | @retval FALSE ARC4 context initialization failed.\r | |
2820 | @retval FALSE This interface is not supported.\r | |
2821 | \r | |
2822 | **/\r | |
2823 | typedef\r | |
2824 | BOOLEAN\r | |
2825 | (EFIAPI *EDKII_CRYPTO_ARC4_INIT) (\r | |
2826 | OUT VOID *Arc4Context,\r | |
2827 | IN CONST UINT8 *Key,\r | |
2828 | IN UINTN KeySize\r | |
2829 | );\r | |
2830 | \r | |
2831 | /**\r | |
2832 | Performs ARC4 encryption on a data buffer of the specified size.\r | |
2833 | \r | |
2834 | This function performs ARC4 encryption on data buffer pointed by Input, of specified\r | |
2835 | size of InputSize.\r | |
2836 | Arc4Context should be already correctly initialized by Arc4Init(). Behavior with\r | |
2837 | invalid ARC4 context is undefined.\r | |
2838 | \r | |
2839 | If Arc4Context is NULL, then return FALSE.\r | |
2840 | If Input is NULL, then return FALSE.\r | |
2841 | If Output is NULL, then return FALSE.\r | |
2842 | If this interface is not supported, then return FALSE.\r | |
2843 | \r | |
2844 | @param[in, out] Arc4Context Pointer to the ARC4 context.\r | |
2845 | @param[in] Input Pointer to the buffer containing the data to be encrypted.\r | |
2846 | @param[in] InputSize Size of the Input buffer in bytes.\r | |
2847 | @param[out] Output Pointer to a buffer that receives the ARC4 encryption output.\r | |
2848 | \r | |
2849 | @retval TRUE ARC4 encryption succeeded.\r | |
2850 | @retval FALSE ARC4 encryption failed.\r | |
2851 | @retval FALSE This interface is not supported.\r | |
2852 | \r | |
2853 | **/\r | |
2854 | typedef\r | |
2855 | BOOLEAN\r | |
2856 | (EFIAPI *EDKII_CRYPTO_ARC4_ENCRYPT) (\r | |
2857 | IN OUT VOID *Arc4Context,\r | |
2858 | IN CONST UINT8 *Input,\r | |
2859 | IN UINTN InputSize,\r | |
2860 | OUT UINT8 *Output\r | |
2861 | );\r | |
2862 | \r | |
2863 | /**\r | |
2864 | Performs ARC4 decryption on a data buffer of the specified size.\r | |
2865 | \r | |
2866 | This function performs ARC4 decryption on data buffer pointed by Input, of specified\r | |
2867 | size of InputSize.\r | |
2868 | Arc4Context should be already correctly initialized by Arc4Init(). Behavior with\r | |
2869 | invalid ARC4 context is undefined.\r | |
2870 | \r | |
2871 | If Arc4Context is NULL, then return FALSE.\r | |
2872 | If Input is NULL, then return FALSE.\r | |
2873 | If Output is NULL, then return FALSE.\r | |
2874 | If this interface is not supported, then return FALSE.\r | |
2875 | \r | |
2876 | @param[in, out] Arc4Context Pointer to the ARC4 context.\r | |
2877 | @param[in] Input Pointer to the buffer containing the data to be decrypted.\r | |
2878 | @param[in] InputSize Size of the Input buffer in bytes.\r | |
2879 | @param[out] Output Pointer to a buffer that receives the ARC4 decryption output.\r | |
2880 | \r | |
2881 | @retval TRUE ARC4 decryption succeeded.\r | |
2882 | @retval FALSE ARC4 decryption failed.\r | |
2883 | @retval FALSE This interface is not supported.\r | |
2884 | \r | |
2885 | **/\r | |
2886 | typedef\r | |
2887 | BOOLEAN\r | |
2888 | (EFIAPI *EDKII_CRYPTO_ARC4_DECRYPT) (\r | |
2889 | IN OUT VOID *Arc4Context,\r | |
2890 | IN UINT8 *Input,\r | |
2891 | IN UINTN InputSize,\r | |
2892 | OUT UINT8 *Output\r | |
2893 | );\r | |
2894 | \r | |
2895 | /**\r | |
2896 | Resets the ARC4 context to the initial state.\r | |
2897 | \r | |
2898 | The function resets the ARC4 context to the state it had immediately after the\r | |
2899 | ARC4Init() function call.\r | |
2900 | Contrary to ARC4Init(), Arc4Reset() requires no secret key as input, but ARC4 context\r | |
2901 | should be already correctly initialized by ARC4Init().\r | |
2902 | \r | |
2903 | If Arc4Context is NULL, then return FALSE.\r | |
2904 | If this interface is not supported, then return FALSE.\r | |
2905 | \r | |
2906 | @param[in, out] Arc4Context Pointer to the ARC4 context.\r | |
2907 | \r | |
2908 | @retval TRUE ARC4 reset succeeded.\r | |
2909 | @retval FALSE ARC4 reset failed.\r | |
2910 | @retval FALSE This interface is not supported.\r | |
2911 | \r | |
2912 | **/\r | |
2913 | typedef\r | |
2914 | BOOLEAN\r | |
2915 | (EFIAPI *EDKII_CRYPTO_ARC4_RESET) (\r | |
2916 | IN OUT VOID *Arc4Context\r | |
2917 | );\r | |
2918 | \r | |
2919 | \r | |
2920 | /**\r | |
2921 | Retrieves the size, in bytes, of the context buffer required for SM3 hash operations.\r | |
2922 | \r | |
2923 | If this interface is not supported, then return zero.\r | |
2924 | \r | |
2925 | @return The size, in bytes, of the context buffer required for SM3 hash operations.\r | |
2926 | @retval 0 This interface is not supported.\r | |
2927 | \r | |
2928 | **/\r | |
2929 | typedef\r | |
2930 | UINTN\r | |
2931 | (EFIAPI* EDKII_CRYPTO_SM3_GET_CONTEXT_SIZE)(\r | |
2932 | VOID\r | |
2933 | );\r | |
2934 | \r | |
2935 | /**\r | |
2936 | Initializes user-supplied memory pointed by Sm3Context as SM3 hash context for\r | |
2937 | subsequent use.\r | |
2938 | \r | |
2939 | If Sm3Context is NULL, then return FALSE.\r | |
2940 | If this interface is not supported, then return FALSE.\r | |
2941 | \r | |
2942 | @param[out] Sm3Context Pointer to SM3 context being initialized.\r | |
2943 | \r | |
2944 | @retval TRUE SM3 context initialization succeeded.\r | |
2945 | @retval FALSE SM3 context initialization failed.\r | |
2946 | @retval FALSE This interface is not supported.\r | |
2947 | \r | |
2948 | **/\r | |
2949 | typedef\r | |
2950 | BOOLEAN\r | |
2951 | (EFIAPI* EDKII_CRYPTO_SM3_INIT)(\r | |
2952 | OUT VOID *Sm3Context);\r | |
2953 | \r | |
2954 | /**\r | |
2955 | Makes a copy of an existing SM3 context.\r | |
2956 | \r | |
2957 | If Sm3Context is NULL, then return FALSE.\r | |
2958 | If NewSm3Context is NULL, then return FALSE.\r | |
2959 | If this interface is not supported, then return FALSE.\r | |
2960 | \r | |
2961 | @param[in] Sm3Context Pointer to SM3 context being copied.\r | |
2962 | @param[out] NewSm3Context Pointer to new SM3 context.\r | |
2963 | \r | |
2964 | @retval TRUE SM3 context copy succeeded.\r | |
2965 | @retval FALSE SM3 context copy failed.\r | |
2966 | @retval FALSE This interface is not supported.\r | |
2967 | \r | |
2968 | **/\r | |
2969 | typedef\r | |
2970 | BOOLEAN\r | |
2971 | (EFIAPI* EDKII_CRYPTO_SM3_DUPLICATE) (\r | |
2972 | IN CONST VOID *Sm3Context,\r | |
2973 | OUT VOID *NewSm3Context);\r | |
2974 | \r | |
2975 | \r | |
2976 | /**\r | |
2977 | Digests the input data and updates SM3 context.\r | |
2978 | \r | |
2979 | This function performs SM3 digest on a data buffer of the specified size.\r | |
2980 | It can be called multiple times to compute the digest of long or discontinuous data streams.\r | |
2981 | SM3 context should be already correctly initialized by Sm3Init(), and should not be finalized\r | |
2982 | by Sm3Final(). Behavior with invalid context is undefined.\r | |
2983 | \r | |
2984 | If Sm3Context is NULL, then return FALSE.\r | |
2985 | If this interface is not supported, then return FALSE.\r | |
2986 | \r | |
2987 | @param[in, out] Sm3Context Pointer to the SM3 context.\r | |
2988 | @param[in] Data Pointer to the buffer containing the data to be hashed.\r | |
2989 | @param[in] DataSize Size of Data buffer in bytes.\r | |
2990 | \r | |
2991 | @retval TRUE SM3 data digest succeeded.\r | |
2992 | @retval FALSE SM3 data digest failed.\r | |
2993 | @retval FALSE This interface is not supported.\r | |
2994 | \r | |
2995 | **/\r | |
2996 | typedef\r | |
2997 | BOOLEAN\r | |
2998 | (EFIAPI* EDKII_CRYPTO_SM3_UPDATE)(\r | |
2999 | IN OUT VOID *Sm3Context,\r | |
3000 | IN CONST VOID *Data,\r | |
3001 | IN UINTN DataSize);\r | |
3002 | \r | |
3003 | \r | |
3004 | /**\r | |
3005 | Completes computation of the SM3 digest value.\r | |
3006 | \r | |
3007 | This function completes SM3 hash computation and retrieves the digest value into\r | |
3008 | the specified memory. After this function has been called, the SM3 context cannot\r | |
3009 | be used again.\r | |
3010 | SM3 context should be already correctly initialized by Sm3Init(), and should not be\r | |
3011 | finalized by Sm3Final(). Behavior with invalid SM3 context is undefined.\r | |
3012 | \r | |
3013 | If Sm3Context is NULL, then return FALSE.\r | |
3014 | If HashValue is NULL, then return FALSE.\r | |
3015 | If this interface is not supported, then return FALSE.\r | |
3016 | \r | |
3017 | @param[in, out] Sm3Context Pointer to the SM3 context.\r | |
3018 | @param[out] HashValue Pointer to a buffer that receives the SM3 digest\r | |
3019 | value (16 bytes).\r | |
3020 | \r | |
3021 | @retval TRUE SM3 digest computation succeeded.\r | |
3022 | @retval FALSE SM3 digest computation failed.\r | |
3023 | @retval FALSE This interface is not supported.\r | |
3024 | \r | |
3025 | **/\r | |
3026 | typedef\r | |
3027 | BOOLEAN\r | |
3028 | (EFIAPI* EDKII_CRYPTO_SM3_FINAL)(\r | |
3029 | IN OUT VOID *Sm3Context,\r | |
3030 | OUT UINT8 *HashValue);\r | |
3031 | \r | |
3032 | \r | |
3033 | /**\r | |
3034 | Computes the SM3 message digest of a input data buffer.\r | |
3035 | \r | |
3036 | This function performs the SM3 message digest of a given data buffer, and places\r | |
3037 | the digest value into the specified memory.\r | |
3038 | \r | |
3039 | If this interface is not supported, then return FALSE.\r | |
3040 | \r | |
3041 | @param[in] Data Pointer to the buffer containing the data to be hashed.\r | |
3042 | @param[in] DataSize Size of Data buffer in bytes.\r | |
3043 | @param[out] HashValue Pointer to a buffer that receives the SM3 digest\r | |
3044 | value (16 bytes).\r | |
3045 | \r | |
3046 | @retval TRUE SM3 digest computation succeeded.\r | |
3047 | @retval FALSE SM3 digest computation failed.\r | |
3048 | @retval FALSE This interface is not supported.\r | |
3049 | \r | |
3050 | **/\r | |
3051 | typedef\r | |
3052 | BOOLEAN\r | |
3053 | (EFIAPI* EDKII_CRYPTO_SM3_HASH_ALL)(\r | |
3054 | IN CONST VOID *Data,\r | |
3055 | IN UINTN DataSize,\r | |
3056 | OUT UINT8 *HashValue);\r | |
3057 | \r | |
3058 | \r | |
3059 | /**\r | |
3060 | Derive key data using HMAC-SHA256 based KDF.\r | |
3061 | \r | |
3062 | @param[in] Key Pointer to the user-supplied key.\r | |
3063 | @param[in] KeySize Key size in bytes.\r | |
3064 | @param[in] Salt Pointer to the salt(non-secret) value.\r | |
3065 | @param[in] SaltSize Salt size in bytes.\r | |
3066 | @param[in] Info Pointer to the application specific info.\r | |
3067 | @param[in] InfoSize Info size in bytes.\r | |
3068 | @param[out] Out Pointer to buffer to receive hkdf value.\r | |
3069 | @param[in] OutSize Size of hkdf bytes to generate.\r | |
3070 | \r | |
3071 | @retval TRUE Hkdf generated successfully.\r | |
3072 | @retval FALSE Hkdf generation failed.\r | |
3073 | \r | |
3074 | **/\r | |
3075 | typedef\r | |
3076 | BOOLEAN\r | |
3077 | (EFIAPI* EDKII_CRYPTO_HKDF_SHA_256_EXTRACT_AND_EXPAND)(\r | |
3078 | IN CONST UINT8 *Key,\r | |
3079 | IN UINTN KeySize,\r | |
3080 | IN CONST UINT8 *Salt,\r | |
3081 | IN UINTN SaltSize,\r | |
3082 | IN CONST UINT8 *Info,\r | |
3083 | IN UINTN InfoSize,\r | |
3084 | OUT UINT8 *Out,\r | |
3085 | IN UINTN OutSize\r | |
3086 | );\r | |
3087 | \r | |
3088 | /**\r | |
3089 | Initializes the OpenSSL library.\r | |
3090 | \r | |
3091 | This function registers ciphers and digests used directly and indirectly\r | |
3092 | by SSL/TLS, and initializes the readable error messages.\r | |
3093 | This function must be called before any other action takes places.\r | |
3094 | \r | |
3095 | @retval TRUE The OpenSSL library has been initialized.\r | |
3096 | @retval FALSE Failed to initialize the OpenSSL library.\r | |
3097 | \r | |
3098 | **/\r | |
3099 | typedef\r | |
3100 | BOOLEAN\r | |
3101 | (EFIAPI* EDKII_CRYPTO_TLS_INITIALIZE)(\r | |
3102 | VOID\r | |
3103 | );\r | |
3104 | \r | |
3105 | /**\r | |
3106 | Free an allocated SSL_CTX object.\r | |
3107 | \r | |
3108 | @param[in] TlsCtx Pointer to the SSL_CTX object to be released.\r | |
3109 | \r | |
3110 | **/\r | |
3111 | typedef\r | |
3112 | VOID\r | |
3113 | (EFIAPI* EDKII_CRYPTO_TLS_CTX_FREE)(\r | |
3114 | IN VOID *TlsCtx\r | |
3115 | );\r | |
3116 | \r | |
3117 | /**\r | |
3118 | Creates a new SSL_CTX object as framework to establish TLS/SSL enabled\r | |
3119 | connections.\r | |
3120 | \r | |
3121 | @param[in] MajorVer Major Version of TLS/SSL Protocol.\r | |
3122 | @param[in] MinorVer Minor Version of TLS/SSL Protocol.\r | |
3123 | \r | |
3124 | @return Pointer to an allocated SSL_CTX object.\r | |
3125 | If the creation failed, TlsCtxNew() returns NULL.\r | |
3126 | \r | |
3127 | **/\r | |
3128 | typedef\r | |
3129 | VOID *\r | |
3130 | (EFIAPI* EDKII_CRYPTO_TLS_CTX_NEW)(\r | |
3131 | IN UINT8 MajorVer,\r | |
3132 | IN UINT8 MinorVer\r | |
3133 | );\r | |
3134 | \r | |
3135 | /**\r | |
3136 | Free an allocated TLS object.\r | |
3137 | \r | |
3138 | This function removes the TLS object pointed to by Tls and frees up the\r | |
3139 | allocated memory. If Tls is NULL, nothing is done.\r | |
3140 | \r | |
3141 | @param[in] Tls Pointer to the TLS object to be freed.\r | |
3142 | \r | |
3143 | **/\r | |
3144 | typedef\r | |
3145 | VOID\r | |
3146 | (EFIAPI* EDKII_CRYPTO_TLS_FREE)(\r | |
3147 | IN VOID *Tls\r | |
3148 | );\r | |
3149 | \r | |
3150 | /**\r | |
3151 | Create a new TLS object for a connection.\r | |
3152 | \r | |
3153 | This function creates a new TLS object for a connection. The new object\r | |
3154 | inherits the setting of the underlying context TlsCtx: connection method,\r | |
3155 | options, verification setting.\r | |
3156 | \r | |
3157 | @param[in] TlsCtx Pointer to the SSL_CTX object.\r | |
3158 | \r | |
3159 | @return Pointer to an allocated SSL object.\r | |
3160 | If the creation failed, TlsNew() returns NULL.\r | |
3161 | \r | |
3162 | **/\r | |
3163 | typedef\r | |
3164 | VOID *\r | |
3165 | (EFIAPI* EDKII_CRYPTO_TLS_NEW)(\r | |
3166 | IN VOID *TlsCtx\r | |
3167 | );\r | |
3168 | \r | |
3169 | /**\r | |
3170 | Checks if the TLS handshake was done.\r | |
3171 | \r | |
3172 | This function will check if the specified TLS handshake was done.\r | |
3173 | \r | |
3174 | @param[in] Tls Pointer to the TLS object for handshake state checking.\r | |
3175 | \r | |
3176 | @retval TRUE The TLS handshake was done.\r | |
3177 | @retval FALSE The TLS handshake was not done.\r | |
3178 | \r | |
3179 | **/\r | |
3180 | typedef\r | |
3181 | BOOLEAN\r | |
3182 | (EFIAPI* EDKII_CRYPTO_TLS_IN_HANDSHAKE)(\r | |
3183 | IN VOID *Tls\r | |
3184 | );\r | |
3185 | \r | |
3186 | /**\r | |
3187 | Perform a TLS/SSL handshake.\r | |
3188 | \r | |
3189 | This function will perform a TLS/SSL handshake.\r | |
3190 | \r | |
3191 | @param[in] Tls Pointer to the TLS object for handshake operation.\r | |
3192 | @param[in] BufferIn Pointer to the most recently received TLS Handshake packet.\r | |
3193 | @param[in] BufferInSize Packet size in bytes for the most recently received TLS\r | |
3194 | Handshake packet.\r | |
3195 | @param[out] BufferOut Pointer to the buffer to hold the built packet.\r | |
3196 | @param[in, out] BufferOutSize Pointer to the buffer size in bytes. On input, it is\r | |
3197 | the buffer size provided by the caller. On output, it\r | |
3198 | is the buffer size in fact needed to contain the\r | |
3199 | packet.\r | |
3200 | \r | |
3201 | @retval EFI_SUCCESS The required TLS packet is built successfully.\r | |
3202 | @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:\r | |
3203 | Tls is NULL.\r | |
3204 | BufferIn is NULL but BufferInSize is NOT 0.\r | |
3205 | BufferInSize is 0 but BufferIn is NOT NULL.\r | |
3206 | BufferOutSize is NULL.\r | |
3207 | BufferOut is NULL if *BufferOutSize is not zero.\r | |
3208 | @retval EFI_BUFFER_TOO_SMALL BufferOutSize is too small to hold the response packet.\r | |
3209 | @retval EFI_ABORTED Something wrong during handshake.\r | |
3210 | \r | |
3211 | **/\r | |
3212 | typedef\r | |
3213 | EFI_STATUS\r | |
3214 | (EFIAPI* EDKII_CRYPTO_TLS_DO_HANDSHAKE)(\r | |
3215 | IN VOID *Tls,\r | |
3216 | IN UINT8 *BufferIn, OPTIONAL\r | |
3217 | IN UINTN BufferInSize, OPTIONAL\r | |
3218 | OUT UINT8 *BufferOut, OPTIONAL\r | |
3219 | IN OUT UINTN *BufferOutSize\r | |
3220 | );\r | |
3221 | \r | |
3222 | /**\r | |
3223 | Handle Alert message recorded in BufferIn. If BufferIn is NULL and BufferInSize is zero,\r | |
3224 | TLS session has errors and the response packet needs to be Alert message based on error type.\r | |
3225 | \r | |
3226 | @param[in] Tls Pointer to the TLS object for state checking.\r | |
3227 | @param[in] BufferIn Pointer to the most recently received TLS Alert packet.\r | |
3228 | @param[in] BufferInSize Packet size in bytes for the most recently received TLS\r | |
3229 | Alert packet.\r | |
3230 | @param[out] BufferOut Pointer to the buffer to hold the built packet.\r | |
3231 | @param[in, out] BufferOutSize Pointer to the buffer size in bytes. On input, it is\r | |
3232 | the buffer size provided by the caller. On output, it\r | |
3233 | is the buffer size in fact needed to contain the\r | |
3234 | packet.\r | |
3235 | \r | |
3236 | @retval EFI_SUCCESS The required TLS packet is built successfully.\r | |
3237 | @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:\r | |
3238 | Tls is NULL.\r | |
3239 | BufferIn is NULL but BufferInSize is NOT 0.\r | |
3240 | BufferInSize is 0 but BufferIn is NOT NULL.\r | |
3241 | BufferOutSize is NULL.\r | |
3242 | BufferOut is NULL if *BufferOutSize is not zero.\r | |
3243 | @retval EFI_ABORTED An error occurred.\r | |
3244 | @retval EFI_BUFFER_TOO_SMALL BufferOutSize is too small to hold the response packet.\r | |
3245 | \r | |
3246 | **/\r | |
3247 | typedef\r | |
3248 | EFI_STATUS\r | |
3249 | (EFIAPI* EDKII_CRYPTO_TLS_HANDLE_ALERT)(\r | |
3250 | IN VOID *Tls,\r | |
3251 | IN UINT8 *BufferIn, OPTIONAL\r | |
3252 | IN UINTN BufferInSize, OPTIONAL\r | |
3253 | OUT UINT8 *BufferOut, OPTIONAL\r | |
3254 | IN OUT UINTN *BufferOutSize\r | |
3255 | );\r | |
3256 | \r | |
3257 | /**\r | |
3258 | Build the CloseNotify packet.\r | |
3259 | \r | |
3260 | @param[in] Tls Pointer to the TLS object for state checking.\r | |
3261 | @param[in, out] Buffer Pointer to the buffer to hold the built packet.\r | |
3262 | @param[in, out] BufferSize Pointer to the buffer size in bytes. On input, it is\r | |
3263 | the buffer size provided by the caller. On output, it\r | |
3264 | is the buffer size in fact needed to contain the\r | |
3265 | packet.\r | |
3266 | \r | |
3267 | @retval EFI_SUCCESS The required TLS packet is built successfully.\r | |
3268 | @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:\r | |
3269 | Tls is NULL.\r | |
3270 | BufferSize is NULL.\r | |
3271 | Buffer is NULL if *BufferSize is not zero.\r | |
3272 | @retval EFI_BUFFER_TOO_SMALL BufferSize is too small to hold the response packet.\r | |
3273 | \r | |
3274 | **/\r | |
3275 | typedef\r | |
3276 | EFI_STATUS\r | |
3277 | (EFIAPI* EDKII_CRYPTO_TLS_CLOSE_NOTIFY)(\r | |
3278 | IN VOID *Tls,\r | |
3279 | IN OUT UINT8 *Buffer,\r | |
3280 | IN OUT UINTN *BufferSize\r | |
3281 | );\r | |
3282 | \r | |
3283 | /**\r | |
3284 | Attempts to read bytes from one TLS object and places the data in Buffer.\r | |
3285 | \r | |
3286 | This function will attempt to read BufferSize bytes from the TLS object\r | |
3287 | and places the data in Buffer.\r | |
3288 | \r | |
3289 | @param[in] Tls Pointer to the TLS object.\r | |
3290 | @param[in,out] Buffer Pointer to the buffer to store the data.\r | |
3291 | @param[in] BufferSize The size of Buffer in bytes.\r | |
3292 | \r | |
3293 | @retval >0 The amount of data successfully read from the TLS object.\r | |
3294 | @retval <=0 No data was successfully read.\r | |
3295 | \r | |
3296 | **/\r | |
3297 | typedef\r | |
3298 | INTN\r | |
3299 | (EFIAPI* EDKII_CRYPTO_TLS_CTRL_TRAFFIC_OUT)(\r | |
3300 | IN VOID *Tls,\r | |
3301 | IN OUT VOID *Buffer,\r | |
3302 | IN UINTN BufferSize\r | |
3303 | );\r | |
3304 | \r | |
3305 | /**\r | |
3306 | Attempts to write data from the buffer to TLS object.\r | |
3307 | \r | |
3308 | This function will attempt to write BufferSize bytes data from the Buffer\r | |
3309 | to the TLS object.\r | |
3310 | \r | |
3311 | @param[in] Tls Pointer to the TLS object.\r | |
3312 | @param[in] Buffer Pointer to the data buffer.\r | |
3313 | @param[in] BufferSize The size of Buffer in bytes.\r | |
3314 | \r | |
3315 | @retval >0 The amount of data successfully written to the TLS object.\r | |
3316 | @retval <=0 No data was successfully written.\r | |
3317 | \r | |
3318 | **/\r | |
3319 | typedef\r | |
3320 | INTN\r | |
3321 | (EFIAPI* EDKII_CRYPTO_TLS_CTRL_TRAFFIC_IN)(\r | |
3322 | IN VOID *Tls,\r | |
3323 | IN VOID *Buffer,\r | |
3324 | IN UINTN BufferSize\r | |
3325 | );\r | |
3326 | \r | |
3327 | /**\r | |
3328 | Attempts to read bytes from the specified TLS connection into the buffer.\r | |
3329 | \r | |
3330 | This function tries to read BufferSize bytes data from the specified TLS\r | |
3331 | connection into the Buffer.\r | |
3332 | \r | |
3333 | @param[in] Tls Pointer to the TLS connection for data reading.\r | |
3334 | @param[in,out] Buffer Pointer to the data buffer.\r | |
3335 | @param[in] BufferSize The size of Buffer in bytes.\r | |
3336 | \r | |
3337 | @retval >0 The read operation was successful, and return value is the\r | |
3338 | number of bytes actually read from the TLS connection.\r | |
3339 | @retval <=0 The read operation was not successful.\r | |
3340 | \r | |
3341 | **/\r | |
3342 | typedef\r | |
3343 | INTN\r | |
3344 | (EFIAPI* EDKII_CRYPTO_TLS_READ)(\r | |
3345 | IN VOID *Tls,\r | |
3346 | IN OUT VOID *Buffer,\r | |
3347 | IN UINTN BufferSize\r | |
3348 | );\r | |
3349 | \r | |
3350 | /**\r | |
3351 | Attempts to write data to a TLS connection.\r | |
3352 | \r | |
3353 | This function tries to write BufferSize bytes data from the Buffer into the\r | |
3354 | specified TLS connection.\r | |
3355 | \r | |
3356 | @param[in] Tls Pointer to the TLS connection for data writing.\r | |
3357 | @param[in] Buffer Pointer to the data buffer.\r | |
3358 | @param[in] BufferSize The size of Buffer in bytes.\r | |
3359 | \r | |
3360 | @retval >0 The write operation was successful, and return value is the\r | |
3361 | number of bytes actually written to the TLS connection.\r | |
3362 | @retval <=0 The write operation was not successful.\r | |
3363 | \r | |
3364 | **/\r | |
3365 | typedef\r | |
3366 | INTN\r | |
3367 | (EFIAPI* EDKII_CRYPTO_TLS_WRITE)(\r | |
3368 | IN VOID *Tls,\r | |
3369 | IN VOID *Buffer,\r | |
3370 | IN UINTN BufferSize\r | |
3371 | );\r | |
3372 | \r | |
3373 | /**\r | |
3374 | Set a new TLS/SSL method for a particular TLS object.\r | |
3375 | \r | |
3376 | This function sets a new TLS/SSL method for a particular TLS object.\r | |
3377 | \r | |
3378 | @param[in] Tls Pointer to a TLS object.\r | |
3379 | @param[in] MajorVer Major Version of TLS/SSL Protocol.\r | |
3380 | @param[in] MinorVer Minor Version of TLS/SSL Protocol.\r | |
3381 | \r | |
3382 | @retval EFI_SUCCESS The TLS/SSL method was set successfully.\r | |
3383 | @retval EFI_INVALID_PARAMETER The parameter is invalid.\r | |
3384 | @retval EFI_UNSUPPORTED Unsupported TLS/SSL method.\r | |
3385 | \r | |
3386 | **/\r | |
3387 | typedef\r | |
3388 | EFI_STATUS\r | |
3389 | (EFIAPI* EDKII_CRYPTO_TLS_SET_VERSION)(\r | |
3390 | IN VOID *Tls,\r | |
3391 | IN UINT8 MajorVer,\r | |
3392 | IN UINT8 MinorVer\r | |
3393 | );\r | |
3394 | \r | |
3395 | /**\r | |
3396 | Set TLS object to work in client or server mode.\r | |
3397 | \r | |
3398 | This function prepares a TLS object to work in client or server mode.\r | |
3399 | \r | |
3400 | @param[in] Tls Pointer to a TLS object.\r | |
3401 | @param[in] IsServer Work in server mode.\r | |
3402 | \r | |
3403 | @retval EFI_SUCCESS The TLS/SSL work mode was set successfully.\r | |
3404 | @retval EFI_INVALID_PARAMETER The parameter is invalid.\r | |
3405 | @retval EFI_UNSUPPORTED Unsupported TLS/SSL work mode.\r | |
3406 | \r | |
3407 | **/\r | |
3408 | typedef\r | |
3409 | EFI_STATUS\r | |
3410 | (EFIAPI* EDKII_CRYPTO_TLS_SET_CONNECTION_END)(\r | |
3411 | IN VOID *Tls,\r | |
3412 | IN BOOLEAN IsServer\r | |
3413 | );\r | |
3414 | \r | |
3415 | /**\r | |
3416 | Set the ciphers list to be used by the TLS object.\r | |
3417 | \r | |
3418 | This function sets the ciphers for use by a specified TLS object.\r | |
3419 | \r | |
3420 | @param[in] Tls Pointer to a TLS object.\r | |
3421 | @param[in] CipherId Array of UINT16 cipher identifiers. Each UINT16\r | |
3422 | cipher identifier comes from the TLS Cipher Suite\r | |
3423 | Registry of the IANA, interpreting Byte1 and Byte2\r | |
3424 | in network (big endian) byte order.\r | |
3425 | @param[in] CipherNum The number of cipher in the list.\r | |
3426 | \r | |
3427 | @retval EFI_SUCCESS The ciphers list was set successfully.\r | |
3428 | @retval EFI_INVALID_PARAMETER The parameter is invalid.\r | |
3429 | @retval EFI_UNSUPPORTED No supported TLS cipher was found in CipherId.\r | |
3430 | @retval EFI_OUT_OF_RESOURCES Memory allocation failed.\r | |
3431 | \r | |
3432 | **/\r | |
3433 | typedef\r | |
3434 | EFI_STATUS\r | |
3435 | (EFIAPI* EDKII_CRYPTO_TLS_SET_CIPHER_LIST)(\r | |
3436 | IN VOID *Tls,\r | |
3437 | IN UINT16 *CipherId,\r | |
3438 | IN UINTN CipherNum\r | |
3439 | );\r | |
3440 | \r | |
3441 | /**\r | |
3442 | Set the compression method for TLS/SSL operations.\r | |
3443 | \r | |
3444 | This function handles TLS/SSL integrated compression methods.\r | |
3445 | \r | |
3446 | @param[in] CompMethod The compression method ID.\r | |
3447 | \r | |
3448 | @retval EFI_SUCCESS The compression method for the communication was\r | |
3449 | set successfully.\r | |
3450 | @retval EFI_UNSUPPORTED Unsupported compression method.\r | |
3451 | \r | |
3452 | **/\r | |
3453 | typedef\r | |
3454 | EFI_STATUS\r | |
3455 | (EFIAPI* EDKII_CRYPTO_TLS_SET_COMPRESSION_METHOD)(\r | |
3456 | IN UINT8 CompMethod\r | |
3457 | );\r | |
3458 | \r | |
3459 | /**\r | |
3460 | Set peer certificate verification mode for the TLS connection.\r | |
3461 | \r | |
3462 | This function sets the verification mode flags for the TLS connection.\r | |
3463 | \r | |
3464 | @param[in] Tls Pointer to the TLS object.\r | |
3465 | @param[in] VerifyMode A set of logically or'ed verification mode flags.\r | |
3466 | \r | |
3467 | **/\r | |
3468 | typedef\r | |
3469 | VOID\r | |
3470 | (EFIAPI* EDKII_CRYPTO_TLS_SET_VERIFY)(\r | |
3471 | IN VOID *Tls,\r | |
3472 | IN UINT32 VerifyMode\r | |
3473 | );\r | |
3474 | \r | |
3475 | /**\r | |
3476 | Set the specified host name to be verified.\r | |
3477 | \r | |
3478 | @param[in] Tls Pointer to the TLS object.\r | |
3479 | @param[in] Flags The setting flags during the validation.\r | |
3480 | @param[in] HostName The specified host name to be verified.\r | |
3481 | \r | |
3482 | @retval EFI_SUCCESS The HostName setting was set successfully.\r | |
3483 | @retval EFI_INVALID_PARAMETER The parameter is invalid.\r | |
3484 | @retval EFI_ABORTED Invalid HostName setting.\r | |
3485 | \r | |
3486 | **/\r | |
3487 | typedef\r | |
3488 | EFI_STATUS\r | |
3489 | (EFIAPI* EDKII_CRYPTO_TLS_SET_VERIFY_HOST)(\r | |
3490 | IN VOID *Tls,\r | |
3491 | IN UINT32 Flags,\r | |
3492 | IN CHAR8 *HostName\r | |
3493 | );\r | |
3494 | \r | |
3495 | /**\r | |
3496 | Sets a TLS/SSL session ID to be used during TLS/SSL connect.\r | |
3497 | \r | |
3498 | This function sets a session ID to be used when the TLS/SSL connection is\r | |
3499 | to be established.\r | |
3500 | \r | |
3501 | @param[in] Tls Pointer to the TLS object.\r | |
3502 | @param[in] SessionId Session ID data used for session resumption.\r | |
3503 | @param[in] SessionIdLen Length of Session ID in bytes.\r | |
3504 | \r | |
3505 | @retval EFI_SUCCESS Session ID was set successfully.\r | |
3506 | @retval EFI_INVALID_PARAMETER The parameter is invalid.\r | |
3507 | @retval EFI_UNSUPPORTED No available session for ID setting.\r | |
3508 | \r | |
3509 | **/\r | |
3510 | typedef\r | |
3511 | EFI_STATUS\r | |
3512 | (EFIAPI* EDKII_CRYPTO_TLS_SET_SESSIONID)(\r | |
3513 | IN VOID *Tls,\r | |
3514 | IN UINT8 *SessionId,\r | |
3515 | IN UINT16 SessionIdLen\r | |
3516 | );\r | |
3517 | \r | |
3518 | /**\r | |
3519 | Adds the CA to the cert store when requesting Server or Client authentication.\r | |
3520 | \r | |
3521 | This function adds the CA certificate to the list of CAs when requesting\r | |
3522 | Server or Client authentication for the chosen TLS connection.\r | |
3523 | \r | |
3524 | @param[in] Tls Pointer to the TLS object.\r | |
3525 | @param[in] Data Pointer to the data buffer of a DER-encoded binary\r | |
3526 | X.509 certificate or PEM-encoded X.509 certificate.\r | |
3527 | @param[in] DataSize The size of data buffer in bytes.\r | |
3528 | \r | |
3529 | @retval EFI_SUCCESS The operation succeeded.\r | |
3530 | @retval EFI_INVALID_PARAMETER The parameter is invalid.\r | |
3531 | @retval EFI_OUT_OF_RESOURCES Required resources could not be allocated.\r | |
3532 | @retval EFI_ABORTED Invalid X.509 certificate.\r | |
3533 | \r | |
3534 | **/\r | |
3535 | typedef\r | |
3536 | EFI_STATUS\r | |
3537 | (EFIAPI* EDKII_CRYPTO_TLS_SET_CA_CERTIFICATE)(\r | |
3538 | IN VOID *Tls,\r | |
3539 | IN VOID *Data,\r | |
3540 | IN UINTN DataSize\r | |
3541 | );\r | |
3542 | \r | |
3543 | /**\r | |
3544 | Loads the local public certificate into the specified TLS object.\r | |
3545 | \r | |
3546 | This function loads the X.509 certificate into the specified TLS object\r | |
3547 | for TLS negotiation.\r | |
3548 | \r | |
3549 | @param[in] Tls Pointer to the TLS object.\r | |
3550 | @param[in] Data Pointer to the data buffer of a DER-encoded binary\r | |
3551 | X.509 certificate or PEM-encoded X.509 certificate.\r | |
3552 | @param[in] DataSize The size of data buffer in bytes.\r | |
3553 | \r | |
3554 | @retval EFI_SUCCESS The operation succeeded.\r | |
3555 | @retval EFI_INVALID_PARAMETER The parameter is invalid.\r | |
3556 | @retval EFI_OUT_OF_RESOURCES Required resources could not be allocated.\r | |
3557 | @retval EFI_ABORTED Invalid X.509 certificate.\r | |
3558 | \r | |
3559 | **/\r | |
3560 | typedef\r | |
3561 | EFI_STATUS\r | |
3562 | (EFIAPI* EDKII_CRYPTO_TLS_SET_HOST_PUBLIC_CERT)(\r | |
3563 | IN VOID *Tls,\r | |
3564 | IN VOID *Data,\r | |
3565 | IN UINTN DataSize\r | |
3566 | );\r | |
3567 | \r | |
3568 | /**\r | |
3569 | Adds the local private key to the specified TLS object.\r | |
3570 | \r | |
3571 | This function adds the local private key (PEM-encoded RSA or PKCS#8 private\r | |
3572 | key) into the specified TLS object for TLS negotiation.\r | |
3573 | \r | |
3574 | @param[in] Tls Pointer to the TLS object.\r | |
3575 | @param[in] Data Pointer to the data buffer of a PEM-encoded RSA\r | |
3576 | or PKCS#8 private key.\r | |
3577 | @param[in] DataSize The size of data buffer in bytes.\r | |
3578 | \r | |
3579 | @retval EFI_SUCCESS The operation succeeded.\r | |
3580 | @retval EFI_UNSUPPORTED This function is not supported.\r | |
3581 | @retval EFI_ABORTED Invalid private key data.\r | |
3582 | \r | |
3583 | **/\r | |
3584 | typedef\r | |
3585 | EFI_STATUS\r | |
3586 | (EFIAPI* EDKII_CRYPTO_TLS_SET_HOST_PRIVATE_KEY)(\r | |
3587 | IN VOID *Tls,\r | |
3588 | IN VOID *Data,\r | |
3589 | IN UINTN DataSize\r | |
3590 | );\r | |
3591 | \r | |
3592 | /**\r | |
3593 | Adds the CA-supplied certificate revocation list for certificate validation.\r | |
3594 | \r | |
3595 | This function adds the CA-supplied certificate revocation list data for\r | |
3596 | certificate validity checking.\r | |
3597 | \r | |
3598 | @param[in] Data Pointer to the data buffer of a DER-encoded CRL data.\r | |
3599 | @param[in] DataSize The size of data buffer in bytes.\r | |
3600 | \r | |
3601 | @retval EFI_SUCCESS The operation succeeded.\r | |
3602 | @retval EFI_UNSUPPORTED This function is not supported.\r | |
3603 | @retval EFI_ABORTED Invalid CRL data.\r | |
3604 | \r | |
3605 | **/\r | |
3606 | typedef\r | |
3607 | EFI_STATUS\r | |
3608 | (EFIAPI* EDKII_CRYPTO_TLS_SET_CERT_REVOCATION_LIST)(\r | |
3609 | IN VOID *Data,\r | |
3610 | IN UINTN DataSize\r | |
3611 | );\r | |
3612 | \r | |
3613 | /**\r | |
3614 | Gets the protocol version used by the specified TLS connection.\r | |
3615 | \r | |
3616 | This function returns the protocol version used by the specified TLS\r | |
3617 | connection.\r | |
3618 | \r | |
3619 | If Tls is NULL, then ASSERT().\r | |
3620 | \r | |
3621 | @param[in] Tls Pointer to the TLS object.\r | |
3622 | \r | |
3623 | @return The protocol version of the specified TLS connection.\r | |
3624 | \r | |
3625 | **/\r | |
3626 | typedef\r | |
3627 | UINT16\r | |
3628 | (EFIAPI* EDKII_CRYPTO_TLS_GET_VERSION)(\r | |
3629 | IN VOID *Tls\r | |
3630 | );\r | |
3631 | \r | |
3632 | /**\r | |
3633 | Gets the connection end of the specified TLS connection.\r | |
3634 | \r | |
3635 | This function returns the connection end (as client or as server) used by\r | |
3636 | the specified TLS connection.\r | |
3637 | \r | |
3638 | If Tls is NULL, then ASSERT().\r | |
3639 | \r | |
3640 | @param[in] Tls Pointer to the TLS object.\r | |
3641 | \r | |
3642 | @return The connection end used by the specified TLS connection.\r | |
3643 | \r | |
3644 | **/\r | |
3645 | typedef\r | |
3646 | UINT8\r | |
3647 | (EFIAPI* EDKII_CRYPTO_TLS_GET_CONNECTION_END)(\r | |
3648 | IN VOID *Tls\r | |
3649 | );\r | |
3650 | \r | |
3651 | /**\r | |
3652 | Gets the cipher suite used by the specified TLS connection.\r | |
3653 | \r | |
3654 | This function returns current cipher suite used by the specified\r | |
3655 | TLS connection.\r | |
3656 | \r | |
3657 | @param[in] Tls Pointer to the TLS object.\r | |
3658 | @param[in,out] CipherId The cipher suite used by the TLS object.\r | |
3659 | \r | |
3660 | @retval EFI_SUCCESS The cipher suite was returned successfully.\r | |
3661 | @retval EFI_INVALID_PARAMETER The parameter is invalid.\r | |
3662 | @retval EFI_UNSUPPORTED Unsupported cipher suite.\r | |
3663 | \r | |
3664 | **/\r | |
3665 | typedef\r | |
3666 | EFI_STATUS\r | |
3667 | (EFIAPI* EDKII_CRYPTO_TLS_GET_CURRENT_CIPHER)(\r | |
3668 | IN VOID *Tls,\r | |
3669 | IN OUT UINT16 *CipherId\r | |
3670 | );\r | |
3671 | \r | |
3672 | /**\r | |
3673 | Gets the compression methods used by the specified TLS connection.\r | |
3674 | \r | |
3675 | This function returns current integrated compression methods used by\r | |
3676 | the specified TLS connection.\r | |
3677 | \r | |
3678 | @param[in] Tls Pointer to the TLS object.\r | |
3679 | @param[in,out] CompressionId The current compression method used by\r | |
3680 | the TLS object.\r | |
3681 | \r | |
3682 | @retval EFI_SUCCESS The compression method was returned successfully.\r | |
3683 | @retval EFI_INVALID_PARAMETER The parameter is invalid.\r | |
3684 | @retval EFI_ABORTED Invalid Compression method.\r | |
3685 | @retval EFI_UNSUPPORTED This function is not supported.\r | |
3686 | \r | |
3687 | **/\r | |
3688 | typedef\r | |
3689 | EFI_STATUS\r | |
3690 | (EFIAPI* EDKII_CRYPTO_TLS_GET_CURRENT_COMPRESSION_ID)(\r | |
3691 | IN VOID *Tls,\r | |
3692 | IN OUT UINT8 *CompressionId\r | |
3693 | );\r | |
3694 | \r | |
3695 | /**\r | |
3696 | Gets the verification mode currently set in the TLS connection.\r | |
3697 | \r | |
3698 | This function returns the peer verification mode currently set in the\r | |
3699 | specified TLS connection.\r | |
3700 | \r | |
3701 | If Tls is NULL, then ASSERT().\r | |
3702 | \r | |
3703 | @param[in] Tls Pointer to the TLS object.\r | |
3704 | \r | |
3705 | @return The verification mode set in the specified TLS connection.\r | |
3706 | \r | |
3707 | **/\r | |
3708 | typedef\r | |
3709 | UINT32\r | |
3710 | (EFIAPI* EDKII_CRYPTO_TLS_GET_VERIFY)(\r | |
3711 | IN VOID *Tls\r | |
3712 | );\r | |
3713 | \r | |
3714 | /**\r | |
3715 | Gets the session ID used by the specified TLS connection.\r | |
3716 | \r | |
3717 | This function returns the TLS/SSL session ID currently used by the\r | |
3718 | specified TLS connection.\r | |
3719 | \r | |
3720 | @param[in] Tls Pointer to the TLS object.\r | |
3721 | @param[in,out] SessionId Buffer to contain the returned session ID.\r | |
3722 | @param[in,out] SessionIdLen The length of Session ID in bytes.\r | |
3723 | \r | |
3724 | @retval EFI_SUCCESS The Session ID was returned successfully.\r | |
3725 | @retval EFI_INVALID_PARAMETER The parameter is invalid.\r | |
3726 | @retval EFI_UNSUPPORTED Invalid TLS/SSL session.\r | |
3727 | \r | |
3728 | **/\r | |
3729 | typedef\r | |
3730 | EFI_STATUS\r | |
3731 | (EFIAPI* EDKII_CRYPTO_TLS_GET_SESSION_ID)(\r | |
3732 | IN VOID *Tls,\r | |
3733 | IN OUT UINT8 *SessionId,\r | |
3734 | IN OUT UINT16 *SessionIdLen\r | |
3735 | );\r | |
3736 | \r | |
3737 | /**\r | |
3738 | Gets the client random data used in the specified TLS connection.\r | |
3739 | \r | |
3740 | This function returns the TLS/SSL client random data currently used in\r | |
3741 | the specified TLS connection.\r | |
3742 | \r | |
3743 | @param[in] Tls Pointer to the TLS object.\r | |
3744 | @param[in,out] ClientRandom Buffer to contain the returned client\r | |
3745 | random data (32 bytes).\r | |
3746 | \r | |
3747 | **/\r | |
3748 | typedef\r | |
3749 | VOID\r | |
3750 | (EFIAPI* EDKII_CRYPTO_TLS_GET_CLIENT_RANDOM)(\r | |
3751 | IN VOID *Tls,\r | |
3752 | IN OUT UINT8 *ClientRandom\r | |
3753 | );\r | |
3754 | \r | |
3755 | /**\r | |
3756 | Gets the server random data used in the specified TLS connection.\r | |
3757 | \r | |
3758 | This function returns the TLS/SSL server random data currently used in\r | |
3759 | the specified TLS connection.\r | |
3760 | \r | |
3761 | @param[in] Tls Pointer to the TLS object.\r | |
3762 | @param[in,out] ServerRandom Buffer to contain the returned server\r | |
3763 | random data (32 bytes).\r | |
3764 | \r | |
3765 | **/\r | |
3766 | typedef\r | |
3767 | VOID\r | |
3768 | (EFIAPI* EDKII_CRYPTO_TLS_GET_SERVER_RANDOM)(\r | |
3769 | IN VOID *Tls,\r | |
3770 | IN OUT UINT8 *ServerRandom\r | |
3771 | );\r | |
3772 | \r | |
3773 | /**\r | |
3774 | Gets the master key data used in the specified TLS connection.\r | |
3775 | \r | |
3776 | This function returns the TLS/SSL master key material currently used in\r | |
3777 | the specified TLS connection.\r | |
3778 | \r | |
3779 | @param[in] Tls Pointer to the TLS object.\r | |
3780 | @param[in,out] KeyMaterial Buffer to contain the returned key material.\r | |
3781 | \r | |
3782 | @retval EFI_SUCCESS Key material was returned successfully.\r | |
3783 | @retval EFI_INVALID_PARAMETER The parameter is invalid.\r | |
3784 | @retval EFI_UNSUPPORTED Invalid TLS/SSL session.\r | |
3785 | \r | |
3786 | **/\r | |
3787 | typedef\r | |
3788 | EFI_STATUS\r | |
3789 | (EFIAPI* EDKII_CRYPTO_TLS_GET_KEY_MATERIAL)(\r | |
3790 | IN VOID *Tls,\r | |
3791 | IN OUT UINT8 *KeyMaterial\r | |
3792 | );\r | |
3793 | \r | |
3794 | /**\r | |
3795 | Gets the CA Certificate from the cert store.\r | |
3796 | \r | |
3797 | This function returns the CA certificate for the chosen\r | |
3798 | TLS connection.\r | |
3799 | \r | |
3800 | @param[in] Tls Pointer to the TLS object.\r | |
3801 | @param[out] Data Pointer to the data buffer to receive the CA\r | |
3802 | certificate data sent to the client.\r | |
3803 | @param[in,out] DataSize The size of data buffer in bytes.\r | |
3804 | \r | |
3805 | @retval EFI_SUCCESS The operation succeeded.\r | |
3806 | @retval EFI_UNSUPPORTED This function is not supported.\r | |
3807 | @retval EFI_BUFFER_TOO_SMALL The Data is too small to hold the data.\r | |
3808 | \r | |
3809 | **/\r | |
3810 | typedef\r | |
3811 | EFI_STATUS\r | |
3812 | (EFIAPI* EDKII_CRYPTO_TLS_GET_CA_CERTIFICATE)(\r | |
3813 | IN VOID *Tls,\r | |
3814 | OUT VOID *Data,\r | |
3815 | IN OUT UINTN *DataSize\r | |
3816 | );\r | |
3817 | \r | |
3818 | /**\r | |
3819 | Gets the local public Certificate set in the specified TLS object.\r | |
3820 | \r | |
3821 | This function returns the local public certificate which was currently set\r | |
3822 | in the specified TLS object.\r | |
3823 | \r | |
3824 | @param[in] Tls Pointer to the TLS object.\r | |
3825 | @param[out] Data Pointer to the data buffer to receive the local\r | |
3826 | public certificate.\r | |
3827 | @param[in,out] DataSize The size of data buffer in bytes.\r | |
3828 | \r | |
3829 | @retval EFI_SUCCESS The operation succeeded.\r | |
3830 | @retval EFI_INVALID_PARAMETER The parameter is invalid.\r | |
3831 | @retval EFI_NOT_FOUND The certificate is not found.\r | |
3832 | @retval EFI_BUFFER_TOO_SMALL The Data is too small to hold the data.\r | |
3833 | \r | |
3834 | **/\r | |
3835 | typedef\r | |
3836 | EFI_STATUS\r | |
3837 | (EFIAPI* EDKII_CRYPTO_TLS_GET_HOST_PUBLIC_CERT)(\r | |
3838 | IN VOID *Tls,\r | |
3839 | OUT VOID *Data,\r | |
3840 | IN OUT UINTN *DataSize\r | |
3841 | );\r | |
3842 | \r | |
3843 | /**\r | |
3844 | Gets the local private key set in the specified TLS object.\r | |
3845 | \r | |
3846 | This function returns the local private key data which was currently set\r | |
3847 | in the specified TLS object.\r | |
3848 | \r | |
3849 | @param[in] Tls Pointer to the TLS object.\r | |
3850 | @param[out] Data Pointer to the data buffer to receive the local\r | |
3851 | private key data.\r | |
3852 | @param[in,out] DataSize The size of data buffer in bytes.\r | |
3853 | \r | |
3854 | @retval EFI_SUCCESS The operation succeeded.\r | |
3855 | @retval EFI_UNSUPPORTED This function is not supported.\r | |
3856 | @retval EFI_BUFFER_TOO_SMALL The Data is too small to hold the data.\r | |
3857 | \r | |
3858 | **/\r | |
3859 | typedef\r | |
3860 | EFI_STATUS\r | |
3861 | (EFIAPI* EDKII_CRYPTO_TLS_GET_HOST_PRIVATE_KEY)(\r | |
3862 | IN VOID *Tls,\r | |
3863 | OUT VOID *Data,\r | |
3864 | IN OUT UINTN *DataSize\r | |
3865 | );\r | |
3866 | \r | |
3867 | /**\r | |
3868 | Gets the CA-supplied certificate revocation list data set in the specified\r | |
3869 | TLS object.\r | |
3870 | \r | |
3871 | This function returns the CA-supplied certificate revocation list data which\r | |
3872 | was currently set in the specified TLS object.\r | |
3873 | \r | |
3874 | @param[out] Data Pointer to the data buffer to receive the CRL data.\r | |
3875 | @param[in,out] DataSize The size of data buffer in bytes.\r | |
3876 | \r | |
3877 | @retval EFI_SUCCESS The operation succeeded.\r | |
3878 | @retval EFI_UNSUPPORTED This function is not supported.\r | |
3879 | @retval EFI_BUFFER_TOO_SMALL The Data is too small to hold the data.\r | |
3880 | \r | |
3881 | **/\r | |
3882 | typedef\r | |
3883 | EFI_STATUS\r | |
3884 | (EFIAPI* EDKII_CRYPTO_TLS_GET_CERT_REVOCATION_LIST)(\r | |
3885 | OUT VOID *DATA,\r | |
3886 | IN OUT UINTN *DataSize\r | |
3887 | );\r | |
3888 | \r | |
3889 | \r | |
3890 | ///\r | |
3891 | /// EDK II Crypto Protocol\r | |
3892 | ///\r | |
3893 | struct _EDKII_CRYPTO_PROTOCOL {\r | |
3894 | /// Version\r | |
3895 | EDKII_CRYPTO_GET_VERSION GetVersion;\r | |
3896 | /// HMAC MD5\r | |
3897 | EDKII_CRYPTO_HMAC_MD5_NEW HmacMd5New;\r | |
3898 | EDKII_CRYPTO_HMAC_MD5_FREE HmacMd5Free;\r | |
3899 | EDKII_CRYPTO_HMAC_MD5_SET_KEY HmacMd5SetKey;\r | |
3900 | EDKII_CRYPTO_HMAC_MD5_DUPLICATE HmacMd5Duplicate;\r | |
3901 | EDKII_CRYPTO_HMAC_MD5_UPDATE HmacMd5Update;\r | |
3902 | EDKII_CRYPTO_HMAC_MD5_FINAL HmacMd5Final;\r | |
3903 | /// HMAC SHA1\r | |
3904 | EDKII_CRYPTO_HMAC_SHA1_NEW HmacSha1New;\r | |
3905 | EDKII_CRYPTO_HMAC_SHA1_FREE HmacSha1Free;\r | |
3906 | EDKII_CRYPTO_HMAC_SHA1_SET_KEY HmacSha1SetKey;\r | |
3907 | EDKII_CRYPTO_HMAC_SHA1_DUPLICATE HmacSha1Duplicate;\r | |
3908 | EDKII_CRYPTO_HMAC_SHA1_UPDATE HmacSha1Update;\r | |
3909 | EDKII_CRYPTO_HMAC_SHA1_FINAL HmacSha1Final;\r | |
3910 | /// HMAC SHA256\r | |
3911 | EDKII_CRYPTO_HMAC_SHA256_NEW HmacSha256New;\r | |
3912 | EDKII_CRYPTO_HMAC_SHA256_FREE HmacSha256Free;\r | |
3913 | EDKII_CRYPTO_HMAC_SHA256_SET_KEY HmacSha256SetKey;\r | |
3914 | EDKII_CRYPTO_HMAC_SHA256_DUPLICATE HmacSha256Duplicate;\r | |
3915 | EDKII_CRYPTO_HMAC_SHA256_UPDATE HmacSha256Update;\r | |
3916 | EDKII_CRYPTO_HMAC_SHA256_FINAL HmacSha256Final;\r | |
0a6fc3d0 ZG |
3917 | /// Md4 - deprecated and unsupported\r |
3918 | DEPRECATED_EDKII_CRYPTO_MD4_GET_CONTEXT_SIZE DeprecatedMd4GetContextSize;\r | |
3919 | DEPRECATED_EDKII_CRYPTO_MD4_INIT DeprecatedMd4Init;\r | |
3920 | DEPRECATED_EDKII_CRYPTO_MD4_DUPLICATE DeprecatedMd4Duplicate;\r | |
3921 | DEPRECATED_EDKII_CRYPTO_MD4_UPDATE DeprecatedMd4Update;\r | |
3922 | DEPRECATED_EDKII_CRYPTO_MD4_FINAL DeprecatedMd4Final;\r | |
3923 | DEPRECATED_EDKII_CRYPTO_MD4_HASH_ALL DeprecatedMd4HashAll;\r | |
3b0e0430 MK |
3924 | /// Md5\r |
3925 | EDKII_CRYPTO_MD5_GET_CONTEXT_SIZE Md5GetContextSize;\r | |
3926 | EDKII_CRYPTO_MD5_INIT Md5Init;\r | |
3927 | EDKII_CRYPTO_MD5_DUPLICATE Md5Duplicate;\r | |
3928 | EDKII_CRYPTO_MD5_UPDATE Md5Update;\r | |
3929 | EDKII_CRYPTO_MD5_FINAL Md5Final;\r | |
3930 | EDKII_CRYPTO_MD5_HASH_ALL Md5HashAll;\r | |
3931 | /// Pkcs\r | |
3932 | EDKII_CRYPTO_PKCS1_ENCRYPT_V2 Pkcs1v2Encrypt;\r | |
3933 | EDKII_CRYPTO_PKCS5_PW_HASH Pkcs5HashPassword;\r | |
3934 | EDKII_CRYPTO_PKCS7_VERIFY Pkcs7Verify;\r | |
3935 | EDKII_CRYPTO_PKCS7_VERIFY_EKU VerifyEKUsInPkcs7Signature;\r | |
3936 | EDKII_CRYPTO_PKCS7_GET_SIGNERS Pkcs7GetSigners;\r | |
3937 | EDKII_CRYPTO_PKCS7_FREE_SIGNERS Pkcs7FreeSigners;\r | |
3938 | EDKII_CRYPTO_PKCS7_SIGN Pkcs7Sign;\r | |
3939 | EDKII_CRYPTO_PKCS7_GET_ATTACHED_CONTENT Pkcs7GetAttachedContent;\r | |
3940 | EDKII_CRYPTO_PKCS7_GET_CERTIFICATES_LIST Pkcs7GetCertificatesList;\r | |
3941 | EDKII_CRYPTO_AUTHENTICODE_VERIFY AuthenticodeVerify;\r | |
3942 | EDKII_CRYPTO_IMAGE_TIMESTAMP_VERIFY ImageTimestampVerify;\r | |
3943 | /// DH\r | |
3944 | EDKII_CRYPTO_DH_NEW DhNew;\r | |
3945 | EDKII_CRYPTO_DH_FREE DhFree;\r | |
3946 | EDKII_CRYPTO_DH_GENERATE_PARAMETER DhGenerateParameter;\r | |
3947 | EDKII_CRYPTO_DH_SET_PARAMETER DhSetParameter;\r | |
3948 | EDKII_CRYPTO_DH_GENERATE_KEY DhGenerateKey;\r | |
3949 | EDKII_CRYPTO_DH_COMPUTE_KEY DhComputeKey;\r | |
3950 | /// Random\r | |
3951 | EDKII_CRYPTO_RANDOM_SEED RandomSeed;\r | |
3952 | EDKII_CRYPTO_RANDOM_BYTES RandomBytes;\r | |
3953 | /// RSA\r | |
3954 | EDKII_CRYPTO_RSA_VERIFY_PKCS1 RsaVerifyPkcs1;\r | |
3955 | EDKII_CRYPTO_RSA_NEW RsaNew;\r | |
3956 | EDKII_CRYPTO_RSA_FREE RsaFree;\r | |
3957 | EDKII_CRYPTO_RSA_SET_KEY RsaSetKey;\r | |
3958 | EDKII_CRYPTO_RSA_GET_KEY RsaGetKey;\r | |
3959 | EDKII_CRYPTO_RSA_GENERATE_KEY RsaGenerateKey;\r | |
3960 | EDKII_CRYPTO_RSA_CHECK_KEY RsaCheckKey;\r | |
3961 | EDKII_CRYPTO_RSA_PKCS1_SIGN RsaPkcs1Sign;\r | |
3962 | EDKII_CRYPTO_RSA_PKCS1_VERIFY RsaPkcs1Verify;\r | |
3963 | EDKII_CRYPTO_RSA_GET_PRIVATE_KEY_FROM_PEM RsaGetPrivateKeyFromPem;\r | |
3964 | EDKII_CRYPTO_RSA_GET_PUBLIC_KEY_FROM_X509 RsaGetPublicKeyFromX509;\r | |
3965 | /// Sha1\r | |
3966 | EDKII_CRYPTO_SHA1_GET_CONTEXT_SIZE Sha1GetContextSize;\r | |
3967 | EDKII_CRYPTO_SHA1_INIT Sha1Init;\r | |
3968 | EDKII_CRYPTO_SHA1_DUPLICATE Sha1Duplicate;\r | |
3969 | EDKII_CRYPTO_SHA1_UPDATE Sha1Update;\r | |
3970 | EDKII_CRYPTO_SHA1_FINAL Sha1Final;\r | |
3971 | EDKII_CRYPTO_SHA1_HASH_ALL Sha1HashAll;\r | |
3972 | /// Sha256\r | |
3973 | EDKII_CRYPTO_SHA256_GET_CONTEXT_SIZE Sha256GetContextSize;\r | |
3974 | EDKII_CRYPTO_SHA256_INIT Sha256Init;\r | |
3975 | EDKII_CRYPTO_SHA256_DUPLICATE Sha256Duplicate;\r | |
3976 | EDKII_CRYPTO_SHA256_UPDATE Sha256Update;\r | |
3977 | EDKII_CRYPTO_SHA256_FINAL Sha256Final;\r | |
3978 | EDKII_CRYPTO_SHA256_HASH_ALL Sha256HashAll;\r | |
3979 | /// Sha384\r | |
3980 | EDKII_CRYPTO_SHA384_GET_CONTEXT_SIZE Sha384GetContextSize;\r | |
3981 | EDKII_CRYPTO_SHA384_INIT Sha384Init;\r | |
3982 | EDKII_CRYPTO_SHA384_DUPLICATE Sha384Duplicate;\r | |
3983 | EDKII_CRYPTO_SHA384_UPDATE Sha384Update;\r | |
3984 | EDKII_CRYPTO_SHA384_FINAL Sha384Final;\r | |
3985 | EDKII_CRYPTO_SHA384_HASH_ALL Sha384HashAll;\r | |
3986 | /// Sha512\r | |
3987 | EDKII_CRYPTO_SHA512_GET_CONTEXT_SIZE Sha512GetContextSize;\r | |
3988 | EDKII_CRYPTO_SHA512_INIT Sha512Init;\r | |
3989 | EDKII_CRYPTO_SHA512_DUPLICATE Sha512Duplicate;\r | |
3990 | EDKII_CRYPTO_SHA512_UPDATE Sha512Update;\r | |
3991 | EDKII_CRYPTO_SHA512_FINAL Sha512Final;\r | |
3992 | EDKII_CRYPTO_SHA512_HASH_ALL Sha512HashAll;\r | |
3993 | /// X509\r | |
3994 | EDKII_CRYPTO_X509_GET_SUBJECT_NAME X509GetSubjectName;\r | |
3995 | EDKII_CRYPTO_X509_GET_COMMON_NAME X509GetCommonName;\r | |
3996 | EDKII_CRYPTO_X509_GET_ORGANIZATION_NAME X509GetOrganizationName;\r | |
3997 | EDKII_CRYPTO_X509_VERIFY_CERT X509VerifyCert;\r | |
3998 | EDKII_CRYPTO_X509_CONSTRUCT_CERTIFICATE X509ConstructCertificate;\r | |
3999 | EDKII_CRYPTO_X509_CONSTRUCT_CERTIFICATE_STACK X509ConstructCertificateStack;\r | |
4000 | EDKII_CRYPTO_X509_FREE X509Free;\r | |
4001 | EDKII_CRYPTO_X509_STACK_FREE X509StackFree;\r | |
4002 | EDKII_CRYPTO_X509_GET_TBS_CERT X509GetTBSCert;\r | |
4003 | /// TDES\r | |
4004 | EDKII_CRYPTO_TDES_GET_CONTEXT_SIZE TdesGetContextSize;\r | |
4005 | EDKII_CRYPTO_TDES_INIT TdesInit;\r | |
4006 | EDKII_CRYPTO_TDES_ECB_ENCRYPT TdesEcbEncrypt;\r | |
4007 | EDKII_CRYPTO_TDES_ECB_DECRYPT TdesEcbDecrypt;\r | |
4008 | EDKII_CRYPTO_TDES_CBC_ENCRYPT TdesCbcEncrypt;\r | |
4009 | EDKII_CRYPTO_TDES_CBC_DECRYPT TdesCbcDecrypt;\r | |
4010 | /// AES\r | |
4011 | EDKII_CRYPTO_AES_GET_CONTEXT_SIZE AesGetContextSize;\r | |
4012 | EDKII_CRYPTO_AES_INIT AesInit;\r | |
4013 | EDKII_CRYPTO_AES_ECB_ENCRYPT AesEcbEncrypt;\r | |
4014 | EDKII_CRYPTO_AES_ECB_DECRYPT AesEcbDecrypt;\r | |
4015 | EDKII_CRYPTO_AES_CBC_ENCRYPT AesCbcEncrypt;\r | |
4016 | EDKII_CRYPTO_AES_CBC_DECRYPT AesCbcDecrypt;\r | |
4017 | /// Arc4\r | |
4018 | EDKII_CRYPTO_ARC4_GET_CONTEXT_SIZE Arc4GetContextSize;\r | |
4019 | EDKII_CRYPTO_ARC4_INIT Arc4Init;\r | |
4020 | EDKII_CRYPTO_ARC4_ENCRYPT Arc4Encrypt;\r | |
4021 | EDKII_CRYPTO_ARC4_DECRYPT Arc4Decrypt;\r | |
4022 | EDKII_CRYPTO_ARC4_RESET Arc4Reset;\r | |
4023 | /// SM3\r | |
4024 | EDKII_CRYPTO_SM3_GET_CONTEXT_SIZE Sm3GetContextSize;\r | |
4025 | EDKII_CRYPTO_SM3_INIT Sm3Init;\r | |
4026 | EDKII_CRYPTO_SM3_DUPLICATE Sm3Duplicate;\r | |
4027 | EDKII_CRYPTO_SM3_UPDATE Sm3Update;\r | |
4028 | EDKII_CRYPTO_SM3_FINAL Sm3Final;\r | |
4029 | EDKII_CRYPTO_SM3_HASH_ALL Sm3HashAll;\r | |
4030 | /// HKDF\r | |
4031 | EDKII_CRYPTO_HKDF_SHA_256_EXTRACT_AND_EXPAND HkdfSha256ExtractAndExpand;\r | |
4032 | /// X509 (Continued)\r | |
4033 | EDKII_CRYPTO_X509_CONSTRUCT_CERTIFICATE_STACK_V X509ConstructCertificateStackV;\r | |
4034 | /// TLS\r | |
4035 | EDKII_CRYPTO_TLS_INITIALIZE TlsInitialize;\r | |
4036 | EDKII_CRYPTO_TLS_CTX_FREE TlsCtxFree;\r | |
4037 | EDKII_CRYPTO_TLS_CTX_NEW TlsCtxNew;\r | |
4038 | EDKII_CRYPTO_TLS_FREE TlsFree;\r | |
4039 | EDKII_CRYPTO_TLS_NEW TlsNew;\r | |
4040 | EDKII_CRYPTO_TLS_IN_HANDSHAKE TlsInHandshake;\r | |
4041 | EDKII_CRYPTO_TLS_DO_HANDSHAKE TlsDoHandshake;\r | |
4042 | EDKII_CRYPTO_TLS_HANDLE_ALERT TlsHandleAlert;\r | |
4043 | EDKII_CRYPTO_TLS_CLOSE_NOTIFY TlsCloseNotify;\r | |
4044 | EDKII_CRYPTO_TLS_CTRL_TRAFFIC_OUT TlsCtrlTrafficOut;\r | |
4045 | EDKII_CRYPTO_TLS_CTRL_TRAFFIC_IN TlsCtrlTrafficIn;\r | |
4046 | EDKII_CRYPTO_TLS_READ TlsRead;\r | |
4047 | EDKII_CRYPTO_TLS_WRITE TlsWrite;\r | |
4048 | /// TLS Set\r | |
4049 | EDKII_CRYPTO_TLS_SET_VERSION TlsSetVersion;\r | |
4050 | EDKII_CRYPTO_TLS_SET_CONNECTION_END TlsSetConnectionEnd;\r | |
4051 | EDKII_CRYPTO_TLS_SET_CIPHER_LIST TlsSetCipherList;\r | |
4052 | EDKII_CRYPTO_TLS_SET_COMPRESSION_METHOD TlsSetCompressionMethod;\r | |
4053 | EDKII_CRYPTO_TLS_SET_VERIFY TlsSetVerify;\r | |
4054 | EDKII_CRYPTO_TLS_SET_VERIFY_HOST TlsSetVerifyHost;\r | |
4055 | EDKII_CRYPTO_TLS_SET_SESSIONID TlsSetSessionId;\r | |
4056 | EDKII_CRYPTO_TLS_SET_CA_CERTIFICATE TlsSetCaCertificate;\r | |
4057 | EDKII_CRYPTO_TLS_SET_HOST_PUBLIC_CERT TlsSetHostPublicCert;\r | |
4058 | EDKII_CRYPTO_TLS_SET_HOST_PRIVATE_KEY TlsSetHostPrivateKey;\r | |
4059 | EDKII_CRYPTO_TLS_SET_CERT_REVOCATION_LIST TlsSetCertRevocationList;\r | |
4060 | /// TLS Get\r | |
4061 | EDKII_CRYPTO_TLS_GET_VERSION TlsGetVersion;\r | |
4062 | EDKII_CRYPTO_TLS_GET_CONNECTION_END TlsGetConnectionEnd;\r | |
4063 | EDKII_CRYPTO_TLS_GET_CURRENT_CIPHER TlsGetCurrentCipher;\r | |
4064 | EDKII_CRYPTO_TLS_GET_CURRENT_COMPRESSION_ID TlsGetCurrentCompressionId;\r | |
4065 | EDKII_CRYPTO_TLS_GET_VERIFY TlsGetVerify;\r | |
4066 | EDKII_CRYPTO_TLS_GET_SESSION_ID TlsGetSessionId;\r | |
4067 | EDKII_CRYPTO_TLS_GET_CLIENT_RANDOM TlsGetClientRandom;\r | |
4068 | EDKII_CRYPTO_TLS_GET_SERVER_RANDOM TlsGetServerRandom;\r | |
4069 | EDKII_CRYPTO_TLS_GET_KEY_MATERIAL TlsGetKeyMaterial;\r | |
4070 | EDKII_CRYPTO_TLS_GET_CA_CERTIFICATE TlsGetCaCertificate;\r | |
4071 | EDKII_CRYPTO_TLS_GET_HOST_PUBLIC_CERT TlsGetHostPublicCert;\r | |
4072 | EDKII_CRYPTO_TLS_GET_HOST_PRIVATE_KEY TlsGetHostPrivateKey;\r | |
4073 | EDKII_CRYPTO_TLS_GET_CERT_REVOCATION_LIST TlsGetCertRevocationList;\r | |
4074 | };\r | |
4075 | \r | |
4076 | extern GUID gEdkiiCryptoProtocolGuid;\r | |
4077 | \r | |
4078 | #endif\r |