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