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