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