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