]>
Commit | Line | Data |
---|---|---|
cc1d13c9 MK |
1 | /** @file\r |
2 | Implements the EDK II Crypto Protocol/PPI services using the library services\r | |
3 | from BaseCryptLib and TlsLib.\r | |
4 | \r | |
5 | Copyright (C) Microsoft Corporation. All rights reserved.\r | |
c1e66210 | 6 | Copyright (c) 2019 - 2022, Intel Corporation. All rights reserved.<BR>\r |
cc1d13c9 MK |
7 | SPDX-License-Identifier: BSD-2-Clause-Patent\r |
8 | \r | |
9 | **/\r | |
10 | #include <Base.h>\r | |
11 | #include <Library/DebugLib.h>\r | |
12 | #include <Library/BaseCryptLib.h>\r | |
13 | #include <Library/TlsLib.h>\r | |
14 | #include <Protocol/Crypto.h>\r | |
15 | #include <Pcd/PcdCryptoServiceFamilyEnable.h>\r | |
16 | \r | |
17 | /**\r | |
18 | A macro used to retrieve the FixedAtBuild PcdCryptoServiceFamilyEnable with a\r | |
19 | typecast to its associcted structure type PCD_CRYPTO_SERVICE_FAMILY_ENABLE.\r | |
20 | **/\r | |
7c342378 | 21 | #define EDKII_CRYPTO_PCD ((const PCD_CRYPTO_SERVICE_FAMILY_ENABLE *)\\r |
cc1d13c9 MK |
22 | (FixedPcdGetPtr (PcdCryptoServiceFamilyEnable)))\r |
23 | \r | |
24 | /**\r | |
25 | A macro used to call a non-void BaseCryptLib function if it is enabled.\r | |
26 | \r | |
27 | If a BaseCryptLib function is not enabled, there will be no references to it\r | |
28 | from this module and will be optimized away reducing the size of this module.\r | |
29 | \r | |
30 | @param Enable The name of the enable field in PCD\r | |
31 | PcdCryptoServiceFamilyEnable for the BaseCryptLib\r | |
32 | function being called. If the value of this field\r | |
33 | is non-zero, then the BaseCryptLib function is\r | |
34 | enabled.\r | |
35 | @param Function The name of the BaseCryptLib function.\r | |
36 | @param Args The argument list to pass to Function.\r | |
37 | @param ErrorReturnValue The value to return if the BaseCryptLib function is\r | |
38 | not enabled.\r | |
39 | \r | |
40 | **/\r | |
41 | #define CALL_BASECRYPTLIB(Enable, Function, Args, ErrorReturnValue) \\r | |
42 | EDKII_CRYPTO_PCD->Enable \\r | |
43 | ? Function Args \\r | |
aaa90aac | 44 | : (BaseCryptLibServiceNotEnabled (#Function), ErrorReturnValue)\r |
cc1d13c9 MK |
45 | \r |
46 | /**\r | |
47 | A macro used to call a void BaseCryptLib function if it is enabled.\r | |
48 | \r | |
49 | If a BaseCryptLib function is not enabled, there will be no references to it\r | |
50 | from this module and will be optimized away reducing the size of this module.\r | |
51 | \r | |
52 | @param Enable The name of the enable field in PCD\r | |
53 | PcdCryptoServiceFamilyEnable for the BaseCryptLib\r | |
54 | function being called. If the value of this field\r | |
55 | is non-zero, then the BaseCryptLib function is\r | |
56 | enabled.\r | |
57 | @param Function The name of the BaseCryptLib function.\r | |
58 | @param Args The argument list to pass to Function.\r | |
59 | \r | |
60 | **/\r | |
61 | #define CALL_VOID_BASECRYPTLIB(Enable, Function, Args) \\r | |
62 | EDKII_CRYPTO_PCD->Enable \\r | |
63 | ? Function Args \\r | |
aaa90aac | 64 | : BaseCryptLibServiceNotEnabled (#Function)\r |
cc1d13c9 MK |
65 | \r |
66 | /**\r | |
67 | Internal worker function that prints a debug message and asserts if a call is\r | |
68 | made to a BaseCryptLib function that is not enabled in the EDK II Crypto\r | |
69 | Protocol/PPI.\r | |
70 | \r | |
71 | If this debug message and assert are observed, then a module is using\r | |
72 | BaseCryptLib function that is not enabled in a Crypto driver. The\r | |
73 | PcdCryptoServiceFamilyEnable should be updated to enable the missing service.\r | |
74 | \r | |
75 | @param[in] FunctionName Null-terminated ASCII string that is the name of an\r | |
76 | EDK II Crypto service.\r | |
77 | \r | |
78 | **/\r | |
79 | static\r | |
80 | VOID\r | |
aaa90aac | 81 | BaseCryptLibServiceNotEnabled (\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 | |
97 | static\r | |
98 | VOID\r | |
99 | BaseCryptLibServiceDeprecated (\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 | |
113 | UINTN\r | |
114 | EFIAPI\r | |
115 | CryptoServiceGetCryptoVersion (\r | |
116 | VOID\r | |
117 | )\r | |
118 | {\r | |
119 | return EDKII_CRYPTO_VERSION;\r | |
120 | }\r | |
121 | \r | |
7c342378 | 122 | // =====================================================================================\r |
cc1d13c9 | 123 | // One-Way Cryptographic Hash Primitives\r |
7c342378 | 124 | // =====================================================================================\r |
cc1d13c9 MK |
125 | \r |
126 | /**\r | |
0a6fc3d0 ZG |
127 | MD4 is deprecated and unsupported any longer.\r |
128 | Keep the function field for binary compability.\r | |
cc1d13c9 | 129 | \r |
cc1d13c9 MK |
130 | @retval 0 This interface is not supported.\r |
131 | \r | |
132 | **/\r | |
133 | UINTN\r | |
134 | EFIAPI\r | |
0a6fc3d0 | 135 | DeprecatedCryptoServiceMd4GetContextSize (\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 | |
151 | BOOLEAN\r | |
152 | EFIAPI\r | |
0a6fc3d0 | 153 | DeprecatedCryptoServiceMd4Init (\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 | |
170 | BOOLEAN\r | |
171 | EFIAPI\r | |
0a6fc3d0 | 172 | DeprecatedCryptoServiceMd4Duplicate (\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 | |
191 | BOOLEAN\r | |
192 | EFIAPI\r | |
0a6fc3d0 | 193 | DeprecatedCryptoServiceMd4Update (\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 | |
213 | BOOLEAN\r | |
214 | EFIAPI\r | |
0a6fc3d0 | 215 | DeprecatedCryptoServiceMd4Final (\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 | |
235 | BOOLEAN\r | |
236 | EFIAPI\r | |
0a6fc3d0 | 237 | DeprecatedCryptoServiceMd4HashAll (\r |
cc1d13c9 MK |
238 | IN CONST VOID *Data,\r |
239 | IN UINTN DataSize,\r | |
240 | OUT UINT8 *HashValue\r | |
241 | )\r | |
242 | {\r | |
0a6fc3d0 | 243 | return BaseCryptLibServiceDeprecated ("Md4HashAll"), FALSE;\r |
cc1d13c9 MK |
244 | }\r |
245 | \r | |
e6a12a0f | 246 | #ifndef ENABLE_MD5_DEPRECATED_INTERFACES\r |
7c342378 | 247 | \r |
acfd5557 ZG |
248 | /**\r |
249 | Retrieves the size, in bytes, of the context buffer required for MD5 hash operations.\r | |
250 | \r | |
251 | If this interface is not supported, then return zero.\r | |
252 | \r | |
253 | @retval 0 This interface is not supported.\r | |
254 | \r | |
255 | **/\r | |
256 | UINTN\r | |
257 | EFIAPI\r | |
258 | DeprecatedCryptoServiceMd5GetContextSize (\r | |
259 | VOID\r | |
260 | )\r | |
261 | {\r | |
262 | return BaseCryptLibServiceDeprecated ("Md5GetContextSize"), 0;\r | |
263 | }\r | |
264 | \r | |
265 | /**\r | |
266 | Initializes user-supplied memory pointed by Md5Context as MD5 hash context for\r | |
267 | subsequent use.\r | |
268 | \r | |
269 | If Md5Context is NULL, then return FALSE.\r | |
270 | If this interface is not supported, then return FALSE.\r | |
271 | \r | |
272 | @param[out] Md5Context Pointer to MD5 context being initialized.\r | |
273 | \r | |
274 | @retval FALSE This interface is not supported.\r | |
275 | \r | |
276 | **/\r | |
277 | BOOLEAN\r | |
278 | EFIAPI\r | |
279 | DeprecatedCryptoServiceMd5Init (\r | |
280 | OUT VOID *Md5Context\r | |
281 | )\r | |
282 | {\r | |
283 | return BaseCryptLibServiceDeprecated ("Md5Init"), FALSE;\r | |
284 | }\r | |
285 | \r | |
286 | /**\r | |
287 | Makes a copy of an existing MD5 context.\r | |
288 | \r | |
289 | If Md5Context is NULL, then return FALSE.\r | |
290 | If NewMd5Context is NULL, then return FALSE.\r | |
291 | If this interface is not supported, then return FALSE.\r | |
292 | \r | |
293 | @param[in] Md5Context Pointer to MD5 context being copied.\r | |
294 | @param[out] NewMd5Context Pointer to new MD5 context.\r | |
295 | \r | |
296 | @retval FALSE This interface is not supported.\r | |
297 | \r | |
298 | **/\r | |
299 | BOOLEAN\r | |
300 | EFIAPI\r | |
301 | DeprecatedCryptoServiceMd5Duplicate (\r | |
302 | IN CONST VOID *Md5Context,\r | |
303 | OUT VOID *NewMd5Context\r | |
304 | )\r | |
305 | {\r | |
306 | return BaseCryptLibServiceDeprecated ("Md5Init"), FALSE;\r | |
307 | }\r | |
308 | \r | |
309 | /**\r | |
310 | Digests the input data and updates MD5 context.\r | |
311 | \r | |
312 | This function performs MD5 digest on a data buffer of the specified size.\r | |
313 | It can be called multiple times to compute the digest of long or discontinuous data streams.\r | |
314 | MD5 context should be already correctly initialized by Md5Init(), and should not be finalized\r | |
315 | by Md5Final(). Behavior with invalid context is undefined.\r | |
316 | \r | |
317 | If Md5Context is NULL, then return FALSE.\r | |
318 | If this interface is not supported, then return FALSE.\r | |
319 | \r | |
320 | @param[in, out] Md5Context Pointer to the MD5 context.\r | |
321 | @param[in] Data Pointer to the buffer containing the data to be hashed.\r | |
322 | @param[in] DataSize Size of Data buffer in bytes.\r | |
323 | \r | |
324 | @retval FALSE This interface is not supported.\r | |
325 | \r | |
326 | **/\r | |
327 | BOOLEAN\r | |
328 | EFIAPI\r | |
329 | DeprecatedCryptoServiceMd5Update (\r | |
330 | IN OUT VOID *Md5Context,\r | |
331 | IN CONST VOID *Data,\r | |
332 | IN UINTN DataSize\r | |
333 | )\r | |
334 | {\r | |
335 | return BaseCryptLibServiceDeprecated ("Md5Init"), FALSE;\r | |
336 | }\r | |
337 | \r | |
338 | /**\r | |
339 | Completes computation of the MD5 digest value.\r | |
340 | \r | |
341 | This function completes MD5 hash computation and retrieves the digest value into\r | |
342 | the specified memory. After this function has been called, the MD5 context cannot\r | |
343 | be used again.\r | |
344 | MD5 context should be already correctly initialized by Md5Init(), and should not be\r | |
345 | finalized by Md5Final(). Behavior with invalid MD5 context is undefined.\r | |
346 | \r | |
347 | If Md5Context is NULL, then return FALSE.\r | |
348 | If HashValue is NULL, then return FALSE.\r | |
349 | If this interface is not supported, then return FALSE.\r | |
350 | \r | |
351 | @param[in, out] Md5Context Pointer to the MD5 context.\r | |
352 | @param[out] HashValue Pointer to a buffer that receives the MD5 digest\r | |
353 | value (16 bytes).\r | |
354 | \r | |
355 | @retval FALSE This interface is not supported.\r | |
356 | \r | |
357 | **/\r | |
358 | BOOLEAN\r | |
359 | EFIAPI\r | |
360 | DeprecatedCryptoServiceMd5Final (\r | |
361 | IN OUT VOID *Md5Context,\r | |
362 | OUT UINT8 *HashValue\r | |
363 | )\r | |
364 | {\r | |
365 | return BaseCryptLibServiceDeprecated ("Md5Final"), FALSE;\r | |
366 | }\r | |
367 | \r | |
368 | /**\r | |
369 | Computes the MD5 message digest of a input data buffer.\r | |
370 | \r | |
371 | This function performs the MD5 message digest of a given data buffer, and places\r | |
372 | the digest value into the specified memory.\r | |
373 | \r | |
374 | If this interface is not supported, then return FALSE.\r | |
375 | \r | |
376 | @param[in] Data Pointer to the buffer containing the data to be hashed.\r | |
377 | @param[in] DataSize Size of Data buffer in bytes.\r | |
378 | @param[out] HashValue Pointer to a buffer that receives the MD5 digest\r | |
379 | value (16 bytes).\r | |
380 | \r | |
381 | @retval FALSE This interface is not supported.\r | |
382 | \r | |
383 | **/\r | |
384 | BOOLEAN\r | |
385 | EFIAPI\r | |
386 | DeprecatedCryptoServiceMd5HashAll (\r | |
387 | IN CONST VOID *Data,\r | |
388 | IN UINTN DataSize,\r | |
389 | OUT UINT8 *HashValue\r | |
390 | )\r | |
391 | {\r | |
392 | return BaseCryptLibServiceDeprecated ("Md5HashAll"), FALSE;\r | |
393 | }\r | |
7c342378 | 394 | \r |
acfd5557 | 395 | #else\r |
7c342378 | 396 | \r |
cc1d13c9 MK |
397 | /**\r |
398 | Retrieves the size, in bytes, of the context buffer required for MD5 hash operations.\r | |
399 | \r | |
400 | If this interface is not supported, then return zero.\r | |
401 | \r | |
402 | @return The size, in bytes, of the context buffer required for MD5 hash operations.\r | |
403 | @retval 0 This interface is not supported.\r | |
404 | \r | |
405 | **/\r | |
406 | UINTN\r | |
407 | EFIAPI\r | |
408 | CryptoServiceMd5GetContextSize (\r | |
409 | VOID\r | |
410 | )\r | |
411 | {\r | |
412 | return CALL_BASECRYPTLIB (Md5.Services.GetContextSize, Md5GetContextSize, (), 0);\r | |
413 | }\r | |
414 | \r | |
415 | /**\r | |
416 | Initializes user-supplied memory pointed by Md5Context as MD5 hash context for\r | |
417 | subsequent use.\r | |
418 | \r | |
419 | If Md5Context is NULL, then return FALSE.\r | |
420 | If this interface is not supported, then return FALSE.\r | |
421 | \r | |
422 | @param[out] Md5Context Pointer to MD5 context being initialized.\r | |
423 | \r | |
424 | @retval TRUE MD5 context initialization succeeded.\r | |
425 | @retval FALSE MD5 context initialization failed.\r | |
426 | @retval FALSE This interface is not supported.\r | |
427 | \r | |
428 | **/\r | |
429 | BOOLEAN\r | |
430 | EFIAPI\r | |
431 | CryptoServiceMd5Init (\r | |
432 | OUT VOID *Md5Context\r | |
433 | )\r | |
434 | {\r | |
435 | return CALL_BASECRYPTLIB (Md5.Services.Init, Md5Init, (Md5Context), FALSE);\r | |
436 | }\r | |
437 | \r | |
438 | /**\r | |
439 | Makes a copy of an existing MD5 context.\r | |
440 | \r | |
441 | If Md5Context is NULL, then return FALSE.\r | |
442 | If NewMd5Context is NULL, then return FALSE.\r | |
443 | If this interface is not supported, then return FALSE.\r | |
444 | \r | |
445 | @param[in] Md5Context Pointer to MD5 context being copied.\r | |
446 | @param[out] NewMd5Context Pointer to new MD5 context.\r | |
447 | \r | |
448 | @retval TRUE MD5 context copy succeeded.\r | |
449 | @retval FALSE MD5 context copy failed.\r | |
450 | @retval FALSE This interface is not supported.\r | |
451 | \r | |
452 | **/\r | |
453 | BOOLEAN\r | |
454 | EFIAPI\r | |
455 | CryptoServiceMd5Duplicate (\r | |
456 | IN CONST VOID *Md5Context,\r | |
457 | OUT VOID *NewMd5Context\r | |
458 | )\r | |
459 | {\r | |
460 | return CALL_BASECRYPTLIB (Md5.Services.Duplicate, Md5Duplicate, (Md5Context, NewMd5Context), FALSE);\r | |
461 | }\r | |
462 | \r | |
463 | /**\r | |
464 | Digests the input data and updates MD5 context.\r | |
465 | \r | |
466 | This function performs MD5 digest on a data buffer of the specified size.\r | |
467 | It can be called multiple times to compute the digest of long or discontinuous data streams.\r | |
468 | MD5 context should be already correctly initialized by Md5Init(), and should not be finalized\r | |
469 | by Md5Final(). Behavior with invalid context is undefined.\r | |
470 | \r | |
471 | If Md5Context is NULL, then return FALSE.\r | |
472 | If this interface is not supported, then return FALSE.\r | |
473 | \r | |
474 | @param[in, out] Md5Context Pointer to the MD5 context.\r | |
475 | @param[in] Data Pointer to the buffer containing the data to be hashed.\r | |
476 | @param[in] DataSize Size of Data buffer in bytes.\r | |
477 | \r | |
478 | @retval TRUE MD5 data digest succeeded.\r | |
479 | @retval FALSE MD5 data digest failed.\r | |
480 | @retval FALSE This interface is not supported.\r | |
481 | \r | |
482 | **/\r | |
483 | BOOLEAN\r | |
484 | EFIAPI\r | |
485 | CryptoServiceMd5Update (\r | |
486 | IN OUT VOID *Md5Context,\r | |
487 | IN CONST VOID *Data,\r | |
488 | IN UINTN DataSize\r | |
489 | )\r | |
490 | {\r | |
491 | return CALL_BASECRYPTLIB (Md5.Services.Update, Md5Update, (Md5Context, Data, DataSize), FALSE);\r | |
492 | }\r | |
493 | \r | |
494 | /**\r | |
495 | Completes computation of the MD5 digest value.\r | |
496 | \r | |
497 | This function completes MD5 hash computation and retrieves the digest value into\r | |
498 | the specified memory. After this function has been called, the MD5 context cannot\r | |
499 | be used again.\r | |
500 | MD5 context should be already correctly initialized by Md5Init(), and should not be\r | |
501 | finalized by Md5Final(). Behavior with invalid MD5 context is undefined.\r | |
502 | \r | |
503 | If Md5Context is NULL, then return FALSE.\r | |
504 | If HashValue is NULL, then return FALSE.\r | |
505 | If this interface is not supported, then return FALSE.\r | |
506 | \r | |
507 | @param[in, out] Md5Context Pointer to the MD5 context.\r | |
508 | @param[out] HashValue Pointer to a buffer that receives the MD5 digest\r | |
509 | value (16 bytes).\r | |
510 | \r | |
511 | @retval TRUE MD5 digest computation succeeded.\r | |
512 | @retval FALSE MD5 digest computation failed.\r | |
513 | @retval FALSE This interface is not supported.\r | |
514 | \r | |
515 | **/\r | |
516 | BOOLEAN\r | |
517 | EFIAPI\r | |
518 | CryptoServiceMd5Final (\r | |
519 | IN OUT VOID *Md5Context,\r | |
520 | OUT UINT8 *HashValue\r | |
521 | )\r | |
522 | {\r | |
523 | return CALL_BASECRYPTLIB (Md5.Services.Final, Md5Final, (Md5Context, HashValue), FALSE);\r | |
524 | }\r | |
525 | \r | |
526 | /**\r | |
527 | Computes the MD5 message digest of a input data buffer.\r | |
528 | \r | |
529 | This function performs the MD5 message digest of a given data buffer, and places\r | |
530 | the digest value into the specified memory.\r | |
531 | \r | |
532 | If this interface is not supported, then return FALSE.\r | |
533 | \r | |
534 | @param[in] Data Pointer to the buffer containing the data to be hashed.\r | |
535 | @param[in] DataSize Size of Data buffer in bytes.\r | |
536 | @param[out] HashValue Pointer to a buffer that receives the MD5 digest\r | |
537 | value (16 bytes).\r | |
538 | \r | |
539 | @retval TRUE MD5 digest computation succeeded.\r | |
540 | @retval FALSE MD5 digest computation failed.\r | |
541 | @retval FALSE This interface is not supported.\r | |
542 | \r | |
543 | **/\r | |
544 | BOOLEAN\r | |
545 | EFIAPI\r | |
546 | CryptoServiceMd5HashAll (\r | |
547 | IN CONST VOID *Data,\r | |
548 | IN UINTN DataSize,\r | |
549 | OUT UINT8 *HashValue\r | |
550 | )\r | |
551 | {\r | |
552 | return CALL_BASECRYPTLIB (Md5.Services.HashAll, Md5HashAll, (Data, DataSize, HashValue), FALSE);\r | |
553 | }\r | |
7c342378 | 554 | \r |
acfd5557 | 555 | #endif\r |
cc1d13c9 | 556 | \r |
0f01cec5 | 557 | #ifdef DISABLE_SHA1_DEPRECATED_INTERFACES\r |
7c342378 | 558 | \r |
0f01cec5 ZG |
559 | /**\r |
560 | Retrieves the size, in bytes, of the context buffer required for SHA-1 hash operations.\r | |
561 | \r | |
562 | If this interface is not supported, then return zero.\r | |
563 | \r | |
564 | @retval 0 This interface is not supported.\r | |
565 | \r | |
566 | **/\r | |
567 | UINTN\r | |
568 | EFIAPI\r | |
569 | DeprecatedCryptoServiceSha1GetContextSize (\r | |
570 | VOID\r | |
571 | )\r | |
572 | {\r | |
573 | return BaseCryptLibServiceDeprecated ("Sha1GetContextSize"), 0;\r | |
574 | }\r | |
575 | \r | |
576 | /**\r | |
577 | Initializes user-supplied memory pointed by Sha1Context as SHA-1 hash context for\r | |
578 | subsequent use.\r | |
579 | \r | |
580 | If Sha1Context is NULL, then return FALSE.\r | |
581 | If this interface is not supported, then return FALSE.\r | |
582 | \r | |
583 | @param[out] Sha1Context Pointer to SHA-1 context being initialized.\r | |
584 | \r | |
585 | @retval TRUE SHA-1 context initialization succeeded.\r | |
586 | @retval FALSE SHA-1 context initialization failed.\r | |
587 | @retval FALSE This interface is not supported.\r | |
588 | \r | |
589 | **/\r | |
590 | BOOLEAN\r | |
591 | EFIAPI\r | |
592 | DeprecatedCryptoServiceSha1Init (\r | |
593 | OUT VOID *Sha1Context\r | |
594 | )\r | |
595 | {\r | |
596 | return BaseCryptLibServiceDeprecated ("Sha1Init"), FALSE;\r | |
597 | }\r | |
598 | \r | |
599 | /**\r | |
600 | Makes a copy of an existing SHA-1 context.\r | |
601 | \r | |
602 | If Sha1Context is NULL, then return FALSE.\r | |
603 | If NewSha1Context is NULL, then return FALSE.\r | |
604 | If this interface is not supported, then return FALSE.\r | |
605 | \r | |
606 | @param[in] Sha1Context Pointer to SHA-1 context being copied.\r | |
607 | @param[out] NewSha1Context Pointer to new SHA-1 context.\r | |
608 | \r | |
609 | @retval FALSE This interface is not supported.\r | |
610 | \r | |
611 | **/\r | |
612 | BOOLEAN\r | |
613 | EFIAPI\r | |
614 | DeprecatedCryptoServiceSha1Duplicate (\r | |
615 | IN CONST VOID *Sha1Context,\r | |
616 | OUT VOID *NewSha1Context\r | |
617 | )\r | |
618 | {\r | |
619 | return BaseCryptLibServiceDeprecated ("Sha1Duplicate"), FALSE;\r | |
620 | }\r | |
621 | \r | |
622 | /**\r | |
623 | Digests the input data and updates SHA-1 context.\r | |
624 | \r | |
625 | This function performs SHA-1 digest on a data buffer of the specified size.\r | |
626 | It can be called multiple times to compute the digest of long or discontinuous data streams.\r | |
627 | SHA-1 context should be already correctly initialized by Sha1Init(), and should not be finalized\r | |
628 | by Sha1Final(). Behavior with invalid context is undefined.\r | |
629 | \r | |
630 | If Sha1Context is NULL, then return FALSE.\r | |
631 | If this interface is not supported, then return FALSE.\r | |
632 | \r | |
633 | @param[in, out] Sha1Context Pointer to the SHA-1 context.\r | |
634 | @param[in] Data Pointer to the buffer containing the data to be hashed.\r | |
635 | @param[in] DataSize Size of Data buffer in bytes.\r | |
636 | \r | |
637 | @retval FALSE This interface is not supported.\r | |
638 | \r | |
639 | **/\r | |
640 | BOOLEAN\r | |
641 | EFIAPI\r | |
642 | DeprecatedCryptoServiceSha1Update (\r | |
643 | IN OUT VOID *Sha1Context,\r | |
644 | IN CONST VOID *Data,\r | |
645 | IN UINTN DataSize\r | |
646 | )\r | |
647 | {\r | |
648 | return BaseCryptLibServiceDeprecated ("Sha1Update"), FALSE;\r | |
649 | }\r | |
650 | \r | |
651 | /**\r | |
652 | Completes computation of the SHA-1 digest value.\r | |
653 | \r | |
654 | This function completes SHA-1 hash computation and retrieves the digest value into\r | |
655 | the specified memory. After this function has been called, the SHA-1 context cannot\r | |
656 | be used again.\r | |
657 | SHA-1 context should be already correctly initialized by Sha1Init(), and should not be\r | |
658 | finalized by Sha1Final(). Behavior with invalid SHA-1 context is undefined.\r | |
659 | \r | |
660 | If Sha1Context is NULL, then return FALSE.\r | |
661 | If HashValue is NULL, then return FALSE.\r | |
662 | If this interface is not supported, then return FALSE.\r | |
663 | \r | |
664 | @param[in, out] Sha1Context Pointer to the SHA-1 context.\r | |
665 | @param[out] HashValue Pointer to a buffer that receives the SHA-1 digest\r | |
666 | value (20 bytes).\r | |
667 | \r | |
668 | @retval FALSE This interface is not supported.\r | |
669 | \r | |
670 | **/\r | |
671 | BOOLEAN\r | |
672 | EFIAPI\r | |
673 | DeprecatedCryptoServiceSha1Final (\r | |
674 | IN OUT VOID *Sha1Context,\r | |
675 | OUT UINT8 *HashValue\r | |
676 | )\r | |
677 | {\r | |
678 | return BaseCryptLibServiceDeprecated ("Sha1Final"), FALSE;\r | |
679 | }\r | |
680 | \r | |
681 | /**\r | |
682 | Computes the SHA-1 message digest of a input data buffer.\r | |
683 | \r | |
684 | This function performs the SHA-1 message digest of a given data buffer, and places\r | |
685 | the digest value into the specified memory.\r | |
686 | \r | |
687 | If this interface is not supported, then return FALSE.\r | |
688 | \r | |
689 | @param[in] Data Pointer to the buffer containing the data to be hashed.\r | |
690 | @param[in] DataSize Size of Data buffer in bytes.\r | |
691 | @param[out] HashValue Pointer to a buffer that receives the SHA-1 digest\r | |
692 | value (20 bytes).\r | |
693 | \r | |
694 | @retval FALSE This interface is not supported.\r | |
695 | \r | |
696 | **/\r | |
697 | BOOLEAN\r | |
698 | EFIAPI\r | |
699 | DeprecatedCryptoServiceSha1HashAll (\r | |
700 | IN CONST VOID *Data,\r | |
701 | IN UINTN DataSize,\r | |
702 | OUT UINT8 *HashValue\r | |
703 | )\r | |
704 | {\r | |
705 | return BaseCryptLibServiceDeprecated ("Sha1HashAll"), FALSE;\r | |
706 | }\r | |
7c342378 | 707 | \r |
0f01cec5 | 708 | #else\r |
7c342378 | 709 | \r |
cc1d13c9 MK |
710 | /**\r |
711 | Retrieves the size, in bytes, of the context buffer required for SHA-1 hash operations.\r | |
712 | \r | |
713 | If this interface is not supported, then return zero.\r | |
714 | \r | |
715 | @return The size, in bytes, of the context buffer required for SHA-1 hash operations.\r | |
716 | @retval 0 This interface is not supported.\r | |
717 | \r | |
718 | **/\r | |
719 | UINTN\r | |
720 | EFIAPI\r | |
721 | CryptoServiceSha1GetContextSize (\r | |
722 | VOID\r | |
723 | )\r | |
724 | {\r | |
725 | return CALL_BASECRYPTLIB (Sha1.Services.GetContextSize, Sha1GetContextSize, (), 0);\r | |
726 | }\r | |
727 | \r | |
728 | /**\r | |
729 | Initializes user-supplied memory pointed by Sha1Context as SHA-1 hash context for\r | |
730 | subsequent use.\r | |
731 | \r | |
732 | If Sha1Context is NULL, then return FALSE.\r | |
733 | If this interface is not supported, then return FALSE.\r | |
734 | \r | |
735 | @param[out] Sha1Context Pointer to SHA-1 context being initialized.\r | |
736 | \r | |
737 | @retval TRUE SHA-1 context initialization succeeded.\r | |
738 | @retval FALSE SHA-1 context initialization failed.\r | |
739 | @retval FALSE This interface is not supported.\r | |
740 | \r | |
741 | **/\r | |
742 | BOOLEAN\r | |
743 | EFIAPI\r | |
744 | CryptoServiceSha1Init (\r | |
745 | OUT VOID *Sha1Context\r | |
746 | )\r | |
747 | {\r | |
748 | return CALL_BASECRYPTLIB (Sha1.Services.Init, Sha1Init, (Sha1Context), FALSE);\r | |
749 | }\r | |
750 | \r | |
751 | /**\r | |
752 | Makes a copy of an existing SHA-1 context.\r | |
753 | \r | |
754 | If Sha1Context is NULL, then return FALSE.\r | |
755 | If NewSha1Context is NULL, then return FALSE.\r | |
756 | If this interface is not supported, then return FALSE.\r | |
757 | \r | |
758 | @param[in] Sha1Context Pointer to SHA-1 context being copied.\r | |
759 | @param[out] NewSha1Context Pointer to new SHA-1 context.\r | |
760 | \r | |
761 | @retval TRUE SHA-1 context copy succeeded.\r | |
762 | @retval FALSE SHA-1 context copy failed.\r | |
763 | @retval FALSE This interface is not supported.\r | |
764 | \r | |
765 | **/\r | |
766 | BOOLEAN\r | |
767 | EFIAPI\r | |
768 | CryptoServiceSha1Duplicate (\r | |
769 | IN CONST VOID *Sha1Context,\r | |
770 | OUT VOID *NewSha1Context\r | |
771 | )\r | |
772 | {\r | |
773 | return CALL_BASECRYPTLIB (Sha1.Services.Duplicate, Sha1Duplicate, (Sha1Context, NewSha1Context), FALSE);\r | |
774 | }\r | |
775 | \r | |
776 | /**\r | |
777 | Digests the input data and updates SHA-1 context.\r | |
778 | \r | |
779 | This function performs SHA-1 digest on a data buffer of the specified size.\r | |
780 | It can be called multiple times to compute the digest of long or discontinuous data streams.\r | |
781 | SHA-1 context should be already correctly initialized by Sha1Init(), and should not be finalized\r | |
782 | by Sha1Final(). Behavior with invalid context is undefined.\r | |
783 | \r | |
784 | If Sha1Context is NULL, then return FALSE.\r | |
785 | If this interface is not supported, then return FALSE.\r | |
786 | \r | |
787 | @param[in, out] Sha1Context Pointer to the SHA-1 context.\r | |
788 | @param[in] Data Pointer to the buffer containing the data to be hashed.\r | |
789 | @param[in] DataSize Size of Data buffer in bytes.\r | |
790 | \r | |
791 | @retval TRUE SHA-1 data digest succeeded.\r | |
792 | @retval FALSE SHA-1 data digest failed.\r | |
793 | @retval FALSE This interface is not supported.\r | |
794 | \r | |
795 | **/\r | |
796 | BOOLEAN\r | |
797 | EFIAPI\r | |
798 | CryptoServiceSha1Update (\r | |
799 | IN OUT VOID *Sha1Context,\r | |
800 | IN CONST VOID *Data,\r | |
801 | IN UINTN DataSize\r | |
802 | )\r | |
803 | {\r | |
804 | return CALL_BASECRYPTLIB (Sha1.Services.Update, Sha1Update, (Sha1Context, Data, DataSize), FALSE);\r | |
805 | }\r | |
806 | \r | |
807 | /**\r | |
808 | Completes computation of the SHA-1 digest value.\r | |
809 | \r | |
810 | This function completes SHA-1 hash computation and retrieves the digest value into\r | |
811 | the specified memory. After this function has been called, the SHA-1 context cannot\r | |
812 | be used again.\r | |
813 | SHA-1 context should be already correctly initialized by Sha1Init(), and should not be\r | |
814 | finalized by Sha1Final(). Behavior with invalid SHA-1 context is undefined.\r | |
815 | \r | |
816 | If Sha1Context is NULL, then return FALSE.\r | |
817 | If HashValue is NULL, then return FALSE.\r | |
818 | If this interface is not supported, then return FALSE.\r | |
819 | \r | |
820 | @param[in, out] Sha1Context Pointer to the SHA-1 context.\r | |
821 | @param[out] HashValue Pointer to a buffer that receives the SHA-1 digest\r | |
822 | value (20 bytes).\r | |
823 | \r | |
824 | @retval TRUE SHA-1 digest computation succeeded.\r | |
825 | @retval FALSE SHA-1 digest computation failed.\r | |
826 | @retval FALSE This interface is not supported.\r | |
827 | \r | |
828 | **/\r | |
829 | BOOLEAN\r | |
830 | EFIAPI\r | |
831 | CryptoServiceSha1Final (\r | |
832 | IN OUT VOID *Sha1Context,\r | |
833 | OUT UINT8 *HashValue\r | |
834 | )\r | |
835 | {\r | |
836 | return CALL_BASECRYPTLIB (Sha1.Services.Final, Sha1Final, (Sha1Context, HashValue), FALSE);\r | |
837 | }\r | |
838 | \r | |
839 | /**\r | |
840 | Computes the SHA-1 message digest of a input data buffer.\r | |
841 | \r | |
842 | This function performs the SHA-1 message digest of a given data buffer, and places\r | |
843 | the digest value into the specified memory.\r | |
844 | \r | |
845 | If this interface is not supported, then return FALSE.\r | |
846 | \r | |
847 | @param[in] Data Pointer to the buffer containing the data to be hashed.\r | |
848 | @param[in] DataSize Size of Data buffer in bytes.\r | |
849 | @param[out] HashValue Pointer to a buffer that receives the SHA-1 digest\r | |
850 | value (20 bytes).\r | |
851 | \r | |
852 | @retval TRUE SHA-1 digest computation succeeded.\r | |
853 | @retval FALSE SHA-1 digest computation failed.\r | |
854 | @retval FALSE This interface is not supported.\r | |
855 | \r | |
856 | **/\r | |
857 | BOOLEAN\r | |
858 | EFIAPI\r | |
859 | CryptoServiceSha1HashAll (\r | |
860 | IN CONST VOID *Data,\r | |
861 | IN UINTN DataSize,\r | |
862 | OUT UINT8 *HashValue\r | |
863 | )\r | |
864 | {\r | |
865 | return CALL_BASECRYPTLIB (Sha1.Services.HashAll, Sha1HashAll, (Data, DataSize, HashValue), FALSE);\r | |
866 | }\r | |
7c342378 | 867 | \r |
0f01cec5 | 868 | #endif\r |
cc1d13c9 MK |
869 | \r |
870 | /**\r | |
871 | Retrieves the size, in bytes, of the context buffer required for SHA-256 hash operations.\r | |
872 | \r | |
873 | @return The size, in bytes, of the context buffer required for SHA-256 hash operations.\r | |
874 | \r | |
875 | **/\r | |
876 | UINTN\r | |
877 | EFIAPI\r | |
878 | CryptoServiceSha256GetContextSize (\r | |
879 | VOID\r | |
880 | )\r | |
881 | {\r | |
882 | return CALL_BASECRYPTLIB (Sha256.Services.GetContextSize, Sha256GetContextSize, (), 0);\r | |
883 | }\r | |
884 | \r | |
885 | /**\r | |
886 | Initializes user-supplied memory pointed by Sha256Context as SHA-256 hash context for\r | |
887 | subsequent use.\r | |
888 | \r | |
889 | If Sha256Context is NULL, then return FALSE.\r | |
890 | \r | |
891 | @param[out] Sha256Context Pointer to SHA-256 context being initialized.\r | |
892 | \r | |
893 | @retval TRUE SHA-256 context initialization succeeded.\r | |
894 | @retval FALSE SHA-256 context initialization failed.\r | |
895 | \r | |
896 | **/\r | |
897 | BOOLEAN\r | |
898 | EFIAPI\r | |
899 | CryptoServiceSha256Init (\r | |
900 | OUT VOID *Sha256Context\r | |
901 | )\r | |
902 | {\r | |
903 | return CALL_BASECRYPTLIB (Sha256.Services.Init, Sha256Init, (Sha256Context), FALSE);\r | |
904 | }\r | |
905 | \r | |
906 | /**\r | |
907 | Makes a copy of an existing SHA-256 context.\r | |
908 | \r | |
909 | If Sha256Context is NULL, then return FALSE.\r | |
910 | If NewSha256Context is NULL, then return FALSE.\r | |
911 | If this interface is not supported, then return FALSE.\r | |
912 | \r | |
913 | @param[in] Sha256Context Pointer to SHA-256 context being copied.\r | |
914 | @param[out] NewSha256Context Pointer to new SHA-256 context.\r | |
915 | \r | |
916 | @retval TRUE SHA-256 context copy succeeded.\r | |
917 | @retval FALSE SHA-256 context copy failed.\r | |
918 | @retval FALSE This interface is not supported.\r | |
919 | \r | |
920 | **/\r | |
921 | BOOLEAN\r | |
922 | EFIAPI\r | |
923 | CryptoServiceSha256Duplicate (\r | |
924 | IN CONST VOID *Sha256Context,\r | |
925 | OUT VOID *NewSha256Context\r | |
926 | )\r | |
927 | {\r | |
928 | return CALL_BASECRYPTLIB (Sha256.Services.Duplicate, Sha256Duplicate, (Sha256Context, NewSha256Context), FALSE);\r | |
929 | }\r | |
930 | \r | |
931 | /**\r | |
932 | Digests the input data and updates SHA-256 context.\r | |
933 | \r | |
934 | This function performs SHA-256 digest on a data buffer of the specified size.\r | |
935 | It can be called multiple times to compute the digest of long or discontinuous data streams.\r | |
936 | SHA-256 context should be already correctly initialized by Sha256Init(), and should not be finalized\r | |
937 | by Sha256Final(). Behavior with invalid context is undefined.\r | |
938 | \r | |
939 | If Sha256Context is NULL, then return FALSE.\r | |
940 | \r | |
941 | @param[in, out] Sha256Context Pointer to the SHA-256 context.\r | |
942 | @param[in] Data Pointer to the buffer containing the data to be hashed.\r | |
943 | @param[in] DataSize Size of Data buffer in bytes.\r | |
944 | \r | |
945 | @retval TRUE SHA-256 data digest succeeded.\r | |
946 | @retval FALSE SHA-256 data digest failed.\r | |
947 | \r | |
948 | **/\r | |
949 | BOOLEAN\r | |
950 | EFIAPI\r | |
951 | CryptoServiceSha256Update (\r | |
952 | IN OUT VOID *Sha256Context,\r | |
953 | IN CONST VOID *Data,\r | |
954 | IN UINTN DataSize\r | |
955 | )\r | |
956 | {\r | |
957 | return CALL_BASECRYPTLIB (Sha256.Services.Update, Sha256Update, (Sha256Context, Data, DataSize), FALSE);\r | |
958 | }\r | |
959 | \r | |
960 | /**\r | |
961 | Completes computation of the SHA-256 digest value.\r | |
962 | \r | |
963 | This function completes SHA-256 hash computation and retrieves the digest value into\r | |
964 | the specified memory. After this function has been called, the SHA-256 context cannot\r | |
965 | be used again.\r | |
966 | SHA-256 context should be already correctly initialized by Sha256Init(), and should not be\r | |
967 | finalized by Sha256Final(). Behavior with invalid SHA-256 context is undefined.\r | |
968 | \r | |
969 | If Sha256Context is NULL, then return FALSE.\r | |
970 | If HashValue is NULL, then return FALSE.\r | |
971 | \r | |
972 | @param[in, out] Sha256Context Pointer to the SHA-256 context.\r | |
973 | @param[out] HashValue Pointer to a buffer that receives the SHA-256 digest\r | |
974 | value (32 bytes).\r | |
975 | \r | |
976 | @retval TRUE SHA-256 digest computation succeeded.\r | |
977 | @retval FALSE SHA-256 digest computation failed.\r | |
978 | \r | |
979 | **/\r | |
980 | BOOLEAN\r | |
981 | EFIAPI\r | |
982 | CryptoServiceSha256Final (\r | |
983 | IN OUT VOID *Sha256Context,\r | |
984 | OUT UINT8 *HashValue\r | |
985 | )\r | |
986 | {\r | |
987 | return CALL_BASECRYPTLIB (Sha256.Services.Final, Sha256Final, (Sha256Context, HashValue), FALSE);\r | |
988 | }\r | |
989 | \r | |
990 | /**\r | |
991 | Computes the SHA-256 message digest of a input data buffer.\r | |
992 | \r | |
993 | This function performs the SHA-256 message digest of a given data buffer, and places\r | |
994 | the digest value into the specified memory.\r | |
995 | \r | |
996 | If this interface is not supported, then return FALSE.\r | |
997 | \r | |
998 | @param[in] Data Pointer to the buffer containing the data to be hashed.\r | |
999 | @param[in] DataSize Size of Data buffer in bytes.\r | |
1000 | @param[out] HashValue Pointer to a buffer that receives the SHA-256 digest\r | |
1001 | value (32 bytes).\r | |
1002 | \r | |
1003 | @retval TRUE SHA-256 digest computation succeeded.\r | |
1004 | @retval FALSE SHA-256 digest computation failed.\r | |
1005 | @retval FALSE This interface is not supported.\r | |
1006 | \r | |
1007 | **/\r | |
1008 | BOOLEAN\r | |
1009 | EFIAPI\r | |
1010 | CryptoServiceSha256HashAll (\r | |
1011 | IN CONST VOID *Data,\r | |
1012 | IN UINTN DataSize,\r | |
1013 | OUT UINT8 *HashValue\r | |
1014 | )\r | |
1015 | {\r | |
1016 | return CALL_BASECRYPTLIB (Sha256.Services.HashAll, Sha256HashAll, (Data, DataSize, HashValue), FALSE);\r | |
1017 | }\r | |
1018 | \r | |
1019 | /**\r | |
1020 | Retrieves the size, in bytes, of the context buffer required for SHA-384 hash operations.\r | |
1021 | \r | |
1022 | @return The size, in bytes, of the context buffer required for SHA-384 hash operations.\r | |
1023 | \r | |
1024 | **/\r | |
1025 | UINTN\r | |
1026 | EFIAPI\r | |
1027 | CryptoServiceSha384GetContextSize (\r | |
1028 | VOID\r | |
1029 | )\r | |
1030 | {\r | |
1031 | return CALL_BASECRYPTLIB (Sha384.Services.GetContextSize, Sha384GetContextSize, (), 0);\r | |
1032 | }\r | |
1033 | \r | |
1034 | /**\r | |
1035 | Initializes user-supplied memory pointed by Sha384Context as SHA-384 hash context for\r | |
1036 | subsequent use.\r | |
1037 | \r | |
1038 | If Sha384Context is NULL, then return FALSE.\r | |
1039 | \r | |
1040 | @param[out] Sha384Context Pointer to SHA-384 context being initialized.\r | |
1041 | \r | |
1042 | @retval TRUE SHA-384 context initialization succeeded.\r | |
1043 | @retval FALSE SHA-384 context initialization failed.\r | |
1044 | \r | |
1045 | **/\r | |
1046 | BOOLEAN\r | |
1047 | EFIAPI\r | |
1048 | CryptoServiceSha384Init (\r | |
1049 | OUT VOID *Sha384Context\r | |
1050 | )\r | |
1051 | {\r | |
1052 | return CALL_BASECRYPTLIB (Sha384.Services.Init, Sha384Init, (Sha384Context), FALSE);\r | |
1053 | }\r | |
1054 | \r | |
1055 | /**\r | |
1056 | Makes a copy of an existing SHA-384 context.\r | |
1057 | \r | |
1058 | If Sha384Context is NULL, then return FALSE.\r | |
1059 | If NewSha384Context is NULL, then return FALSE.\r | |
1060 | If this interface is not supported, then return FALSE.\r | |
1061 | \r | |
1062 | @param[in] Sha384Context Pointer to SHA-384 context being copied.\r | |
1063 | @param[out] NewSha384Context Pointer to new SHA-384 context.\r | |
1064 | \r | |
1065 | @retval TRUE SHA-384 context copy succeeded.\r | |
1066 | @retval FALSE SHA-384 context copy failed.\r | |
1067 | @retval FALSE This interface is not supported.\r | |
1068 | \r | |
1069 | **/\r | |
1070 | BOOLEAN\r | |
1071 | EFIAPI\r | |
1072 | CryptoServiceSha384Duplicate (\r | |
1073 | IN CONST VOID *Sha384Context,\r | |
1074 | OUT VOID *NewSha384Context\r | |
1075 | )\r | |
1076 | {\r | |
1077 | return CALL_BASECRYPTLIB (Sha384.Services.Duplicate, Sha384Duplicate, (Sha384Context, NewSha384Context), FALSE);\r | |
1078 | }\r | |
1079 | \r | |
1080 | /**\r | |
1081 | Digests the input data and updates SHA-384 context.\r | |
1082 | \r | |
1083 | This function performs SHA-384 digest on a data buffer of the specified size.\r | |
1084 | It can be called multiple times to compute the digest of long or discontinuous data streams.\r | |
1085 | SHA-384 context should be already correctly initialized by Sha384Init(), and should not be finalized\r | |
1086 | by Sha384Final(). Behavior with invalid context is undefined.\r | |
1087 | \r | |
1088 | If Sha384Context is NULL, then return FALSE.\r | |
1089 | \r | |
1090 | @param[in, out] Sha384Context Pointer to the SHA-384 context.\r | |
1091 | @param[in] Data Pointer to the buffer containing the data to be hashed.\r | |
1092 | @param[in] DataSize Size of Data buffer in bytes.\r | |
1093 | \r | |
1094 | @retval TRUE SHA-384 data digest succeeded.\r | |
1095 | @retval FALSE SHA-384 data digest failed.\r | |
1096 | \r | |
1097 | **/\r | |
1098 | BOOLEAN\r | |
1099 | EFIAPI\r | |
1100 | CryptoServiceSha384Update (\r | |
1101 | IN OUT VOID *Sha384Context,\r | |
1102 | IN CONST VOID *Data,\r | |
1103 | IN UINTN DataSize\r | |
1104 | )\r | |
1105 | {\r | |
1106 | return CALL_BASECRYPTLIB (Sha384.Services.Update, Sha384Update, (Sha384Context, Data, DataSize), FALSE);\r | |
1107 | }\r | |
1108 | \r | |
1109 | /**\r | |
1110 | Completes computation of the SHA-384 digest value.\r | |
1111 | \r | |
1112 | This function completes SHA-384 hash computation and retrieves the digest value into\r | |
1113 | the specified memory. After this function has been called, the SHA-384 context cannot\r | |
1114 | be used again.\r | |
1115 | SHA-384 context should be already correctly initialized by Sha384Init(), and should not be\r | |
1116 | finalized by Sha384Final(). Behavior with invalid SHA-384 context is undefined.\r | |
1117 | \r | |
1118 | If Sha384Context is NULL, then return FALSE.\r | |
1119 | If HashValue is NULL, then return FALSE.\r | |
1120 | \r | |
1121 | @param[in, out] Sha384Context Pointer to the SHA-384 context.\r | |
1122 | @param[out] HashValue Pointer to a buffer that receives the SHA-384 digest\r | |
1123 | value (48 bytes).\r | |
1124 | \r | |
1125 | @retval TRUE SHA-384 digest computation succeeded.\r | |
1126 | @retval FALSE SHA-384 digest computation failed.\r | |
1127 | \r | |
1128 | **/\r | |
1129 | BOOLEAN\r | |
1130 | EFIAPI\r | |
1131 | CryptoServiceSha384Final (\r | |
1132 | IN OUT VOID *Sha384Context,\r | |
1133 | OUT UINT8 *HashValue\r | |
1134 | )\r | |
1135 | {\r | |
1136 | return CALL_BASECRYPTLIB (Sha384.Services.Final, Sha384Final, (Sha384Context, HashValue), FALSE);\r | |
1137 | }\r | |
1138 | \r | |
1139 | /**\r | |
1140 | Computes the SHA-384 message digest of a input data buffer.\r | |
1141 | \r | |
1142 | This function performs the SHA-384 message digest of a given data buffer, and places\r | |
1143 | the digest value into the specified memory.\r | |
1144 | \r | |
1145 | If this interface is not supported, then return FALSE.\r | |
1146 | \r | |
1147 | @param[in] Data Pointer to the buffer containing the data to be hashed.\r | |
1148 | @param[in] DataSize Size of Data buffer in bytes.\r | |
1149 | @param[out] HashValue Pointer to a buffer that receives the SHA-384 digest\r | |
1150 | value (48 bytes).\r | |
1151 | \r | |
1152 | @retval TRUE SHA-384 digest computation succeeded.\r | |
1153 | @retval FALSE SHA-384 digest computation failed.\r | |
1154 | @retval FALSE This interface is not supported.\r | |
1155 | \r | |
1156 | **/\r | |
1157 | BOOLEAN\r | |
1158 | EFIAPI\r | |
1159 | CryptoServiceSha384HashAll (\r | |
1160 | IN CONST VOID *Data,\r | |
1161 | IN UINTN DataSize,\r | |
1162 | OUT UINT8 *HashValue\r | |
1163 | )\r | |
1164 | {\r | |
1165 | return CALL_BASECRYPTLIB (Sha384.Services.HashAll, Sha384HashAll, (Data, DataSize, HashValue), FALSE);\r | |
1166 | }\r | |
1167 | \r | |
1168 | /**\r | |
1169 | Retrieves the size, in bytes, of the context buffer required for SHA-512 hash operations.\r | |
1170 | \r | |
1171 | @return The size, in bytes, of the context buffer required for SHA-512 hash operations.\r | |
1172 | \r | |
1173 | **/\r | |
1174 | UINTN\r | |
1175 | EFIAPI\r | |
1176 | CryptoServiceSha512GetContextSize (\r | |
1177 | VOID\r | |
1178 | )\r | |
1179 | {\r | |
1180 | return CALL_BASECRYPTLIB (Sha512.Services.GetContextSize, Sha512GetContextSize, (), 0);\r | |
1181 | }\r | |
1182 | \r | |
1183 | /**\r | |
1184 | Initializes user-supplied memory pointed by Sha512Context as SHA-512 hash context for\r | |
1185 | subsequent use.\r | |
1186 | \r | |
1187 | If Sha512Context is NULL, then return FALSE.\r | |
1188 | \r | |
1189 | @param[out] Sha512Context Pointer to SHA-512 context being initialized.\r | |
1190 | \r | |
1191 | @retval TRUE SHA-512 context initialization succeeded.\r | |
1192 | @retval FALSE SHA-512 context initialization failed.\r | |
1193 | \r | |
1194 | **/\r | |
1195 | BOOLEAN\r | |
1196 | EFIAPI\r | |
1197 | CryptoServiceSha512Init (\r | |
1198 | OUT VOID *Sha512Context\r | |
1199 | )\r | |
1200 | {\r | |
1201 | return CALL_BASECRYPTLIB (Sha512.Services.Init, Sha512Init, (Sha512Context), FALSE);\r | |
1202 | }\r | |
1203 | \r | |
1204 | /**\r | |
1205 | Makes a copy of an existing SHA-512 context.\r | |
1206 | \r | |
1207 | If Sha512Context is NULL, then return FALSE.\r | |
1208 | If NewSha512Context is NULL, then return FALSE.\r | |
1209 | If this interface is not supported, then return FALSE.\r | |
1210 | \r | |
1211 | @param[in] Sha512Context Pointer to SHA-512 context being copied.\r | |
1212 | @param[out] NewSha512Context Pointer to new SHA-512 context.\r | |
1213 | \r | |
1214 | @retval TRUE SHA-512 context copy succeeded.\r | |
1215 | @retval FALSE SHA-512 context copy failed.\r | |
1216 | @retval FALSE This interface is not supported.\r | |
1217 | \r | |
1218 | **/\r | |
1219 | BOOLEAN\r | |
1220 | EFIAPI\r | |
1221 | CryptoServiceSha512Duplicate (\r | |
1222 | IN CONST VOID *Sha512Context,\r | |
1223 | OUT VOID *NewSha512Context\r | |
1224 | )\r | |
1225 | {\r | |
1226 | return CALL_BASECRYPTLIB (Sha512.Services.Duplicate, Sha512Duplicate, (Sha512Context, NewSha512Context), FALSE);\r | |
1227 | }\r | |
1228 | \r | |
1229 | /**\r | |
1230 | Digests the input data and updates SHA-512 context.\r | |
1231 | \r | |
1232 | This function performs SHA-512 digest on a data buffer of the specified size.\r | |
1233 | It can be called multiple times to compute the digest of long or discontinuous data streams.\r | |
1234 | SHA-512 context should be already correctly initialized by Sha512Init(), and should not be finalized\r | |
1235 | by Sha512Final(). Behavior with invalid context is undefined.\r | |
1236 | \r | |
1237 | If Sha512Context is NULL, then return FALSE.\r | |
1238 | \r | |
1239 | @param[in, out] Sha512Context Pointer to the SHA-512 context.\r | |
1240 | @param[in] Data Pointer to the buffer containing the data to be hashed.\r | |
1241 | @param[in] DataSize Size of Data buffer in bytes.\r | |
1242 | \r | |
1243 | @retval TRUE SHA-512 data digest succeeded.\r | |
1244 | @retval FALSE SHA-512 data digest failed.\r | |
1245 | \r | |
1246 | **/\r | |
1247 | BOOLEAN\r | |
1248 | EFIAPI\r | |
1249 | CryptoServiceSha512Update (\r | |
1250 | IN OUT VOID *Sha512Context,\r | |
1251 | IN CONST VOID *Data,\r | |
1252 | IN UINTN DataSize\r | |
1253 | )\r | |
1254 | {\r | |
1255 | return CALL_BASECRYPTLIB (Sha512.Services.Update, Sha512Update, (Sha512Context, Data, DataSize), FALSE);\r | |
1256 | }\r | |
1257 | \r | |
1258 | /**\r | |
1259 | Completes computation of the SHA-512 digest value.\r | |
1260 | \r | |
1261 | This function completes SHA-512 hash computation and retrieves the digest value into\r | |
1262 | the specified memory. After this function has been called, the SHA-512 context cannot\r | |
1263 | be used again.\r | |
1264 | SHA-512 context should be already correctly initialized by Sha512Init(), and should not be\r | |
1265 | finalized by Sha512Final(). Behavior with invalid SHA-512 context is undefined.\r | |
1266 | \r | |
1267 | If Sha512Context is NULL, then return FALSE.\r | |
1268 | If HashValue is NULL, then return FALSE.\r | |
1269 | \r | |
1270 | @param[in, out] Sha512Context Pointer to the SHA-512 context.\r | |
1271 | @param[out] HashValue Pointer to a buffer that receives the SHA-512 digest\r | |
1272 | value (64 bytes).\r | |
1273 | \r | |
1274 | @retval TRUE SHA-512 digest computation succeeded.\r | |
1275 | @retval FALSE SHA-512 digest computation failed.\r | |
1276 | \r | |
1277 | **/\r | |
1278 | BOOLEAN\r | |
1279 | EFIAPI\r | |
1280 | CryptoServiceSha512Final (\r | |
1281 | IN OUT VOID *Sha512Context,\r | |
1282 | OUT UINT8 *HashValue\r | |
1283 | )\r | |
1284 | {\r | |
1285 | return CALL_BASECRYPTLIB (Sha512.Services.Final, Sha512Final, (Sha512Context, HashValue), FALSE);\r | |
1286 | }\r | |
1287 | \r | |
1288 | /**\r | |
1289 | Computes the SHA-512 message digest of a input data buffer.\r | |
1290 | \r | |
1291 | This function performs the SHA-512 message digest of a given data buffer, and places\r | |
1292 | the digest value into the specified memory.\r | |
1293 | \r | |
1294 | If this interface is not supported, then return FALSE.\r | |
1295 | \r | |
1296 | @param[in] Data Pointer to the buffer containing the data to be hashed.\r | |
1297 | @param[in] DataSize Size of Data buffer in bytes.\r | |
1298 | @param[out] HashValue Pointer to a buffer that receives the SHA-512 digest\r | |
1299 | value (64 bytes).\r | |
1300 | \r | |
1301 | @retval TRUE SHA-512 digest computation succeeded.\r | |
1302 | @retval FALSE SHA-512 digest computation failed.\r | |
1303 | @retval FALSE This interface is not supported.\r | |
1304 | \r | |
1305 | **/\r | |
1306 | BOOLEAN\r | |
1307 | EFIAPI\r | |
1308 | CryptoServiceSha512HashAll (\r | |
1309 | IN CONST VOID *Data,\r | |
1310 | IN UINTN DataSize,\r | |
1311 | OUT UINT8 *HashValue\r | |
1312 | )\r | |
1313 | {\r | |
1314 | return CALL_BASECRYPTLIB (Sha512.Services.HashAll, Sha512HashAll, (Data, DataSize, HashValue), FALSE);\r | |
1315 | }\r | |
1316 | \r | |
1317 | /**\r | |
1318 | Retrieves the size, in bytes, of the context buffer required for SM3 hash operations.\r | |
1319 | \r | |
1320 | @return The size, in bytes, of the context buffer required for SM3 hash operations.\r | |
1321 | \r | |
1322 | **/\r | |
1323 | UINTN\r | |
1324 | EFIAPI\r | |
1325 | CryptoServiceSm3GetContextSize (\r | |
1326 | VOID\r | |
1327 | )\r | |
1328 | {\r | |
1329 | return CALL_BASECRYPTLIB (Sm3.Services.GetContextSize, Sm3GetContextSize, (), 0);\r | |
1330 | }\r | |
1331 | \r | |
1332 | /**\r | |
1333 | Initializes user-supplied memory pointed by Sm3Context as SM3 hash context for\r | |
1334 | subsequent use.\r | |
1335 | \r | |
1336 | If Sm3Context is NULL, then return FALSE.\r | |
1337 | \r | |
1338 | @param[out] Sm3Context Pointer to SM3 context being initialized.\r | |
1339 | \r | |
1340 | @retval TRUE SM3 context initialization succeeded.\r | |
1341 | @retval FALSE SM3 context initialization failed.\r | |
1342 | \r | |
1343 | **/\r | |
1344 | BOOLEAN\r | |
1345 | EFIAPI\r | |
1346 | CryptoServiceSm3Init (\r | |
1347 | OUT VOID *Sm3Context\r | |
1348 | )\r | |
1349 | {\r | |
1350 | return CALL_BASECRYPTLIB (Sm3.Services.Init, Sm3Init, (Sm3Context), FALSE);\r | |
1351 | }\r | |
1352 | \r | |
1353 | /**\r | |
1354 | Makes a copy of an existing SM3 context.\r | |
1355 | \r | |
1356 | If Sm3Context is NULL, then return FALSE.\r | |
1357 | If NewSm3Context is NULL, then return FALSE.\r | |
1358 | If this interface is not supported, then return FALSE.\r | |
1359 | \r | |
1360 | @param[in] Sm3Context Pointer to SM3 context being copied.\r | |
1361 | @param[out] NewSm3Context Pointer to new SM3 context.\r | |
1362 | \r | |
1363 | @retval TRUE SM3 context copy succeeded.\r | |
1364 | @retval FALSE SM3 context copy failed.\r | |
1365 | @retval FALSE This interface is not supported.\r | |
1366 | \r | |
1367 | **/\r | |
1368 | BOOLEAN\r | |
1369 | EFIAPI\r | |
1370 | CryptoServiceSm3Duplicate (\r | |
1371 | IN CONST VOID *Sm3Context,\r | |
1372 | OUT VOID *NewSm3Context\r | |
1373 | )\r | |
1374 | {\r | |
1375 | return CALL_BASECRYPTLIB (Sm3.Services.Duplicate, Sm3Duplicate, (Sm3Context, NewSm3Context), FALSE);\r | |
1376 | }\r | |
1377 | \r | |
1378 | /**\r | |
1379 | Digests the input data and updates SM3 context.\r | |
1380 | \r | |
1381 | This function performs SM3 digest on a data buffer of the specified size.\r | |
1382 | It can be called multiple times to compute the digest of long or discontinuous data streams.\r | |
1383 | SM3 context should be already correctly initialized by Sm3Init(), and should not be finalized\r | |
1384 | by Sm3Final(). Behavior with invalid context is undefined.\r | |
1385 | \r | |
1386 | If Sm3Context is NULL, then return FALSE.\r | |
1387 | \r | |
1388 | @param[in, out] Sm3Context Pointer to the SM3 context.\r | |
1389 | @param[in] Data Pointer to the buffer containing the data to be hashed.\r | |
1390 | @param[in] DataSize Size of Data buffer in bytes.\r | |
1391 | \r | |
1392 | @retval TRUE SM3 data digest succeeded.\r | |
1393 | @retval FALSE SM3 data digest failed.\r | |
1394 | \r | |
1395 | **/\r | |
1396 | BOOLEAN\r | |
1397 | EFIAPI\r | |
1398 | CryptoServiceSm3Update (\r | |
1399 | IN OUT VOID *Sm3Context,\r | |
1400 | IN CONST VOID *Data,\r | |
1401 | IN UINTN DataSize\r | |
1402 | )\r | |
1403 | {\r | |
1404 | return CALL_BASECRYPTLIB (Sm3.Services.Update, Sm3Update, (Sm3Context, Data, DataSize), FALSE);\r | |
1405 | }\r | |
1406 | \r | |
1407 | /**\r | |
1408 | Completes computation of the SM3 digest value.\r | |
1409 | \r | |
1410 | This function completes SM3 hash computation and retrieves the digest value into\r | |
1411 | the specified memory. After this function has been called, the SM3 context cannot\r | |
1412 | be used again.\r | |
1413 | SM3 context should be already correctly initialized by Sm3Init(), and should not be\r | |
1414 | finalized by Sm3Final(). Behavior with invalid SM3 context is undefined.\r | |
1415 | \r | |
1416 | If Sm3Context is NULL, then return FALSE.\r | |
1417 | If HashValue is NULL, then return FALSE.\r | |
1418 | \r | |
1419 | @param[in, out] Sm3Context Pointer to the SM3 context.\r | |
1420 | @param[out] HashValue Pointer to a buffer that receives the SM3 digest\r | |
1421 | value (32 bytes).\r | |
1422 | \r | |
1423 | @retval TRUE SM3 digest computation succeeded.\r | |
1424 | @retval FALSE SM3 digest computation failed.\r | |
1425 | \r | |
1426 | **/\r | |
1427 | BOOLEAN\r | |
1428 | EFIAPI\r | |
1429 | CryptoServiceSm3Final (\r | |
1430 | IN OUT VOID *Sm3Context,\r | |
1431 | OUT UINT8 *HashValue\r | |
1432 | )\r | |
1433 | {\r | |
1434 | return CALL_BASECRYPTLIB (Sm3.Services.Final, Sm3Final, (Sm3Context, HashValue), FALSE);\r | |
1435 | }\r | |
1436 | \r | |
1437 | /**\r | |
1438 | Computes the SM3 message digest of a input data buffer.\r | |
1439 | \r | |
1440 | This function performs the SM3 message digest of a given data buffer, and places\r | |
1441 | the digest value into the specified memory.\r | |
1442 | \r | |
1443 | If this interface is not supported, then return FALSE.\r | |
1444 | \r | |
1445 | @param[in] Data Pointer to the buffer containing the data to be hashed.\r | |
1446 | @param[in] DataSize Size of Data buffer in bytes.\r | |
1447 | @param[out] HashValue Pointer to a buffer that receives the SM3 digest\r | |
1448 | value (32 bytes).\r | |
1449 | \r | |
1450 | @retval TRUE SM3 digest computation succeeded.\r | |
1451 | @retval FALSE SM3 digest computation failed.\r | |
1452 | @retval FALSE This interface is not supported.\r | |
1453 | \r | |
1454 | **/\r | |
1455 | BOOLEAN\r | |
1456 | EFIAPI\r | |
1457 | CryptoServiceSm3HashAll (\r | |
1458 | IN CONST VOID *Data,\r | |
1459 | IN UINTN DataSize,\r | |
1460 | OUT UINT8 *HashValue\r | |
1461 | )\r | |
1462 | {\r | |
1463 | return CALL_BASECRYPTLIB (Sm3.Services.HashAll, Sm3HashAll, (Data, DataSize, HashValue), FALSE);\r | |
1464 | }\r | |
1465 | \r | |
7c342378 | 1466 | // =====================================================================================\r |
cc1d13c9 | 1467 | // MAC (Message Authentication Code) Primitive\r |
7c342378 | 1468 | // =====================================================================================\r |
cc1d13c9 MK |
1469 | \r |
1470 | /**\r | |
b6174e2d ZG |
1471 | HMAC MD5 is deprecated and unsupported any longer.\r |
1472 | Keep the function field for binary compability.\r | |
cc1d13c9 | 1473 | \r |
cc1d13c9 MK |
1474 | @retval NULL This interface is not supported.\r |
1475 | \r | |
1476 | **/\r | |
1477 | VOID *\r | |
1478 | EFIAPI\r | |
b6174e2d | 1479 | DeprecatedCryptoServiceHmacMd5New (\r |
cc1d13c9 MK |
1480 | VOID\r |
1481 | )\r | |
1482 | {\r | |
b6174e2d | 1483 | return BaseCryptLibServiceDeprecated ("HmacMd5New"), NULL;\r |
cc1d13c9 MK |
1484 | }\r |
1485 | \r | |
1486 | /**\r | |
b6174e2d ZG |
1487 | HMAC MD5 is deprecated and unsupported any longer.\r |
1488 | Keep the function field for binary compability.\r | |
cc1d13c9 MK |
1489 | \r |
1490 | @param[in] HmacMd5Ctx Pointer to the HMAC_CTX context to be released.\r | |
1491 | \r | |
1492 | **/\r | |
1493 | VOID\r | |
1494 | EFIAPI\r | |
b6174e2d | 1495 | DeprecatedCryptoServiceHmacMd5Free (\r |
cc1d13c9 MK |
1496 | IN VOID *HmacMd5Ctx\r |
1497 | )\r | |
1498 | {\r | |
b6174e2d | 1499 | BaseCryptLibServiceDeprecated ("HmacMd5Free");\r |
cc1d13c9 MK |
1500 | }\r |
1501 | \r | |
1502 | /**\r | |
b6174e2d ZG |
1503 | HMAC MD5 is deprecated and unsupported any longer.\r |
1504 | Keep the function field for binary compability.\r | |
cc1d13c9 MK |
1505 | \r |
1506 | @param[out] HmacMd5Context Pointer to HMAC-MD5 context.\r | |
1507 | @param[in] Key Pointer to the user-supplied key.\r | |
1508 | @param[in] KeySize Key size in bytes.\r | |
1509 | \r | |
cc1d13c9 MK |
1510 | @retval FALSE This interface is not supported.\r |
1511 | \r | |
1512 | **/\r | |
1513 | BOOLEAN\r | |
1514 | EFIAPI\r | |
b6174e2d | 1515 | DeprecatedCryptoServiceHmacMd5SetKey (\r |
cc1d13c9 MK |
1516 | OUT VOID *HmacMd5Context,\r |
1517 | IN CONST UINT8 *Key,\r | |
1518 | IN UINTN KeySize\r | |
1519 | )\r | |
1520 | {\r | |
b6174e2d | 1521 | return BaseCryptLibServiceDeprecated ("HmacMd5SetKey"), FALSE;\r |
cc1d13c9 MK |
1522 | }\r |
1523 | \r | |
1524 | /**\r | |
b6174e2d ZG |
1525 | HMAC MD5 is deprecated and unsupported any longer.\r |
1526 | Keep the function field for binary compability.\r | |
cc1d13c9 MK |
1527 | \r |
1528 | @param[in] HmacMd5Context Pointer to HMAC-MD5 context being copied.\r | |
1529 | @param[out] NewHmacMd5Context Pointer to new HMAC-MD5 context.\r | |
1530 | \r | |
cc1d13c9 MK |
1531 | @retval FALSE This interface is not supported.\r |
1532 | \r | |
1533 | **/\r | |
1534 | BOOLEAN\r | |
1535 | EFIAPI\r | |
b6174e2d | 1536 | DeprecatedCryptoServiceHmacMd5Duplicate (\r |
cc1d13c9 MK |
1537 | IN CONST VOID *HmacMd5Context,\r |
1538 | OUT VOID *NewHmacMd5Context\r | |
1539 | )\r | |
1540 | {\r | |
b6174e2d | 1541 | return BaseCryptLibServiceDeprecated ("HmacMd5Duplicate"), FALSE;\r |
cc1d13c9 MK |
1542 | }\r |
1543 | \r | |
1544 | /**\r | |
b6174e2d ZG |
1545 | HMAC MD5 is deprecated and unsupported any longer.\r |
1546 | Keep the function field for binary compability.\r | |
cc1d13c9 MK |
1547 | \r |
1548 | @param[in, out] HmacMd5Context Pointer to the HMAC-MD5 context.\r | |
1549 | @param[in] Data Pointer to the buffer containing the data to be digested.\r | |
1550 | @param[in] DataSize Size of Data buffer in bytes.\r | |
1551 | \r | |
cc1d13c9 MK |
1552 | @retval FALSE This interface is not supported.\r |
1553 | \r | |
1554 | **/\r | |
1555 | BOOLEAN\r | |
1556 | EFIAPI\r | |
b6174e2d | 1557 | DeprecatedCryptoServiceHmacMd5Update (\r |
cc1d13c9 MK |
1558 | IN OUT VOID *HmacMd5Context,\r |
1559 | IN CONST VOID *Data,\r | |
1560 | IN UINTN DataSize\r | |
1561 | )\r | |
1562 | {\r | |
b6174e2d | 1563 | return BaseCryptLibServiceDeprecated ("HmacMd5Update"), FALSE;\r |
cc1d13c9 MK |
1564 | }\r |
1565 | \r | |
1566 | /**\r | |
b6174e2d ZG |
1567 | HMAC MD5 is deprecated and unsupported any longer.\r |
1568 | Keep the function field for binary compability.\r | |
cc1d13c9 MK |
1569 | \r |
1570 | @param[in, out] HmacMd5Context Pointer to the HMAC-MD5 context.\r | |
1571 | @param[out] HmacValue Pointer to a buffer that receives the HMAC-MD5 digest\r | |
1572 | value (16 bytes).\r | |
1573 | \r | |
cc1d13c9 MK |
1574 | @retval FALSE This interface is not supported.\r |
1575 | \r | |
1576 | **/\r | |
1577 | BOOLEAN\r | |
1578 | EFIAPI\r | |
b6174e2d | 1579 | DeprecatedCryptoServiceHmacMd5Final (\r |
cc1d13c9 MK |
1580 | IN OUT VOID *HmacMd5Context,\r |
1581 | OUT UINT8 *HmacValue\r | |
1582 | )\r | |
1583 | {\r | |
b6174e2d | 1584 | return BaseCryptLibServiceDeprecated ("HmacMd5Final"), FALSE;\r |
cc1d13c9 MK |
1585 | }\r |
1586 | \r | |
1587 | /**\r | |
c812d320 ZG |
1588 | HMAC SHA1 is deprecated and unsupported any longer.\r |
1589 | Keep the function field for binary compability.\r | |
cc1d13c9 | 1590 | \r |
cc1d13c9 MK |
1591 | @return NULL This interface is not supported.\r |
1592 | \r | |
1593 | **/\r | |
1594 | VOID *\r | |
1595 | EFIAPI\r | |
c812d320 | 1596 | DeprecatedCryptoServiceHmacSha1New (\r |
cc1d13c9 MK |
1597 | VOID\r |
1598 | )\r | |
1599 | {\r | |
c812d320 | 1600 | return BaseCryptLibServiceDeprecated ("HmacSha1New"), NULL;\r |
cc1d13c9 MK |
1601 | }\r |
1602 | \r | |
1603 | /**\r | |
c812d320 ZG |
1604 | HMAC SHA1 is deprecated and unsupported any longer.\r |
1605 | Keep the function field for binary compability.\r | |
cc1d13c9 MK |
1606 | \r |
1607 | @param[in] HmacSha1Ctx Pointer to the HMAC_CTX context to be released.\r | |
1608 | \r | |
1609 | **/\r | |
1610 | VOID\r | |
1611 | EFIAPI\r | |
c812d320 | 1612 | DeprecatedCryptoServiceHmacSha1Free (\r |
cc1d13c9 MK |
1613 | IN VOID *HmacSha1Ctx\r |
1614 | )\r | |
1615 | {\r | |
c812d320 | 1616 | BaseCryptLibServiceDeprecated ("HmacSha1Free");\r |
cc1d13c9 MK |
1617 | }\r |
1618 | \r | |
1619 | /**\r | |
c812d320 ZG |
1620 | HMAC SHA1 is deprecated and unsupported any longer.\r |
1621 | Keep the function field for binary compability.\r | |
cc1d13c9 MK |
1622 | \r |
1623 | @param[out] HmacSha1Context Pointer to HMAC-SHA1 context.\r | |
1624 | @param[in] Key Pointer to the user-supplied key.\r | |
1625 | @param[in] KeySize Key size in bytes.\r | |
1626 | \r | |
cc1d13c9 MK |
1627 | @retval FALSE This interface is not supported.\r |
1628 | \r | |
1629 | **/\r | |
1630 | BOOLEAN\r | |
1631 | EFIAPI\r | |
c812d320 | 1632 | DeprecatedCryptoServiceHmacSha1SetKey (\r |
cc1d13c9 MK |
1633 | OUT VOID *HmacSha1Context,\r |
1634 | IN CONST UINT8 *Key,\r | |
1635 | IN UINTN KeySize\r | |
1636 | )\r | |
1637 | {\r | |
c812d320 | 1638 | return BaseCryptLibServiceDeprecated ("HmacSha1SetKey"), FALSE;\r |
cc1d13c9 MK |
1639 | }\r |
1640 | \r | |
1641 | /**\r | |
c812d320 ZG |
1642 | HMAC SHA1 is deprecated and unsupported any longer.\r |
1643 | Keep the function field for binary compability.\r | |
cc1d13c9 MK |
1644 | \r |
1645 | @param[in] HmacSha1Context Pointer to HMAC-SHA1 context being copied.\r | |
1646 | @param[out] NewHmacSha1Context Pointer to new HMAC-SHA1 context.\r | |
1647 | \r | |
cc1d13c9 MK |
1648 | @retval FALSE This interface is not supported.\r |
1649 | \r | |
1650 | **/\r | |
1651 | BOOLEAN\r | |
1652 | EFIAPI\r | |
c812d320 | 1653 | DeprecatedCryptoServiceHmacSha1Duplicate (\r |
cc1d13c9 MK |
1654 | IN CONST VOID *HmacSha1Context,\r |
1655 | OUT VOID *NewHmacSha1Context\r | |
1656 | )\r | |
1657 | {\r | |
c812d320 | 1658 | return BaseCryptLibServiceDeprecated ("HmacSha1Duplicate"), FALSE;\r |
cc1d13c9 MK |
1659 | }\r |
1660 | \r | |
1661 | /**\r | |
c812d320 ZG |
1662 | HMAC SHA1 is deprecated and unsupported any longer.\r |
1663 | Keep the function field for binary compability.\r | |
cc1d13c9 MK |
1664 | \r |
1665 | @param[in, out] HmacSha1Context Pointer to the HMAC-SHA1 context.\r | |
1666 | @param[in] Data Pointer to the buffer containing the data to be digested.\r | |
1667 | @param[in] DataSize Size of Data buffer in bytes.\r | |
1668 | \r | |
cc1d13c9 MK |
1669 | @retval FALSE This interface is not supported.\r |
1670 | \r | |
1671 | **/\r | |
1672 | BOOLEAN\r | |
1673 | EFIAPI\r | |
c812d320 | 1674 | DeprecatedCryptoServiceHmacSha1Update (\r |
cc1d13c9 MK |
1675 | IN OUT VOID *HmacSha1Context,\r |
1676 | IN CONST VOID *Data,\r | |
1677 | IN UINTN DataSize\r | |
1678 | )\r | |
1679 | {\r | |
c812d320 | 1680 | return BaseCryptLibServiceDeprecated ("HmacSha1Update"), FALSE;\r |
cc1d13c9 MK |
1681 | }\r |
1682 | \r | |
1683 | /**\r | |
c812d320 ZG |
1684 | HMAC SHA1 is deprecated and unsupported any longer.\r |
1685 | Keep the function field for binary compability.\r | |
cc1d13c9 MK |
1686 | \r |
1687 | @param[in, out] HmacSha1Context Pointer to the HMAC-SHA1 context.\r | |
1688 | @param[out] HmacValue Pointer to a buffer that receives the HMAC-SHA1 digest\r | |
1689 | value (20 bytes).\r | |
1690 | \r | |
cc1d13c9 MK |
1691 | @retval FALSE This interface is not supported.\r |
1692 | \r | |
1693 | **/\r | |
1694 | BOOLEAN\r | |
1695 | EFIAPI\r | |
c812d320 | 1696 | DeprecatedCryptoServiceHmacSha1Final (\r |
cc1d13c9 MK |
1697 | IN OUT VOID *HmacSha1Context,\r |
1698 | OUT UINT8 *HmacValue\r | |
1699 | )\r | |
1700 | {\r | |
c812d320 | 1701 | return BaseCryptLibServiceDeprecated ("HmacSha1Final"), FALSE;\r |
cc1d13c9 MK |
1702 | }\r |
1703 | \r | |
1704 | /**\r | |
1705 | Allocates and initializes one HMAC_CTX context for subsequent HMAC-SHA256 use.\r | |
1706 | \r | |
1707 | @return Pointer to the HMAC_CTX context that has been initialized.\r | |
1708 | If the allocations fails, HmacSha256New() returns NULL.\r | |
1709 | \r | |
1710 | **/\r | |
1711 | VOID *\r | |
1712 | EFIAPI\r | |
1713 | CryptoServiceHmacSha256New (\r | |
1714 | VOID\r | |
1715 | )\r | |
1716 | {\r | |
1717 | return CALL_BASECRYPTLIB (HmacSha256.Services.New, HmacSha256New, (), NULL);\r | |
1718 | }\r | |
1719 | \r | |
1720 | /**\r | |
1721 | Release the specified HMAC_CTX context.\r | |
1722 | \r | |
1723 | @param[in] HmacSha256Ctx Pointer to the HMAC_CTX context to be released.\r | |
1724 | \r | |
1725 | **/\r | |
1726 | VOID\r | |
1727 | EFIAPI\r | |
1728 | CryptoServiceHmacSha256Free (\r | |
1729 | IN VOID *HmacSha256Ctx\r | |
1730 | )\r | |
1731 | {\r | |
1732 | CALL_VOID_BASECRYPTLIB (HmacSha256.Services.Free, HmacSha256Free, (HmacSha256Ctx));\r | |
1733 | }\r | |
1734 | \r | |
1735 | /**\r | |
1736 | Set user-supplied key for subsequent use. It must be done before any\r | |
1737 | calling to HmacSha256Update().\r | |
1738 | \r | |
1739 | If HmacSha256Context is NULL, then return FALSE.\r | |
1740 | If this interface is not supported, then return FALSE.\r | |
1741 | \r | |
1742 | @param[out] HmacSha256Context Pointer to HMAC-SHA256 context.\r | |
1743 | @param[in] Key Pointer to the user-supplied key.\r | |
1744 | @param[in] KeySize Key size in bytes.\r | |
1745 | \r | |
1746 | @retval TRUE The Key is set successfully.\r | |
1747 | @retval FALSE The Key is set unsuccessfully.\r | |
1748 | @retval FALSE This interface is not supported.\r | |
1749 | \r | |
1750 | **/\r | |
1751 | BOOLEAN\r | |
1752 | EFIAPI\r | |
1753 | CryptoServiceHmacSha256SetKey (\r | |
1754 | OUT VOID *HmacSha256Context,\r | |
1755 | IN CONST UINT8 *Key,\r | |
1756 | IN UINTN KeySize\r | |
1757 | )\r | |
1758 | {\r | |
1759 | return CALL_BASECRYPTLIB (HmacSha256.Services.SetKey, HmacSha256SetKey, (HmacSha256Context, Key, KeySize), FALSE);\r | |
1760 | }\r | |
1761 | \r | |
1762 | /**\r | |
1763 | Makes a copy of an existing HMAC-SHA256 context.\r | |
1764 | \r | |
1765 | If HmacSha256Context is NULL, then return FALSE.\r | |
1766 | If NewHmacSha256Context is NULL, then return FALSE.\r | |
1767 | If this interface is not supported, then return FALSE.\r | |
1768 | \r | |
1769 | @param[in] HmacSha256Context Pointer to HMAC-SHA256 context being copied.\r | |
1770 | @param[out] NewHmacSha256Context Pointer to new HMAC-SHA256 context.\r | |
1771 | \r | |
1772 | @retval TRUE HMAC-SHA256 context copy succeeded.\r | |
1773 | @retval FALSE HMAC-SHA256 context copy failed.\r | |
1774 | @retval FALSE This interface is not supported.\r | |
1775 | \r | |
1776 | **/\r | |
1777 | BOOLEAN\r | |
1778 | EFIAPI\r | |
1779 | CryptoServiceHmacSha256Duplicate (\r | |
1780 | IN CONST VOID *HmacSha256Context,\r | |
1781 | OUT VOID *NewHmacSha256Context\r | |
1782 | )\r | |
1783 | {\r | |
1784 | return CALL_BASECRYPTLIB (HmacSha256.Services.Duplicate, HmacSha256Duplicate, (HmacSha256Context, NewHmacSha256Context), FALSE);\r | |
1785 | }\r | |
1786 | \r | |
1787 | /**\r | |
1788 | Digests the input data and updates HMAC-SHA256 context.\r | |
1789 | \r | |
1790 | This function performs HMAC-SHA256 digest on a data buffer of the specified size.\r | |
1791 | It can be called multiple times to compute the digest of long or discontinuous data streams.\r | |
1792 | HMAC-SHA256 context should be initialized by HmacSha256New(), and should not be finalized\r | |
1793 | by HmacSha256Final(). Behavior with invalid context is undefined.\r | |
1794 | \r | |
1795 | If HmacSha256Context is NULL, then return FALSE.\r | |
1796 | If this interface is not supported, then return FALSE.\r | |
1797 | \r | |
1798 | @param[in, out] HmacSha256Context Pointer to the HMAC-SHA256 context.\r | |
1799 | @param[in] Data Pointer to the buffer containing the data to be digested.\r | |
1800 | @param[in] DataSize Size of Data buffer in bytes.\r | |
1801 | \r | |
1802 | @retval TRUE HMAC-SHA256 data digest succeeded.\r | |
1803 | @retval FALSE HMAC-SHA256 data digest failed.\r | |
1804 | @retval FALSE This interface is not supported.\r | |
1805 | \r | |
1806 | **/\r | |
1807 | BOOLEAN\r | |
1808 | EFIAPI\r | |
1809 | CryptoServiceHmacSha256Update (\r | |
1810 | IN OUT VOID *HmacSha256Context,\r | |
1811 | IN CONST VOID *Data,\r | |
1812 | IN UINTN DataSize\r | |
1813 | )\r | |
1814 | {\r | |
1815 | return CALL_BASECRYPTLIB (HmacSha256.Services.Update, HmacSha256Update, (HmacSha256Context, Data, DataSize), FALSE);\r | |
1816 | }\r | |
1817 | \r | |
1818 | /**\r | |
1819 | Completes computation of the HMAC-SHA256 digest value.\r | |
1820 | \r | |
1821 | This function completes HMAC-SHA256 hash computation and retrieves the digest value into\r | |
1822 | the specified memory. After this function has been called, the HMAC-SHA256 context cannot\r | |
1823 | be used again.\r | |
1824 | HMAC-SHA256 context should be initialized by HmacSha256New(), and should not be finalized\r | |
1825 | by HmacSha256Final(). Behavior with invalid HMAC-SHA256 context is undefined.\r | |
1826 | \r | |
1827 | If HmacSha256Context is NULL, then return FALSE.\r | |
1828 | If HmacValue is NULL, then return FALSE.\r | |
1829 | If this interface is not supported, then return FALSE.\r | |
1830 | \r | |
1831 | @param[in, out] HmacSha256Context Pointer to the HMAC-SHA256 context.\r | |
1832 | @param[out] HmacValue Pointer to a buffer that receives the HMAC-SHA256 digest\r | |
1833 | value (32 bytes).\r | |
1834 | \r | |
1835 | @retval TRUE HMAC-SHA256 digest computation succeeded.\r | |
1836 | @retval FALSE HMAC-SHA256 digest computation failed.\r | |
1837 | @retval FALSE This interface is not supported.\r | |
1838 | \r | |
1839 | **/\r | |
1840 | BOOLEAN\r | |
1841 | EFIAPI\r | |
1842 | CryptoServiceHmacSha256Final (\r | |
1843 | IN OUT VOID *HmacSha256Context,\r | |
1844 | OUT UINT8 *HmacValue\r | |
1845 | )\r | |
1846 | {\r | |
1847 | return CALL_BASECRYPTLIB (HmacSha256.Services.Final, HmacSha256Final, (HmacSha256Context, HmacValue), FALSE);\r | |
1848 | }\r | |
1849 | \r | |
3f77ccb9 QZ |
1850 | /**\r |
1851 | Computes the HMAC-SHA256 digest of a input data buffer.\r | |
1852 | \r | |
1853 | This function performs the HMAC-SHA256 digest of a given data buffer, and places\r | |
1854 | the digest value into the specified memory.\r | |
1855 | \r | |
1856 | If this interface is not supported, then return FALSE.\r | |
1857 | \r | |
1858 | @param[in] Data Pointer to the buffer containing the data to be digested.\r | |
1859 | @param[in] DataSize Size of Data buffer in bytes.\r | |
1860 | @param[in] Key Pointer to the user-supplied key.\r | |
1861 | @param[in] KeySize Key size in bytes.\r | |
1862 | @param[out] HmacValue Pointer to a buffer that receives the HMAC-SHA256 digest\r | |
1863 | value (32 bytes).\r | |
1864 | \r | |
1865 | @retval TRUE HMAC-SHA256 digest computation succeeded.\r | |
1866 | @retval FALSE HMAC-SHA256 digest computation failed.\r | |
1867 | @retval FALSE This interface is not supported.\r | |
1868 | \r | |
1869 | **/\r | |
1870 | BOOLEAN\r | |
1871 | EFIAPI\r | |
1872 | CryptoServiceHmacSha256All (\r | |
1873 | IN CONST VOID *Data,\r | |
1874 | IN UINTN DataSize,\r | |
1875 | IN CONST UINT8 *Key,\r | |
1876 | IN UINTN KeySize,\r | |
1877 | OUT UINT8 *HmacValue\r | |
1878 | )\r | |
1879 | {\r | |
1880 | return CALL_BASECRYPTLIB (HmacSha256.Services.All, HmacSha256All, (Data, DataSize, Key, KeySize, HmacValue), FALSE);\r | |
1881 | }\r | |
1882 | \r | |
1883 | /**\r | |
1884 | Allocates and initializes one HMAC_CTX context for subsequent HMAC-SHA384 use.\r | |
1885 | \r | |
1886 | @return Pointer to the HMAC_CTX context that has been initialized.\r | |
1887 | If the allocations fails, HmacSha384New() returns NULL.\r | |
1888 | \r | |
1889 | **/\r | |
1890 | VOID *\r | |
1891 | EFIAPI\r | |
1892 | CryptoServiceHmacSha384New (\r | |
1893 | VOID\r | |
1894 | )\r | |
1895 | {\r | |
1896 | return CALL_BASECRYPTLIB (HmacSha384.Services.New, HmacSha384New, (), NULL);\r | |
1897 | }\r | |
1898 | \r | |
1899 | /**\r | |
1900 | Release the specified HMAC_CTX context.\r | |
1901 | \r | |
1902 | @param[in] HmacSha384Ctx Pointer to the HMAC_CTX context to be released.\r | |
1903 | \r | |
1904 | **/\r | |
1905 | VOID\r | |
1906 | EFIAPI\r | |
1907 | CryptoServiceHmacSha384Free (\r | |
1908 | IN VOID *HmacSha384Ctx\r | |
1909 | )\r | |
1910 | {\r | |
1911 | CALL_VOID_BASECRYPTLIB (HmacSha384.Services.Free, HmacSha384Free, (HmacSha384Ctx));\r | |
1912 | }\r | |
1913 | \r | |
1914 | /**\r | |
1915 | Set user-supplied key for subsequent use. It must be done before any\r | |
1916 | calling to HmacSha384Update().\r | |
1917 | \r | |
1918 | If HmacSha384Context is NULL, then return FALSE.\r | |
1919 | If this interface is not supported, then return FALSE.\r | |
1920 | \r | |
1921 | @param[out] HmacSha384Context Pointer to HMAC-SHA384 context.\r | |
1922 | @param[in] Key Pointer to the user-supplied key.\r | |
1923 | @param[in] KeySize Key size in bytes.\r | |
1924 | \r | |
1925 | @retval TRUE The Key is set successfully.\r | |
1926 | @retval FALSE The Key is set unsuccessfully.\r | |
1927 | @retval FALSE This interface is not supported.\r | |
1928 | \r | |
1929 | **/\r | |
1930 | BOOLEAN\r | |
1931 | EFIAPI\r | |
1932 | CryptoServiceHmacSha384SetKey (\r | |
1933 | OUT VOID *HmacSha384Context,\r | |
1934 | IN CONST UINT8 *Key,\r | |
1935 | IN UINTN KeySize\r | |
1936 | )\r | |
1937 | {\r | |
1938 | return CALL_BASECRYPTLIB (HmacSha384.Services.SetKey, HmacSha384SetKey, (HmacSha384Context, Key, KeySize), FALSE);\r | |
1939 | }\r | |
1940 | \r | |
1941 | /**\r | |
1942 | Makes a copy of an existing HMAC-SHA384 context.\r | |
1943 | \r | |
1944 | If HmacSha384Context is NULL, then return FALSE.\r | |
1945 | If NewHmacSha384Context is NULL, then return FALSE.\r | |
1946 | If this interface is not supported, then return FALSE.\r | |
1947 | \r | |
1948 | @param[in] HmacSha384Context Pointer to HMAC-SHA384 context being copied.\r | |
1949 | @param[out] NewHmacSha384Context Pointer to new HMAC-SHA384 context.\r | |
1950 | \r | |
1951 | @retval TRUE HMAC-SHA384 context copy succeeded.\r | |
1952 | @retval FALSE HMAC-SHA384 context copy failed.\r | |
1953 | @retval FALSE This interface is not supported.\r | |
1954 | \r | |
1955 | **/\r | |
1956 | BOOLEAN\r | |
1957 | EFIAPI\r | |
1958 | CryptoServiceHmacSha384Duplicate (\r | |
1959 | IN CONST VOID *HmacSha384Context,\r | |
1960 | OUT VOID *NewHmacSha384Context\r | |
1961 | )\r | |
1962 | {\r | |
1963 | return CALL_BASECRYPTLIB (HmacSha384.Services.Duplicate, HmacSha256Duplicate, (HmacSha384Context, NewHmacSha384Context), FALSE);\r | |
1964 | }\r | |
1965 | \r | |
1966 | /**\r | |
1967 | Digests the input data and updates HMAC-SHA384 context.\r | |
1968 | \r | |
1969 | This function performs HMAC-SHA384 digest on a data buffer of the specified size.\r | |
1970 | It can be called multiple times to compute the digest of long or discontinuous data streams.\r | |
1971 | HMAC-SHA384 context should be initialized by HmacSha384New(), and should not be finalized\r | |
1972 | by HmacSha384Final(). Behavior with invalid context is undefined.\r | |
1973 | \r | |
1974 | If HmacSha384Context is NULL, then return FALSE.\r | |
1975 | If this interface is not supported, then return FALSE.\r | |
1976 | \r | |
1977 | @param[in, out] HmacSha384Context Pointer to the HMAC-SHA384 context.\r | |
1978 | @param[in] Data Pointer to the buffer containing the data to be digested.\r | |
1979 | @param[in] DataSize Size of Data buffer in bytes.\r | |
1980 | \r | |
1981 | @retval TRUE HMAC-SHA384 data digest succeeded.\r | |
1982 | @retval FALSE HMAC-SHA384 data digest failed.\r | |
1983 | @retval FALSE This interface is not supported.\r | |
1984 | \r | |
1985 | **/\r | |
1986 | BOOLEAN\r | |
1987 | EFIAPI\r | |
1988 | CryptoServiceHmacSha384Update (\r | |
1989 | IN OUT VOID *HmacSha384Context,\r | |
1990 | IN CONST VOID *Data,\r | |
1991 | IN UINTN DataSize\r | |
1992 | )\r | |
1993 | {\r | |
1994 | return CALL_BASECRYPTLIB (HmacSha384.Services.Update, HmacSha384Update, (HmacSha384Context, Data, DataSize), FALSE);\r | |
1995 | }\r | |
1996 | \r | |
1997 | /**\r | |
1998 | Completes computation of the HMAC-SHA384 digest value.\r | |
1999 | \r | |
2000 | This function completes HMAC-SHA384 hash computation and retrieves the digest value into\r | |
2001 | the specified memory. After this function has been called, the HMAC-SHA384 context cannot\r | |
2002 | be used again.\r | |
2003 | HMAC-SHA384 context should be initialized by HmacSha384New(), and should not be finalized\r | |
2004 | by HmacSha384Final(). Behavior with invalid HMAC-SHA384 context is undefined.\r | |
2005 | \r | |
2006 | If HmacSha384Context is NULL, then return FALSE.\r | |
2007 | If HmacValue is NULL, then return FALSE.\r | |
2008 | If this interface is not supported, then return FALSE.\r | |
2009 | \r | |
2010 | @param[in, out] HmacSha384Context Pointer to the HMAC-SHA384 context.\r | |
2011 | @param[out] HmacValue Pointer to a buffer that receives the HMAC-SHA384 digest\r | |
2012 | value (48 bytes).\r | |
2013 | \r | |
2014 | @retval TRUE HMAC-SHA384 digest computation succeeded.\r | |
2015 | @retval FALSE HMAC-SHA384 digest computation failed.\r | |
2016 | @retval FALSE This interface is not supported.\r | |
2017 | \r | |
2018 | **/\r | |
2019 | BOOLEAN\r | |
2020 | EFIAPI\r | |
2021 | CryptoServiceHmacSha384Final (\r | |
2022 | IN OUT VOID *HmacSha384Context,\r | |
2023 | OUT UINT8 *HmacValue\r | |
2024 | )\r | |
2025 | {\r | |
2026 | return CALL_BASECRYPTLIB (HmacSha384.Services.Final, HmacSha384Final, (HmacSha384Context, HmacValue), FALSE);\r | |
2027 | }\r | |
2028 | \r | |
2029 | /**\r | |
2030 | Computes the HMAC-SHA384 digest of a input data buffer.\r | |
2031 | \r | |
2032 | This function performs the HMAC-SHA384 digest of a given data buffer, and places\r | |
2033 | the digest value into the specified memory.\r | |
2034 | \r | |
2035 | If this interface is not supported, then return FALSE.\r | |
2036 | \r | |
2037 | @param[in] Data Pointer to the buffer containing the data to be digested.\r | |
2038 | @param[in] DataSize Size of Data buffer in bytes.\r | |
2039 | @param[in] Key Pointer to the user-supplied key.\r | |
2040 | @param[in] KeySize Key size in bytes.\r | |
2041 | @param[out] HmacValue Pointer to a buffer that receives the HMAC-SHA384 digest\r | |
2042 | value (48 bytes).\r | |
2043 | \r | |
2044 | @retval TRUE HMAC-SHA384 digest computation succeeded.\r | |
2045 | @retval FALSE HMAC-SHA384 digest computation failed.\r | |
2046 | @retval FALSE This interface is not supported.\r | |
2047 | \r | |
2048 | **/\r | |
2049 | BOOLEAN\r | |
2050 | EFIAPI\r | |
2051 | CryptoServiceHmacSha384All (\r | |
2052 | IN CONST VOID *Data,\r | |
2053 | IN UINTN DataSize,\r | |
2054 | IN CONST UINT8 *Key,\r | |
2055 | IN UINTN KeySize,\r | |
2056 | OUT UINT8 *HmacValue\r | |
2057 | )\r | |
2058 | {\r | |
2059 | return CALL_BASECRYPTLIB (HmacSha384.Services.All, HmacSha384All, (Data, DataSize, Key, KeySize, HmacValue), FALSE);\r | |
2060 | }\r | |
2061 | \r | |
7c342378 | 2062 | // =====================================================================================\r |
cc1d13c9 | 2063 | // Symmetric Cryptography Primitive\r |
7c342378 | 2064 | // =====================================================================================\r |
cc1d13c9 MK |
2065 | \r |
2066 | /**\r | |
b8af2c9e ZG |
2067 | TDES is deprecated and unsupported any longer.\r |
2068 | Keep the function field for binary compability.\r | |
cc1d13c9 | 2069 | \r |
cc1d13c9 MK |
2070 | @retval 0 This interface is not supported.\r |
2071 | \r | |
2072 | **/\r | |
2073 | UINTN\r | |
2074 | EFIAPI\r | |
b8af2c9e | 2075 | DeprecatedCryptoServiceTdesGetContextSize (\r |
cc1d13c9 MK |
2076 | VOID\r |
2077 | )\r | |
2078 | {\r | |
b8af2c9e | 2079 | return BaseCryptLibServiceDeprecated ("TdesGetContextSize"), 0;\r |
cc1d13c9 MK |
2080 | }\r |
2081 | \r | |
2082 | /**\r | |
b8af2c9e ZG |
2083 | TDES is deprecated and unsupported any longer.\r |
2084 | Keep the function field for binary compability.\r | |
cc1d13c9 MK |
2085 | \r |
2086 | @param[out] TdesContext Pointer to TDES context being initialized.\r | |
2087 | @param[in] Key Pointer to the user-supplied TDES key.\r | |
2088 | @param[in] KeyLength Length of TDES key in bits.\r | |
2089 | \r | |
cc1d13c9 MK |
2090 | @retval FALSE This interface is not supported.\r |
2091 | \r | |
2092 | **/\r | |
2093 | BOOLEAN\r | |
2094 | EFIAPI\r | |
b8af2c9e | 2095 | DeprecatedCryptoServiceTdesInit (\r |
cc1d13c9 MK |
2096 | OUT VOID *TdesContext,\r |
2097 | IN CONST UINT8 *Key,\r | |
2098 | IN UINTN KeyLength\r | |
2099 | )\r | |
2100 | {\r | |
b8af2c9e | 2101 | return BaseCryptLibServiceDeprecated ("TdesInit"), FALSE;\r |
cc1d13c9 MK |
2102 | }\r |
2103 | \r | |
2104 | /**\r | |
b8af2c9e ZG |
2105 | TDES is deprecated and unsupported any longer.\r |
2106 | Keep the function field for binary compability.\r | |
cc1d13c9 MK |
2107 | \r |
2108 | @param[in] TdesContext Pointer to the TDES context.\r | |
2109 | @param[in] Input Pointer to the buffer containing the data to be encrypted.\r | |
2110 | @param[in] InputSize Size of the Input buffer in bytes.\r | |
2111 | @param[out] Output Pointer to a buffer that receives the TDES encryption output.\r | |
2112 | \r | |
cc1d13c9 MK |
2113 | @retval FALSE This interface is not supported.\r |
2114 | \r | |
2115 | **/\r | |
2116 | BOOLEAN\r | |
2117 | EFIAPI\r | |
b8af2c9e | 2118 | DeprecatedCryptoServiceTdesEcbEncrypt (\r |
cc1d13c9 MK |
2119 | IN VOID *TdesContext,\r |
2120 | IN CONST UINT8 *Input,\r | |
2121 | IN UINTN InputSize,\r | |
2122 | OUT UINT8 *Output\r | |
2123 | )\r | |
2124 | {\r | |
b8af2c9e | 2125 | return BaseCryptLibServiceDeprecated ("TdesEcbEncrypt"), FALSE;\r |
cc1d13c9 MK |
2126 | }\r |
2127 | \r | |
2128 | /**\r | |
b8af2c9e ZG |
2129 | TDES is deprecated and unsupported any longer.\r |
2130 | Keep the function field for binary compability.\r | |
cc1d13c9 MK |
2131 | \r |
2132 | @param[in] TdesContext Pointer to the TDES context.\r | |
2133 | @param[in] Input Pointer to the buffer containing the data to be decrypted.\r | |
2134 | @param[in] InputSize Size of the Input buffer in bytes.\r | |
2135 | @param[out] Output Pointer to a buffer that receives the TDES decryption output.\r | |
2136 | \r | |
cc1d13c9 MK |
2137 | @retval FALSE This interface is not supported.\r |
2138 | \r | |
2139 | **/\r | |
2140 | BOOLEAN\r | |
2141 | EFIAPI\r | |
b8af2c9e | 2142 | DeprecatedCryptoServiceTdesEcbDecrypt (\r |
cc1d13c9 MK |
2143 | IN VOID *TdesContext,\r |
2144 | IN CONST UINT8 *Input,\r | |
2145 | IN UINTN InputSize,\r | |
2146 | OUT UINT8 *Output\r | |
2147 | )\r | |
2148 | {\r | |
b8af2c9e | 2149 | return BaseCryptLibServiceDeprecated ("TdesEcbDecrypt"), FALSE;\r |
cc1d13c9 MK |
2150 | }\r |
2151 | \r | |
2152 | /**\r | |
b8af2c9e ZG |
2153 | TDES is deprecated and unsupported any longer.\r |
2154 | Keep the function field for binary compability.\r | |
cc1d13c9 MK |
2155 | \r |
2156 | @param[in] TdesContext Pointer to the TDES context.\r | |
2157 | @param[in] Input Pointer to the buffer containing the data to be encrypted.\r | |
2158 | @param[in] InputSize Size of the Input buffer in bytes.\r | |
2159 | @param[in] Ivec Pointer to initialization vector.\r | |
2160 | @param[out] Output Pointer to a buffer that receives the TDES encryption output.\r | |
2161 | \r | |
cc1d13c9 MK |
2162 | @retval FALSE This interface is not supported.\r |
2163 | \r | |
2164 | **/\r | |
2165 | BOOLEAN\r | |
2166 | EFIAPI\r | |
b8af2c9e | 2167 | DeprecatedCryptoServiceTdesCbcEncrypt (\r |
cc1d13c9 MK |
2168 | IN VOID *TdesContext,\r |
2169 | IN CONST UINT8 *Input,\r | |
2170 | IN UINTN InputSize,\r | |
2171 | IN CONST UINT8 *Ivec,\r | |
2172 | OUT UINT8 *Output\r | |
2173 | )\r | |
2174 | {\r | |
b8af2c9e | 2175 | return BaseCryptLibServiceDeprecated ("TdesCbcEncrypt"), FALSE;\r |
cc1d13c9 MK |
2176 | }\r |
2177 | \r | |
2178 | /**\r | |
b8af2c9e ZG |
2179 | TDES is deprecated and unsupported any longer.\r |
2180 | Keep the function field for binary compability.\r | |
cc1d13c9 MK |
2181 | \r |
2182 | @param[in] TdesContext Pointer to the TDES context.\r | |
2183 | @param[in] Input Pointer to the buffer containing the data to be encrypted.\r | |
2184 | @param[in] InputSize Size of the Input buffer in bytes.\r | |
2185 | @param[in] Ivec Pointer to initialization vector.\r | |
2186 | @param[out] Output Pointer to a buffer that receives the TDES encryption output.\r | |
2187 | \r | |
cc1d13c9 MK |
2188 | @retval FALSE This interface is not supported.\r |
2189 | \r | |
2190 | **/\r | |
2191 | BOOLEAN\r | |
2192 | EFIAPI\r | |
b8af2c9e | 2193 | DeprecatedCryptoServiceTdesCbcDecrypt (\r |
cc1d13c9 MK |
2194 | IN VOID *TdesContext,\r |
2195 | IN CONST UINT8 *Input,\r | |
2196 | IN UINTN InputSize,\r | |
2197 | IN CONST UINT8 *Ivec,\r | |
2198 | OUT UINT8 *Output\r | |
2199 | )\r | |
2200 | {\r | |
b8af2c9e | 2201 | return BaseCryptLibServiceDeprecated ("TdesCbcDecrypt"), FALSE;\r |
cc1d13c9 MK |
2202 | }\r |
2203 | \r | |
2204 | /**\r | |
2205 | Retrieves the size, in bytes, of the context buffer required for AES operations.\r | |
2206 | \r | |
2207 | If this interface is not supported, then return zero.\r | |
2208 | \r | |
2209 | @return The size, in bytes, of the context buffer required for AES operations.\r | |
2210 | @retval 0 This interface is not supported.\r | |
2211 | \r | |
2212 | **/\r | |
2213 | UINTN\r | |
2214 | EFIAPI\r | |
2215 | CryptoServiceAesGetContextSize (\r | |
2216 | VOID\r | |
2217 | )\r | |
2218 | {\r | |
2219 | return CALL_BASECRYPTLIB (Aes.Services.GetContextSize, AesGetContextSize, (), 0);\r | |
2220 | }\r | |
2221 | \r | |
2222 | /**\r | |
2223 | Initializes user-supplied memory as AES context for subsequent use.\r | |
2224 | \r | |
2225 | This function initializes user-supplied memory pointed by AesContext as AES context.\r | |
2226 | In addition, it sets up all AES key materials for subsequent encryption and decryption\r | |
2227 | operations.\r | |
2228 | There are 3 options for key length, 128 bits, 192 bits, and 256 bits.\r | |
2229 | \r | |
2230 | If AesContext is NULL, then return FALSE.\r | |
2231 | If Key is NULL, then return FALSE.\r | |
2232 | If KeyLength is not valid, then return FALSE.\r | |
2233 | If this interface is not supported, then return FALSE.\r | |
2234 | \r | |
2235 | @param[out] AesContext Pointer to AES context being initialized.\r | |
2236 | @param[in] Key Pointer to the user-supplied AES key.\r | |
2237 | @param[in] KeyLength Length of AES key in bits.\r | |
2238 | \r | |
2239 | @retval TRUE AES context initialization succeeded.\r | |
2240 | @retval FALSE AES context initialization failed.\r | |
2241 | @retval FALSE This interface is not supported.\r | |
2242 | \r | |
2243 | **/\r | |
2244 | BOOLEAN\r | |
2245 | EFIAPI\r | |
2246 | CryptoServiceAesInit (\r | |
2247 | OUT VOID *AesContext,\r | |
2248 | IN CONST UINT8 *Key,\r | |
2249 | IN UINTN KeyLength\r | |
2250 | )\r | |
2251 | {\r | |
2252 | return CALL_BASECRYPTLIB (Aes.Services.Init, AesInit, (AesContext, Key, KeyLength), FALSE);\r | |
2253 | }\r | |
2254 | \r | |
2255 | /**\r | |
80e28dce ZG |
2256 | AES ECB Mode is deprecated and unsupported any longer.\r |
2257 | Keep the function field for binary compability.\r | |
cc1d13c9 MK |
2258 | \r |
2259 | @param[in] AesContext Pointer to the AES context.\r | |
2260 | @param[in] Input Pointer to the buffer containing the data to be encrypted.\r | |
2261 | @param[in] InputSize Size of the Input buffer in bytes.\r | |
2262 | @param[out] Output Pointer to a buffer that receives the AES encryption output.\r | |
2263 | \r | |
cc1d13c9 MK |
2264 | @retval FALSE This interface is not supported.\r |
2265 | \r | |
2266 | **/\r | |
2267 | BOOLEAN\r | |
2268 | EFIAPI\r | |
80e28dce | 2269 | DeprecatedCryptoServiceAesEcbEncrypt (\r |
cc1d13c9 MK |
2270 | IN VOID *AesContext,\r |
2271 | IN CONST UINT8 *Input,\r | |
2272 | IN UINTN InputSize,\r | |
2273 | OUT UINT8 *Output\r | |
2274 | )\r | |
2275 | {\r | |
80e28dce | 2276 | return BaseCryptLibServiceDeprecated ("AesEcbEncrypt"), FALSE;\r |
cc1d13c9 MK |
2277 | }\r |
2278 | \r | |
2279 | /**\r | |
80e28dce ZG |
2280 | AES ECB Mode is deprecated and unsupported any longer.\r |
2281 | Keep the function field for binary compability.\r | |
cc1d13c9 MK |
2282 | \r |
2283 | @param[in] AesContext Pointer to the AES context.\r | |
2284 | @param[in] Input Pointer to the buffer containing the data to be decrypted.\r | |
2285 | @param[in] InputSize Size of the Input buffer in bytes.\r | |
2286 | @param[out] Output Pointer to a buffer that receives the AES decryption output.\r | |
2287 | \r | |
cc1d13c9 MK |
2288 | @retval FALSE This interface is not supported.\r |
2289 | \r | |
2290 | **/\r | |
2291 | BOOLEAN\r | |
2292 | EFIAPI\r | |
80e28dce | 2293 | DeprecatedCryptoServiceAesEcbDecrypt (\r |
cc1d13c9 MK |
2294 | IN VOID *AesContext,\r |
2295 | IN CONST UINT8 *Input,\r | |
2296 | IN UINTN InputSize,\r | |
2297 | OUT UINT8 *Output\r | |
2298 | )\r | |
2299 | {\r | |
80e28dce | 2300 | return BaseCryptLibServiceDeprecated ("AesEcbDecrypt"), FALSE;\r |
cc1d13c9 MK |
2301 | }\r |
2302 | \r | |
2303 | /**\r | |
2304 | Performs AES encryption on a data buffer of the specified size in CBC mode.\r | |
2305 | \r | |
2306 | This function performs AES encryption on data buffer pointed by Input, of specified\r | |
2307 | size of InputSize, in CBC mode.\r | |
2308 | InputSize must be multiple of block size (16 bytes). This function does not perform\r | |
2309 | padding. Caller must perform padding, if necessary, to ensure valid input data size.\r | |
2310 | Initialization vector should be one block size (16 bytes).\r | |
2311 | AesContext should be already correctly initialized by AesInit(). Behavior with\r | |
2312 | invalid AES context is undefined.\r | |
2313 | \r | |
2314 | If AesContext is NULL, then return FALSE.\r | |
2315 | If Input is NULL, then return FALSE.\r | |
2316 | If InputSize is not multiple of block size (16 bytes), then return FALSE.\r | |
2317 | If Ivec is NULL, then return FALSE.\r | |
2318 | If Output is NULL, then return FALSE.\r | |
2319 | If this interface is not supported, then return FALSE.\r | |
2320 | \r | |
2321 | @param[in] AesContext Pointer to the AES context.\r | |
2322 | @param[in] Input Pointer to the buffer containing the data to be encrypted.\r | |
2323 | @param[in] InputSize Size of the Input buffer in bytes.\r | |
2324 | @param[in] Ivec Pointer to initialization vector.\r | |
2325 | @param[out] Output Pointer to a buffer that receives the AES encryption output.\r | |
2326 | \r | |
2327 | @retval TRUE AES encryption succeeded.\r | |
2328 | @retval FALSE AES encryption failed.\r | |
2329 | @retval FALSE This interface is not supported.\r | |
2330 | \r | |
2331 | **/\r | |
2332 | BOOLEAN\r | |
2333 | EFIAPI\r | |
2334 | CryptoServiceAesCbcEncrypt (\r | |
2335 | IN VOID *AesContext,\r | |
2336 | IN CONST UINT8 *Input,\r | |
2337 | IN UINTN InputSize,\r | |
2338 | IN CONST UINT8 *Ivec,\r | |
2339 | OUT UINT8 *Output\r | |
2340 | )\r | |
2341 | {\r | |
2342 | return CALL_BASECRYPTLIB (Aes.Services.CbcEncrypt, AesCbcEncrypt, (AesContext, Input, InputSize, Ivec, Output), FALSE);\r | |
2343 | }\r | |
2344 | \r | |
2345 | /**\r | |
2346 | Performs AES decryption on a data buffer of the specified size in CBC mode.\r | |
2347 | \r | |
2348 | This function performs AES decryption on data buffer pointed by Input, of specified\r | |
2349 | size of InputSize, in CBC mode.\r | |
2350 | InputSize must be multiple of block size (16 bytes). This function does not perform\r | |
2351 | padding. Caller must perform padding, if necessary, to ensure valid input data size.\r | |
2352 | Initialization vector should be one block size (16 bytes).\r | |
2353 | AesContext should be already correctly initialized by AesInit(). Behavior with\r | |
2354 | invalid AES context is undefined.\r | |
2355 | \r | |
2356 | If AesContext is NULL, then return FALSE.\r | |
2357 | If Input is NULL, then return FALSE.\r | |
2358 | If InputSize is not multiple of block size (16 bytes), then return FALSE.\r | |
2359 | If Ivec is NULL, then return FALSE.\r | |
2360 | If Output is NULL, then return FALSE.\r | |
2361 | If this interface is not supported, then return FALSE.\r | |
2362 | \r | |
2363 | @param[in] AesContext Pointer to the AES context.\r | |
2364 | @param[in] Input Pointer to the buffer containing the data to be encrypted.\r | |
2365 | @param[in] InputSize Size of the Input buffer in bytes.\r | |
2366 | @param[in] Ivec Pointer to initialization vector.\r | |
2367 | @param[out] Output Pointer to a buffer that receives the AES encryption output.\r | |
2368 | \r | |
2369 | @retval TRUE AES decryption succeeded.\r | |
2370 | @retval FALSE AES decryption failed.\r | |
2371 | @retval FALSE This interface is not supported.\r | |
2372 | \r | |
2373 | **/\r | |
2374 | BOOLEAN\r | |
2375 | EFIAPI\r | |
2376 | CryptoServiceAesCbcDecrypt (\r | |
2377 | IN VOID *AesContext,\r | |
2378 | IN CONST UINT8 *Input,\r | |
2379 | IN UINTN InputSize,\r | |
2380 | IN CONST UINT8 *Ivec,\r | |
2381 | OUT UINT8 *Output\r | |
2382 | )\r | |
2383 | {\r | |
2384 | return CALL_BASECRYPTLIB (Aes.Services.CbcDecrypt, AesCbcDecrypt, (AesContext, Input, InputSize, Ivec, Output), FALSE);\r | |
2385 | }\r | |
2386 | \r | |
2387 | /**\r | |
c22a32e1 ZG |
2388 | ARC4 is deprecated and unsupported any longer.\r |
2389 | Keep the function field for binary compability.\r | |
cc1d13c9 | 2390 | \r |
cc1d13c9 MK |
2391 | @retval 0 This interface is not supported.\r |
2392 | \r | |
2393 | **/\r | |
2394 | UINTN\r | |
2395 | EFIAPI\r | |
c22a32e1 | 2396 | DeprecatedCryptoServiceArc4GetContextSize (\r |
cc1d13c9 MK |
2397 | VOID\r |
2398 | )\r | |
2399 | {\r | |
c22a32e1 | 2400 | return BaseCryptLibServiceDeprecated ("Arc4GetContextSize"), 0;\r |
cc1d13c9 MK |
2401 | }\r |
2402 | \r | |
2403 | /**\r | |
c22a32e1 ZG |
2404 | ARC4 is deprecated and unsupported any longer.\r |
2405 | Keep the function field for binary compability.\r | |
cc1d13c9 MK |
2406 | \r |
2407 | @param[out] Arc4Context Pointer to ARC4 context being initialized.\r | |
2408 | @param[in] Key Pointer to the user-supplied ARC4 key.\r | |
2409 | @param[in] KeySize Size of ARC4 key in bytes.\r | |
2410 | \r | |
cc1d13c9 MK |
2411 | @retval FALSE This interface is not supported.\r |
2412 | \r | |
2413 | **/\r | |
2414 | BOOLEAN\r | |
2415 | EFIAPI\r | |
c22a32e1 | 2416 | DeprecatedCryptoServiceArc4Init (\r |
cc1d13c9 MK |
2417 | OUT VOID *Arc4Context,\r |
2418 | IN CONST UINT8 *Key,\r | |
2419 | IN UINTN KeySize\r | |
2420 | )\r | |
2421 | {\r | |
c22a32e1 | 2422 | return BaseCryptLibServiceDeprecated ("Arc4Init"), FALSE;\r |
cc1d13c9 MK |
2423 | }\r |
2424 | \r | |
2425 | /**\r | |
c22a32e1 ZG |
2426 | ARC4 is deprecated and unsupported any longer.\r |
2427 | Keep the function field for binary compability.\r | |
cc1d13c9 MK |
2428 | \r |
2429 | @param[in, out] Arc4Context Pointer to the ARC4 context.\r | |
2430 | @param[in] Input Pointer to the buffer containing the data to be encrypted.\r | |
2431 | @param[in] InputSize Size of the Input buffer in bytes.\r | |
2432 | @param[out] Output Pointer to a buffer that receives the ARC4 encryption output.\r | |
2433 | \r | |
cc1d13c9 MK |
2434 | @retval FALSE This interface is not supported.\r |
2435 | \r | |
2436 | **/\r | |
2437 | BOOLEAN\r | |
2438 | EFIAPI\r | |
c22a32e1 | 2439 | DeprecatedCryptoServiceArc4Encrypt (\r |
cc1d13c9 MK |
2440 | IN OUT VOID *Arc4Context,\r |
2441 | IN CONST UINT8 *Input,\r | |
2442 | IN UINTN InputSize,\r | |
2443 | OUT UINT8 *Output\r | |
2444 | )\r | |
2445 | {\r | |
c22a32e1 | 2446 | return BaseCryptLibServiceDeprecated ("Arc4Encrypt"), FALSE;\r |
cc1d13c9 MK |
2447 | }\r |
2448 | \r | |
2449 | /**\r | |
c22a32e1 ZG |
2450 | ARC4 is deprecated and unsupported any longer.\r |
2451 | Keep the function field for binary compability.\r | |
cc1d13c9 MK |
2452 | \r |
2453 | @param[in, out] Arc4Context Pointer to the ARC4 context.\r | |
2454 | @param[in] Input Pointer to the buffer containing the data to be decrypted.\r | |
2455 | @param[in] InputSize Size of the Input buffer in bytes.\r | |
2456 | @param[out] Output Pointer to a buffer that receives the ARC4 decryption output.\r | |
2457 | \r | |
cc1d13c9 MK |
2458 | @retval FALSE This interface is not supported.\r |
2459 | \r | |
2460 | **/\r | |
2461 | BOOLEAN\r | |
2462 | EFIAPI\r | |
c22a32e1 | 2463 | DeprecatedCryptoServiceArc4Decrypt (\r |
cc1d13c9 MK |
2464 | IN OUT VOID *Arc4Context,\r |
2465 | IN UINT8 *Input,\r | |
2466 | IN UINTN InputSize,\r | |
2467 | OUT UINT8 *Output\r | |
2468 | )\r | |
2469 | {\r | |
c22a32e1 | 2470 | return BaseCryptLibServiceDeprecated ("Arc4Decrypt"), FALSE;\r |
cc1d13c9 MK |
2471 | }\r |
2472 | \r | |
2473 | /**\r | |
c22a32e1 ZG |
2474 | ARC4 is deprecated and unsupported any longer.\r |
2475 | Keep the function field for binary compability.\r | |
cc1d13c9 MK |
2476 | \r |
2477 | @param[in, out] Arc4Context Pointer to the ARC4 context.\r | |
2478 | \r | |
cc1d13c9 MK |
2479 | @retval FALSE This interface is not supported.\r |
2480 | \r | |
2481 | **/\r | |
2482 | BOOLEAN\r | |
2483 | EFIAPI\r | |
c22a32e1 | 2484 | DeprecatedCryptoServiceArc4Reset (\r |
cc1d13c9 MK |
2485 | IN OUT VOID *Arc4Context\r |
2486 | )\r | |
2487 | {\r | |
c22a32e1 | 2488 | return BaseCryptLibServiceDeprecated ("Arc4Reset"), FALSE;\r |
cc1d13c9 MK |
2489 | }\r |
2490 | \r | |
7c342378 | 2491 | // =====================================================================================\r |
cc1d13c9 | 2492 | // Asymmetric Cryptography Primitive\r |
7c342378 | 2493 | // =====================================================================================\r |
cc1d13c9 MK |
2494 | \r |
2495 | /**\r | |
2496 | Allocates and initializes one RSA context for subsequent use.\r | |
2497 | \r | |
2498 | @return Pointer to the RSA context that has been initialized.\r | |
2499 | If the allocations fails, RsaNew() returns NULL.\r | |
2500 | \r | |
2501 | **/\r | |
2502 | VOID *\r | |
2503 | EFIAPI\r | |
2504 | CryptoServiceRsaNew (\r | |
2505 | VOID\r | |
2506 | )\r | |
2507 | {\r | |
2508 | return CALL_BASECRYPTLIB (Rsa.Services.New, RsaNew, (), NULL);\r | |
2509 | }\r | |
2510 | \r | |
2511 | /**\r | |
2512 | Release the specified RSA context.\r | |
2513 | \r | |
2514 | If RsaContext is NULL, then return FALSE.\r | |
2515 | \r | |
2516 | @param[in] RsaContext Pointer to the RSA context to be released.\r | |
2517 | \r | |
2518 | **/\r | |
2519 | VOID\r | |
2520 | EFIAPI\r | |
2521 | CryptoServiceRsaFree (\r | |
2522 | IN VOID *RsaContext\r | |
2523 | )\r | |
2524 | {\r | |
2525 | CALL_VOID_BASECRYPTLIB (Rsa.Services.Free, RsaFree, (RsaContext));\r | |
2526 | }\r | |
2527 | \r | |
2528 | /**\r | |
2529 | Sets the tag-designated key component into the established RSA context.\r | |
2530 | \r | |
2531 | This function sets the tag-designated RSA key component into the established\r | |
2532 | RSA context from the user-specified non-negative integer (octet string format\r | |
2533 | represented in RSA PKCS#1).\r | |
2534 | If BigNumber is NULL, then the specified key component in RSA context is cleared.\r | |
2535 | \r | |
2536 | If RsaContext is NULL, then return FALSE.\r | |
2537 | \r | |
2538 | @param[in, out] RsaContext Pointer to RSA context being set.\r | |
2539 | @param[in] KeyTag Tag of RSA key component being set.\r | |
2540 | @param[in] BigNumber Pointer to octet integer buffer.\r | |
2541 | If NULL, then the specified key component in RSA\r | |
2542 | context is cleared.\r | |
2543 | @param[in] BnSize Size of big number buffer in bytes.\r | |
2544 | If BigNumber is NULL, then it is ignored.\r | |
2545 | \r | |
2546 | @retval TRUE RSA key component was set successfully.\r | |
2547 | @retval FALSE Invalid RSA key component tag.\r | |
2548 | \r | |
2549 | **/\r | |
2550 | BOOLEAN\r | |
2551 | EFIAPI\r | |
2552 | CryptoServiceRsaSetKey (\r | |
2553 | IN OUT VOID *RsaContext,\r | |
2554 | IN RSA_KEY_TAG KeyTag,\r | |
2555 | IN CONST UINT8 *BigNumber,\r | |
2556 | IN UINTN BnSize\r | |
2557 | )\r | |
2558 | {\r | |
2559 | return CALL_BASECRYPTLIB (Rsa.Services.SetKey, RsaSetKey, (RsaContext, KeyTag, BigNumber, BnSize), FALSE);\r | |
2560 | }\r | |
2561 | \r | |
2562 | /**\r | |
2563 | Gets the tag-designated RSA key component from the established RSA context.\r | |
2564 | \r | |
2565 | This function retrieves the tag-designated RSA key component from the\r | |
2566 | established RSA context as a non-negative integer (octet string format\r | |
2567 | represented in RSA PKCS#1).\r | |
2568 | If specified key component has not been set or has been cleared, then returned\r | |
2569 | BnSize is set to 0.\r | |
2570 | If the BigNumber buffer is too small to hold the contents of the key, FALSE\r | |
2571 | is returned and BnSize is set to the required buffer size to obtain the key.\r | |
2572 | \r | |
2573 | If RsaContext is NULL, then return FALSE.\r | |
2574 | If BnSize is NULL, then return FALSE.\r | |
2575 | If BnSize is large enough but BigNumber is NULL, then return FALSE.\r | |
2576 | If this interface is not supported, then return FALSE.\r | |
2577 | \r | |
2578 | @param[in, out] RsaContext Pointer to RSA context being set.\r | |
2579 | @param[in] KeyTag Tag of RSA key component being set.\r | |
2580 | @param[out] BigNumber Pointer to octet integer buffer.\r | |
2581 | @param[in, out] BnSize On input, the size of big number buffer in bytes.\r | |
2582 | On output, the size of data returned in big number buffer in bytes.\r | |
2583 | \r | |
2584 | @retval TRUE RSA key component was retrieved successfully.\r | |
2585 | @retval FALSE Invalid RSA key component tag.\r | |
2586 | @retval FALSE BnSize is too small.\r | |
2587 | @retval FALSE This interface is not supported.\r | |
2588 | \r | |
2589 | **/\r | |
2590 | BOOLEAN\r | |
2591 | EFIAPI\r | |
2592 | CryptoServiceRsaGetKey (\r | |
2593 | IN OUT VOID *RsaContext,\r | |
2594 | IN RSA_KEY_TAG KeyTag,\r | |
2595 | OUT UINT8 *BigNumber,\r | |
2596 | IN OUT UINTN *BnSize\r | |
2597 | )\r | |
2598 | {\r | |
2599 | return CALL_BASECRYPTLIB (Rsa.Services.GetKey, RsaGetKey, (RsaContext, KeyTag, BigNumber, BnSize), FALSE);\r | |
2600 | }\r | |
2601 | \r | |
2602 | /**\r | |
2603 | Generates RSA key components.\r | |
2604 | \r | |
2605 | This function generates RSA key components. It takes RSA public exponent E and\r | |
2606 | length in bits of RSA modulus N as input, and generates all key components.\r | |
2607 | If PublicExponent is NULL, the default RSA public exponent (0x10001) will be used.\r | |
2608 | \r | |
2609 | Before this function can be invoked, pseudorandom number generator must be correctly\r | |
2610 | initialized by RandomSeed().\r | |
2611 | \r | |
2612 | If RsaContext is NULL, then return FALSE.\r | |
2613 | If this interface is not supported, then return FALSE.\r | |
2614 | \r | |
2615 | @param[in, out] RsaContext Pointer to RSA context being set.\r | |
2616 | @param[in] ModulusLength Length of RSA modulus N in bits.\r | |
2617 | @param[in] PublicExponent Pointer to RSA public exponent.\r | |
2618 | @param[in] PublicExponentSize Size of RSA public exponent buffer in bytes.\r | |
2619 | \r | |
2620 | @retval TRUE RSA key component was generated successfully.\r | |
2621 | @retval FALSE Invalid RSA key component tag.\r | |
2622 | @retval FALSE This interface is not supported.\r | |
2623 | \r | |
2624 | **/\r | |
2625 | BOOLEAN\r | |
2626 | EFIAPI\r | |
2627 | CryptoServiceRsaGenerateKey (\r | |
2628 | IN OUT VOID *RsaContext,\r | |
2629 | IN UINTN ModulusLength,\r | |
2630 | IN CONST UINT8 *PublicExponent,\r | |
2631 | IN UINTN PublicExponentSize\r | |
2632 | )\r | |
2633 | {\r | |
2634 | return CALL_BASECRYPTLIB (Rsa.Services.GenerateKey, RsaGenerateKey, (RsaContext, ModulusLength, PublicExponent, PublicExponentSize), FALSE);\r | |
2635 | }\r | |
2636 | \r | |
2637 | /**\r | |
2638 | Validates key components of RSA context.\r | |
2639 | NOTE: This function performs integrity checks on all the RSA key material, so\r | |
2640 | the RSA key structure must contain all the private key data.\r | |
2641 | \r | |
2642 | This function validates key components of RSA context in following aspects:\r | |
2643 | - Whether p is a prime\r | |
2644 | - Whether q is a prime\r | |
2645 | - Whether n = p * q\r | |
2646 | - Whether d*e = 1 mod lcm(p-1,q-1)\r | |
2647 | \r | |
2648 | If RsaContext is NULL, then return FALSE.\r | |
2649 | If this interface is not supported, then return FALSE.\r | |
2650 | \r | |
2651 | @param[in] RsaContext Pointer to RSA context to check.\r | |
2652 | \r | |
2653 | @retval TRUE RSA key components are valid.\r | |
2654 | @retval FALSE RSA key components are not valid.\r | |
2655 | @retval FALSE This interface is not supported.\r | |
2656 | \r | |
2657 | **/\r | |
2658 | BOOLEAN\r | |
2659 | EFIAPI\r | |
2660 | CryptoServiceRsaCheckKey (\r | |
2661 | IN VOID *RsaContext\r | |
2662 | )\r | |
2663 | {\r | |
2664 | return CALL_BASECRYPTLIB (Rsa.Services.CheckKey, RsaCheckKey, (RsaContext), FALSE);\r | |
2665 | }\r | |
2666 | \r | |
2667 | /**\r | |
2668 | Carries out the RSA-SSA signature generation with EMSA-PKCS1-v1_5 encoding scheme.\r | |
2669 | \r | |
2670 | This function carries out the RSA-SSA signature generation with EMSA-PKCS1-v1_5 encoding scheme defined in\r | |
2671 | RSA PKCS#1.\r | |
2672 | If the Signature buffer is too small to hold the contents of signature, FALSE\r | |
2673 | is returned and SigSize is set to the required buffer size to obtain the signature.\r | |
2674 | \r | |
2675 | If RsaContext is NULL, then return FALSE.\r | |
2676 | If MessageHash is NULL, then return FALSE.\r | |
2677 | If HashSize is not equal to the size of MD5, SHA-1 or SHA-256 digest, then return FALSE.\r | |
2678 | If SigSize is large enough but Signature is NULL, then return FALSE.\r | |
2679 | If this interface is not supported, then return FALSE.\r | |
2680 | \r | |
2681 | @param[in] RsaContext Pointer to RSA context for signature generation.\r | |
2682 | @param[in] MessageHash Pointer to octet message hash to be signed.\r | |
2683 | @param[in] HashSize Size of the message hash in bytes.\r | |
2684 | @param[out] Signature Pointer to buffer to receive RSA PKCS1-v1_5 signature.\r | |
2685 | @param[in, out] SigSize On input, the size of Signature buffer in bytes.\r | |
2686 | On output, the size of data returned in Signature buffer in bytes.\r | |
2687 | \r | |
2688 | @retval TRUE Signature successfully generated in PKCS1-v1_5.\r | |
2689 | @retval FALSE Signature generation failed.\r | |
2690 | @retval FALSE SigSize is too small.\r | |
2691 | @retval FALSE This interface is not supported.\r | |
2692 | \r | |
2693 | **/\r | |
2694 | BOOLEAN\r | |
2695 | EFIAPI\r | |
2696 | CryptoServiceRsaPkcs1Sign (\r | |
2697 | IN VOID *RsaContext,\r | |
2698 | IN CONST UINT8 *MessageHash,\r | |
2699 | IN UINTN HashSize,\r | |
2700 | OUT UINT8 *Signature,\r | |
2701 | IN OUT UINTN *SigSize\r | |
2702 | )\r | |
2703 | {\r | |
2704 | return CALL_BASECRYPTLIB (Rsa.Services.Pkcs1Sign, RsaPkcs1Sign, (RsaContext, MessageHash, HashSize, Signature, SigSize), FALSE);\r | |
2705 | }\r | |
2706 | \r | |
2707 | /**\r | |
2708 | Verifies the RSA-SSA signature with EMSA-PKCS1-v1_5 encoding scheme defined in\r | |
2709 | RSA PKCS#1.\r | |
2710 | \r | |
2711 | If RsaContext is NULL, then return FALSE.\r | |
2712 | If MessageHash is NULL, then return FALSE.\r | |
2713 | If Signature is NULL, then return FALSE.\r | |
2714 | If HashSize is not equal to the size of MD5, SHA-1, SHA-256 digest, then return FALSE.\r | |
2715 | \r | |
2716 | @param[in] RsaContext Pointer to RSA context for signature verification.\r | |
2717 | @param[in] MessageHash Pointer to octet message hash to be checked.\r | |
2718 | @param[in] HashSize Size of the message hash in bytes.\r | |
2719 | @param[in] Signature Pointer to RSA PKCS1-v1_5 signature to be verified.\r | |
2720 | @param[in] SigSize Size of signature in bytes.\r | |
2721 | \r | |
2722 | @retval TRUE Valid signature encoded in PKCS1-v1_5.\r | |
2723 | @retval FALSE Invalid signature or invalid RSA context.\r | |
2724 | \r | |
2725 | **/\r | |
2726 | BOOLEAN\r | |
2727 | EFIAPI\r | |
2728 | CryptoServiceRsaPkcs1Verify (\r | |
2729 | IN VOID *RsaContext,\r | |
2730 | IN CONST UINT8 *MessageHash,\r | |
2731 | IN UINTN HashSize,\r | |
2732 | IN CONST UINT8 *Signature,\r | |
2733 | IN UINTN SigSize\r | |
2734 | )\r | |
2735 | {\r | |
2736 | return CALL_BASECRYPTLIB (Rsa.Services.Pkcs1Verify, RsaPkcs1Verify, (RsaContext, MessageHash, HashSize, Signature, SigSize), FALSE);\r | |
2737 | }\r | |
2738 | \r | |
2739 | /**\r | |
2740 | Retrieve the RSA Private Key from the password-protected PEM key data.\r | |
2741 | \r | |
2742 | If PemData is NULL, then return FALSE.\r | |
2743 | If RsaContext is NULL, then return FALSE.\r | |
2744 | If this interface is not supported, then return FALSE.\r | |
2745 | \r | |
2746 | @param[in] PemData Pointer to the PEM-encoded key data to be retrieved.\r | |
2747 | @param[in] PemSize Size of the PEM key data in bytes.\r | |
2748 | @param[in] Password NULL-terminated passphrase used for encrypted PEM key data.\r | |
2749 | @param[out] RsaContext Pointer to new-generated RSA context which contain the retrieved\r | |
2750 | RSA private key component. Use RsaFree() function to free the\r | |
2751 | resource.\r | |
2752 | \r | |
2753 | @retval TRUE RSA Private Key was retrieved successfully.\r | |
2754 | @retval FALSE Invalid PEM key data or incorrect password.\r | |
2755 | @retval FALSE This interface is not supported.\r | |
2756 | \r | |
2757 | **/\r | |
2758 | BOOLEAN\r | |
2759 | EFIAPI\r | |
2760 | CryptoServiceRsaGetPrivateKeyFromPem (\r | |
2761 | IN CONST UINT8 *PemData,\r | |
2762 | IN UINTN PemSize,\r | |
2763 | IN CONST CHAR8 *Password,\r | |
2764 | OUT VOID **RsaContext\r | |
2765 | )\r | |
2766 | {\r | |
2767 | return CALL_BASECRYPTLIB (Rsa.Services.GetPrivateKeyFromPem, RsaGetPrivateKeyFromPem, (PemData, PemSize, Password, RsaContext), FALSE);\r | |
2768 | }\r | |
2769 | \r | |
2770 | /**\r | |
2771 | Retrieve the RSA Public Key from one DER-encoded X509 certificate.\r | |
2772 | \r | |
2773 | If Cert is NULL, then return FALSE.\r | |
2774 | If RsaContext is NULL, then return FALSE.\r | |
2775 | If this interface is not supported, then return FALSE.\r | |
2776 | \r | |
2777 | @param[in] Cert Pointer to the DER-encoded X509 certificate.\r | |
2778 | @param[in] CertSize Size of the X509 certificate in bytes.\r | |
2779 | @param[out] RsaContext Pointer to new-generated RSA context which contain the retrieved\r | |
2780 | RSA public key component. Use RsaFree() function to free the\r | |
2781 | resource.\r | |
2782 | \r | |
2783 | @retval TRUE RSA Public Key was retrieved successfully.\r | |
2784 | @retval FALSE Fail to retrieve RSA public key from X509 certificate.\r | |
2785 | @retval FALSE This interface is not supported.\r | |
2786 | \r | |
2787 | **/\r | |
2788 | BOOLEAN\r | |
2789 | EFIAPI\r | |
2790 | CryptoServiceRsaGetPublicKeyFromX509 (\r | |
2791 | IN CONST UINT8 *Cert,\r | |
2792 | IN UINTN CertSize,\r | |
2793 | OUT VOID **RsaContext\r | |
2794 | )\r | |
2795 | {\r | |
2796 | return CALL_BASECRYPTLIB (Rsa.Services.GetPublicKeyFromX509, RsaGetPublicKeyFromX509, (Cert, CertSize, RsaContext), FALSE);\r | |
2797 | }\r | |
2798 | \r | |
2799 | /**\r | |
2800 | Retrieve the subject bytes from one X.509 certificate.\r | |
2801 | \r | |
2802 | If Cert is NULL, then return FALSE.\r | |
2803 | If SubjectSize is NULL, then return FALSE.\r | |
2804 | If this interface is not supported, then return FALSE.\r | |
2805 | \r | |
2806 | @param[in] Cert Pointer to the DER-encoded X509 certificate.\r | |
2807 | @param[in] CertSize Size of the X509 certificate in bytes.\r | |
2808 | @param[out] CertSubject Pointer to the retrieved certificate subject bytes.\r | |
2809 | @param[in, out] SubjectSize The size in bytes of the CertSubject buffer on input,\r | |
2810 | and the size of buffer returned CertSubject on output.\r | |
2811 | \r | |
2812 | @retval TRUE The certificate subject retrieved successfully.\r | |
2813 | @retval FALSE Invalid certificate, or the SubjectSize is too small for the result.\r | |
2814 | The SubjectSize will be updated with the required size.\r | |
2815 | @retval FALSE This interface is not supported.\r | |
2816 | \r | |
2817 | **/\r | |
2818 | BOOLEAN\r | |
2819 | EFIAPI\r | |
2820 | CryptoServiceX509GetSubjectName (\r | |
2821 | IN CONST UINT8 *Cert,\r | |
2822 | IN UINTN CertSize,\r | |
2823 | OUT UINT8 *CertSubject,\r | |
2824 | IN OUT UINTN *SubjectSize\r | |
2825 | )\r | |
2826 | {\r | |
2827 | return CALL_BASECRYPTLIB (X509.Services.GetSubjectName, X509GetSubjectName, (Cert, CertSize, CertSubject, SubjectSize), FALSE);\r | |
2828 | }\r | |
2829 | \r | |
2830 | /**\r | |
2831 | Retrieve the common name (CN) string from one X.509 certificate.\r | |
2832 | \r | |
2833 | @param[in] Cert Pointer to the DER-encoded X509 certificate.\r | |
2834 | @param[in] CertSize Size of the X509 certificate in bytes.\r | |
2835 | @param[out] CommonName Buffer to contain the retrieved certificate common\r | |
2836 | name string (UTF8). At most CommonNameSize bytes will be\r | |
2837 | written and the string will be null terminated. May be\r | |
2838 | NULL in order to determine the size buffer needed.\r | |
2839 | @param[in,out] CommonNameSize The size in bytes of the CommonName buffer on input,\r | |
2840 | and the size of buffer returned CommonName on output.\r | |
2841 | If CommonName is NULL then the amount of space needed\r | |
2842 | in buffer (including the final null) is returned.\r | |
2843 | \r | |
2844 | @retval RETURN_SUCCESS The certificate CommonName retrieved successfully.\r | |
2845 | @retval RETURN_INVALID_PARAMETER If Cert is NULL.\r | |
2846 | If CommonNameSize is NULL.\r | |
2847 | If CommonName is not NULL and *CommonNameSize is 0.\r | |
2848 | If Certificate is invalid.\r | |
2849 | @retval RETURN_NOT_FOUND If no CommonName entry exists.\r | |
2850 | @retval RETURN_BUFFER_TOO_SMALL If the CommonName is NULL. The required buffer size\r | |
2851 | (including the final null) is returned in the\r | |
2852 | CommonNameSize parameter.\r | |
2853 | @retval RETURN_UNSUPPORTED The operation is not supported.\r | |
2854 | \r | |
2855 | **/\r | |
2856 | RETURN_STATUS\r | |
2857 | EFIAPI\r | |
2858 | CryptoServiceX509GetCommonName (\r | |
2859 | IN CONST UINT8 *Cert,\r | |
2860 | IN UINTN CertSize,\r | |
c8f46130 | 2861 | OUT CHAR8 *CommonName OPTIONAL,\r |
cc1d13c9 MK |
2862 | IN OUT UINTN *CommonNameSize\r |
2863 | )\r | |
2864 | {\r | |
2865 | return CALL_BASECRYPTLIB (X509.Services.GetCommonName, X509GetCommonName, (Cert, CertSize, CommonName, CommonNameSize), RETURN_UNSUPPORTED);\r | |
2866 | }\r | |
2867 | \r | |
2868 | /**\r | |
2869 | Retrieve the organization name (O) string from one X.509 certificate.\r | |
2870 | \r | |
2871 | @param[in] Cert Pointer to the DER-encoded X509 certificate.\r | |
2872 | @param[in] CertSize Size of the X509 certificate in bytes.\r | |
2873 | @param[out] NameBuffer Buffer to contain the retrieved certificate organization\r | |
2874 | name string. At most NameBufferSize bytes will be\r | |
2875 | written and the string will be null terminated. May be\r | |
2876 | NULL in order to determine the size buffer needed.\r | |
2877 | @param[in,out] NameBufferSize The size in bytes of the Name buffer on input,\r | |
2878 | and the size of buffer returned Name on output.\r | |
2879 | If NameBuffer is NULL then the amount of space needed\r | |
2880 | in buffer (including the final null) is returned.\r | |
2881 | \r | |
2882 | @retval RETURN_SUCCESS The certificate Organization Name retrieved successfully.\r | |
2883 | @retval RETURN_INVALID_PARAMETER If Cert is NULL.\r | |
2884 | If NameBufferSize is NULL.\r | |
2885 | If NameBuffer is not NULL and *CommonNameSize is 0.\r | |
2886 | If Certificate is invalid.\r | |
2887 | @retval RETURN_NOT_FOUND If no Organization Name entry exists.\r | |
2888 | @retval RETURN_BUFFER_TOO_SMALL If the NameBuffer is NULL. The required buffer size\r | |
2889 | (including the final null) is returned in the\r | |
2890 | CommonNameSize parameter.\r | |
2891 | @retval RETURN_UNSUPPORTED The operation is not supported.\r | |
2892 | \r | |
2893 | **/\r | |
2894 | RETURN_STATUS\r | |
2895 | EFIAPI\r | |
2896 | CryptoServiceX509GetOrganizationName (\r | |
7c342378 MK |
2897 | IN CONST UINT8 *Cert,\r |
2898 | IN UINTN CertSize,\r | |
2899 | OUT CHAR8 *NameBuffer OPTIONAL,\r | |
2900 | IN OUT UINTN *NameBufferSize\r | |
cc1d13c9 MK |
2901 | )\r |
2902 | {\r | |
2903 | return CALL_BASECRYPTLIB (X509.Services.GetOrganizationName, X509GetOrganizationName, (Cert, CertSize, NameBuffer, NameBufferSize), RETURN_UNSUPPORTED);\r | |
2904 | }\r | |
2905 | \r | |
2906 | /**\r | |
2907 | Verify one X509 certificate was issued by the trusted CA.\r | |
2908 | \r | |
2909 | If Cert is NULL, then return FALSE.\r | |
2910 | If CACert is NULL, then return FALSE.\r | |
2911 | If this interface is not supported, then return FALSE.\r | |
2912 | \r | |
2913 | @param[in] Cert Pointer to the DER-encoded X509 certificate to be verified.\r | |
2914 | @param[in] CertSize Size of the X509 certificate in bytes.\r | |
2915 | @param[in] CACert Pointer to the DER-encoded trusted CA certificate.\r | |
2916 | @param[in] CACertSize Size of the CA Certificate in bytes.\r | |
2917 | \r | |
2918 | @retval TRUE The certificate was issued by the trusted CA.\r | |
2919 | @retval FALSE Invalid certificate or the certificate was not issued by the given\r | |
2920 | trusted CA.\r | |
2921 | @retval FALSE This interface is not supported.\r | |
2922 | \r | |
2923 | **/\r | |
2924 | BOOLEAN\r | |
2925 | EFIAPI\r | |
2926 | CryptoServiceX509VerifyCert (\r | |
2927 | IN CONST UINT8 *Cert,\r | |
2928 | IN UINTN CertSize,\r | |
2929 | IN CONST UINT8 *CACert,\r | |
2930 | IN UINTN CACertSize\r | |
2931 | )\r | |
2932 | {\r | |
2933 | return CALL_BASECRYPTLIB (X509.Services.VerifyCert, X509VerifyCert, (Cert, CertSize, CACert, CACertSize), FALSE);\r | |
2934 | }\r | |
2935 | \r | |
2936 | /**\r | |
2937 | Construct a X509 object from DER-encoded certificate data.\r | |
2938 | \r | |
2939 | If Cert is NULL, then return FALSE.\r | |
2940 | If SingleX509Cert is NULL, then return FALSE.\r | |
2941 | If this interface is not supported, then return FALSE.\r | |
2942 | \r | |
2943 | @param[in] Cert Pointer to the DER-encoded certificate data.\r | |
2944 | @param[in] CertSize The size of certificate data in bytes.\r | |
2945 | @param[out] SingleX509Cert The generated X509 object.\r | |
2946 | \r | |
2947 | @retval TRUE The X509 object generation succeeded.\r | |
2948 | @retval FALSE The operation failed.\r | |
2949 | @retval FALSE This interface is not supported.\r | |
2950 | \r | |
2951 | **/\r | |
2952 | BOOLEAN\r | |
2953 | EFIAPI\r | |
2954 | CryptoServiceX509ConstructCertificate (\r | |
2955 | IN CONST UINT8 *Cert,\r | |
2956 | IN UINTN CertSize,\r | |
2957 | OUT UINT8 **SingleX509Cert\r | |
2958 | )\r | |
2959 | {\r | |
2960 | return CALL_BASECRYPTLIB (X509.Services.ConstructCertificate, X509ConstructCertificate, (Cert, CertSize, SingleX509Cert), FALSE);\r | |
2961 | }\r | |
2962 | \r | |
2963 | /**\r | |
2964 | Construct a X509 stack object from a list of DER-encoded certificate data.\r | |
2965 | \r | |
2966 | If X509Stack is NULL, then return FALSE.\r | |
2967 | If this interface is not supported, then return FALSE.\r | |
2968 | \r | |
2969 | @param[in, out] X509Stack On input, pointer to an existing or NULL X509 stack object.\r | |
2970 | On output, pointer to the X509 stack object with new\r | |
2971 | inserted X509 certificate.\r | |
2972 | @param[in] Args VA_LIST marker for the variable argument list.\r | |
2973 | A list of DER-encoded single certificate data followed\r | |
2974 | by certificate size. A NULL terminates the list. The\r | |
2975 | pairs are the arguments to X509ConstructCertificate().\r | |
2976 | \r | |
2977 | @retval TRUE The X509 stack construction succeeded.\r | |
2978 | @retval FALSE The construction operation failed.\r | |
2979 | @retval FALSE This interface is not supported.\r | |
2980 | \r | |
2981 | **/\r | |
2982 | BOOLEAN\r | |
2983 | EFIAPI\r | |
2984 | CryptoServiceX509ConstructCertificateStackV (\r | |
2985 | IN OUT UINT8 **X509Stack,\r | |
2986 | IN VA_LIST Args\r | |
2987 | )\r | |
2988 | {\r | |
2989 | return CALL_BASECRYPTLIB (X509.Services.ConstructCertificateStackV, X509ConstructCertificateStackV, (X509Stack, Args), FALSE);\r | |
2990 | }\r | |
2991 | \r | |
2992 | /**\r | |
2993 | Construct a X509 stack object from a list of DER-encoded certificate data.\r | |
2994 | \r | |
2995 | If X509Stack is NULL, then return FALSE.\r | |
2996 | If this interface is not supported, then return FALSE.\r | |
2997 | \r | |
2998 | @param[in, out] X509Stack On input, pointer to an existing or NULL X509 stack object.\r | |
2999 | On output, pointer to the X509 stack object with new\r | |
3000 | inserted X509 certificate.\r | |
3001 | @param ... A list of DER-encoded single certificate data followed\r | |
3002 | by certificate size. A NULL terminates the list. The\r | |
3003 | pairs are the arguments to X509ConstructCertificate().\r | |
3004 | \r | |
3005 | @retval TRUE The X509 stack construction succeeded.\r | |
3006 | @retval FALSE The construction operation failed.\r | |
3007 | @retval FALSE This interface is not supported.\r | |
3008 | \r | |
3009 | **/\r | |
3010 | BOOLEAN\r | |
3011 | EFIAPI\r | |
3012 | CryptoServiceX509ConstructCertificateStack (\r | |
3013 | IN OUT UINT8 **X509Stack,\r | |
3014 | ...\r | |
3015 | )\r | |
3016 | {\r | |
3017 | VA_LIST Args;\r | |
3018 | BOOLEAN Result;\r | |
3019 | \r | |
3020 | VA_START (Args, X509Stack);\r | |
3021 | Result = CryptoServiceX509ConstructCertificateStackV (X509Stack, Args);\r | |
3022 | VA_END (Args);\r | |
3023 | return Result;\r | |
3024 | }\r | |
3025 | \r | |
3026 | /**\r | |
3027 | Release the specified X509 object.\r | |
3028 | \r | |
3029 | If the interface is not supported, then ASSERT().\r | |
3030 | \r | |
3031 | @param[in] X509Cert Pointer to the X509 object to be released.\r | |
3032 | \r | |
3033 | **/\r | |
3034 | VOID\r | |
3035 | EFIAPI\r | |
3036 | CryptoServiceX509Free (\r | |
3037 | IN VOID *X509Cert\r | |
3038 | )\r | |
3039 | {\r | |
3040 | CALL_VOID_BASECRYPTLIB (X509.Services.Free, X509Free, (X509Cert));\r | |
3041 | }\r | |
3042 | \r | |
3043 | /**\r | |
3044 | Release the specified X509 stack object.\r | |
3045 | \r | |
3046 | If the interface is not supported, then ASSERT().\r | |
3047 | \r | |
3048 | @param[in] X509Stack Pointer to the X509 stack object to be released.\r | |
3049 | \r | |
3050 | **/\r | |
3051 | VOID\r | |
3052 | EFIAPI\r | |
3053 | CryptoServiceX509StackFree (\r | |
3054 | IN VOID *X509Stack\r | |
3055 | )\r | |
3056 | {\r | |
3057 | CALL_VOID_BASECRYPTLIB (X509.Services.StackFree, X509StackFree, (X509Stack));\r | |
3058 | }\r | |
3059 | \r | |
3060 | /**\r | |
3061 | Retrieve the TBSCertificate from one given X.509 certificate.\r | |
3062 | \r | |
3063 | @param[in] Cert Pointer to the given DER-encoded X509 certificate.\r | |
3064 | @param[in] CertSize Size of the X509 certificate in bytes.\r | |
3065 | @param[out] TBSCert DER-Encoded To-Be-Signed certificate.\r | |
3066 | @param[out] TBSCertSize Size of the TBS certificate in bytes.\r | |
3067 | \r | |
3068 | If Cert is NULL, then return FALSE.\r | |
3069 | If TBSCert is NULL, then return FALSE.\r | |
3070 | If TBSCertSize is NULL, then return FALSE.\r | |
3071 | If this interface is not supported, then return FALSE.\r | |
3072 | \r | |
3073 | @retval TRUE The TBSCertificate was retrieved successfully.\r | |
3074 | @retval FALSE Invalid X.509 certificate.\r | |
3075 | \r | |
3076 | **/\r | |
3077 | BOOLEAN\r | |
3078 | EFIAPI\r | |
3079 | CryptoServiceX509GetTBSCert (\r | |
3080 | IN CONST UINT8 *Cert,\r | |
3081 | IN UINTN CertSize,\r | |
3082 | OUT UINT8 **TBSCert,\r | |
3083 | OUT UINTN *TBSCertSize\r | |
3084 | )\r | |
3085 | {\r | |
3086 | return CALL_BASECRYPTLIB (X509.Services.GetTBSCert, X509GetTBSCert, (Cert, CertSize, TBSCert, TBSCertSize), FALSE);\r | |
3087 | }\r | |
3088 | \r | |
3089 | /**\r | |
3090 | Derives a key from a password using a salt and iteration count, based on PKCS#5 v2.0\r | |
3091 | password based encryption key derivation function PBKDF2, as specified in RFC 2898.\r | |
3092 | \r | |
3093 | If Password or Salt or OutKey is NULL, then return FALSE.\r | |
3094 | If the hash algorithm could not be determined, then return FALSE.\r | |
3095 | If this interface is not supported, then return FALSE.\r | |
3096 | \r | |
3097 | @param[in] PasswordLength Length of input password in bytes.\r | |
3098 | @param[in] Password Pointer to the array for the password.\r | |
3099 | @param[in] SaltLength Size of the Salt in bytes.\r | |
3100 | @param[in] Salt Pointer to the Salt.\r | |
3101 | @param[in] IterationCount Number of iterations to perform. Its value should be\r | |
3102 | greater than or equal to 1.\r | |
3103 | @param[in] DigestSize Size of the message digest to be used (eg. SHA256_DIGEST_SIZE).\r | |
3104 | NOTE: DigestSize will be used to determine the hash algorithm.\r | |
3105 | Only SHA1_DIGEST_SIZE or SHA256_DIGEST_SIZE is supported.\r | |
3106 | @param[in] KeyLength Size of the derived key buffer in bytes.\r | |
3107 | @param[out] OutKey Pointer to the output derived key buffer.\r | |
3108 | \r | |
3109 | @retval TRUE A key was derived successfully.\r | |
3110 | @retval FALSE One of the pointers was NULL or one of the sizes was too large.\r | |
3111 | @retval FALSE The hash algorithm could not be determined from the digest size.\r | |
3112 | @retval FALSE The key derivation operation failed.\r | |
3113 | @retval FALSE This interface is not supported.\r | |
3114 | \r | |
3115 | **/\r | |
3116 | BOOLEAN\r | |
3117 | EFIAPI\r | |
3118 | CryptoServicePkcs5HashPassword (\r | |
3119 | IN UINTN PasswordLength,\r | |
3120 | IN CONST CHAR8 *Password,\r | |
3121 | IN UINTN SaltLength,\r | |
3122 | IN CONST UINT8 *Salt,\r | |
3123 | IN UINTN IterationCount,\r | |
3124 | IN UINTN DigestSize,\r | |
3125 | IN UINTN KeyLength,\r | |
3126 | OUT UINT8 *OutKey\r | |
3127 | )\r | |
3128 | {\r | |
3129 | return CALL_BASECRYPTLIB (Pkcs.Services.Pkcs5HashPassword, Pkcs5HashPassword, (PasswordLength, Password, SaltLength, Salt, IterationCount, DigestSize, KeyLength, OutKey), FALSE);\r | |
3130 | }\r | |
3131 | \r | |
3132 | /**\r | |
3133 | Encrypts a blob using PKCS1v2 (RSAES-OAEP) schema. On success, will return the\r | |
3134 | encrypted message in a newly allocated buffer.\r | |
3135 | \r | |
3136 | Things that can cause a failure include:\r | |
3137 | - X509 key size does not match any known key size.\r | |
3138 | - Fail to parse X509 certificate.\r | |
3139 | - Fail to allocate an intermediate buffer.\r | |
3140 | - Null pointer provided for a non-optional parameter.\r | |
3141 | - Data size is too large for the provided key size (max size is a function of key size\r | |
3142 | and hash digest size).\r | |
3143 | \r | |
3144 | @param[in] PublicKey A pointer to the DER-encoded X509 certificate that\r | |
3145 | will be used to encrypt the data.\r | |
3146 | @param[in] PublicKeySize Size of the X509 cert buffer.\r | |
3147 | @param[in] InData Data to be encrypted.\r | |
3148 | @param[in] InDataSize Size of the data buffer.\r | |
3149 | @param[in] PrngSeed [Optional] If provided, a pointer to a random seed buffer\r | |
3150 | to be used when initializing the PRNG. NULL otherwise.\r | |
3151 | @param[in] PrngSeedSize [Optional] If provided, size of the random seed buffer.\r | |
3152 | 0 otherwise.\r | |
3153 | @param[out] EncryptedData Pointer to an allocated buffer containing the encrypted\r | |
3154 | message.\r | |
3155 | @param[out] EncryptedDataSize Size of the encrypted message buffer.\r | |
3156 | \r | |
3157 | @retval TRUE Encryption was successful.\r | |
3158 | @retval FALSE Encryption failed.\r | |
3159 | \r | |
3160 | **/\r | |
3161 | BOOLEAN\r | |
3162 | EFIAPI\r | |
3163 | CryptoServicePkcs1v2Encrypt (\r | |
3164 | IN CONST UINT8 *PublicKey,\r | |
3165 | IN UINTN PublicKeySize,\r | |
3166 | IN UINT8 *InData,\r | |
3167 | IN UINTN InDataSize,\r | |
c8f46130 MK |
3168 | IN CONST UINT8 *PrngSeed OPTIONAL,\r |
3169 | IN UINTN PrngSeedSize OPTIONAL,\r | |
cc1d13c9 MK |
3170 | OUT UINT8 **EncryptedData,\r |
3171 | OUT UINTN *EncryptedDataSize\r | |
3172 | )\r | |
3173 | {\r | |
3174 | return CALL_BASECRYPTLIB (Pkcs.Services.Pkcs1v2Encrypt, Pkcs1v2Encrypt, (PublicKey, PublicKeySize, InData, InDataSize, PrngSeed, PrngSeedSize, EncryptedData, EncryptedDataSize), FALSE);\r | |
3175 | }\r | |
3176 | \r | |
3177 | /**\r | |
3178 | Get the signer's certificates from PKCS#7 signed data as described in "PKCS #7:\r | |
3179 | Cryptographic Message Syntax Standard". The input signed data could be wrapped\r | |
3180 | in a ContentInfo structure.\r | |
3181 | \r | |
3182 | If P7Data, CertStack, StackLength, TrustedCert or CertLength is NULL, then\r | |
3183 | return FALSE. If P7Length overflow, then return FALSE.\r | |
3184 | If this interface is not supported, then return FALSE.\r | |
3185 | \r | |
3186 | @param[in] P7Data Pointer to the PKCS#7 message to verify.\r | |
3187 | @param[in] P7Length Length of the PKCS#7 message in bytes.\r | |
3188 | @param[out] CertStack Pointer to Signer's certificates retrieved from P7Data.\r | |
3189 | It's caller's responsibility to free the buffer with\r | |
3190 | Pkcs7FreeSigners().\r | |
3191 | This data structure is EFI_CERT_STACK type.\r | |
3192 | @param[out] StackLength Length of signer's certificates in bytes.\r | |
3193 | @param[out] TrustedCert Pointer to a trusted certificate from Signer's certificates.\r | |
3194 | It's caller's responsibility to free the buffer with\r | |
3195 | Pkcs7FreeSigners().\r | |
3196 | @param[out] CertLength Length of the trusted certificate in bytes.\r | |
3197 | \r | |
3198 | @retval TRUE The operation is finished successfully.\r | |
3199 | @retval FALSE Error occurs during the operation.\r | |
3200 | @retval FALSE This interface is not supported.\r | |
3201 | \r | |
3202 | **/\r | |
3203 | BOOLEAN\r | |
3204 | EFIAPI\r | |
3205 | CryptoServicePkcs7GetSigners (\r | |
3206 | IN CONST UINT8 *P7Data,\r | |
3207 | IN UINTN P7Length,\r | |
3208 | OUT UINT8 **CertStack,\r | |
3209 | OUT UINTN *StackLength,\r | |
3210 | OUT UINT8 **TrustedCert,\r | |
3211 | OUT UINTN *CertLength\r | |
3212 | )\r | |
3213 | {\r | |
3214 | return CALL_BASECRYPTLIB (Pkcs.Services.Pkcs7GetSigners, Pkcs7GetSigners, (P7Data, P7Length, CertStack, StackLength, TrustedCert, CertLength), FALSE);\r | |
3215 | }\r | |
3216 | \r | |
3217 | /**\r | |
3218 | Wrap function to use free() to free allocated memory for certificates.\r | |
3219 | \r | |
3220 | If this interface is not supported, then ASSERT().\r | |
3221 | \r | |
3222 | @param[in] Certs Pointer to the certificates to be freed.\r | |
3223 | \r | |
3224 | **/\r | |
3225 | VOID\r | |
3226 | EFIAPI\r | |
3227 | CryptoServicePkcs7FreeSigners (\r | |
7c342378 | 3228 | IN UINT8 *Certs\r |
cc1d13c9 MK |
3229 | )\r |
3230 | {\r | |
3231 | CALL_VOID_BASECRYPTLIB (Pkcs.Services.Pkcs7FreeSigners, Pkcs7FreeSigners, (Certs));\r | |
3232 | }\r | |
3233 | \r | |
3234 | /**\r | |
3235 | Retrieves all embedded certificates from PKCS#7 signed data as described in "PKCS #7:\r | |
3236 | Cryptographic Message Syntax Standard", and outputs two certificate lists chained and\r | |
3237 | unchained to the signer's certificates.\r | |
3238 | The input signed data could be wrapped in a ContentInfo structure.\r | |
3239 | \r | |
3240 | @param[in] P7Data Pointer to the PKCS#7 message.\r | |
3241 | @param[in] P7Length Length of the PKCS#7 message in bytes.\r | |
3242 | @param[out] SignerChainCerts Pointer to the certificates list chained to signer's\r | |
3243 | certificate. It's caller's responsibility to free the buffer\r | |
3244 | with Pkcs7FreeSigners().\r | |
3245 | This data structure is EFI_CERT_STACK type.\r | |
3246 | @param[out] ChainLength Length of the chained certificates list buffer in bytes.\r | |
3247 | @param[out] UnchainCerts Pointer to the unchained certificates lists. It's caller's\r | |
3248 | responsibility to free the buffer with Pkcs7FreeSigners().\r | |
3249 | This data structure is EFI_CERT_STACK type.\r | |
3250 | @param[out] UnchainLength Length of the unchained certificates list buffer in bytes.\r | |
3251 | \r | |
3252 | @retval TRUE The operation is finished successfully.\r | |
3253 | @retval FALSE Error occurs during the operation.\r | |
3254 | \r | |
3255 | **/\r | |
3256 | BOOLEAN\r | |
3257 | EFIAPI\r | |
3258 | CryptoServicePkcs7GetCertificatesList (\r | |
3259 | IN CONST UINT8 *P7Data,\r | |
3260 | IN UINTN P7Length,\r | |
3261 | OUT UINT8 **SignerChainCerts,\r | |
3262 | OUT UINTN *ChainLength,\r | |
3263 | OUT UINT8 **UnchainCerts,\r | |
3264 | OUT UINTN *UnchainLength\r | |
3265 | )\r | |
3266 | {\r | |
3267 | return CALL_BASECRYPTLIB (Pkcs.Services.Pkcs7GetCertificatesList, Pkcs7GetCertificatesList, (P7Data, P7Length, SignerChainCerts, ChainLength, UnchainCerts, UnchainLength), FALSE);\r | |
3268 | }\r | |
3269 | \r | |
3270 | /**\r | |
3271 | Creates a PKCS#7 signedData as described in "PKCS #7: Cryptographic Message\r | |
3272 | Syntax Standard, version 1.5". This interface is only intended to be used for\r | |
3273 | application to perform PKCS#7 functionality validation.\r | |
3274 | \r | |
3275 | If this interface is not supported, then return FALSE.\r | |
3276 | \r | |
3277 | @param[in] PrivateKey Pointer to the PEM-formatted private key data for\r | |
3278 | data signing.\r | |
3279 | @param[in] PrivateKeySize Size of the PEM private key data in bytes.\r | |
3280 | @param[in] KeyPassword NULL-terminated passphrase used for encrypted PEM\r | |
3281 | key data.\r | |
3282 | @param[in] InData Pointer to the content to be signed.\r | |
3283 | @param[in] InDataSize Size of InData in bytes.\r | |
3284 | @param[in] SignCert Pointer to signer's DER-encoded certificate to sign with.\r | |
3285 | @param[in] OtherCerts Pointer to an optional additional set of certificates to\r | |
3286 | include in the PKCS#7 signedData (e.g. any intermediate\r | |
3287 | CAs in the chain).\r | |
3288 | @param[out] SignedData Pointer to output PKCS#7 signedData. It's caller's\r | |
3289 | responsibility to free the buffer with FreePool().\r | |
3290 | @param[out] SignedDataSize Size of SignedData in bytes.\r | |
3291 | \r | |
3292 | @retval TRUE PKCS#7 data signing succeeded.\r | |
3293 | @retval FALSE PKCS#7 data signing failed.\r | |
3294 | @retval FALSE This interface is not supported.\r | |
3295 | \r | |
3296 | **/\r | |
3297 | BOOLEAN\r | |
3298 | EFIAPI\r | |
3299 | CryptoServicePkcs7Sign (\r | |
3300 | IN CONST UINT8 *PrivateKey,\r | |
3301 | IN UINTN PrivateKeySize,\r | |
3302 | IN CONST UINT8 *KeyPassword,\r | |
3303 | IN UINT8 *InData,\r | |
3304 | IN UINTN InDataSize,\r | |
3305 | IN UINT8 *SignCert,\r | |
3306 | IN UINT8 *OtherCerts OPTIONAL,\r | |
3307 | OUT UINT8 **SignedData,\r | |
3308 | OUT UINTN *SignedDataSize\r | |
3309 | )\r | |
3310 | {\r | |
3311 | return CALL_BASECRYPTLIB (Pkcs.Services.Pkcs7Sign, Pkcs7Sign, (PrivateKey, PrivateKeySize, KeyPassword, InData, InDataSize, SignCert, OtherCerts, SignedData, SignedDataSize), FALSE);\r | |
3312 | }\r | |
3313 | \r | |
3314 | /**\r | |
3315 | Verifies the validity of a PKCS#7 signed data as described in "PKCS #7:\r | |
3316 | Cryptographic Message Syntax Standard". The input signed data could be wrapped\r | |
3317 | in a ContentInfo structure.\r | |
3318 | \r | |
3319 | If P7Data, TrustedCert or InData is NULL, then return FALSE.\r | |
3320 | If P7Length, CertLength or DataLength overflow, then return FALSE.\r | |
3321 | If this interface is not supported, then return FALSE.\r | |
3322 | \r | |
3323 | @param[in] P7Data Pointer to the PKCS#7 message to verify.\r | |
3324 | @param[in] P7Length Length of the PKCS#7 message in bytes.\r | |
3325 | @param[in] TrustedCert Pointer to a trusted/root certificate encoded in DER, which\r | |
3326 | is used for certificate chain verification.\r | |
3327 | @param[in] CertLength Length of the trusted certificate in bytes.\r | |
3328 | @param[in] InData Pointer to the content to be verified.\r | |
3329 | @param[in] DataLength Length of InData in bytes.\r | |
3330 | \r | |
3331 | @retval TRUE The specified PKCS#7 signed data is valid.\r | |
3332 | @retval FALSE Invalid PKCS#7 signed data.\r | |
3333 | @retval FALSE This interface is not supported.\r | |
3334 | \r | |
3335 | **/\r | |
3336 | BOOLEAN\r | |
3337 | EFIAPI\r | |
3338 | CryptoServicePkcs7Verify (\r | |
3339 | IN CONST UINT8 *P7Data,\r | |
3340 | IN UINTN P7Length,\r | |
3341 | IN CONST UINT8 *TrustedCert,\r | |
3342 | IN UINTN CertLength,\r | |
3343 | IN CONST UINT8 *InData,\r | |
3344 | IN UINTN DataLength\r | |
3345 | )\r | |
3346 | {\r | |
3347 | return CALL_BASECRYPTLIB (Pkcs.Services.Pkcs7Verify, Pkcs7Verify, (P7Data, P7Length, TrustedCert, CertLength, InData, DataLength), FALSE);\r | |
3348 | }\r | |
3349 | \r | |
3350 | /**\r | |
3351 | This function receives a PKCS7 formatted signature, and then verifies that\r | |
3352 | the specified Enhanced or Extended Key Usages (EKU's) are present in the end-entity\r | |
3353 | leaf signing certificate.\r | |
3354 | Note that this function does not validate the certificate chain.\r | |
3355 | \r | |
3356 | Applications for custom EKU's are quite flexible. For example, a policy EKU\r | |
3357 | may be present in an Issuing Certificate Authority (CA), and any sub-ordinate\r | |
3358 | certificate issued might also contain this EKU, thus constraining the\r | |
3359 | sub-ordinate certificate. Other applications might allow a certificate\r | |
3360 | embedded in a device to specify that other Object Identifiers (OIDs) are\r | |
3361 | present which contains binary data specifying custom capabilities that\r | |
3362 | the device is able to do.\r | |
3363 | \r | |
3364 | @param[in] Pkcs7Signature The PKCS#7 signed information content block. An array\r | |
3365 | containing the content block with both the signature,\r | |
3366 | the signer's certificate, and any necessary intermediate\r | |
3367 | certificates.\r | |
3368 | @param[in] Pkcs7SignatureSize Number of bytes in Pkcs7Signature.\r | |
3369 | @param[in] RequiredEKUs Array of null-terminated strings listing OIDs of\r | |
3370 | required EKUs that must be present in the signature.\r | |
3371 | @param[in] RequiredEKUsSize Number of elements in the RequiredEKUs string array.\r | |
3372 | @param[in] RequireAllPresent If this is TRUE, then all of the specified EKU's\r | |
3373 | must be present in the leaf signer. If it is\r | |
3374 | FALSE, then we will succeed if we find any\r | |
3375 | of the specified EKU's.\r | |
3376 | \r | |
3377 | @retval EFI_SUCCESS The required EKUs were found in the signature.\r | |
3378 | @retval EFI_INVALID_PARAMETER A parameter was invalid.\r | |
3379 | @retval EFI_NOT_FOUND One or more EKU's were not found in the signature.\r | |
3380 | \r | |
3381 | **/\r | |
3382 | RETURN_STATUS\r | |
3383 | EFIAPI\r | |
3384 | CryptoServiceVerifyEKUsInPkcs7Signature (\r | |
3385 | IN CONST UINT8 *Pkcs7Signature,\r | |
3386 | IN CONST UINT32 SignatureSize,\r | |
3387 | IN CONST CHAR8 *RequiredEKUs[],\r | |
3388 | IN CONST UINT32 RequiredEKUsSize,\r | |
3389 | IN BOOLEAN RequireAllPresent\r | |
3390 | )\r | |
3391 | {\r | |
3392 | return CALL_BASECRYPTLIB (Pkcs.Services.VerifyEKUsInPkcs7Signature, VerifyEKUsInPkcs7Signature, (Pkcs7Signature, SignatureSize, RequiredEKUs, RequiredEKUsSize, RequireAllPresent), FALSE);\r | |
3393 | }\r | |
3394 | \r | |
cc1d13c9 MK |
3395 | /**\r |
3396 | Extracts the attached content from a PKCS#7 signed data if existed. The input signed\r | |
3397 | data could be wrapped in a ContentInfo structure.\r | |
3398 | \r | |
3399 | If P7Data, Content, or ContentSize is NULL, then return FALSE. If P7Length overflow,\r | |
3400 | then return FALSE. If the P7Data is not correctly formatted, then return FALSE.\r | |
3401 | \r | |
3402 | Caution: This function may receive untrusted input. So this function will do\r | |
3403 | basic check for PKCS#7 data structure.\r | |
3404 | \r | |
3405 | @param[in] P7Data Pointer to the PKCS#7 signed data to process.\r | |
3406 | @param[in] P7Length Length of the PKCS#7 signed data in bytes.\r | |
3407 | @param[out] Content Pointer to the extracted content from the PKCS#7 signedData.\r | |
3408 | It's caller's responsibility to free the buffer with FreePool().\r | |
3409 | @param[out] ContentSize The size of the extracted content in bytes.\r | |
3410 | \r | |
3411 | @retval TRUE The P7Data was correctly formatted for processing.\r | |
3412 | @retval FALSE The P7Data was not correctly formatted for processing.\r | |
3413 | \r | |
3414 | **/\r | |
3415 | BOOLEAN\r | |
3416 | EFIAPI\r | |
3417 | CryptoServicePkcs7GetAttachedContent (\r | |
3418 | IN CONST UINT8 *P7Data,\r | |
3419 | IN UINTN P7Length,\r | |
3420 | OUT VOID **Content,\r | |
3421 | OUT UINTN *ContentSize\r | |
3422 | )\r | |
3423 | {\r | |
3424 | return CALL_BASECRYPTLIB (Pkcs.Services.Pkcs7GetAttachedContent, Pkcs7GetAttachedContent, (P7Data, P7Length, Content, ContentSize), FALSE);\r | |
3425 | }\r | |
3426 | \r | |
3427 | /**\r | |
3428 | Verifies the validity of a PE/COFF Authenticode Signature as described in "Windows\r | |
3429 | Authenticode Portable Executable Signature Format".\r | |
3430 | \r | |
3431 | If AuthData is NULL, then return FALSE.\r | |
3432 | If ImageHash is NULL, then return FALSE.\r | |
3433 | If this interface is not supported, then return FALSE.\r | |
3434 | \r | |
3435 | @param[in] AuthData Pointer to the Authenticode Signature retrieved from signed\r | |
3436 | PE/COFF image to be verified.\r | |
3437 | @param[in] DataSize Size of the Authenticode Signature in bytes.\r | |
3438 | @param[in] TrustedCert Pointer to a trusted/root certificate encoded in DER, which\r | |
3439 | is used for certificate chain verification.\r | |
3440 | @param[in] CertSize Size of the trusted certificate in bytes.\r | |
3441 | @param[in] ImageHash Pointer to the original image file hash value. The procedure\r | |
3442 | for calculating the image hash value is described in Authenticode\r | |
3443 | specification.\r | |
3444 | @param[in] HashSize Size of Image hash value in bytes.\r | |
3445 | \r | |
3446 | @retval TRUE The specified Authenticode Signature is valid.\r | |
3447 | @retval FALSE Invalid Authenticode Signature.\r | |
3448 | @retval FALSE This interface is not supported.\r | |
3449 | \r | |
3450 | **/\r | |
3451 | BOOLEAN\r | |
3452 | EFIAPI\r | |
3453 | CryptoServiceAuthenticodeVerify (\r | |
3454 | IN CONST UINT8 *AuthData,\r | |
3455 | IN UINTN DataSize,\r | |
3456 | IN CONST UINT8 *TrustedCert,\r | |
3457 | IN UINTN CertSize,\r | |
3458 | IN CONST UINT8 *ImageHash,\r | |
3459 | IN UINTN HashSize\r | |
3460 | )\r | |
3461 | {\r | |
3462 | return CALL_BASECRYPTLIB (Pkcs.Services.AuthenticodeVerify, AuthenticodeVerify, (AuthData, DataSize, TrustedCert, CertSize, ImageHash, HashSize), FALSE);\r | |
3463 | }\r | |
3464 | \r | |
3465 | /**\r | |
3466 | Verifies the validity of a RFC3161 Timestamp CounterSignature embedded in PE/COFF Authenticode\r | |
3467 | signature.\r | |
3468 | \r | |
3469 | If AuthData is NULL, then return FALSE.\r | |
3470 | If this interface is not supported, then return FALSE.\r | |
3471 | \r | |
3472 | @param[in] AuthData Pointer to the Authenticode Signature retrieved from signed\r | |
3473 | PE/COFF image to be verified.\r | |
3474 | @param[in] DataSize Size of the Authenticode Signature in bytes.\r | |
3475 | @param[in] TsaCert Pointer to a trusted/root TSA certificate encoded in DER, which\r | |
3476 | is used for TSA certificate chain verification.\r | |
3477 | @param[in] CertSize Size of the trusted certificate in bytes.\r | |
3478 | @param[out] SigningTime Return the time of timestamp generation time if the timestamp\r | |
3479 | signature is valid.\r | |
3480 | \r | |
3481 | @retval TRUE The specified Authenticode includes a valid RFC3161 Timestamp CounterSignature.\r | |
3482 | @retval FALSE No valid RFC3161 Timestamp CounterSignature in the specified Authenticode data.\r | |
3483 | \r | |
3484 | **/\r | |
3485 | BOOLEAN\r | |
3486 | EFIAPI\r | |
3487 | CryptoServiceImageTimestampVerify (\r | |
3488 | IN CONST UINT8 *AuthData,\r | |
3489 | IN UINTN DataSize,\r | |
3490 | IN CONST UINT8 *TsaCert,\r | |
3491 | IN UINTN CertSize,\r | |
3492 | OUT EFI_TIME *SigningTime\r | |
3493 | )\r | |
3494 | {\r | |
3495 | return CALL_BASECRYPTLIB (Pkcs.Services.ImageTimestampVerify, ImageTimestampVerify, (AuthData, DataSize, TsaCert, CertSize, SigningTime), FALSE);\r | |
3496 | }\r | |
3497 | \r | |
7c342378 | 3498 | // =====================================================================================\r |
cc1d13c9 | 3499 | // DH Key Exchange Primitive\r |
7c342378 | 3500 | // =====================================================================================\r |
cc1d13c9 MK |
3501 | \r |
3502 | /**\r | |
3503 | Allocates and Initializes one Diffie-Hellman Context for subsequent use.\r | |
3504 | \r | |
3505 | @return Pointer to the Diffie-Hellman Context that has been initialized.\r | |
3506 | If the allocations fails, DhNew() returns NULL.\r | |
3507 | If the interface is not supported, DhNew() returns NULL.\r | |
3508 | \r | |
3509 | **/\r | |
3510 | VOID *\r | |
3511 | EFIAPI\r | |
3512 | CryptoServiceDhNew (\r | |
3513 | VOID\r | |
3514 | )\r | |
3515 | {\r | |
3516 | return CALL_BASECRYPTLIB (Dh.Services.New, DhNew, (), NULL);\r | |
3517 | }\r | |
3518 | \r | |
3519 | /**\r | |
3520 | Release the specified DH context.\r | |
3521 | \r | |
3522 | If the interface is not supported, then ASSERT().\r | |
3523 | \r | |
3524 | @param[in] DhContext Pointer to the DH context to be released.\r | |
3525 | \r | |
3526 | **/\r | |
3527 | VOID\r | |
3528 | EFIAPI\r | |
3529 | CryptoServiceDhFree (\r | |
3530 | IN VOID *DhContext\r | |
3531 | )\r | |
3532 | {\r | |
3533 | CALL_VOID_BASECRYPTLIB (Dh.Services.Free, DhFree, (DhContext));\r | |
3534 | }\r | |
3535 | \r | |
3536 | /**\r | |
3537 | Generates DH parameter.\r | |
3538 | \r | |
3539 | Given generator g, and length of prime number p in bits, this function generates p,\r | |
3540 | and sets DH context according to value of g and p.\r | |
3541 | \r | |
3542 | Before this function can be invoked, pseudorandom number generator must be correctly\r | |
3543 | initialized by RandomSeed().\r | |
3544 | \r | |
3545 | If DhContext is NULL, then return FALSE.\r | |
3546 | If Prime is NULL, then return FALSE.\r | |
3547 | If this interface is not supported, then return FALSE.\r | |
3548 | \r | |
3549 | @param[in, out] DhContext Pointer to the DH context.\r | |
3550 | @param[in] Generator Value of generator.\r | |
3551 | @param[in] PrimeLength Length in bits of prime to be generated.\r | |
3552 | @param[out] Prime Pointer to the buffer to receive the generated prime number.\r | |
3553 | \r | |
3554 | @retval TRUE DH parameter generation succeeded.\r | |
3555 | @retval FALSE Value of Generator is not supported.\r | |
3556 | @retval FALSE PRNG fails to generate random prime number with PrimeLength.\r | |
3557 | @retval FALSE This interface is not supported.\r | |
3558 | \r | |
3559 | **/\r | |
3560 | BOOLEAN\r | |
3561 | EFIAPI\r | |
3562 | CryptoServiceDhGenerateParameter (\r | |
3563 | IN OUT VOID *DhContext,\r | |
3564 | IN UINTN Generator,\r | |
3565 | IN UINTN PrimeLength,\r | |
3566 | OUT UINT8 *Prime\r | |
3567 | )\r | |
3568 | {\r | |
3569 | return CALL_BASECRYPTLIB (Dh.Services.GenerateParameter, DhGenerateParameter, (DhContext, Generator, PrimeLength, Prime), FALSE);\r | |
3570 | }\r | |
3571 | \r | |
3572 | /**\r | |
3573 | Sets generator and prime parameters for DH.\r | |
3574 | \r | |
3575 | Given generator g, and prime number p, this function and sets DH\r | |
3576 | context accordingly.\r | |
3577 | \r | |
3578 | If DhContext is NULL, then return FALSE.\r | |
3579 | If Prime is NULL, then return FALSE.\r | |
3580 | If this interface is not supported, then return FALSE.\r | |
3581 | \r | |
3582 | @param[in, out] DhContext Pointer to the DH context.\r | |
3583 | @param[in] Generator Value of generator.\r | |
3584 | @param[in] PrimeLength Length in bits of prime to be generated.\r | |
3585 | @param[in] Prime Pointer to the prime number.\r | |
3586 | \r | |
3587 | @retval TRUE DH parameter setting succeeded.\r | |
3588 | @retval FALSE Value of Generator is not supported.\r | |
3589 | @retval FALSE Value of Generator is not suitable for the Prime.\r | |
3590 | @retval FALSE Value of Prime is not a prime number.\r | |
3591 | @retval FALSE Value of Prime is not a safe prime number.\r | |
3592 | @retval FALSE This interface is not supported.\r | |
3593 | \r | |
3594 | **/\r | |
3595 | BOOLEAN\r | |
3596 | EFIAPI\r | |
3597 | CryptoServiceDhSetParameter (\r | |
3598 | IN OUT VOID *DhContext,\r | |
3599 | IN UINTN Generator,\r | |
3600 | IN UINTN PrimeLength,\r | |
3601 | IN CONST UINT8 *Prime\r | |
3602 | )\r | |
3603 | {\r | |
3604 | return CALL_BASECRYPTLIB (Dh.Services.SetParameter, DhSetParameter, (DhContext, Generator, PrimeLength, Prime), FALSE);\r | |
3605 | }\r | |
3606 | \r | |
3607 | /**\r | |
3608 | Generates DH public key.\r | |
3609 | \r | |
3610 | This function generates random secret exponent, and computes the public key, which is\r | |
3611 | returned via parameter PublicKey and PublicKeySize. DH context is updated accordingly.\r | |
3612 | If the PublicKey buffer is too small to hold the public key, FALSE is returned and\r | |
3613 | PublicKeySize is set to the required buffer size to obtain the public key.\r | |
3614 | \r | |
3615 | If DhContext is NULL, then return FALSE.\r | |
3616 | If PublicKeySize is NULL, then return FALSE.\r | |
3617 | If PublicKeySize is large enough but PublicKey is NULL, then return FALSE.\r | |
3618 | If this interface is not supported, then return FALSE.\r | |
3619 | \r | |
3620 | @param[in, out] DhContext Pointer to the DH context.\r | |
3621 | @param[out] PublicKey Pointer to the buffer to receive generated public key.\r | |
3622 | @param[in, out] PublicKeySize On input, the size of PublicKey buffer in bytes.\r | |
3623 | On output, the size of data returned in PublicKey buffer in bytes.\r | |
3624 | \r | |
3625 | @retval TRUE DH public key generation succeeded.\r | |
3626 | @retval FALSE DH public key generation failed.\r | |
3627 | @retval FALSE PublicKeySize is not large enough.\r | |
3628 | @retval FALSE This interface is not supported.\r | |
3629 | \r | |
3630 | **/\r | |
3631 | BOOLEAN\r | |
3632 | EFIAPI\r | |
3633 | CryptoServiceDhGenerateKey (\r | |
3634 | IN OUT VOID *DhContext,\r | |
3635 | OUT UINT8 *PublicKey,\r | |
3636 | IN OUT UINTN *PublicKeySize\r | |
3637 | )\r | |
3638 | {\r | |
3639 | return CALL_BASECRYPTLIB (Dh.Services.GenerateKey, DhGenerateKey, (DhContext, PublicKey, PublicKeySize), FALSE);\r | |
3640 | }\r | |
3641 | \r | |
3642 | /**\r | |
3643 | Computes exchanged common key.\r | |
3644 | \r | |
3645 | Given peer's public key, this function computes the exchanged common key, based on its own\r | |
3646 | context including value of prime modulus and random secret exponent.\r | |
3647 | \r | |
3648 | If DhContext is NULL, then return FALSE.\r | |
3649 | If PeerPublicKey is NULL, then return FALSE.\r | |
3650 | If KeySize is NULL, then return FALSE.\r | |
3651 | If Key is NULL, then return FALSE.\r | |
3652 | If KeySize is not large enough, then return FALSE.\r | |
3653 | If this interface is not supported, then return FALSE.\r | |
3654 | \r | |
3655 | @param[in, out] DhContext Pointer to the DH context.\r | |
3656 | @param[in] PeerPublicKey Pointer to the peer's public key.\r | |
3657 | @param[in] PeerPublicKeySize Size of peer's public key in bytes.\r | |
3658 | @param[out] Key Pointer to the buffer to receive generated key.\r | |
3659 | @param[in, out] KeySize On input, the size of Key buffer in bytes.\r | |
3660 | On output, the size of data returned in Key buffer in bytes.\r | |
3661 | \r | |
3662 | @retval TRUE DH exchanged key generation succeeded.\r | |
3663 | @retval FALSE DH exchanged key generation failed.\r | |
3664 | @retval FALSE KeySize is not large enough.\r | |
3665 | @retval FALSE This interface is not supported.\r | |
3666 | \r | |
3667 | **/\r | |
3668 | BOOLEAN\r | |
3669 | EFIAPI\r | |
3670 | CryptoServiceDhComputeKey (\r | |
3671 | IN OUT VOID *DhContext,\r | |
3672 | IN CONST UINT8 *PeerPublicKey,\r | |
3673 | IN UINTN PeerPublicKeySize,\r | |
3674 | OUT UINT8 *Key,\r | |
3675 | IN OUT UINTN *KeySize\r | |
3676 | )\r | |
3677 | {\r | |
3678 | return CALL_BASECRYPTLIB (Dh.Services.ComputeKey, DhComputeKey, (DhContext, PeerPublicKey, PeerPublicKeySize, Key, KeySize), FALSE);\r | |
3679 | }\r | |
3680 | \r | |
7c342378 | 3681 | // =====================================================================================\r |
cc1d13c9 | 3682 | // Pseudo-Random Generation Primitive\r |
7c342378 | 3683 | // =====================================================================================\r |
cc1d13c9 MK |
3684 | \r |
3685 | /**\r | |
3686 | Sets up the seed value for the pseudorandom number generator.\r | |
3687 | \r | |
3688 | This function sets up the seed value for the pseudorandom number generator.\r | |
3689 | If Seed is not NULL, then the seed passed in is used.\r | |
3690 | If Seed is NULL, then default seed is used.\r | |
3691 | If this interface is not supported, then return FALSE.\r | |
3692 | \r | |
3693 | @param[in] Seed Pointer to seed value.\r | |
3694 | If NULL, default seed is used.\r | |
3695 | @param[in] SeedSize Size of seed value.\r | |
3696 | If Seed is NULL, this parameter is ignored.\r | |
3697 | \r | |
3698 | @retval TRUE Pseudorandom number generator has enough entropy for random generation.\r | |
3699 | @retval FALSE Pseudorandom number generator does not have enough entropy for random generation.\r | |
3700 | @retval FALSE This interface is not supported.\r | |
3701 | \r | |
3702 | **/\r | |
3703 | BOOLEAN\r | |
3704 | EFIAPI\r | |
3705 | CryptoServiceRandomSeed (\r | |
3706 | IN CONST UINT8 *Seed OPTIONAL,\r | |
3707 | IN UINTN SeedSize\r | |
3708 | )\r | |
3709 | {\r | |
3710 | return CALL_BASECRYPTLIB (Random.Services.Seed, RandomSeed, (Seed, SeedSize), FALSE);\r | |
3711 | }\r | |
3712 | \r | |
3713 | /**\r | |
3714 | Generates a pseudorandom byte stream of the specified size.\r | |
3715 | \r | |
3716 | If Output is NULL, then return FALSE.\r | |
3717 | If this interface is not supported, then return FALSE.\r | |
3718 | \r | |
3719 | @param[out] Output Pointer to buffer to receive random value.\r | |
3720 | @param[in] Size Size of random bytes to generate.\r | |
3721 | \r | |
3722 | @retval TRUE Pseudorandom byte stream generated successfully.\r | |
3723 | @retval FALSE Pseudorandom number generator fails to generate due to lack of entropy.\r | |
3724 | @retval FALSE This interface is not supported.\r | |
3725 | \r | |
3726 | **/\r | |
3727 | BOOLEAN\r | |
3728 | EFIAPI\r | |
3729 | CryptoServiceRandomBytes (\r | |
3730 | OUT UINT8 *Output,\r | |
3731 | IN UINTN Size\r | |
3732 | )\r | |
3733 | {\r | |
3734 | return CALL_BASECRYPTLIB (Random.Services.Bytes, RandomBytes, (Output, Size), FALSE);\r | |
3735 | }\r | |
3736 | \r | |
7c342378 | 3737 | // =====================================================================================\r |
cc1d13c9 | 3738 | // Key Derivation Function Primitive\r |
7c342378 | 3739 | // =====================================================================================\r |
cc1d13c9 MK |
3740 | \r |
3741 | /**\r | |
3742 | Derive key data using HMAC-SHA256 based KDF.\r | |
3743 | \r | |
3744 | @param[in] Key Pointer to the user-supplied key.\r | |
3745 | @param[in] KeySize Key size in bytes.\r | |
3746 | @param[in] Salt Pointer to the salt(non-secret) value.\r | |
3747 | @param[in] SaltSize Salt size in bytes.\r | |
3748 | @param[in] Info Pointer to the application specific info.\r | |
3749 | @param[in] InfoSize Info size in bytes.\r | |
3750 | @param[out] Out Pointer to buffer to receive hkdf value.\r | |
3751 | @param[in] OutSize Size of hkdf bytes to generate.\r | |
3752 | \r | |
3753 | @retval TRUE Hkdf generated successfully.\r | |
3754 | @retval FALSE Hkdf generation failed.\r | |
3755 | \r | |
3756 | **/\r | |
3757 | BOOLEAN\r | |
3758 | EFIAPI\r | |
3759 | CryptoServiceHkdfSha256ExtractAndExpand (\r | |
3760 | IN CONST UINT8 *Key,\r | |
3761 | IN UINTN KeySize,\r | |
3762 | IN CONST UINT8 *Salt,\r | |
3763 | IN UINTN SaltSize,\r | |
3764 | IN CONST UINT8 *Info,\r | |
3765 | IN UINTN InfoSize,\r | |
3766 | OUT UINT8 *Out,\r | |
3767 | IN UINTN OutSize\r | |
3768 | )\r | |
3769 | {\r | |
3770 | return CALL_BASECRYPTLIB (Hkdf.Services.Sha256ExtractAndExpand, HkdfSha256ExtractAndExpand, (Key, KeySize, Salt, SaltSize, Info, InfoSize, Out, OutSize), FALSE);\r | |
3771 | }\r | |
3772 | \r | |
e919c390 QZ |
3773 | /**\r |
3774 | Derive SHA256 HMAC-based Extract key Derivation Function (HKDF).\r | |
3775 | \r | |
3776 | @param[in] Key Pointer to the user-supplied key.\r | |
3777 | @param[in] KeySize key size in bytes.\r | |
3778 | @param[in] Salt Pointer to the salt(non-secret) value.\r | |
3779 | @param[in] SaltSize salt size in bytes.\r | |
3780 | @param[out] PrkOut Pointer to buffer to receive hkdf value.\r | |
3781 | @param[in] PrkOutSize size of hkdf bytes to generate.\r | |
3782 | \r | |
3783 | @retval true Hkdf generated successfully.\r | |
3784 | @retval false Hkdf generation failed.\r | |
3785 | \r | |
3786 | **/\r | |
3787 | BOOLEAN\r | |
3788 | EFIAPI\r | |
3789 | CryptoServiceHkdfSha256Extract (\r | |
3790 | IN CONST UINT8 *Key,\r | |
3791 | IN UINTN KeySize,\r | |
3792 | IN CONST UINT8 *Salt,\r | |
3793 | IN UINTN SaltSize,\r | |
3794 | OUT UINT8 *PrkOut,\r | |
3795 | UINTN PrkOutSize\r | |
3796 | )\r | |
3797 | {\r | |
3798 | return CALL_BASECRYPTLIB (Hkdf.Services.Sha256Extract, HkdfSha256Extract, (Key, KeySize, Salt, SaltSize, PrkOut, PrkOutSize), FALSE);\r | |
3799 | }\r | |
3800 | \r | |
3801 | /**\r | |
3802 | Derive SHA256 HMAC-based Expand Key Derivation Function (HKDF).\r | |
3803 | \r | |
3804 | @param[in] Prk Pointer to the user-supplied key.\r | |
3805 | @param[in] PrkSize Key size in bytes.\r | |
3806 | @param[in] Info Pointer to the application specific info.\r | |
3807 | @param[in] InfoSize Info size in bytes.\r | |
3808 | @param[out] Out Pointer to buffer to receive hkdf value.\r | |
3809 | @param[in] OutSize Size of hkdf bytes to generate.\r | |
3810 | \r | |
3811 | @retval TRUE Hkdf generated successfully.\r | |
3812 | @retval FALSE Hkdf generation failed.\r | |
3813 | \r | |
3814 | **/\r | |
3815 | BOOLEAN\r | |
3816 | EFIAPI\r | |
3817 | CryptoServiceHkdfSha256Expand (\r | |
3818 | IN CONST UINT8 *Prk,\r | |
3819 | IN UINTN PrkSize,\r | |
3820 | IN CONST UINT8 *Info,\r | |
3821 | IN UINTN InfoSize,\r | |
3822 | OUT UINT8 *Out,\r | |
3823 | IN UINTN OutSize\r | |
3824 | )\r | |
3825 | {\r | |
3826 | return CALL_BASECRYPTLIB (Hkdf.Services.Sha256Expand, HkdfSha256Expand, (Prk, PrkSize, Info, InfoSize, Out, OutSize), FALSE);\r | |
3827 | }\r | |
3828 | \r | |
3829 | /**\r | |
3830 | Derive SHA384 HMAC-based Extract-and-Expand Key Derivation Function (HKDF).\r | |
3831 | \r | |
3832 | @param[in] Key Pointer to the user-supplied key.\r | |
3833 | @param[in] KeySize Key size in bytes.\r | |
3834 | @param[in] Salt Pointer to the salt(non-secret) value.\r | |
3835 | @param[in] SaltSize Salt size in bytes.\r | |
3836 | @param[in] Info Pointer to the application specific info.\r | |
3837 | @param[in] InfoSize Info size in bytes.\r | |
3838 | @param[out] Out Pointer to buffer to receive hkdf value.\r | |
3839 | @param[in] OutSize Size of hkdf bytes to generate.\r | |
3840 | \r | |
3841 | @retval TRUE Hkdf generated successfully.\r | |
3842 | @retval FALSE Hkdf generation failed.\r | |
3843 | \r | |
3844 | **/\r | |
3845 | BOOLEAN\r | |
3846 | EFIAPI\r | |
3847 | CryptoServiceHkdfSha384ExtractAndExpand (\r | |
3848 | IN CONST UINT8 *Key,\r | |
3849 | IN UINTN KeySize,\r | |
3850 | IN CONST UINT8 *Salt,\r | |
3851 | IN UINTN SaltSize,\r | |
3852 | IN CONST UINT8 *Info,\r | |
3853 | IN UINTN InfoSize,\r | |
3854 | OUT UINT8 *Out,\r | |
3855 | IN UINTN OutSize\r | |
3856 | )\r | |
3857 | {\r | |
3858 | return CALL_BASECRYPTLIB (Hkdf.Services.Sha384ExtractAndExpand, HkdfSha384ExtractAndExpand, (Key, KeySize, Salt, SaltSize, Info, InfoSize, Out, OutSize), FALSE);\r | |
3859 | }\r | |
3860 | \r | |
3861 | /**\r | |
3862 | Derive SHA384 HMAC-based Extract key Derivation Function (HKDF).\r | |
3863 | \r | |
3864 | @param[in] Key Pointer to the user-supplied key.\r | |
3865 | @param[in] KeySize key size in bytes.\r | |
3866 | @param[in] Salt Pointer to the salt(non-secret) value.\r | |
3867 | @param[in] SaltSize salt size in bytes.\r | |
3868 | @param[out] PrkOut Pointer to buffer to receive hkdf value.\r | |
3869 | @param[in] PrkOutSize size of hkdf bytes to generate.\r | |
3870 | \r | |
3871 | @retval true Hkdf generated successfully.\r | |
3872 | @retval false Hkdf generation failed.\r | |
3873 | \r | |
3874 | **/\r | |
3875 | BOOLEAN\r | |
3876 | EFIAPI\r | |
3877 | CryptoServiceHkdfSha384Extract (\r | |
3878 | IN CONST UINT8 *Key,\r | |
3879 | IN UINTN KeySize,\r | |
3880 | IN CONST UINT8 *Salt,\r | |
3881 | IN UINTN SaltSize,\r | |
3882 | OUT UINT8 *PrkOut,\r | |
3883 | UINTN PrkOutSize\r | |
3884 | )\r | |
3885 | {\r | |
3886 | return CALL_BASECRYPTLIB (Hkdf.Services.Sha384Extract, HkdfSha384Extract, (Key, KeySize, Salt, SaltSize, PrkOut, PrkOutSize), FALSE);\r | |
3887 | }\r | |
3888 | \r | |
3889 | /**\r | |
3890 | Derive SHA384 HMAC-based Expand Key Derivation Function (HKDF).\r | |
3891 | \r | |
3892 | @param[in] Prk Pointer to the user-supplied key.\r | |
3893 | @param[in] PrkSize Key size in bytes.\r | |
3894 | @param[in] Info Pointer to the application specific info.\r | |
3895 | @param[in] InfoSize Info size in bytes.\r | |
3896 | @param[out] Out Pointer to buffer to receive hkdf value.\r | |
3897 | @param[in] OutSize Size of hkdf bytes to generate.\r | |
3898 | \r | |
3899 | @retval TRUE Hkdf generated successfully.\r | |
3900 | @retval FALSE Hkdf generation failed.\r | |
3901 | \r | |
3902 | **/\r | |
3903 | BOOLEAN\r | |
3904 | EFIAPI\r | |
3905 | CryptoServiceHkdfSha384Expand (\r | |
3906 | IN CONST UINT8 *Prk,\r | |
3907 | IN UINTN PrkSize,\r | |
3908 | IN CONST UINT8 *Info,\r | |
3909 | IN UINTN InfoSize,\r | |
3910 | OUT UINT8 *Out,\r | |
3911 | IN UINTN OutSize\r | |
3912 | )\r | |
3913 | {\r | |
3914 | return CALL_BASECRYPTLIB (Hkdf.Services.Sha384Expand, HkdfSha384Expand, (Prk, PrkSize, Info, InfoSize, Out, OutSize), FALSE);\r | |
3915 | }\r | |
3916 | \r | |
cc1d13c9 MK |
3917 | /**\r |
3918 | Initializes the OpenSSL library.\r | |
3919 | \r | |
3920 | This function registers ciphers and digests used directly and indirectly\r | |
3921 | by SSL/TLS, and initializes the readable error messages.\r | |
3922 | This function must be called before any other action takes places.\r | |
3923 | \r | |
3924 | @retval TRUE The OpenSSL library has been initialized.\r | |
3925 | @retval FALSE Failed to initialize the OpenSSL library.\r | |
3926 | \r | |
3927 | **/\r | |
3928 | BOOLEAN\r | |
3929 | EFIAPI\r | |
3930 | CryptoServiceTlsInitialize (\r | |
3931 | VOID\r | |
3932 | )\r | |
3933 | {\r | |
3934 | return CALL_BASECRYPTLIB (Tls.Services.Initialize, TlsInitialize, (), FALSE);\r | |
3935 | }\r | |
3936 | \r | |
3937 | /**\r | |
3938 | Free an allocated SSL_CTX object.\r | |
3939 | \r | |
3940 | @param[in] TlsCtx Pointer to the SSL_CTX object to be released.\r | |
3941 | \r | |
3942 | **/\r | |
3943 | VOID\r | |
3944 | EFIAPI\r | |
3945 | CryptoServiceTlsCtxFree (\r | |
7c342378 | 3946 | IN VOID *TlsCtx\r |
cc1d13c9 MK |
3947 | )\r |
3948 | {\r | |
3949 | CALL_VOID_BASECRYPTLIB (Tls.Services.CtxFree, TlsCtxFree, (TlsCtx));\r | |
3950 | }\r | |
3951 | \r | |
3952 | /**\r | |
3953 | Creates a new SSL_CTX object as framework to establish TLS/SSL enabled\r | |
3954 | connections.\r | |
3955 | \r | |
3956 | @param[in] MajorVer Major Version of TLS/SSL Protocol.\r | |
3957 | @param[in] MinorVer Minor Version of TLS/SSL Protocol.\r | |
3958 | \r | |
3959 | @return Pointer to an allocated SSL_CTX object.\r | |
3960 | If the creation failed, TlsCtxNew() returns NULL.\r | |
3961 | \r | |
3962 | **/\r | |
3963 | VOID *\r | |
3964 | EFIAPI\r | |
3965 | CryptoServiceTlsCtxNew (\r | |
7c342378 MK |
3966 | IN UINT8 MajorVer,\r |
3967 | IN UINT8 MinorVer\r | |
cc1d13c9 MK |
3968 | )\r |
3969 | {\r | |
3970 | return CALL_BASECRYPTLIB (Tls.Services.CtxNew, TlsCtxNew, (MajorVer, MinorVer), NULL);\r | |
3971 | }\r | |
3972 | \r | |
3973 | /**\r | |
3974 | Free an allocated TLS object.\r | |
3975 | \r | |
3976 | This function removes the TLS object pointed to by Tls and frees up the\r | |
3977 | allocated memory. If Tls is NULL, nothing is done.\r | |
3978 | \r | |
3979 | @param[in] Tls Pointer to the TLS object to be freed.\r | |
3980 | \r | |
3981 | **/\r | |
3982 | VOID\r | |
3983 | EFIAPI\r | |
3984 | CryptoServiceTlsFree (\r | |
7c342378 | 3985 | IN VOID *Tls\r |
cc1d13c9 MK |
3986 | )\r |
3987 | {\r | |
3988 | CALL_VOID_BASECRYPTLIB (Tls.Services.Free, TlsFree, (Tls));\r | |
3989 | }\r | |
3990 | \r | |
3991 | /**\r | |
3992 | Create a new TLS object for a connection.\r | |
3993 | \r | |
3994 | This function creates a new TLS object for a connection. The new object\r | |
3995 | inherits the setting of the underlying context TlsCtx: connection method,\r | |
3996 | options, verification setting.\r | |
3997 | \r | |
3998 | @param[in] TlsCtx Pointer to the SSL_CTX object.\r | |
3999 | \r | |
4000 | @return Pointer to an allocated SSL object.\r | |
4001 | If the creation failed, TlsNew() returns NULL.\r | |
4002 | \r | |
4003 | **/\r | |
4004 | VOID *\r | |
4005 | EFIAPI\r | |
4006 | CryptoServiceTlsNew (\r | |
7c342378 | 4007 | IN VOID *TlsCtx\r |
cc1d13c9 MK |
4008 | )\r |
4009 | {\r | |
4010 | return CALL_BASECRYPTLIB (Tls.Services.New, TlsNew, (TlsCtx), NULL);\r | |
4011 | }\r | |
4012 | \r | |
4013 | /**\r | |
4014 | Checks if the TLS handshake was done.\r | |
4015 | \r | |
4016 | This function will check if the specified TLS handshake was done.\r | |
4017 | \r | |
4018 | @param[in] Tls Pointer to the TLS object for handshake state checking.\r | |
4019 | \r | |
4020 | @retval TRUE The TLS handshake was done.\r | |
4021 | @retval FALSE The TLS handshake was not done.\r | |
4022 | \r | |
4023 | **/\r | |
4024 | BOOLEAN\r | |
4025 | EFIAPI\r | |
4026 | CryptoServiceTlsInHandshake (\r | |
7c342378 | 4027 | IN VOID *Tls\r |
cc1d13c9 MK |
4028 | )\r |
4029 | {\r | |
4030 | return CALL_BASECRYPTLIB (Tls.Services.InHandshake, TlsInHandshake, (Tls), FALSE);\r | |
4031 | }\r | |
4032 | \r | |
4033 | /**\r | |
4034 | Perform a TLS/SSL handshake.\r | |
4035 | \r | |
4036 | This function will perform a TLS/SSL handshake.\r | |
4037 | \r | |
4038 | @param[in] Tls Pointer to the TLS object for handshake operation.\r | |
4039 | @param[in] BufferIn Pointer to the most recently received TLS Handshake packet.\r | |
4040 | @param[in] BufferInSize Packet size in bytes for the most recently received TLS\r | |
4041 | Handshake packet.\r | |
4042 | @param[out] BufferOut Pointer to the buffer to hold the built packet.\r | |
4043 | @param[in, out] BufferOutSize Pointer to the buffer size in bytes. On input, it is\r | |
4044 | the buffer size provided by the caller. On output, it\r | |
4045 | is the buffer size in fact needed to contain the\r | |
4046 | packet.\r | |
4047 | \r | |
4048 | @retval EFI_SUCCESS The required TLS packet is built successfully.\r | |
4049 | @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:\r | |
4050 | Tls is NULL.\r | |
4051 | BufferIn is NULL but BufferInSize is NOT 0.\r | |
4052 | BufferInSize is 0 but BufferIn is NOT NULL.\r | |
4053 | BufferOutSize is NULL.\r | |
4054 | BufferOut is NULL if *BufferOutSize is not zero.\r | |
4055 | @retval EFI_BUFFER_TOO_SMALL BufferOutSize is too small to hold the response packet.\r | |
4056 | @retval EFI_ABORTED Something wrong during handshake.\r | |
4057 | \r | |
4058 | **/\r | |
4059 | EFI_STATUS\r | |
4060 | EFIAPI\r | |
4061 | CryptoServiceTlsDoHandshake (\r | |
7c342378 MK |
4062 | IN VOID *Tls,\r |
4063 | IN UINT8 *BufferIn OPTIONAL,\r | |
4064 | IN UINTN BufferInSize OPTIONAL,\r | |
4065 | OUT UINT8 *BufferOut OPTIONAL,\r | |
4066 | IN OUT UINTN *BufferOutSize\r | |
cc1d13c9 MK |
4067 | )\r |
4068 | {\r | |
4069 | return CALL_BASECRYPTLIB (Tls.Services.DoHandshake, TlsDoHandshake, (Tls, BufferIn, BufferInSize, BufferOut, BufferOutSize), EFI_UNSUPPORTED);\r | |
4070 | }\r | |
4071 | \r | |
4072 | /**\r | |
4073 | Handle Alert message recorded in BufferIn. If BufferIn is NULL and BufferInSize is zero,\r | |
4074 | TLS session has errors and the response packet needs to be Alert message based on error type.\r | |
4075 | \r | |
4076 | @param[in] Tls Pointer to the TLS object for state checking.\r | |
4077 | @param[in] BufferIn Pointer to the most recently received TLS Alert packet.\r | |
4078 | @param[in] BufferInSize Packet size in bytes for the most recently received TLS\r | |
4079 | Alert packet.\r | |
4080 | @param[out] BufferOut Pointer to the buffer to hold the built packet.\r | |
4081 | @param[in, out] BufferOutSize Pointer to the buffer size in bytes. On input, it is\r | |
4082 | the buffer size provided by the caller. On output, it\r | |
4083 | is the buffer size in fact needed to contain the\r | |
4084 | packet.\r | |
4085 | \r | |
4086 | @retval EFI_SUCCESS The required TLS packet is built successfully.\r | |
4087 | @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:\r | |
4088 | Tls is NULL.\r | |
4089 | BufferIn is NULL but BufferInSize is NOT 0.\r | |
4090 | BufferInSize is 0 but BufferIn is NOT NULL.\r | |
4091 | BufferOutSize is NULL.\r | |
4092 | BufferOut is NULL if *BufferOutSize is not zero.\r | |
4093 | @retval EFI_ABORTED An error occurred.\r | |
4094 | @retval EFI_BUFFER_TOO_SMALL BufferOutSize is too small to hold the response packet.\r | |
4095 | \r | |
4096 | **/\r | |
4097 | EFI_STATUS\r | |
4098 | EFIAPI\r | |
4099 | CryptoServiceTlsHandleAlert (\r | |
7c342378 MK |
4100 | IN VOID *Tls,\r |
4101 | IN UINT8 *BufferIn OPTIONAL,\r | |
4102 | IN UINTN BufferInSize OPTIONAL,\r | |
4103 | OUT UINT8 *BufferOut OPTIONAL,\r | |
4104 | IN OUT UINTN *BufferOutSize\r | |
cc1d13c9 MK |
4105 | )\r |
4106 | {\r | |
4107 | return CALL_BASECRYPTLIB (Tls.Services.HandleAlert, TlsHandleAlert, (Tls, BufferIn, BufferInSize, BufferOut, BufferOutSize), EFI_UNSUPPORTED);\r | |
4108 | }\r | |
4109 | \r | |
4110 | /**\r | |
4111 | Build the CloseNotify packet.\r | |
4112 | \r | |
4113 | @param[in] Tls Pointer to the TLS object for state checking.\r | |
4114 | @param[in, out] Buffer Pointer to the buffer to hold the built packet.\r | |
4115 | @param[in, out] BufferSize Pointer to the buffer size in bytes. On input, it is\r | |
4116 | the buffer size provided by the caller. On output, it\r | |
4117 | is the buffer size in fact needed to contain the\r | |
4118 | packet.\r | |
4119 | \r | |
4120 | @retval EFI_SUCCESS The required TLS packet is built successfully.\r | |
4121 | @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:\r | |
4122 | Tls is NULL.\r | |
4123 | BufferSize is NULL.\r | |
4124 | Buffer is NULL if *BufferSize is not zero.\r | |
4125 | @retval EFI_BUFFER_TOO_SMALL BufferSize is too small to hold the response packet.\r | |
4126 | \r | |
4127 | **/\r | |
4128 | EFI_STATUS\r | |
4129 | EFIAPI\r | |
4130 | CryptoServiceTlsCloseNotify (\r | |
7c342378 MK |
4131 | IN VOID *Tls,\r |
4132 | IN OUT UINT8 *Buffer,\r | |
4133 | IN OUT UINTN *BufferSize\r | |
cc1d13c9 MK |
4134 | )\r |
4135 | {\r | |
4136 | return CALL_BASECRYPTLIB (Tls.Services.CloseNotify, TlsCloseNotify, (Tls, Buffer, BufferSize), EFI_UNSUPPORTED);\r | |
4137 | }\r | |
4138 | \r | |
4139 | /**\r | |
4140 | Attempts to read bytes from one TLS object and places the data in Buffer.\r | |
4141 | \r | |
4142 | This function will attempt to read BufferSize bytes from the TLS object\r | |
4143 | and places the data in Buffer.\r | |
4144 | \r | |
4145 | @param[in] Tls Pointer to the TLS object.\r | |
4146 | @param[in,out] Buffer Pointer to the buffer to store the data.\r | |
4147 | @param[in] BufferSize The size of Buffer in bytes.\r | |
4148 | \r | |
4149 | @retval >0 The amount of data successfully read from the TLS object.\r | |
4150 | @retval <=0 No data was successfully read.\r | |
4151 | \r | |
4152 | **/\r | |
4153 | INTN\r | |
4154 | EFIAPI\r | |
4155 | CryptoServiceTlsCtrlTrafficOut (\r | |
7c342378 MK |
4156 | IN VOID *Tls,\r |
4157 | IN OUT VOID *Buffer,\r | |
4158 | IN UINTN BufferSize\r | |
cc1d13c9 MK |
4159 | )\r |
4160 | {\r | |
4161 | return CALL_BASECRYPTLIB (Tls.Services.CtrlTrafficOut, TlsCtrlTrafficOut, (Tls, Buffer, BufferSize), 0);\r | |
4162 | }\r | |
4163 | \r | |
4164 | /**\r | |
4165 | Attempts to write data from the buffer to TLS object.\r | |
4166 | \r | |
4167 | This function will attempt to write BufferSize bytes data from the Buffer\r | |
4168 | to the TLS object.\r | |
4169 | \r | |
4170 | @param[in] Tls Pointer to the TLS object.\r | |
4171 | @param[in] Buffer Pointer to the data buffer.\r | |
4172 | @param[in] BufferSize The size of Buffer in bytes.\r | |
4173 | \r | |
4174 | @retval >0 The amount of data successfully written to the TLS object.\r | |
4175 | @retval <=0 No data was successfully written.\r | |
4176 | \r | |
4177 | **/\r | |
4178 | INTN\r | |
4179 | EFIAPI\r | |
4180 | CryptoServiceTlsCtrlTrafficIn (\r | |
7c342378 MK |
4181 | IN VOID *Tls,\r |
4182 | IN VOID *Buffer,\r | |
4183 | IN UINTN BufferSize\r | |
cc1d13c9 MK |
4184 | )\r |
4185 | {\r | |
4186 | return CALL_BASECRYPTLIB (Tls.Services.CtrlTrafficIn, TlsCtrlTrafficIn, (Tls, Buffer, BufferSize), 0);\r | |
4187 | }\r | |
4188 | \r | |
4189 | /**\r | |
4190 | Attempts to read bytes from the specified TLS connection into the buffer.\r | |
4191 | \r | |
4192 | This function tries to read BufferSize bytes data from the specified TLS\r | |
4193 | connection into the Buffer.\r | |
4194 | \r | |
4195 | @param[in] Tls Pointer to the TLS connection for data reading.\r | |
4196 | @param[in,out] Buffer Pointer to the data buffer.\r | |
4197 | @param[in] BufferSize The size of Buffer in bytes.\r | |
4198 | \r | |
4199 | @retval >0 The read operation was successful, and return value is the\r | |
4200 | number of bytes actually read from the TLS connection.\r | |
4201 | @retval <=0 The read operation was not successful.\r | |
4202 | \r | |
4203 | **/\r | |
4204 | INTN\r | |
4205 | EFIAPI\r | |
4206 | CryptoServiceTlsRead (\r | |
7c342378 MK |
4207 | IN VOID *Tls,\r |
4208 | IN OUT VOID *Buffer,\r | |
4209 | IN UINTN BufferSize\r | |
cc1d13c9 MK |
4210 | )\r |
4211 | {\r | |
4212 | return CALL_BASECRYPTLIB (Tls.Services.Read, TlsRead, (Tls, Buffer, BufferSize), 0);\r | |
4213 | }\r | |
4214 | \r | |
4215 | /**\r | |
4216 | Attempts to write data to a TLS connection.\r | |
4217 | \r | |
4218 | This function tries to write BufferSize bytes data from the Buffer into the\r | |
4219 | specified TLS connection.\r | |
4220 | \r | |
4221 | @param[in] Tls Pointer to the TLS connection for data writing.\r | |
4222 | @param[in] Buffer Pointer to the data buffer.\r | |
4223 | @param[in] BufferSize The size of Buffer in bytes.\r | |
4224 | \r | |
4225 | @retval >0 The write operation was successful, and return value is the\r | |
4226 | number of bytes actually written to the TLS connection.\r | |
4227 | @retval <=0 The write operation was not successful.\r | |
4228 | \r | |
4229 | **/\r | |
4230 | INTN\r | |
4231 | EFIAPI\r | |
4232 | CryptoServiceTlsWrite (\r | |
7c342378 MK |
4233 | IN VOID *Tls,\r |
4234 | IN VOID *Buffer,\r | |
4235 | IN UINTN BufferSize\r | |
cc1d13c9 MK |
4236 | )\r |
4237 | {\r | |
4238 | return CALL_BASECRYPTLIB (Tls.Services.Write, TlsWrite, (Tls, Buffer, BufferSize), 0);\r | |
4239 | }\r | |
4240 | \r | |
4241 | /**\r | |
4242 | Set a new TLS/SSL method for a particular TLS object.\r | |
4243 | \r | |
4244 | This function sets a new TLS/SSL method for a particular TLS object.\r | |
4245 | \r | |
4246 | @param[in] Tls Pointer to a TLS object.\r | |
4247 | @param[in] MajorVer Major Version of TLS/SSL Protocol.\r | |
4248 | @param[in] MinorVer Minor Version of TLS/SSL Protocol.\r | |
4249 | \r | |
4250 | @retval EFI_SUCCESS The TLS/SSL method was set successfully.\r | |
4251 | @retval EFI_INVALID_PARAMETER The parameter is invalid.\r | |
4252 | @retval EFI_UNSUPPORTED Unsupported TLS/SSL method.\r | |
4253 | \r | |
4254 | **/\r | |
4255 | EFI_STATUS\r | |
4256 | EFIAPI\r | |
4257 | CryptoServiceTlsSetVersion (\r | |
7c342378 MK |
4258 | IN VOID *Tls,\r |
4259 | IN UINT8 MajorVer,\r | |
4260 | IN UINT8 MinorVer\r | |
cc1d13c9 MK |
4261 | )\r |
4262 | {\r | |
4263 | return CALL_BASECRYPTLIB (TlsSet.Services.Version, TlsSetVersion, (Tls, MajorVer, MinorVer), EFI_UNSUPPORTED);\r | |
4264 | }\r | |
4265 | \r | |
4266 | /**\r | |
4267 | Set TLS object to work in client or server mode.\r | |
4268 | \r | |
4269 | This function prepares a TLS object to work in client or server mode.\r | |
4270 | \r | |
4271 | @param[in] Tls Pointer to a TLS object.\r | |
4272 | @param[in] IsServer Work in server mode.\r | |
4273 | \r | |
4274 | @retval EFI_SUCCESS The TLS/SSL work mode was set successfully.\r | |
4275 | @retval EFI_INVALID_PARAMETER The parameter is invalid.\r | |
4276 | @retval EFI_UNSUPPORTED Unsupported TLS/SSL work mode.\r | |
4277 | \r | |
4278 | **/\r | |
4279 | EFI_STATUS\r | |
4280 | EFIAPI\r | |
4281 | CryptoServiceTlsSetConnectionEnd (\r | |
7c342378 MK |
4282 | IN VOID *Tls,\r |
4283 | IN BOOLEAN IsServer\r | |
cc1d13c9 MK |
4284 | )\r |
4285 | {\r | |
4286 | return CALL_BASECRYPTLIB (TlsSet.Services.ConnectionEnd, TlsSetConnectionEnd, (Tls, IsServer), EFI_UNSUPPORTED);\r | |
4287 | }\r | |
4288 | \r | |
4289 | /**\r | |
4290 | Set the ciphers list to be used by the TLS object.\r | |
4291 | \r | |
4292 | This function sets the ciphers for use by a specified TLS object.\r | |
4293 | \r | |
4294 | @param[in] Tls Pointer to a TLS object.\r | |
4295 | @param[in] CipherId Array of UINT16 cipher identifiers. Each UINT16\r | |
4296 | cipher identifier comes from the TLS Cipher Suite\r | |
4297 | Registry of the IANA, interpreting Byte1 and Byte2\r | |
4298 | in network (big endian) byte order.\r | |
4299 | @param[in] CipherNum The number of cipher in the list.\r | |
4300 | \r | |
4301 | @retval EFI_SUCCESS The ciphers list was set successfully.\r | |
4302 | @retval EFI_INVALID_PARAMETER The parameter is invalid.\r | |
4303 | @retval EFI_UNSUPPORTED No supported TLS cipher was found in CipherId.\r | |
4304 | @retval EFI_OUT_OF_RESOURCES Memory allocation failed.\r | |
4305 | \r | |
4306 | **/\r | |
4307 | EFI_STATUS\r | |
4308 | EFIAPI\r | |
4309 | CryptoServiceTlsSetCipherList (\r | |
7c342378 MK |
4310 | IN VOID *Tls,\r |
4311 | IN UINT16 *CipherId,\r | |
4312 | IN UINTN CipherNum\r | |
cc1d13c9 MK |
4313 | )\r |
4314 | {\r | |
4315 | return CALL_BASECRYPTLIB (TlsSet.Services.CipherList, TlsSetCipherList, (Tls, CipherId, CipherNum), EFI_UNSUPPORTED);\r | |
4316 | }\r | |
4317 | \r | |
4318 | /**\r | |
4319 | Set the compression method for TLS/SSL operations.\r | |
4320 | \r | |
4321 | This function handles TLS/SSL integrated compression methods.\r | |
4322 | \r | |
4323 | @param[in] CompMethod The compression method ID.\r | |
4324 | \r | |
4325 | @retval EFI_SUCCESS The compression method for the communication was\r | |
4326 | set successfully.\r | |
4327 | @retval EFI_UNSUPPORTED Unsupported compression method.\r | |
4328 | \r | |
4329 | **/\r | |
4330 | EFI_STATUS\r | |
4331 | EFIAPI\r | |
4332 | CryptoServiceTlsSetCompressionMethod (\r | |
7c342378 | 4333 | IN UINT8 CompMethod\r |
cc1d13c9 MK |
4334 | )\r |
4335 | {\r | |
4336 | return CALL_BASECRYPTLIB (TlsSet.Services.CompressionMethod, TlsSetCompressionMethod, (CompMethod), EFI_UNSUPPORTED);\r | |
4337 | }\r | |
4338 | \r | |
4339 | /**\r | |
4340 | Set peer certificate verification mode for the TLS connection.\r | |
4341 | \r | |
4342 | This function sets the verification mode flags for the TLS connection.\r | |
4343 | \r | |
4344 | @param[in] Tls Pointer to the TLS object.\r | |
4345 | @param[in] VerifyMode A set of logically or'ed verification mode flags.\r | |
4346 | \r | |
4347 | **/\r | |
4348 | VOID\r | |
4349 | EFIAPI\r | |
4350 | CryptoServiceTlsSetVerify (\r | |
7c342378 MK |
4351 | IN VOID *Tls,\r |
4352 | IN UINT32 VerifyMode\r | |
cc1d13c9 MK |
4353 | )\r |
4354 | {\r | |
4355 | CALL_VOID_BASECRYPTLIB (TlsSet.Services.Verify, TlsSetVerify, (Tls, VerifyMode));\r | |
4356 | }\r | |
4357 | \r | |
4358 | /**\r | |
4359 | Set the specified host name to be verified.\r | |
4360 | \r | |
4361 | @param[in] Tls Pointer to the TLS object.\r | |
4362 | @param[in] Flags The setting flags during the validation.\r | |
4363 | @param[in] HostName The specified host name to be verified.\r | |
4364 | \r | |
4365 | @retval EFI_SUCCESS The HostName setting was set successfully.\r | |
4366 | @retval EFI_INVALID_PARAMETER The parameter is invalid.\r | |
4367 | @retval EFI_ABORTED Invalid HostName setting.\r | |
4368 | \r | |
4369 | **/\r | |
4370 | EFI_STATUS\r | |
4371 | EFIAPI\r | |
4372 | CryptoServiceTlsSetVerifyHost (\r | |
7c342378 MK |
4373 | IN VOID *Tls,\r |
4374 | IN UINT32 Flags,\r | |
4375 | IN CHAR8 *HostName\r | |
cc1d13c9 MK |
4376 | )\r |
4377 | {\r | |
4378 | return CALL_BASECRYPTLIB (TlsSet.Services.VerifyHost, TlsSetVerifyHost, (Tls, Flags, HostName), EFI_UNSUPPORTED);\r | |
4379 | }\r | |
4380 | \r | |
4381 | /**\r | |
4382 | Sets a TLS/SSL session ID to be used during TLS/SSL connect.\r | |
4383 | \r | |
4384 | This function sets a session ID to be used when the TLS/SSL connection is\r | |
4385 | to be established.\r | |
4386 | \r | |
4387 | @param[in] Tls Pointer to the TLS object.\r | |
4388 | @param[in] SessionId Session ID data used for session resumption.\r | |
4389 | @param[in] SessionIdLen Length of Session ID in bytes.\r | |
4390 | \r | |
4391 | @retval EFI_SUCCESS Session ID was set successfully.\r | |
4392 | @retval EFI_INVALID_PARAMETER The parameter is invalid.\r | |
4393 | @retval EFI_UNSUPPORTED No available session for ID setting.\r | |
4394 | \r | |
4395 | **/\r | |
4396 | EFI_STATUS\r | |
4397 | EFIAPI\r | |
4398 | CryptoServiceTlsSetSessionId (\r | |
7c342378 MK |
4399 | IN VOID *Tls,\r |
4400 | IN UINT8 *SessionId,\r | |
4401 | IN UINT16 SessionIdLen\r | |
cc1d13c9 MK |
4402 | )\r |
4403 | {\r | |
4404 | return CALL_BASECRYPTLIB (TlsSet.Services.SessionId, TlsSetSessionId, (Tls, SessionId, SessionIdLen), EFI_UNSUPPORTED);\r | |
4405 | }\r | |
4406 | \r | |
4407 | /**\r | |
4408 | Adds the CA to the cert store when requesting Server or Client authentication.\r | |
4409 | \r | |
4410 | This function adds the CA certificate to the list of CAs when requesting\r | |
4411 | Server or Client authentication for the chosen TLS connection.\r | |
4412 | \r | |
4413 | @param[in] Tls Pointer to the TLS object.\r | |
4414 | @param[in] Data Pointer to the data buffer of a DER-encoded binary\r | |
4415 | X.509 certificate or PEM-encoded X.509 certificate.\r | |
4416 | @param[in] DataSize The size of data buffer in bytes.\r | |
4417 | \r | |
4418 | @retval EFI_SUCCESS The operation succeeded.\r | |
4419 | @retval EFI_INVALID_PARAMETER The parameter is invalid.\r | |
4420 | @retval EFI_OUT_OF_RESOURCES Required resources could not be allocated.\r | |
4421 | @retval EFI_ABORTED Invalid X.509 certificate.\r | |
4422 | \r | |
4423 | **/\r | |
4424 | EFI_STATUS\r | |
4425 | EFIAPI\r | |
4426 | CryptoServiceTlsSetCaCertificate (\r | |
7c342378 MK |
4427 | IN VOID *Tls,\r |
4428 | IN VOID *Data,\r | |
4429 | IN UINTN DataSize\r | |
cc1d13c9 MK |
4430 | )\r |
4431 | {\r | |
4432 | return CALL_BASECRYPTLIB (TlsSet.Services.CaCertificate, TlsSetCaCertificate, (Tls, Data, DataSize), EFI_UNSUPPORTED);\r | |
4433 | }\r | |
4434 | \r | |
4435 | /**\r | |
4436 | Loads the local public certificate into the specified TLS object.\r | |
4437 | \r | |
4438 | This function loads the X.509 certificate into the specified TLS object\r | |
4439 | for TLS negotiation.\r | |
4440 | \r | |
4441 | @param[in] Tls Pointer to the TLS object.\r | |
4442 | @param[in] Data Pointer to the data buffer of a DER-encoded binary\r | |
4443 | X.509 certificate or PEM-encoded X.509 certificate.\r | |
4444 | @param[in] DataSize The size of data buffer in bytes.\r | |
4445 | \r | |
4446 | @retval EFI_SUCCESS The operation succeeded.\r | |
4447 | @retval EFI_INVALID_PARAMETER The parameter is invalid.\r | |
4448 | @retval EFI_OUT_OF_RESOURCES Required resources could not be allocated.\r | |
4449 | @retval EFI_ABORTED Invalid X.509 certificate.\r | |
4450 | \r | |
4451 | **/\r | |
4452 | EFI_STATUS\r | |
4453 | EFIAPI\r | |
4454 | CryptoServiceTlsSetHostPublicCert (\r | |
7c342378 MK |
4455 | IN VOID *Tls,\r |
4456 | IN VOID *Data,\r | |
4457 | IN UINTN DataSize\r | |
cc1d13c9 MK |
4458 | )\r |
4459 | {\r | |
4460 | return CALL_BASECRYPTLIB (TlsSet.Services.HostPublicCert, TlsSetHostPublicCert, (Tls, Data, DataSize), EFI_UNSUPPORTED);\r | |
4461 | }\r | |
4462 | \r | |
4463 | /**\r | |
4464 | Adds the local private key to the specified TLS object.\r | |
4465 | \r | |
4466 | This function adds the local private key (PEM-encoded RSA or PKCS#8 private\r | |
4467 | key) into the specified TLS object for TLS negotiation.\r | |
4468 | \r | |
4469 | @param[in] Tls Pointer to the TLS object.\r | |
4470 | @param[in] Data Pointer to the data buffer of a PEM-encoded RSA\r | |
4471 | or PKCS#8 private key.\r | |
4472 | @param[in] DataSize The size of data buffer in bytes.\r | |
4473 | \r | |
4474 | @retval EFI_SUCCESS The operation succeeded.\r | |
4475 | @retval EFI_UNSUPPORTED This function is not supported.\r | |
4476 | @retval EFI_ABORTED Invalid private key data.\r | |
4477 | \r | |
4478 | **/\r | |
4479 | EFI_STATUS\r | |
4480 | EFIAPI\r | |
4481 | CryptoServiceTlsSetHostPrivateKey (\r | |
7c342378 MK |
4482 | IN VOID *Tls,\r |
4483 | IN VOID *Data,\r | |
4484 | IN UINTN DataSize\r | |
cc1d13c9 MK |
4485 | )\r |
4486 | {\r | |
4487 | return CALL_BASECRYPTLIB (TlsSet.Services.HostPrivateKey, TlsSetHostPrivateKey, (Tls, Data, DataSize), EFI_UNSUPPORTED);\r | |
4488 | }\r | |
4489 | \r | |
4490 | /**\r | |
4491 | Adds the CA-supplied certificate revocation list for certificate validation.\r | |
4492 | \r | |
4493 | This function adds the CA-supplied certificate revocation list data for\r | |
4494 | certificate validity checking.\r | |
4495 | \r | |
4496 | @param[in] Data Pointer to the data buffer of a DER-encoded CRL data.\r | |
4497 | @param[in] DataSize The size of data buffer in bytes.\r | |
4498 | \r | |
4499 | @retval EFI_SUCCESS The operation succeeded.\r | |
4500 | @retval EFI_UNSUPPORTED This function is not supported.\r | |
4501 | @retval EFI_ABORTED Invalid CRL data.\r | |
4502 | \r | |
4503 | **/\r | |
4504 | EFI_STATUS\r | |
4505 | EFIAPI\r | |
4506 | CryptoServiceTlsSetCertRevocationList (\r | |
7c342378 MK |
4507 | IN VOID *Data,\r |
4508 | IN UINTN DataSize\r | |
cc1d13c9 MK |
4509 | )\r |
4510 | {\r | |
4511 | return CALL_BASECRYPTLIB (TlsSet.Services.CertRevocationList, TlsSetCertRevocationList, (Data, DataSize), EFI_UNSUPPORTED);\r | |
4512 | }\r | |
4513 | \r | |
4514 | /**\r | |
4515 | Gets the protocol version used by the specified TLS connection.\r | |
4516 | \r | |
4517 | This function returns the protocol version used by the specified TLS\r | |
4518 | connection.\r | |
4519 | \r | |
4520 | If Tls is NULL, then ASSERT().\r | |
4521 | \r | |
4522 | @param[in] Tls Pointer to the TLS object.\r | |
4523 | \r | |
4524 | @return The protocol version of the specified TLS connection.\r | |
4525 | \r | |
4526 | **/\r | |
4527 | UINT16\r | |
4528 | EFIAPI\r | |
4529 | CryptoServiceTlsGetVersion (\r | |
7c342378 | 4530 | IN VOID *Tls\r |
cc1d13c9 MK |
4531 | )\r |
4532 | {\r | |
4533 | return CALL_BASECRYPTLIB (TlsGet.Services.Version, TlsGetVersion, (Tls), 0);\r | |
4534 | }\r | |
4535 | \r | |
4536 | /**\r | |
4537 | Gets the connection end of the specified TLS connection.\r | |
4538 | \r | |
4539 | This function returns the connection end (as client or as server) used by\r | |
4540 | the specified TLS connection.\r | |
4541 | \r | |
4542 | If Tls is NULL, then ASSERT().\r | |
4543 | \r | |
4544 | @param[in] Tls Pointer to the TLS object.\r | |
4545 | \r | |
4546 | @return The connection end used by the specified TLS connection.\r | |
4547 | \r | |
4548 | **/\r | |
4549 | UINT8\r | |
4550 | EFIAPI\r | |
4551 | CryptoServiceTlsGetConnectionEnd (\r | |
7c342378 | 4552 | IN VOID *Tls\r |
cc1d13c9 MK |
4553 | )\r |
4554 | {\r | |
4555 | return CALL_BASECRYPTLIB (TlsGet.Services.ConnectionEnd, TlsGetConnectionEnd, (Tls), 0);\r | |
4556 | }\r | |
4557 | \r | |
4558 | /**\r | |
4559 | Gets the cipher suite used by the specified TLS connection.\r | |
4560 | \r | |
4561 | This function returns current cipher suite used by the specified\r | |
4562 | TLS connection.\r | |
4563 | \r | |
4564 | @param[in] Tls Pointer to the TLS object.\r | |
4565 | @param[in,out] CipherId The cipher suite used by the TLS object.\r | |
4566 | \r | |
4567 | @retval EFI_SUCCESS The cipher suite was returned successfully.\r | |
4568 | @retval EFI_INVALID_PARAMETER The parameter is invalid.\r | |
4569 | @retval EFI_UNSUPPORTED Unsupported cipher suite.\r | |
4570 | \r | |
4571 | **/\r | |
4572 | EFI_STATUS\r | |
4573 | EFIAPI\r | |
4574 | CryptoServiceTlsGetCurrentCipher (\r | |
7c342378 MK |
4575 | IN VOID *Tls,\r |
4576 | IN OUT UINT16 *CipherId\r | |
cc1d13c9 MK |
4577 | )\r |
4578 | {\r | |
4579 | return CALL_BASECRYPTLIB (TlsGet.Services.CurrentCipher, TlsGetCurrentCipher, (Tls, CipherId), EFI_UNSUPPORTED);\r | |
4580 | }\r | |
4581 | \r | |
4582 | /**\r | |
4583 | Gets the compression methods used by the specified TLS connection.\r | |
4584 | \r | |
4585 | This function returns current integrated compression methods used by\r | |
4586 | the specified TLS connection.\r | |
4587 | \r | |
4588 | @param[in] Tls Pointer to the TLS object.\r | |
4589 | @param[in,out] CompressionId The current compression method used by\r | |
4590 | the TLS object.\r | |
4591 | \r | |
4592 | @retval EFI_SUCCESS The compression method was returned successfully.\r | |
4593 | @retval EFI_INVALID_PARAMETER The parameter is invalid.\r | |
4594 | @retval EFI_ABORTED Invalid Compression method.\r | |
4595 | @retval EFI_UNSUPPORTED This function is not supported.\r | |
4596 | \r | |
4597 | **/\r | |
4598 | EFI_STATUS\r | |
4599 | EFIAPI\r | |
4600 | CryptoServiceTlsGetCurrentCompressionId (\r | |
7c342378 MK |
4601 | IN VOID *Tls,\r |
4602 | IN OUT UINT8 *CompressionId\r | |
cc1d13c9 MK |
4603 | )\r |
4604 | {\r | |
4605 | return CALL_BASECRYPTLIB (TlsGet.Services.CurrentCompressionId, TlsGetCurrentCompressionId, (Tls, CompressionId), EFI_UNSUPPORTED);\r | |
4606 | }\r | |
4607 | \r | |
4608 | /**\r | |
4609 | Gets the verification mode currently set in the TLS connection.\r | |
4610 | \r | |
4611 | This function returns the peer verification mode currently set in the\r | |
4612 | specified TLS connection.\r | |
4613 | \r | |
4614 | If Tls is NULL, then ASSERT().\r | |
4615 | \r | |
4616 | @param[in] Tls Pointer to the TLS object.\r | |
4617 | \r | |
4618 | @return The verification mode set in the specified TLS connection.\r | |
4619 | \r | |
4620 | **/\r | |
4621 | UINT32\r | |
4622 | EFIAPI\r | |
4623 | CryptoServiceTlsGetVerify (\r | |
7c342378 | 4624 | IN VOID *Tls\r |
cc1d13c9 MK |
4625 | )\r |
4626 | {\r | |
4627 | return CALL_BASECRYPTLIB (TlsGet.Services.Verify, TlsGetVerify, (Tls), 0);\r | |
4628 | }\r | |
4629 | \r | |
4630 | /**\r | |
4631 | Gets the session ID used by the specified TLS connection.\r | |
4632 | \r | |
4633 | This function returns the TLS/SSL session ID currently used by the\r | |
4634 | specified TLS connection.\r | |
4635 | \r | |
4636 | @param[in] Tls Pointer to the TLS object.\r | |
4637 | @param[in,out] SessionId Buffer to contain the returned session ID.\r | |
4638 | @param[in,out] SessionIdLen The length of Session ID in bytes.\r | |
4639 | \r | |
4640 | @retval EFI_SUCCESS The Session ID was returned successfully.\r | |
4641 | @retval EFI_INVALID_PARAMETER The parameter is invalid.\r | |
4642 | @retval EFI_UNSUPPORTED Invalid TLS/SSL session.\r | |
4643 | \r | |
4644 | **/\r | |
4645 | EFI_STATUS\r | |
4646 | EFIAPI\r | |
4647 | CryptoServiceTlsGetSessionId (\r | |
7c342378 MK |
4648 | IN VOID *Tls,\r |
4649 | IN OUT UINT8 *SessionId,\r | |
4650 | IN OUT UINT16 *SessionIdLen\r | |
cc1d13c9 MK |
4651 | )\r |
4652 | {\r | |
4653 | return CALL_BASECRYPTLIB (TlsGet.Services.SessionId, TlsGetSessionId, (Tls, SessionId, SessionIdLen), EFI_UNSUPPORTED);\r | |
4654 | }\r | |
4655 | \r | |
4656 | /**\r | |
4657 | Gets the client random data used in the specified TLS connection.\r | |
4658 | \r | |
4659 | This function returns the TLS/SSL client random data currently used in\r | |
4660 | the specified TLS connection.\r | |
4661 | \r | |
4662 | @param[in] Tls Pointer to the TLS object.\r | |
4663 | @param[in,out] ClientRandom Buffer to contain the returned client\r | |
4664 | random data (32 bytes).\r | |
4665 | \r | |
4666 | **/\r | |
4667 | VOID\r | |
4668 | EFIAPI\r | |
4669 | CryptoServiceTlsGetClientRandom (\r | |
7c342378 MK |
4670 | IN VOID *Tls,\r |
4671 | IN OUT UINT8 *ClientRandom\r | |
cc1d13c9 MK |
4672 | )\r |
4673 | {\r | |
4674 | CALL_VOID_BASECRYPTLIB (TlsGet.Services.ClientRandom, TlsGetClientRandom, (Tls, ClientRandom));\r | |
4675 | }\r | |
4676 | \r | |
4677 | /**\r | |
4678 | Gets the server random data used in the specified TLS connection.\r | |
4679 | \r | |
4680 | This function returns the TLS/SSL server random data currently used in\r | |
4681 | the specified TLS connection.\r | |
4682 | \r | |
4683 | @param[in] Tls Pointer to the TLS object.\r | |
4684 | @param[in,out] ServerRandom Buffer to contain the returned server\r | |
4685 | random data (32 bytes).\r | |
4686 | \r | |
4687 | **/\r | |
4688 | VOID\r | |
4689 | EFIAPI\r | |
4690 | CryptoServiceTlsGetServerRandom (\r | |
7c342378 MK |
4691 | IN VOID *Tls,\r |
4692 | IN OUT UINT8 *ServerRandom\r | |
cc1d13c9 MK |
4693 | )\r |
4694 | {\r | |
4695 | CALL_VOID_BASECRYPTLIB (TlsGet.Services.ServerRandom, TlsGetServerRandom, (Tls, ServerRandom));\r | |
4696 | }\r | |
4697 | \r | |
4698 | /**\r | |
4699 | Gets the master key data used in the specified TLS connection.\r | |
4700 | \r | |
4701 | This function returns the TLS/SSL master key material currently used in\r | |
4702 | the specified TLS connection.\r | |
4703 | \r | |
4704 | @param[in] Tls Pointer to the TLS object.\r | |
4705 | @param[in,out] KeyMaterial Buffer to contain the returned key material.\r | |
4706 | \r | |
4707 | @retval EFI_SUCCESS Key material was returned successfully.\r | |
4708 | @retval EFI_INVALID_PARAMETER The parameter is invalid.\r | |
4709 | @retval EFI_UNSUPPORTED Invalid TLS/SSL session.\r | |
4710 | \r | |
4711 | **/\r | |
4712 | EFI_STATUS\r | |
4713 | EFIAPI\r | |
4714 | CryptoServiceTlsGetKeyMaterial (\r | |
7c342378 MK |
4715 | IN VOID *Tls,\r |
4716 | IN OUT UINT8 *KeyMaterial\r | |
cc1d13c9 MK |
4717 | )\r |
4718 | {\r | |
4719 | return CALL_BASECRYPTLIB (TlsGet.Services.KeyMaterial, TlsGetKeyMaterial, (Tls, KeyMaterial), EFI_UNSUPPORTED);\r | |
4720 | }\r | |
4721 | \r | |
4722 | /**\r | |
4723 | Gets the CA Certificate from the cert store.\r | |
4724 | \r | |
4725 | This function returns the CA certificate for the chosen\r | |
4726 | TLS connection.\r | |
4727 | \r | |
4728 | @param[in] Tls Pointer to the TLS object.\r | |
4729 | @param[out] Data Pointer to the data buffer to receive the CA\r | |
4730 | certificate data sent to the client.\r | |
4731 | @param[in,out] DataSize The size of data buffer in bytes.\r | |
4732 | \r | |
4733 | @retval EFI_SUCCESS The operation succeeded.\r | |
4734 | @retval EFI_UNSUPPORTED This function is not supported.\r | |
4735 | @retval EFI_BUFFER_TOO_SMALL The Data is too small to hold the data.\r | |
4736 | \r | |
4737 | **/\r | |
4738 | EFI_STATUS\r | |
4739 | EFIAPI\r | |
4740 | CryptoServiceTlsGetCaCertificate (\r | |
7c342378 MK |
4741 | IN VOID *Tls,\r |
4742 | OUT VOID *Data,\r | |
4743 | IN OUT UINTN *DataSize\r | |
cc1d13c9 MK |
4744 | )\r |
4745 | {\r | |
4746 | return CALL_BASECRYPTLIB (TlsGet.Services.CaCertificate, TlsGetCaCertificate, (Tls, Data, DataSize), EFI_UNSUPPORTED);\r | |
4747 | }\r | |
4748 | \r | |
4749 | /**\r | |
4750 | Gets the local public Certificate set in the specified TLS object.\r | |
4751 | \r | |
4752 | This function returns the local public certificate which was currently set\r | |
4753 | in the specified TLS object.\r | |
4754 | \r | |
4755 | @param[in] Tls Pointer to the TLS object.\r | |
4756 | @param[out] Data Pointer to the data buffer to receive the local\r | |
4757 | public certificate.\r | |
4758 | @param[in,out] DataSize The size of data buffer in bytes.\r | |
4759 | \r | |
4760 | @retval EFI_SUCCESS The operation succeeded.\r | |
4761 | @retval EFI_INVALID_PARAMETER The parameter is invalid.\r | |
4762 | @retval EFI_NOT_FOUND The certificate is not found.\r | |
4763 | @retval EFI_BUFFER_TOO_SMALL The Data is too small to hold the data.\r | |
4764 | \r | |
4765 | **/\r | |
4766 | EFI_STATUS\r | |
4767 | EFIAPI\r | |
4768 | CryptoServiceTlsGetHostPublicCert (\r | |
7c342378 MK |
4769 | IN VOID *Tls,\r |
4770 | OUT VOID *Data,\r | |
4771 | IN OUT UINTN *DataSize\r | |
cc1d13c9 MK |
4772 | )\r |
4773 | {\r | |
4774 | return CALL_BASECRYPTLIB (TlsGet.Services.HostPublicCert, TlsGetHostPublicCert, (Tls, Data, DataSize), EFI_UNSUPPORTED);\r | |
4775 | }\r | |
4776 | \r | |
4777 | /**\r | |
4778 | Gets the local private key set in the specified TLS object.\r | |
4779 | \r | |
4780 | This function returns the local private key data which was currently set\r | |
4781 | in the specified TLS object.\r | |
4782 | \r | |
4783 | @param[in] Tls Pointer to the TLS object.\r | |
4784 | @param[out] Data Pointer to the data buffer to receive the local\r | |
4785 | private key data.\r | |
4786 | @param[in,out] DataSize The size of data buffer in bytes.\r | |
4787 | \r | |
4788 | @retval EFI_SUCCESS The operation succeeded.\r | |
4789 | @retval EFI_UNSUPPORTED This function is not supported.\r | |
4790 | @retval EFI_BUFFER_TOO_SMALL The Data is too small to hold the data.\r | |
4791 | \r | |
4792 | **/\r | |
4793 | EFI_STATUS\r | |
4794 | EFIAPI\r | |
4795 | CryptoServiceTlsGetHostPrivateKey (\r | |
7c342378 MK |
4796 | IN VOID *Tls,\r |
4797 | OUT VOID *Data,\r | |
4798 | IN OUT UINTN *DataSize\r | |
cc1d13c9 MK |
4799 | )\r |
4800 | {\r | |
4801 | return CALL_BASECRYPTLIB (TlsGet.Services.HostPrivateKey, TlsGetHostPrivateKey, (Tls, Data, DataSize), EFI_UNSUPPORTED);\r | |
4802 | }\r | |
4803 | \r | |
4804 | /**\r | |
4805 | Gets the CA-supplied certificate revocation list data set in the specified\r | |
4806 | TLS object.\r | |
4807 | \r | |
4808 | This function returns the CA-supplied certificate revocation list data which\r | |
4809 | was currently set in the specified TLS object.\r | |
4810 | \r | |
4811 | @param[out] Data Pointer to the data buffer to receive the CRL data.\r | |
4812 | @param[in,out] DataSize The size of data buffer in bytes.\r | |
4813 | \r | |
4814 | @retval EFI_SUCCESS The operation succeeded.\r | |
4815 | @retval EFI_UNSUPPORTED This function is not supported.\r | |
4816 | @retval EFI_BUFFER_TOO_SMALL The Data is too small to hold the data.\r | |
4817 | \r | |
4818 | **/\r | |
4819 | EFI_STATUS\r | |
4820 | EFIAPI\r | |
4821 | CryptoServiceTlsGetCertRevocationList (\r | |
7c342378 MK |
4822 | OUT VOID *Data,\r |
4823 | IN OUT UINTN *DataSize\r | |
cc1d13c9 MK |
4824 | )\r |
4825 | {\r | |
4826 | return CALL_BASECRYPTLIB (TlsGet.Services.CertRevocationList, TlsGetCertRevocationList, (Data, DataSize), EFI_UNSUPPORTED);\r | |
4827 | }\r | |
4828 | \r | |
c1e66210 ZL |
4829 | /**\r |
4830 | Carries out the RSA-SSA signature generation with EMSA-PSS encoding scheme.\r | |
4831 | \r | |
4832 | This function carries out the RSA-SSA signature generation with EMSA-PSS encoding scheme defined in\r | |
4833 | RFC 8017.\r | |
4834 | Mask generation function is the same as the message digest algorithm.\r | |
4835 | If the Signature buffer is too small to hold the contents of signature, FALSE\r | |
4836 | is returned and SigSize is set to the required buffer size to obtain the signature.\r | |
4837 | \r | |
4838 | If RsaContext is NULL, then return FALSE.\r | |
4839 | If Message is NULL, then return FALSE.\r | |
4840 | If MsgSize is zero or > INT_MAX, then return FALSE.\r | |
4841 | If DigestLen is NOT 32, 48 or 64, return FALSE.\r | |
4842 | If SaltLen is not equal to DigestLen, then return FALSE.\r | |
4843 | If SigSize is large enough but Signature is NULL, then return FALSE.\r | |
4844 | If this interface is not supported, then return FALSE.\r | |
4845 | \r | |
4846 | @param[in] RsaContext Pointer to RSA context for signature generation.\r | |
4847 | @param[in] Message Pointer to octet message to be signed.\r | |
4848 | @param[in] MsgSize Size of the message in bytes.\r | |
4849 | @param[in] DigestLen Length of the digest in bytes to be used for RSA signature operation.\r | |
4850 | @param[in] SaltLen Length of the salt in bytes to be used for PSS encoding.\r | |
4851 | @param[out] Signature Pointer to buffer to receive RSA PSS signature.\r | |
4852 | @param[in, out] SigSize On input, the size of Signature buffer in bytes.\r | |
4853 | On output, the size of data returned in Signature buffer in bytes.\r | |
4854 | \r | |
4855 | @retval TRUE Signature successfully generated in RSASSA-PSS.\r | |
4856 | @retval FALSE Signature generation failed.\r | |
4857 | @retval FALSE SigSize is too small.\r | |
4858 | @retval FALSE This interface is not supported.\r | |
4859 | \r | |
4860 | **/\r | |
4861 | BOOLEAN\r | |
4862 | EFIAPI\r | |
4863 | CryptoServiceRsaPssSign (\r | |
4864 | IN VOID *RsaContext,\r | |
4865 | IN CONST UINT8 *Message,\r | |
4866 | IN UINTN MsgSize,\r | |
4867 | IN UINT16 DigestLen,\r | |
4868 | IN UINT16 SaltLen,\r | |
4869 | OUT UINT8 *Signature,\r | |
4870 | IN OUT UINTN *SigSize\r | |
4871 | )\r | |
4872 | {\r | |
4873 | return CALL_BASECRYPTLIB (RsaPss.Services.Sign, RsaPssSign, (RsaContext, Message, MsgSize, DigestLen, SaltLen, Signature, SigSize), FALSE);\r | |
4874 | }\r | |
4875 | \r | |
4876 | /**\r | |
4877 | Verifies the RSA signature with RSASSA-PSS signature scheme defined in RFC 8017.\r | |
4878 | Implementation determines salt length automatically from the signature encoding.\r | |
4879 | Mask generation function is the same as the message digest algorithm.\r | |
4880 | Salt length should be equal to digest length.\r | |
4881 | \r | |
4882 | @param[in] RsaContext Pointer to RSA context for signature verification.\r | |
4883 | @param[in] Message Pointer to octet message to be verified.\r | |
4884 | @param[in] MsgSize Size of the message in bytes.\r | |
4885 | @param[in] Signature Pointer to RSASSA-PSS signature to be verified.\r | |
4886 | @param[in] SigSize Size of signature in bytes.\r | |
4887 | @param[in] DigestLen Length of digest for RSA operation.\r | |
4888 | @param[in] SaltLen Salt length for PSS encoding.\r | |
4889 | \r | |
4890 | @retval TRUE Valid signature encoded in RSASSA-PSS.\r | |
4891 | @retval FALSE Invalid signature or invalid RSA context.\r | |
4892 | \r | |
4893 | **/\r | |
4894 | BOOLEAN\r | |
4895 | EFIAPI\r | |
4896 | CryptoServiceRsaPssVerify (\r | |
4897 | IN VOID *RsaContext,\r | |
4898 | IN CONST UINT8 *Message,\r | |
4899 | IN UINTN MsgSize,\r | |
4900 | IN CONST UINT8 *Signature,\r | |
4901 | IN UINTN SigSize,\r | |
4902 | IN UINT16 DigestLen,\r | |
4903 | IN UINT16 SaltLen\r | |
4904 | )\r | |
4905 | {\r | |
4906 | return CALL_BASECRYPTLIB (RsaPss.Services.Verify, RsaPssVerify, (RsaContext, Message, MsgSize, Signature, SigSize, DigestLen, SaltLen), FALSE);\r | |
4907 | }\r | |
4908 | \r | |
4909 | /**\r | |
4910 | Parallel hash function ParallelHash256, as defined in NIST's Special Publication 800-185,\r | |
4911 | published December 2016.\r | |
4912 | \r | |
4913 | @param[in] Input Pointer to the input message (X).\r | |
4914 | @param[in] InputByteLen The number(>0) of input bytes provided for the input data.\r | |
4915 | @param[in] BlockSize The size of each block (B).\r | |
4916 | @param[out] Output Pointer to the output buffer.\r | |
4917 | @param[in] OutputByteLen The desired number of output bytes (L).\r | |
4918 | @param[in] Customization Pointer to the customization string (S).\r | |
4919 | @param[in] CustomByteLen The length of the customization string in bytes.\r | |
4920 | \r | |
4921 | @retval TRUE ParallelHash256 digest computation succeeded.\r | |
4922 | @retval FALSE ParallelHash256 digest computation failed.\r | |
4923 | @retval FALSE This interface is not supported.\r | |
4924 | \r | |
4925 | **/\r | |
4926 | BOOLEAN\r | |
4927 | EFIAPI\r | |
4928 | CryptoServiceParallelHash256HashAll (\r | |
4929 | IN CONST VOID *Input,\r | |
4930 | IN UINTN InputByteLen,\r | |
4931 | IN UINTN BlockSize,\r | |
4932 | OUT VOID *Output,\r | |
4933 | IN UINTN OutputByteLen,\r | |
4934 | IN CONST VOID *Customization,\r | |
4935 | IN UINTN CustomByteLen\r | |
4936 | )\r | |
4937 | {\r | |
4938 | return CALL_BASECRYPTLIB (ParallelHash.Services.HashAll, ParallelHash256HashAll, (Input, InputByteLen, BlockSize, Output, OutputByteLen, Customization, CustomByteLen), FALSE);\r | |
4939 | }\r | |
4940 | \r | |
022787f8 QZ |
4941 | /**\r |
4942 | Performs AEAD AES-GCM authenticated encryption on a data buffer and additional authenticated data (AAD).\r | |
4943 | \r | |
4944 | IvSize must be 12, otherwise FALSE is returned.\r | |
4945 | KeySize must be 16, 24 or 32, otherwise FALSE is returned.\r | |
4946 | TagSize must be 12, 13, 14, 15, 16, otherwise FALSE is returned.\r | |
4947 | \r | |
4948 | @param[in] Key Pointer to the encryption key.\r | |
4949 | @param[in] KeySize Size of the encryption key in bytes.\r | |
4950 | @param[in] Iv Pointer to the IV value.\r | |
4951 | @param[in] IvSize Size of the IV value in bytes.\r | |
4952 | @param[in] AData Pointer to the additional authenticated data (AAD).\r | |
4953 | @param[in] ADataSize Size of the additional authenticated data (AAD) in bytes.\r | |
4954 | @param[in] DataIn Pointer to the input data buffer to be encrypted.\r | |
4955 | @param[in] DataInSize Size of the input data buffer in bytes.\r | |
4956 | @param[out] TagOut Pointer to a buffer that receives the authentication tag output.\r | |
4957 | @param[in] TagSize Size of the authentication tag in bytes.\r | |
4958 | @param[out] DataOut Pointer to a buffer that receives the encryption output.\r | |
4959 | @param[out] DataOutSize Size of the output data buffer in bytes.\r | |
4960 | \r | |
4961 | @retval TRUE AEAD AES-GCM authenticated encryption succeeded.\r | |
4962 | @retval FALSE AEAD AES-GCM authenticated encryption failed.\r | |
4963 | \r | |
4964 | **/\r | |
4965 | BOOLEAN\r | |
4966 | EFIAPI\r | |
4967 | CryptoServiceAeadAesGcmEncrypt (\r | |
4968 | IN CONST UINT8 *Key,\r | |
4969 | IN UINTN KeySize,\r | |
4970 | IN CONST UINT8 *Iv,\r | |
4971 | IN UINTN IvSize,\r | |
4972 | IN CONST UINT8 *AData,\r | |
4973 | IN UINTN ADataSize,\r | |
4974 | IN CONST UINT8 *DataIn,\r | |
4975 | IN UINTN DataInSize,\r | |
4976 | OUT UINT8 *TagOut,\r | |
4977 | IN UINTN TagSize,\r | |
4978 | OUT UINT8 *DataOut,\r | |
4979 | OUT UINTN *DataOutSize\r | |
4980 | )\r | |
4981 | {\r | |
4982 | return CALL_BASECRYPTLIB (AeadAesGcm.Services.Encrypt, AeadAesGcmEncrypt, (Key, KeySize, Iv, IvSize, AData, ADataSize, DataIn, DataInSize, TagOut, TagSize, DataOut, DataOutSize), FALSE);\r | |
4983 | }\r | |
4984 | \r | |
4985 | /**\r | |
4986 | Performs AEAD AES-GCM authenticated decryption on a data buffer and additional authenticated data (AAD).\r | |
4987 | \r | |
4988 | IvSize must be 12, otherwise FALSE is returned.\r | |
4989 | KeySize must be 16, 24 or 32, otherwise FALSE is returned.\r | |
4990 | TagSize must be 12, 13, 14, 15, 16, otherwise FALSE is returned.\r | |
4991 | If additional authenticated data verification fails, FALSE is returned.\r | |
4992 | \r | |
4993 | @param[in] Key Pointer to the encryption key.\r | |
4994 | @param[in] KeySize Size of the encryption key in bytes.\r | |
4995 | @param[in] Iv Pointer to the IV value.\r | |
4996 | @param[in] IvSize Size of the IV value in bytes.\r | |
4997 | @param[in] AData Pointer to the additional authenticated data (AAD).\r | |
4998 | @param[in] ADataSize Size of the additional authenticated data (AAD) in bytes.\r | |
4999 | @param[in] DataIn Pointer to the input data buffer to be decrypted.\r | |
5000 | @param[in] DataInSize Size of the input data buffer in bytes.\r | |
5001 | @param[in] Tag Pointer to a buffer that contains the authentication tag.\r | |
5002 | @param[in] TagSize Size of the authentication tag in bytes.\r | |
5003 | @param[out] DataOut Pointer to a buffer that receives the decryption output.\r | |
5004 | @param[out] DataOutSize Size of the output data buffer in bytes.\r | |
5005 | \r | |
5006 | @retval TRUE AEAD AES-GCM authenticated decryption succeeded.\r | |
5007 | @retval FALSE AEAD AES-GCM authenticated decryption failed.\r | |
5008 | \r | |
5009 | **/\r | |
5010 | BOOLEAN\r | |
5011 | EFIAPI\r | |
5012 | CryptoServiceAeadAesGcmDecrypt (\r | |
5013 | IN CONST UINT8 *Key,\r | |
5014 | IN UINTN KeySize,\r | |
5015 | IN CONST UINT8 *Iv,\r | |
5016 | IN UINTN IvSize,\r | |
5017 | IN CONST UINT8 *AData,\r | |
5018 | IN UINTN ADataSize,\r | |
5019 | IN CONST UINT8 *DataIn,\r | |
5020 | IN UINTN DataInSize,\r | |
5021 | IN CONST UINT8 *Tag,\r | |
5022 | IN UINTN TagSize,\r | |
5023 | OUT UINT8 *DataOut,\r | |
5024 | OUT UINTN *DataOutSize\r | |
5025 | )\r | |
5026 | {\r | |
5027 | return CALL_BASECRYPTLIB (AeadAesGcm.Services.Decrypt, AeadAesGcmDecrypt, (Key, KeySize, Iv, IvSize, AData, ADataSize, DataIn, DataInSize, Tag, TagSize, DataOut, DataOutSize), FALSE);\r | |
5028 | }\r | |
5029 | \r | |
42951543 YL |
5030 | // =====================================================================================\r |
5031 | // Big number primitives\r | |
5032 | // =====================================================================================\r | |
5033 | \r | |
5034 | /**\r | |
5035 | Allocate new Big Number.\r | |
5036 | \r | |
5037 | @retval New BigNum opaque structure or NULL on failure.\r | |
5038 | **/\r | |
5039 | VOID *\r | |
5040 | EFIAPI\r | |
5041 | CryptoServiceBigNumInit (\r | |
5042 | VOID\r | |
5043 | )\r | |
5044 | {\r | |
5045 | return CALL_BASECRYPTLIB (Bn.Services.Init, BigNumInit, (), NULL);\r | |
5046 | }\r | |
5047 | \r | |
5048 | /**\r | |
5049 | Allocate new Big Number and assign the provided value to it.\r | |
5050 | \r | |
5051 | @param[in] Buf Big endian encoded buffer.\r | |
5052 | @param[in] Len Buffer length.\r | |
5053 | \r | |
5054 | @retval New BigNum opaque structure or NULL on failure.\r | |
5055 | **/\r | |
5056 | VOID *\r | |
5057 | EFIAPI\r | |
5058 | CryptoServiceBigNumFromBin (\r | |
5059 | IN CONST UINT8 *Buf,\r | |
5060 | IN UINTN Len\r | |
5061 | )\r | |
5062 | {\r | |
5063 | return CALL_BASECRYPTLIB (Bn.Services.FromBin, BigNumFromBin, (Buf, Len), NULL);\r | |
5064 | }\r | |
5065 | \r | |
5066 | /**\r | |
5067 | Convert the absolute value of Bn into big-endian form and store it at Buf.\r | |
5068 | The Buf array should have at least BigNumBytes() in it.\r | |
5069 | \r | |
5070 | @param[in] Bn Big number to convert.\r | |
5071 | @param[out] Buf Output buffer.\r | |
5072 | \r | |
5073 | @retval The length of the big-endian number placed at Buf or -1 on error.\r | |
5074 | **/\r | |
5075 | INTN\r | |
5076 | EFIAPI\r | |
5077 | CryptoServiceBigNumToBin (\r | |
5078 | IN CONST VOID *Bn,\r | |
5079 | OUT UINT8 *Buf\r | |
5080 | )\r | |
5081 | {\r | |
5082 | return CALL_BASECRYPTLIB (Bn.Services.ToBin, BigNumToBin, (Bn, Buf), -1);\r | |
5083 | }\r | |
5084 | \r | |
5085 | /**\r | |
5086 | Free the Big Number.\r | |
5087 | \r | |
5088 | @param[in] Bn Big number to free.\r | |
5089 | @param[in] Clear TRUE if the buffer should be cleared.\r | |
5090 | **/\r | |
5091 | VOID\r | |
5092 | EFIAPI\r | |
5093 | CryptoServiceBigNumFree (\r | |
5094 | IN VOID *Bn,\r | |
5095 | IN BOOLEAN Clear\r | |
5096 | )\r | |
5097 | {\r | |
5098 | CALL_VOID_BASECRYPTLIB (Bn.Services.Free, BigNumFree, (Bn, Clear));\r | |
5099 | }\r | |
5100 | \r | |
5101 | /**\r | |
5102 | Calculate the sum of two Big Numbers.\r | |
5103 | Please note, all "out" Big number arguments should be properly initialized\r | |
5104 | by calling to BigNumInit() or BigNumFromBin() functions.\r | |
5105 | \r | |
5106 | @param[in] BnA Big number.\r | |
5107 | @param[in] BnB Big number.\r | |
5108 | @param[out] BnRes The result of BnA + BnB.\r | |
5109 | \r | |
5110 | @retval TRUE On success.\r | |
5111 | @retval FALSE Otherwise.\r | |
5112 | **/\r | |
5113 | BOOLEAN\r | |
5114 | EFIAPI\r | |
5115 | CryptoServiceBigNumAdd (\r | |
5116 | IN CONST VOID *BnA,\r | |
5117 | IN CONST VOID *BnB,\r | |
5118 | OUT VOID *BnRes\r | |
5119 | )\r | |
5120 | {\r | |
5121 | return CALL_BASECRYPTLIB (Bn.Services.Add, BigNumAdd, (BnA, BnB, BnRes), FALSE);\r | |
5122 | }\r | |
5123 | \r | |
5124 | /**\r | |
5125 | Subtract two Big Numbers.\r | |
5126 | Please note, all "out" Big number arguments should be properly initialized\r | |
5127 | by calling to BigNumInit() or BigNumFromBin() functions.\r | |
5128 | \r | |
5129 | @param[in] BnA Big number.\r | |
5130 | @param[in] BnB Big number.\r | |
5131 | @param[out] BnRes The result of BnA - BnB.\r | |
5132 | \r | |
5133 | @retval TRUE On success.\r | |
5134 | @retval FALSE Otherwise.\r | |
5135 | **/\r | |
5136 | BOOLEAN\r | |
5137 | EFIAPI\r | |
5138 | CryptoServiceBigNumSub (\r | |
5139 | IN CONST VOID *BnA,\r | |
5140 | IN CONST VOID *BnB,\r | |
5141 | OUT VOID *BnRes\r | |
5142 | )\r | |
5143 | {\r | |
5144 | return CALL_BASECRYPTLIB (Bn.Services.Sub, BigNumSub, (BnA, BnB, BnRes), FALSE);\r | |
5145 | }\r | |
5146 | \r | |
5147 | /**\r | |
5148 | Calculate remainder: BnRes = BnA % BnB.\r | |
5149 | Please note, all "out" Big number arguments should be properly initialized\r | |
5150 | by calling to BigNumInit() or BigNumFromBin() functions.\r | |
5151 | \r | |
5152 | @param[in] BnA Big number.\r | |
5153 | @param[in] BnB Big number.\r | |
5154 | @param[out] BnRes The result of BnA % BnB.\r | |
5155 | \r | |
5156 | @retval TRUE On success.\r | |
5157 | @retval FALSE Otherwise.\r | |
5158 | **/\r | |
5159 | BOOLEAN\r | |
5160 | EFIAPI\r | |
5161 | CryptoServiceBigNumMod (\r | |
5162 | IN CONST VOID *BnA,\r | |
5163 | IN CONST VOID *BnB,\r | |
5164 | OUT VOID *BnRes\r | |
5165 | )\r | |
5166 | {\r | |
5167 | return CALL_BASECRYPTLIB (Bn.Services.Mod, BigNumMod, (BnA, BnB, BnRes), FALSE);\r | |
5168 | }\r | |
5169 | \r | |
5170 | /**\r | |
5171 | Compute BnA to the BnP-th power modulo BnM.\r | |
5172 | Please note, all "out" Big number arguments should be properly initialized.\r | |
5173 | by calling to BigNumInit() or BigNumFromBin() functions.\r | |
5174 | \r | |
5175 | @param[in] BnA Big number.\r | |
5176 | @param[in] BnP Big number (power).\r | |
5177 | @param[in] BnM Big number (modulo).\r | |
5178 | @param[out] BnRes The result of (BnA ^ BnP) % BnM.\r | |
5179 | \r | |
5180 | @retval TRUE On success.\r | |
5181 | @retval FALSE Otherwise.\r | |
5182 | **/\r | |
5183 | BOOLEAN\r | |
5184 | EFIAPI\r | |
5185 | CryptoServiceBigNumExpMod (\r | |
5186 | IN CONST VOID *BnA,\r | |
5187 | IN CONST VOID *BnP,\r | |
5188 | IN CONST VOID *BnM,\r | |
5189 | OUT VOID *BnRes\r | |
5190 | )\r | |
5191 | {\r | |
5192 | return CALL_BASECRYPTLIB (Bn.Services.ExpMod, BigNumExpMod, (BnA, BnP, BnM, BnRes), FALSE);\r | |
5193 | }\r | |
5194 | \r | |
5195 | /**\r | |
5196 | Compute BnA inverse modulo BnM.\r | |
5197 | Please note, all "out" Big number arguments should be properly initialized\r | |
5198 | by calling to BigNumInit() or BigNumFromBin() functions.\r | |
5199 | \r | |
5200 | @param[in] BnA Big number.\r | |
5201 | @param[in] BnM Big number (modulo).\r | |
5202 | @param[out] BnRes The result, such that (BnA * BnRes) % BnM == 1.\r | |
5203 | \r | |
5204 | @retval TRUE On success.\r | |
5205 | @retval FALSE Otherwise.\r | |
5206 | **/\r | |
5207 | BOOLEAN\r | |
5208 | EFIAPI\r | |
5209 | CryptoServiceBigNumInverseMod (\r | |
5210 | IN CONST VOID *BnA,\r | |
5211 | IN CONST VOID *BnM,\r | |
5212 | OUT VOID *BnRes\r | |
5213 | )\r | |
5214 | {\r | |
5215 | return CALL_BASECRYPTLIB (Bn.Services.InverseMod, BigNumInverseMod, (BnA, BnM, BnRes), FALSE);\r | |
5216 | }\r | |
5217 | \r | |
5218 | /**\r | |
5219 | Divide two Big Numbers.\r | |
5220 | Please note, all "out" Big number arguments should be properly initialized\r | |
5221 | by calling to BigNumInit() or BigNumFromBin() functions.\r | |
5222 | \r | |
5223 | @param[in] BnA Big number.\r | |
5224 | @param[in] BnB Big number.\r | |
5225 | @param[out] BnRes The result, such that BnA / BnB.\r | |
5226 | \r | |
5227 | @retval TRUE On success.\r | |
5228 | @retval FALSE Otherwise.\r | |
5229 | **/\r | |
5230 | BOOLEAN\r | |
5231 | EFIAPI\r | |
5232 | CryptoServiceBigNumDiv (\r | |
5233 | IN CONST VOID *BnA,\r | |
5234 | IN CONST VOID *BnB,\r | |
5235 | OUT VOID *BnRes\r | |
5236 | )\r | |
5237 | {\r | |
5238 | return CALL_BASECRYPTLIB (Bn.Services.Div, BigNumDiv, (BnA, BnB, BnRes), FALSE);\r | |
5239 | }\r | |
5240 | \r | |
5241 | /**\r | |
5242 | Multiply two Big Numbers modulo BnM.\r | |
5243 | Please note, all "out" Big number arguments should be properly initialized\r | |
5244 | by calling to BigNumInit() or BigNumFromBin() functions.\r | |
5245 | \r | |
5246 | @param[in] BnA Big number.\r | |
5247 | @param[in] BnB Big number.\r | |
5248 | @param[in] BnM Big number (modulo).\r | |
5249 | @param[out] BnRes The result, such that (BnA * BnB) % BnM.\r | |
5250 | \r | |
5251 | @retval TRUE On success.\r | |
5252 | @retval FALSE Otherwise.\r | |
5253 | **/\r | |
5254 | BOOLEAN\r | |
5255 | EFIAPI\r | |
5256 | CryptoServiceBigNumMulMod (\r | |
5257 | IN CONST VOID *BnA,\r | |
5258 | IN CONST VOID *BnB,\r | |
5259 | IN CONST VOID *BnM,\r | |
5260 | OUT VOID *BnRes\r | |
5261 | )\r | |
5262 | {\r | |
5263 | return CALL_BASECRYPTLIB (Bn.Services.MulMod, BigNumMulMod, (BnA, BnB, BnM, BnRes), FALSE);\r | |
5264 | }\r | |
5265 | \r | |
5266 | /**\r | |
5267 | Compare two Big Numbers.\r | |
5268 | \r | |
5269 | @param[in] BnA Big number.\r | |
5270 | @param[in] BnB Big number.\r | |
5271 | \r | |
5272 | @retval 0 BnA == BnB.\r | |
5273 | @retval 1 BnA > BnB.\r | |
5274 | @retval -1 BnA < BnB.\r | |
5275 | **/\r | |
5276 | INTN\r | |
5277 | EFIAPI\r | |
5278 | CryptoServiceBigNumCmp (\r | |
5279 | IN CONST VOID *BnA,\r | |
5280 | IN CONST VOID *BnB\r | |
5281 | )\r | |
5282 | {\r | |
5283 | return CALL_BASECRYPTLIB (Bn.Services.Cmp, BigNumCmp, (BnA, BnB), 0);\r | |
5284 | }\r | |
5285 | \r | |
5286 | /**\r | |
5287 | Get number of bits in Bn.\r | |
5288 | \r | |
5289 | @param[in] Bn Big number.\r | |
5290 | \r | |
5291 | @retval Number of bits.\r | |
5292 | **/\r | |
5293 | UINTN\r | |
5294 | EFIAPI\r | |
5295 | CryptoServiceBigNumBits (\r | |
5296 | IN CONST VOID *Bn\r | |
5297 | )\r | |
5298 | {\r | |
5299 | return CALL_BASECRYPTLIB (Bn.Services.Bits, BigNumBits, (Bn), 0);\r | |
5300 | }\r | |
5301 | \r | |
5302 | /**\r | |
5303 | Get number of bytes in Bn.\r | |
5304 | \r | |
5305 | @param[in] Bn Big number.\r | |
5306 | \r | |
5307 | @retval Number of bytes.\r | |
5308 | **/\r | |
5309 | UINTN\r | |
5310 | EFIAPI\r | |
5311 | CryptoServiceBigNumBytes (\r | |
5312 | IN CONST VOID *Bn\r | |
5313 | )\r | |
5314 | {\r | |
5315 | return CALL_BASECRYPTLIB (Bn.Services.Bytes, BigNumBytes, (Bn), 0);\r | |
5316 | }\r | |
5317 | \r | |
5318 | /**\r | |
5319 | Checks if Big Number equals to the given Num.\r | |
5320 | \r | |
5321 | @param[in] Bn Big number.\r | |
5322 | @param[in] Num Number.\r | |
5323 | \r | |
5324 | @retval TRUE iff Bn == Num.\r | |
5325 | @retval FALSE otherwise.\r | |
5326 | **/\r | |
5327 | BOOLEAN\r | |
5328 | EFIAPI\r | |
5329 | CryptoServiceBigNumIsWord (\r | |
5330 | IN CONST VOID *Bn,\r | |
5331 | IN UINTN Num\r | |
5332 | )\r | |
5333 | {\r | |
5334 | return CALL_BASECRYPTLIB (Bn.Services.IsWord, BigNumIsWord, (Bn, Num), FALSE);\r | |
5335 | }\r | |
5336 | \r | |
5337 | /**\r | |
5338 | Checks if Big Number is odd.\r | |
5339 | \r | |
5340 | @param[in] Bn Big number.\r | |
5341 | \r | |
5342 | @retval TRUE Bn is odd (Bn % 2 == 1).\r | |
5343 | @retval FALSE otherwise.\r | |
5344 | **/\r | |
5345 | BOOLEAN\r | |
5346 | EFIAPI\r | |
5347 | CryptoServiceBigNumIsOdd (\r | |
5348 | IN CONST VOID *Bn\r | |
5349 | )\r | |
5350 | {\r | |
5351 | return CALL_BASECRYPTLIB (Bn.Services.IsOdd, BigNumIsOdd, (Bn), FALSE);\r | |
5352 | }\r | |
5353 | \r | |
5354 | /**\r | |
5355 | Copy Big number.\r | |
5356 | \r | |
5357 | @param[out] BnDst Destination.\r | |
5358 | @param[in] BnSrc Source.\r | |
5359 | \r | |
5360 | @retval BnDst on success.\r | |
5361 | @retval NULL otherwise.\r | |
5362 | **/\r | |
5363 | VOID *\r | |
5364 | EFIAPI\r | |
5365 | CryptoServiceBigNumCopy (\r | |
5366 | OUT VOID *BnDst,\r | |
5367 | IN CONST VOID *BnSrc\r | |
5368 | )\r | |
5369 | {\r | |
5370 | return CALL_BASECRYPTLIB (Bn.Services.Copy, BigNumCopy, (BnDst, BnSrc), NULL);\r | |
5371 | }\r | |
5372 | \r | |
5373 | /**\r | |
5374 | Get constant Big number with value of "1".\r | |
5375 | This may be used to save expensive allocations.\r | |
5376 | \r | |
5377 | @retval Big Number with value of 1.\r | |
5378 | **/\r | |
5379 | CONST VOID *\r | |
5380 | EFIAPI\r | |
5381 | CryptoServiceBigNumValueOne (\r | |
5382 | VOID\r | |
5383 | )\r | |
5384 | {\r | |
5385 | return CALL_BASECRYPTLIB (Bn.Services.ValueOne, BigNumValueOne, (), NULL);\r | |
5386 | }\r | |
5387 | \r | |
5388 | /**\r | |
5389 | Shift right Big Number.\r | |
5390 | Please note, all "out" Big number arguments should be properly initialized\r | |
5391 | by calling to BigNumInit() or BigNumFromBin() functions.\r | |
5392 | \r | |
5393 | @param[in] Bn Big number.\r | |
5394 | @param[in] N Number of bits to shift.\r | |
5395 | @param[out] BnRes The result.\r | |
5396 | \r | |
5397 | @retval TRUE On success.\r | |
5398 | @retval FALSE Otherwise.\r | |
5399 | **/\r | |
5400 | BOOLEAN\r | |
5401 | EFIAPI\r | |
5402 | CryptoServiceBigNumRShift (\r | |
5403 | IN CONST VOID *Bn,\r | |
5404 | IN UINTN N,\r | |
5405 | OUT VOID *BnRes\r | |
5406 | )\r | |
5407 | {\r | |
5408 | return CALL_BASECRYPTLIB (Bn.Services.RShift, BigNumRShift, (Bn, N, BnRes), FALSE);\r | |
5409 | }\r | |
5410 | \r | |
5411 | /**\r | |
5412 | Mark Big Number for constant time computations.\r | |
5413 | This function should be called before any constant time computations are\r | |
5414 | performed on the given Big number.\r | |
5415 | \r | |
5416 | @param[in] Bn Big number.\r | |
5417 | **/\r | |
5418 | VOID\r | |
5419 | EFIAPI\r | |
5420 | CryptoServiceBigNumConstTime (\r | |
5421 | IN VOID *Bn\r | |
5422 | )\r | |
5423 | {\r | |
5424 | CALL_VOID_BASECRYPTLIB (Bn.Services.ConstTime, BigNumConstTime, (Bn));\r | |
5425 | }\r | |
5426 | \r | |
5427 | /**\r | |
5428 | Calculate square modulo.\r | |
5429 | Please note, all "out" Big number arguments should be properly initialized\r | |
5430 | by calling to BigNumInit() or BigNumFromBin() functions.\r | |
5431 | \r | |
5432 | @param[in] BnA Big number.\r | |
5433 | @param[in] BnM Big number (modulo).\r | |
5434 | @param[out] BnRes The result, such that (BnA ^ 2) % BnM.\r | |
5435 | \r | |
5436 | @retval TRUE On success.\r | |
5437 | @retval FALSE Otherwise.\r | |
5438 | **/\r | |
5439 | BOOLEAN\r | |
5440 | EFIAPI\r | |
5441 | CryptoServiceBigNumSqrMod (\r | |
5442 | IN CONST VOID *BnA,\r | |
5443 | IN CONST VOID *BnM,\r | |
5444 | OUT VOID *BnRes\r | |
5445 | )\r | |
5446 | {\r | |
5447 | return CALL_BASECRYPTLIB (Bn.Services.SqrMod, BigNumSqrMod, (BnA, BnM, BnRes), FALSE);\r | |
5448 | }\r | |
5449 | \r | |
5450 | /**\r | |
5451 | Create new Big Number computation context. This is an opaque structure\r | |
5452 | which should be passed to any function that requires it. The BN context is\r | |
5453 | needed to optimize calculations and expensive allocations.\r | |
5454 | \r | |
5455 | @retval Big Number context struct or NULL on failure.\r | |
5456 | **/\r | |
5457 | VOID *\r | |
5458 | EFIAPI\r | |
5459 | CryptoServiceBigNumNewContext (\r | |
5460 | VOID\r | |
5461 | )\r | |
5462 | {\r | |
5463 | return CALL_BASECRYPTLIB (Bn.Services.NewContext, BigNumNewContext, (), NULL);\r | |
5464 | }\r | |
5465 | \r | |
5466 | /**\r | |
5467 | Free Big Number context that was allocated with BigNumNewContext().\r | |
5468 | \r | |
5469 | @param[in] BnCtx Big number context to free.\r | |
5470 | **/\r | |
5471 | VOID\r | |
5472 | EFIAPI\r | |
5473 | CryptoServiceBigNumContextFree (\r | |
5474 | IN VOID *BnCtx\r | |
5475 | )\r | |
5476 | {\r | |
5477 | CALL_VOID_BASECRYPTLIB (Bn.Services.ContextFree, BigNumContextFree, (BnCtx));\r | |
5478 | }\r | |
5479 | \r | |
5480 | /**\r | |
5481 | Set Big Number to a given value.\r | |
5482 | \r | |
5483 | @param[in] Bn Big number to set.\r | |
5484 | @param[in] Val Value to set.\r | |
5485 | \r | |
5486 | @retval TRUE On success.\r | |
5487 | @retval FALSE Otherwise.\r | |
5488 | **/\r | |
5489 | BOOLEAN\r | |
5490 | EFIAPI\r | |
5491 | CryptoServiceBigNumSetUint (\r | |
5492 | IN VOID *Bn,\r | |
5493 | IN UINTN Val\r | |
5494 | )\r | |
5495 | {\r | |
5496 | return CALL_BASECRYPTLIB (Bn.Services.SetUint, BigNumSetUint, (Bn, Val), FALSE);\r | |
5497 | }\r | |
5498 | \r | |
5499 | /**\r | |
5500 | Add two Big Numbers modulo BnM.\r | |
5501 | \r | |
5502 | @param[in] BnA Big number.\r | |
5503 | @param[in] BnB Big number.\r | |
5504 | @param[in] BnM Big number (modulo).\r | |
5505 | @param[out] BnRes The result, such that (BnA + BnB) % BnM.\r | |
5506 | \r | |
5507 | @retval TRUE On success.\r | |
5508 | @retval FALSE Otherwise.\r | |
5509 | **/\r | |
5510 | BOOLEAN\r | |
5511 | EFIAPI\r | |
5512 | CryptoServiceBigNumAddMod (\r | |
5513 | IN CONST VOID *BnA,\r | |
5514 | IN CONST VOID *BnB,\r | |
5515 | IN CONST VOID *BnM,\r | |
5516 | OUT VOID *BnRes\r | |
5517 | )\r | |
5518 | {\r | |
5519 | return CALL_BASECRYPTLIB (Bn.Services.AddMod, BigNumAddMod, (BnA, BnB, BnM, BnRes), FALSE);\r | |
5520 | }\r | |
5521 | \r | |
3b382f5b YL |
5522 | // =====================================================================================\r |
5523 | // Basic Elliptic Curve Primitives\r | |
5524 | // =====================================================================================\r | |
5525 | \r | |
5526 | /**\r | |
5527 | Initialize new opaque EcGroup object. This object represents an EC curve and\r | |
5528 | and is used for calculation within this group. This object should be freed\r | |
5529 | using EcGroupFree() function.\r | |
5530 | \r | |
5531 | @param[in] CryptoNid Identifying number for the ECC curve (Defined in\r | |
5532 | BaseCryptLib.h).\r | |
5533 | \r | |
5534 | @retval EcGroup object On success.\r | |
5535 | @retval NULL On failure.\r | |
5536 | **/\r | |
5537 | VOID *\r | |
5538 | EFIAPI\r | |
5539 | CryptoServiceEcGroupInit (\r | |
5540 | IN UINTN CryptoNid\r | |
5541 | )\r | |
5542 | {\r | |
5543 | return CALL_BASECRYPTLIB (Ec.Services.GroupInit, EcGroupInit, (CryptoNid), NULL);\r | |
5544 | }\r | |
5545 | \r | |
5546 | /**\r | |
5547 | Get EC curve parameters. While elliptic curve equation is Y^2 mod P = (X^3 + AX + B) Mod P.\r | |
5548 | This function will set the provided Big Number objects to the corresponding\r | |
5549 | values. The caller needs to make sure all the "out" BigNumber parameters\r | |
5550 | are properly initialized.\r | |
5551 | @param[in] EcGroup EC group object.\r | |
5552 | @param[out] BnPrime Group prime number.\r | |
5553 | @param[out] BnA A coefficient.\r | |
5554 | @param[out] BnB B coefficient.\r | |
5555 | @param[in] BnCtx BN context.\r | |
5556 | \r | |
5557 | @retval TRUE On success.\r | |
5558 | @retval FALSE Otherwise.\r | |
5559 | **/\r | |
5560 | BOOLEAN\r | |
5561 | EFIAPI\r | |
5562 | CryptoServiceEcGroupGetCurve (\r | |
5563 | IN CONST VOID *EcGroup,\r | |
5564 | OUT VOID *BnPrime,\r | |
5565 | OUT VOID *BnA,\r | |
5566 | OUT VOID *BnB,\r | |
5567 | IN VOID *BnCtx\r | |
5568 | )\r | |
5569 | {\r | |
5570 | return CALL_BASECRYPTLIB (Ec.Services.GroupGetCurve, EcGroupGetCurve, (EcGroup, BnPrime, BnA, BnB, BnCtx), FALSE);\r | |
5571 | }\r | |
5572 | \r | |
5573 | /**\r | |
5574 | Get EC group order.\r | |
5575 | This function will set the provided Big Number object to the corresponding\r | |
5576 | value. The caller needs to make sure that the "out" BigNumber parameter\r | |
5577 | is properly initialized.\r | |
5578 | \r | |
5579 | @param[in] EcGroup EC group object.\r | |
5580 | @param[out] BnOrder Group prime number.\r | |
5581 | \r | |
5582 | @retval TRUE On success.\r | |
5583 | @retval FALSE Otherwise.\r | |
5584 | **/\r | |
5585 | BOOLEAN\r | |
5586 | EFIAPI\r | |
5587 | CryptoServiceEcGroupGetOrder (\r | |
5588 | IN VOID *EcGroup,\r | |
5589 | OUT VOID *BnOrder\r | |
5590 | )\r | |
5591 | {\r | |
5592 | return CALL_BASECRYPTLIB (Ec.Services.GroupGetOrder, EcGroupGetOrder, (EcGroup, BnOrder), FALSE);\r | |
5593 | }\r | |
5594 | \r | |
5595 | /**\r | |
5596 | Free previously allocated EC group object using EcGroupInit().\r | |
5597 | \r | |
5598 | @param[in] EcGroup EC group object to free.\r | |
5599 | **/\r | |
5600 | VOID\r | |
5601 | EFIAPI\r | |
5602 | CryptoServiceEcGroupFree (\r | |
5603 | IN VOID *EcGroup\r | |
5604 | )\r | |
5605 | {\r | |
5606 | CALL_VOID_BASECRYPTLIB (Ec.Services.GroupFree, EcGroupFree, (EcGroup));\r | |
5607 | }\r | |
5608 | \r | |
5609 | /**\r | |
5610 | Initialize new opaque EC Point object. This object represents an EC point\r | |
5611 | within the given EC group (curve).\r | |
5612 | \r | |
5613 | @param[in] EC Group, properly initialized using EcGroupInit().\r | |
5614 | \r | |
5615 | @retval EC Point object On success.\r | |
5616 | @retval NULL On failure.\r | |
5617 | **/\r | |
5618 | VOID *\r | |
5619 | EFIAPI\r | |
5620 | CryptoServiceEcPointInit (\r | |
5621 | IN CONST VOID *EcGroup\r | |
5622 | )\r | |
5623 | {\r | |
5624 | return CALL_BASECRYPTLIB (Ec.Services.PointInit, EcPointInit, (EcGroup), NULL);\r | |
5625 | }\r | |
5626 | \r | |
5627 | /**\r | |
5628 | Free previously allocated EC Point object using EcPointInit().\r | |
5629 | \r | |
5630 | @param[in] EcPoint EC Point to free.\r | |
5631 | @param[in] Clear TRUE iff the memory should be cleared.\r | |
5632 | **/\r | |
5633 | VOID\r | |
5634 | EFIAPI\r | |
5635 | CryptoServiceEcPointDeInit (\r | |
5636 | IN VOID *EcPoint,\r | |
5637 | IN BOOLEAN Clear\r | |
5638 | )\r | |
5639 | {\r | |
5640 | CALL_VOID_BASECRYPTLIB (Ec.Services.PointDeInit, EcPointDeInit, (EcPoint, Clear));\r | |
5641 | }\r | |
5642 | \r | |
5643 | /**\r | |
5644 | Get EC point affine (x,y) coordinates.\r | |
5645 | This function will set the provided Big Number objects to the corresponding\r | |
5646 | values. The caller needs to make sure all the "out" BigNumber parameters\r | |
5647 | are properly initialized.\r | |
5648 | \r | |
5649 | @param[in] EcGroup EC group object.\r | |
5650 | @param[in] EcPoint EC point object.\r | |
5651 | @param[out] BnX X coordinate.\r | |
5652 | @param[out] BnY Y coordinate.\r | |
5653 | @param[in] BnCtx BN context, created with BigNumNewContext().\r | |
5654 | \r | |
5655 | @retval TRUE On success.\r | |
5656 | @retval FALSE Otherwise.\r | |
5657 | **/\r | |
5658 | BOOLEAN\r | |
5659 | EFIAPI\r | |
5660 | CryptoServiceEcPointGetAffineCoordinates (\r | |
5661 | IN CONST VOID *EcGroup,\r | |
5662 | IN CONST VOID *EcPoint,\r | |
5663 | OUT VOID *BnX,\r | |
5664 | OUT VOID *BnY,\r | |
5665 | IN VOID *BnCtx\r | |
5666 | )\r | |
5667 | {\r | |
5668 | return CALL_BASECRYPTLIB (Ec.Services.PointGetAffineCoordinates, EcPointGetAffineCoordinates, (EcGroup, EcPoint, BnX, BnY, BnCtx), FALSE);\r | |
5669 | }\r | |
5670 | \r | |
5671 | /**\r | |
5672 | Set EC point affine (x,y) coordinates.\r | |
5673 | \r | |
5674 | @param[in] EcGroup EC group object.\r | |
5675 | @param[in] EcPoint EC point object.\r | |
5676 | @param[in] BnX X coordinate.\r | |
5677 | @param[in] BnY Y coordinate.\r | |
5678 | @param[in] BnCtx BN context, created with BigNumNewContext().\r | |
5679 | \r | |
5680 | @retval TRUE On success.\r | |
5681 | @retval FALSE Otherwise.\r | |
5682 | **/\r | |
5683 | BOOLEAN\r | |
5684 | EFIAPI\r | |
5685 | CryptoServiceEcPointSetAffineCoordinates (\r | |
5686 | IN CONST VOID *EcGroup,\r | |
5687 | IN VOID *EcPoint,\r | |
5688 | IN CONST VOID *BnX,\r | |
5689 | IN CONST VOID *BnY,\r | |
5690 | IN VOID *BnCtx\r | |
5691 | )\r | |
5692 | {\r | |
5693 | return CALL_BASECRYPTLIB (Ec.Services.PointSetAffineCoordinates, EcPointSetAffineCoordinates, (EcGroup, EcPoint, BnX, BnY, BnCtx), FALSE);\r | |
5694 | }\r | |
5695 | \r | |
5696 | /**\r | |
5697 | EC Point addition. EcPointResult = EcPointA + EcPointB.\r | |
5698 | @param[in] EcGroup EC group object.\r | |
5699 | @param[out] EcPointResult EC point to hold the result. The point should\r | |
5700 | be properly initialized.\r | |
5701 | @param[in] EcPointA EC Point.\r | |
5702 | @param[in] EcPointB EC Point.\r | |
5703 | @param[in] BnCtx BN context, created with BigNumNewContext().\r | |
5704 | \r | |
5705 | @retval TRUE On success.\r | |
5706 | @retval FALSE Otherwise.\r | |
5707 | **/\r | |
5708 | BOOLEAN\r | |
5709 | EFIAPI\r | |
5710 | CryptoServiceEcPointAdd (\r | |
5711 | IN CONST VOID *EcGroup,\r | |
5712 | OUT VOID *EcPointResult,\r | |
5713 | IN CONST VOID *EcPointA,\r | |
5714 | IN CONST VOID *EcPointB,\r | |
5715 | IN VOID *BnCtx\r | |
5716 | )\r | |
5717 | {\r | |
5718 | return CALL_BASECRYPTLIB (Ec.Services.PointAdd, EcPointAdd, (EcGroup, EcPointResult, EcPointA, EcPointB, BnCtx), FALSE);\r | |
5719 | }\r | |
5720 | \r | |
5721 | /**\r | |
5722 | Variable EC point multiplication. EcPointResult = EcPoint * BnPScalar.\r | |
5723 | \r | |
5724 | @param[in] EcGroup EC group object.\r | |
5725 | @param[out] EcPointResult EC point to hold the result. The point should\r | |
5726 | be properly initialized.\r | |
5727 | @param[in] EcPoint EC Point.\r | |
5728 | @param[in] BnPScalar P Scalar.\r | |
5729 | @param[in] BnCtx BN context, created with BigNumNewContext().\r | |
5730 | \r | |
5731 | @retval TRUE On success.\r | |
5732 | @retval FALSE Otherwise.\r | |
5733 | **/\r | |
5734 | BOOLEAN\r | |
5735 | EFIAPI\r | |
5736 | CryptoServiceEcPointMul (\r | |
5737 | IN CONST VOID *EcGroup,\r | |
5738 | OUT VOID *EcPointResult,\r | |
5739 | IN CONST VOID *EcPoint,\r | |
5740 | IN CONST VOID *BnPScalar,\r | |
5741 | IN VOID *BnCtx\r | |
5742 | )\r | |
5743 | {\r | |
5744 | return CALL_BASECRYPTLIB (Ec.Services.PointMul, EcPointMul, (EcGroup, EcPointResult, EcPoint, BnPScalar, BnCtx), FALSE);\r | |
5745 | }\r | |
5746 | \r | |
5747 | /**\r | |
5748 | Calculate the inverse of the supplied EC point.\r | |
5749 | \r | |
5750 | @param[in] EcGroup EC group object.\r | |
5751 | @param[in,out] EcPoint EC point to invert.\r | |
5752 | @param[in] BnCtx BN context, created with BigNumNewContext().\r | |
5753 | \r | |
5754 | @retval TRUE On success.\r | |
5755 | @retval FALSE Otherwise.\r | |
5756 | **/\r | |
5757 | BOOLEAN\r | |
5758 | EFIAPI\r | |
5759 | CryptoServiceEcPointInvert (\r | |
5760 | IN CONST VOID *EcGroup,\r | |
5761 | IN OUT VOID *EcPoint,\r | |
5762 | IN VOID *BnCtx\r | |
5763 | )\r | |
5764 | {\r | |
5765 | return CALL_BASECRYPTLIB (Ec.Services.PointInvert, EcPointInvert, (EcGroup, EcPoint, BnCtx), FALSE);\r | |
5766 | }\r | |
5767 | \r | |
5768 | /**\r | |
5769 | Check if the supplied point is on EC curve.\r | |
5770 | \r | |
5771 | @param[in] EcGroup EC group object.\r | |
5772 | @param[in] EcPoint EC point to check.\r | |
5773 | @param[in] BnCtx BN context, created with BigNumNewContext().\r | |
5774 | \r | |
5775 | @retval TRUE On curve.\r | |
5776 | @retval FALSE Otherwise.\r | |
5777 | **/\r | |
5778 | BOOLEAN\r | |
5779 | EFIAPI\r | |
5780 | CryptoServiceEcPointIsOnCurve (\r | |
5781 | IN CONST VOID *EcGroup,\r | |
5782 | IN CONST VOID *EcPoint,\r | |
5783 | IN VOID *BnCtx\r | |
5784 | )\r | |
5785 | {\r | |
5786 | return CALL_BASECRYPTLIB (Ec.Services.PointIsOnCurve, EcPointIsOnCurve, (EcGroup, EcPoint, BnCtx), FALSE);\r | |
5787 | }\r | |
5788 | \r | |
5789 | /**\r | |
5790 | Check if the supplied point is at infinity.\r | |
5791 | \r | |
5792 | @param[in] EcGroup EC group object.\r | |
5793 | @param[in] EcPoint EC point to check.\r | |
5794 | \r | |
5795 | @retval TRUE At infinity.\r | |
5796 | @retval FALSE Otherwise.\r | |
5797 | **/\r | |
5798 | BOOLEAN\r | |
5799 | EFIAPI\r | |
5800 | CryptoServiceEcPointIsAtInfinity (\r | |
5801 | IN CONST VOID *EcGroup,\r | |
5802 | IN CONST VOID *EcPoint\r | |
5803 | )\r | |
5804 | {\r | |
5805 | return CALL_BASECRYPTLIB (Ec.Services.PointIsAtInfinity, EcPointIsAtInfinity, (EcGroup, EcPoint), FALSE);\r | |
5806 | }\r | |
5807 | \r | |
5808 | /**\r | |
5809 | Check if EC points are equal.\r | |
5810 | \r | |
5811 | @param[in] EcGroup EC group object.\r | |
5812 | @param[in] EcPointA EC point A.\r | |
5813 | @param[in] EcPointB EC point B.\r | |
5814 | @param[in] BnCtx BN context, created with BigNumNewContext().\r | |
5815 | \r | |
5816 | @retval TRUE A == B.\r | |
5817 | @retval FALSE Otherwise.\r | |
5818 | **/\r | |
5819 | BOOLEAN\r | |
5820 | EFIAPI\r | |
5821 | CryptoServiceEcPointEqual (\r | |
5822 | IN CONST VOID *EcGroup,\r | |
5823 | IN CONST VOID *EcPointA,\r | |
5824 | IN CONST VOID *EcPointB,\r | |
5825 | IN VOID *BnCtx\r | |
5826 | )\r | |
5827 | {\r | |
5828 | return CALL_BASECRYPTLIB (Ec.Services.PointEqual, EcPointEqual, (EcGroup, EcPointA, EcPointB, BnCtx), FALSE);\r | |
5829 | }\r | |
5830 | \r | |
5831 | /**\r | |
5832 | Set EC point compressed coordinates. Points can be described in terms of\r | |
5833 | their compressed coordinates. For a point (x, y), for any given value for x\r | |
5834 | such that the point is on the curve there will only ever be two possible\r | |
5835 | values for y. Therefore, a point can be set using this function where BnX is\r | |
5836 | the x coordinate and YBit is a value 0 or 1 to identify which of the two\r | |
5837 | possible values for y should be used.\r | |
5838 | \r | |
5839 | @param[in] EcGroup EC group object.\r | |
5840 | @param[in] EcPoint EC Point.\r | |
5841 | @param[in] BnX X coordinate.\r | |
5842 | @param[in] YBit 0 or 1 to identify which Y value is used.\r | |
5843 | @param[in] BnCtx BN context, created with BigNumNewContext().\r | |
5844 | \r | |
5845 | @retval TRUE On success.\r | |
5846 | @retval FALSE Otherwise.\r | |
5847 | **/\r | |
5848 | BOOLEAN\r | |
5849 | EFIAPI\r | |
5850 | CryptoServiceEcPointSetCompressedCoordinates (\r | |
5851 | IN CONST VOID *EcGroup,\r | |
5852 | IN VOID *EcPoint,\r | |
5853 | IN CONST VOID *BnX,\r | |
5854 | IN UINT8 YBit,\r | |
5855 | IN VOID *BnCtx\r | |
5856 | )\r | |
5857 | {\r | |
5858 | return CALL_BASECRYPTLIB (Ec.Services.PointSetCompressedCoordinates, EcPointSetCompressedCoordinates, (EcGroup, EcPoint, BnX, YBit, BnCtx), FALSE);\r | |
5859 | }\r | |
5860 | \r | |
5861 | // =====================================================================================\r | |
5862 | // Elliptic Curve Diffie Hellman Primitives\r | |
5863 | // =====================================================================================\r | |
5864 | \r | |
5865 | /**\r | |
5866 | Allocates and Initializes one Elliptic Curve Context for subsequent use\r | |
5867 | with the NID.\r | |
5868 | \r | |
5869 | @param[in] Nid cipher NID\r | |
5870 | @return Pointer to the Elliptic Curve Context that has been initialized.\r | |
5871 | If the allocations fails, EcNewByNid() returns NULL.\r | |
5872 | **/\r | |
5873 | VOID *\r | |
5874 | EFIAPI\r | |
5875 | CryptoServiceEcNewByNid (\r | |
5876 | IN UINTN Nid\r | |
5877 | )\r | |
5878 | {\r | |
5879 | return CALL_BASECRYPTLIB (Ec.Services.NewByNid, EcNewByNid, (Nid), NULL);\r | |
5880 | }\r | |
5881 | \r | |
5882 | /**\r | |
5883 | Release the specified EC context.\r | |
5884 | \r | |
5885 | @param[in] EcContext Pointer to the EC context to be released.\r | |
5886 | **/\r | |
5887 | VOID\r | |
5888 | EFIAPI\r | |
5889 | CryptoServiceEcFree (\r | |
5890 | IN VOID *EcContext\r | |
5891 | )\r | |
5892 | {\r | |
5893 | CALL_VOID_BASECRYPTLIB (Ec.Services.Free, EcFree, (EcContext));\r | |
5894 | }\r | |
5895 | \r | |
5896 | /**\r | |
5897 | Generates EC key and returns EC public key (X, Y), Please note, this function uses\r | |
5898 | pseudo random number generator. The caller must make sure RandomSeed()\r | |
5899 | function was properly called before.\r | |
5900 | The Ec context should be correctly initialized by EcNewByNid.\r | |
5901 | This function generates random secret, and computes the public key (X, Y), which is\r | |
5902 | returned via parameter Public, PublicSize.\r | |
5903 | X is the first half of Public with size being PublicSize / 2,\r | |
5904 | Y is the second half of Public with size being PublicSize / 2.\r | |
5905 | EC context is updated accordingly.\r | |
5906 | If the Public buffer is too small to hold the public X, Y, FALSE is returned and\r | |
5907 | PublicSize is set to the required buffer size to obtain the public X, Y.\r | |
5908 | For P-256, the PublicSize is 64. First 32-byte is X, Second 32-byte is Y.\r | |
5909 | For P-384, the PublicSize is 96. First 48-byte is X, Second 48-byte is Y.\r | |
5910 | For P-521, the PublicSize is 132. First 66-byte is X, Second 66-byte is Y.\r | |
5911 | If EcContext is NULL, then return FALSE.\r | |
5912 | If PublicSize is NULL, then return FALSE.\r | |
5913 | If PublicSize is large enough but Public is NULL, then return FALSE.\r | |
5914 | @param[in, out] EcContext Pointer to the EC context.\r | |
5915 | @param[out] PublicKey Pointer to t buffer to receive generated public X,Y.\r | |
5916 | @param[in, out] PublicKeySize On input, the size of Public buffer in bytes.\r | |
5917 | On output, the size of data returned in Public buffer in bytes.\r | |
5918 | @retval TRUE EC public X,Y generation succeeded.\r | |
5919 | @retval FALSE EC public X,Y generation failed.\r | |
5920 | @retval FALSE PublicKeySize is not large enough.\r | |
5921 | **/\r | |
5922 | BOOLEAN\r | |
5923 | EFIAPI\r | |
5924 | CryptoServiceEcGenerateKey (\r | |
5925 | IN OUT VOID *EcContext,\r | |
5926 | OUT UINT8 *PublicKey,\r | |
5927 | IN OUT UINTN *PublicKeySize\r | |
5928 | )\r | |
5929 | {\r | |
5930 | return CALL_BASECRYPTLIB (Ec.Services.GenerateKey, EcGenerateKey, (EcContext, PublicKey, PublicKeySize), FALSE);\r | |
5931 | }\r | |
5932 | \r | |
5933 | /**\r | |
5934 | Gets the public key component from the established EC context.\r | |
5935 | The Ec context should be correctly initialized by EcNewByNid, and successfully\r | |
5936 | generate key pair from EcGenerateKey().\r | |
5937 | For P-256, the PublicSize is 64. First 32-byte is X, Second 32-byte is Y.\r | |
5938 | For P-384, the PublicSize is 96. First 48-byte is X, Second 48-byte is Y.\r | |
5939 | For P-521, the PublicSize is 132. First 66-byte is X, Second 66-byte is Y.\r | |
5940 | @param[in, out] EcContext Pointer to EC context being set.\r | |
5941 | @param[out] PublicKey Pointer to t buffer to receive generated public X,Y.\r | |
5942 | @param[in, out] PublicKeySize On input, the size of Public buffer in bytes.\r | |
5943 | On output, the size of data returned in Public buffer in bytes.\r | |
5944 | @retval TRUE EC key component was retrieved successfully.\r | |
5945 | @retval FALSE Invalid EC key component.\r | |
5946 | **/\r | |
5947 | BOOLEAN\r | |
5948 | EFIAPI\r | |
5949 | CryptoServiceEcGetPubKey (\r | |
5950 | IN OUT VOID *EcContext,\r | |
5951 | OUT UINT8 *PublicKey,\r | |
5952 | IN OUT UINTN *PublicKeySize\r | |
5953 | )\r | |
5954 | {\r | |
5955 | return CALL_BASECRYPTLIB (Ec.Services.GetPubKey, EcGetPubKey, (EcContext, PublicKey, PublicKeySize), FALSE);\r | |
5956 | }\r | |
5957 | \r | |
5958 | /**\r | |
5959 | Computes exchanged common key.\r | |
5960 | Given peer's public key (X, Y), this function computes the exchanged common key,\r | |
5961 | based on its own context including value of curve parameter and random secret.\r | |
5962 | X is the first half of PeerPublic with size being PeerPublicSize / 2,\r | |
5963 | Y is the second half of PeerPublic with size being PeerPublicSize / 2.\r | |
5964 | If EcContext is NULL, then return FALSE.\r | |
5965 | If PeerPublic is NULL, then return FALSE.\r | |
5966 | If PeerPublicSize is 0, then return FALSE.\r | |
5967 | If Key is NULL, then return FALSE.\r | |
5968 | If KeySize is not large enough, then return FALSE.\r | |
5969 | For P-256, the PeerPublicSize is 64. First 32-byte is X, Second 32-byte is Y.\r | |
5970 | For P-384, the PeerPublicSize is 96. First 48-byte is X, Second 48-byte is Y.\r | |
5971 | For P-521, the PeerPublicSize is 132. First 66-byte is X, Second 66-byte is Y.\r | |
5972 | @param[in, out] EcContext Pointer to the EC context.\r | |
5973 | @param[in] PeerPublic Pointer to the peer's public X,Y.\r | |
5974 | @param[in] PeerPublicSize Size of peer's public X,Y in bytes.\r | |
5975 | @param[in] CompressFlag Flag of PeerPublic is compressed or not.\r | |
5976 | @param[out] Key Pointer to the buffer to receive generated key.\r | |
5977 | @param[in, out] KeySize On input, the size of Key buffer in bytes.\r | |
5978 | On output, the size of data returned in Key buffer in bytes.\r | |
5979 | @retval TRUE EC exchanged key generation succeeded.\r | |
5980 | @retval FALSE EC exchanged key generation failed.\r | |
5981 | @retval FALSE KeySize is not large enough.\r | |
5982 | **/\r | |
5983 | BOOLEAN\r | |
5984 | EFIAPI\r | |
5985 | CryptoServiceEcDhComputeKey (\r | |
5986 | IN OUT VOID *EcContext,\r | |
5987 | IN CONST UINT8 *PeerPublic,\r | |
5988 | IN UINTN PeerPublicSize,\r | |
5989 | IN CONST INT32 *CompressFlag,\r | |
5990 | OUT UINT8 *Key,\r | |
5991 | IN OUT UINTN *KeySize\r | |
5992 | )\r | |
5993 | {\r | |
5994 | return CALL_BASECRYPTLIB (Ec.Services.DhComputeKey, EcDhComputeKey, (EcContext, PeerPublic, PeerPublicSize, CompressFlag, Key, KeySize), FALSE);\r | |
5995 | }\r | |
5996 | \r | |
7c342378 | 5997 | const EDKII_CRYPTO_PROTOCOL mEdkiiCrypto = {\r |
cc1d13c9 MK |
5998 | /// Version\r |
5999 | CryptoServiceGetCryptoVersion,\r | |
b6174e2d ZG |
6000 | /// HMAC MD5 - deprecated and unsupported\r |
6001 | DeprecatedCryptoServiceHmacMd5New,\r | |
6002 | DeprecatedCryptoServiceHmacMd5Free,\r | |
6003 | DeprecatedCryptoServiceHmacMd5SetKey,\r | |
6004 | DeprecatedCryptoServiceHmacMd5Duplicate,\r | |
6005 | DeprecatedCryptoServiceHmacMd5Update,\r | |
6006 | DeprecatedCryptoServiceHmacMd5Final,\r | |
c812d320 ZG |
6007 | /// HMAC SHA1 - deprecated and unsupported\r |
6008 | DeprecatedCryptoServiceHmacSha1New,\r | |
6009 | DeprecatedCryptoServiceHmacSha1Free,\r | |
6010 | DeprecatedCryptoServiceHmacSha1SetKey,\r | |
6011 | DeprecatedCryptoServiceHmacSha1Duplicate,\r | |
6012 | DeprecatedCryptoServiceHmacSha1Update,\r | |
6013 | DeprecatedCryptoServiceHmacSha1Final,\r | |
cc1d13c9 MK |
6014 | /// HMAC SHA256\r |
6015 | CryptoServiceHmacSha256New,\r | |
6016 | CryptoServiceHmacSha256Free,\r | |
6017 | CryptoServiceHmacSha256SetKey,\r | |
6018 | CryptoServiceHmacSha256Duplicate,\r | |
6019 | CryptoServiceHmacSha256Update,\r | |
6020 | CryptoServiceHmacSha256Final,\r | |
0a6fc3d0 ZG |
6021 | /// Md4 - deprecated and unsupported\r |
6022 | DeprecatedCryptoServiceMd4GetContextSize,\r | |
6023 | DeprecatedCryptoServiceMd4Init,\r | |
6024 | DeprecatedCryptoServiceMd4Duplicate,\r | |
6025 | DeprecatedCryptoServiceMd4Update,\r | |
6026 | DeprecatedCryptoServiceMd4Final,\r | |
6027 | DeprecatedCryptoServiceMd4HashAll,\r | |
7c342378 | 6028 | #ifndef ENABLE_MD5_DEPRECATED_INTERFACES\r |
acfd5557 ZG |
6029 | /// Md5 - deprecated and unsupported\r |
6030 | DeprecatedCryptoServiceMd5GetContextSize,\r | |
6031 | DeprecatedCryptoServiceMd5Init,\r | |
6032 | DeprecatedCryptoServiceMd5Duplicate,\r | |
6033 | DeprecatedCryptoServiceMd5Update,\r | |
6034 | DeprecatedCryptoServiceMd5Final,\r | |
6035 | DeprecatedCryptoServiceMd5HashAll,\r | |
7c342378 | 6036 | #else\r |
cc1d13c9 MK |
6037 | /// Md5\r |
6038 | CryptoServiceMd5GetContextSize,\r | |
6039 | CryptoServiceMd5Init,\r | |
6040 | CryptoServiceMd5Duplicate,\r | |
6041 | CryptoServiceMd5Update,\r | |
6042 | CryptoServiceMd5Final,\r | |
6043 | CryptoServiceMd5HashAll,\r | |
7c342378 | 6044 | #endif\r |
cc1d13c9 MK |
6045 | /// Pkcs\r |
6046 | CryptoServicePkcs1v2Encrypt,\r | |
6047 | CryptoServicePkcs5HashPassword,\r | |
6048 | CryptoServicePkcs7Verify,\r | |
6049 | CryptoServiceVerifyEKUsInPkcs7Signature,\r | |
6050 | CryptoServicePkcs7GetSigners,\r | |
6051 | CryptoServicePkcs7FreeSigners,\r | |
6052 | CryptoServicePkcs7Sign,\r | |
6053 | CryptoServicePkcs7GetAttachedContent,\r | |
6054 | CryptoServicePkcs7GetCertificatesList,\r | |
6055 | CryptoServiceAuthenticodeVerify,\r | |
6056 | CryptoServiceImageTimestampVerify,\r | |
6057 | /// DH\r | |
6058 | CryptoServiceDhNew,\r | |
6059 | CryptoServiceDhFree,\r | |
6060 | CryptoServiceDhGenerateParameter,\r | |
6061 | CryptoServiceDhSetParameter,\r | |
6062 | CryptoServiceDhGenerateKey,\r | |
6063 | CryptoServiceDhComputeKey,\r | |
6064 | /// Random\r | |
6065 | CryptoServiceRandomSeed,\r | |
6066 | CryptoServiceRandomBytes,\r | |
6067 | /// RSA\r | |
6068 | CryptoServiceRsaPkcs1Verify,\r | |
6069 | CryptoServiceRsaNew,\r | |
6070 | CryptoServiceRsaFree,\r | |
6071 | CryptoServiceRsaSetKey,\r | |
6072 | CryptoServiceRsaGetKey,\r | |
6073 | CryptoServiceRsaGenerateKey,\r | |
6074 | CryptoServiceRsaCheckKey,\r | |
6075 | CryptoServiceRsaPkcs1Sign,\r | |
6076 | CryptoServiceRsaPkcs1Verify,\r | |
6077 | CryptoServiceRsaGetPrivateKeyFromPem,\r | |
6078 | CryptoServiceRsaGetPublicKeyFromX509,\r | |
7c342378 | 6079 | #ifdef DISABLE_SHA1_DEPRECATED_INTERFACES\r |
0f01cec5 ZG |
6080 | /// Sha1 - deprecated and unsupported\r |
6081 | DeprecatedCryptoServiceSha1GetContextSize,\r | |
6082 | DeprecatedCryptoServiceSha1Init,\r | |
6083 | DeprecatedCryptoServiceSha1Duplicate,\r | |
6084 | DeprecatedCryptoServiceSha1Update,\r | |
6085 | DeprecatedCryptoServiceSha1Final,\r | |
6086 | DeprecatedCryptoServiceSha1HashAll,\r | |
7c342378 | 6087 | #else\r |
cc1d13c9 MK |
6088 | /// Sha1\r |
6089 | CryptoServiceSha1GetContextSize,\r | |
6090 | CryptoServiceSha1Init,\r | |
6091 | CryptoServiceSha1Duplicate,\r | |
6092 | CryptoServiceSha1Update,\r | |
6093 | CryptoServiceSha1Final,\r | |
6094 | CryptoServiceSha1HashAll,\r | |
7c342378 | 6095 | #endif\r |
cc1d13c9 MK |
6096 | /// Sha256\r |
6097 | CryptoServiceSha256GetContextSize,\r | |
6098 | CryptoServiceSha256Init,\r | |
6099 | CryptoServiceSha256Duplicate,\r | |
6100 | CryptoServiceSha256Update,\r | |
6101 | CryptoServiceSha256Final,\r | |
6102 | CryptoServiceSha256HashAll,\r | |
6103 | /// Sha384\r | |
6104 | CryptoServiceSha384GetContextSize,\r | |
6105 | CryptoServiceSha384Init,\r | |
6106 | CryptoServiceSha384Duplicate,\r | |
6107 | CryptoServiceSha384Update,\r | |
6108 | CryptoServiceSha384Final,\r | |
6109 | CryptoServiceSha384HashAll,\r | |
6110 | /// Sha512\r | |
6111 | CryptoServiceSha512GetContextSize,\r | |
6112 | CryptoServiceSha512Init,\r | |
6113 | CryptoServiceSha512Duplicate,\r | |
6114 | CryptoServiceSha512Update,\r | |
6115 | CryptoServiceSha512Final,\r | |
6116 | CryptoServiceSha512HashAll,\r | |
6117 | /// X509\r | |
6118 | CryptoServiceX509GetSubjectName,\r | |
6119 | CryptoServiceX509GetCommonName,\r | |
6120 | CryptoServiceX509GetOrganizationName,\r | |
6121 | CryptoServiceX509VerifyCert,\r | |
6122 | CryptoServiceX509ConstructCertificate,\r | |
6123 | CryptoServiceX509ConstructCertificateStack,\r | |
6124 | CryptoServiceX509Free,\r | |
6125 | CryptoServiceX509StackFree,\r | |
6126 | CryptoServiceX509GetTBSCert,\r | |
b8af2c9e ZG |
6127 | /// TDES - deprecated and unsupported\r |
6128 | DeprecatedCryptoServiceTdesGetContextSize,\r | |
6129 | DeprecatedCryptoServiceTdesInit,\r | |
6130 | DeprecatedCryptoServiceTdesEcbEncrypt,\r | |
6131 | DeprecatedCryptoServiceTdesEcbDecrypt,\r | |
6132 | DeprecatedCryptoServiceTdesCbcEncrypt,\r | |
6133 | DeprecatedCryptoServiceTdesCbcDecrypt,\r | |
80e28dce | 6134 | /// AES - ECB mode is deprecated and unsupported\r |
cc1d13c9 MK |
6135 | CryptoServiceAesGetContextSize,\r |
6136 | CryptoServiceAesInit,\r | |
80e28dce ZG |
6137 | DeprecatedCryptoServiceAesEcbEncrypt,\r |
6138 | DeprecatedCryptoServiceAesEcbDecrypt,\r | |
cc1d13c9 MK |
6139 | CryptoServiceAesCbcEncrypt,\r |
6140 | CryptoServiceAesCbcDecrypt,\r | |
c22a32e1 ZG |
6141 | /// Arc4 - deprecated and unsupported\r |
6142 | DeprecatedCryptoServiceArc4GetContextSize,\r | |
6143 | DeprecatedCryptoServiceArc4Init,\r | |
6144 | DeprecatedCryptoServiceArc4Encrypt,\r | |
6145 | DeprecatedCryptoServiceArc4Decrypt,\r | |
6146 | DeprecatedCryptoServiceArc4Reset,\r | |
cc1d13c9 MK |
6147 | /// SM3\r |
6148 | CryptoServiceSm3GetContextSize,\r | |
6149 | CryptoServiceSm3Init,\r | |
6150 | CryptoServiceSm3Duplicate,\r | |
6151 | CryptoServiceSm3Update,\r | |
6152 | CryptoServiceSm3Final,\r | |
6153 | CryptoServiceSm3HashAll,\r | |
6154 | /// HKDF\r | |
6155 | CryptoServiceHkdfSha256ExtractAndExpand,\r | |
6156 | /// X509 (Continued)\r | |
6157 | CryptoServiceX509ConstructCertificateStackV,\r | |
6158 | /// TLS\r | |
6159 | CryptoServiceTlsInitialize,\r | |
6160 | CryptoServiceTlsCtxFree,\r | |
6161 | CryptoServiceTlsCtxNew,\r | |
6162 | CryptoServiceTlsFree,\r | |
6163 | CryptoServiceTlsNew,\r | |
6164 | CryptoServiceTlsInHandshake,\r | |
6165 | CryptoServiceTlsDoHandshake,\r | |
6166 | CryptoServiceTlsHandleAlert,\r | |
6167 | CryptoServiceTlsCloseNotify,\r | |
6168 | CryptoServiceTlsCtrlTrafficOut,\r | |
6169 | CryptoServiceTlsCtrlTrafficIn,\r | |
6170 | CryptoServiceTlsRead,\r | |
6171 | CryptoServiceTlsWrite,\r | |
6172 | /// TLS Set\r | |
6173 | CryptoServiceTlsSetVersion,\r | |
6174 | CryptoServiceTlsSetConnectionEnd,\r | |
6175 | CryptoServiceTlsSetCipherList,\r | |
6176 | CryptoServiceTlsSetCompressionMethod,\r | |
6177 | CryptoServiceTlsSetVerify,\r | |
6178 | CryptoServiceTlsSetVerifyHost,\r | |
6179 | CryptoServiceTlsSetSessionId,\r | |
6180 | CryptoServiceTlsSetCaCertificate,\r | |
6181 | CryptoServiceTlsSetHostPublicCert,\r | |
6182 | CryptoServiceTlsSetHostPrivateKey,\r | |
6183 | CryptoServiceTlsSetCertRevocationList,\r | |
6184 | /// TLS Get\r | |
6185 | CryptoServiceTlsGetVersion,\r | |
6186 | CryptoServiceTlsGetConnectionEnd,\r | |
6187 | CryptoServiceTlsGetCurrentCipher,\r | |
6188 | CryptoServiceTlsGetCurrentCompressionId,\r | |
6189 | CryptoServiceTlsGetVerify,\r | |
6190 | CryptoServiceTlsGetSessionId,\r | |
6191 | CryptoServiceTlsGetClientRandom,\r | |
6192 | CryptoServiceTlsGetServerRandom,\r | |
6193 | CryptoServiceTlsGetKeyMaterial,\r | |
6194 | CryptoServiceTlsGetCaCertificate,\r | |
6195 | CryptoServiceTlsGetHostPublicCert,\r | |
6196 | CryptoServiceTlsGetHostPrivateKey,\r | |
c1e66210 ZL |
6197 | CryptoServiceTlsGetCertRevocationList,\r |
6198 | /// RSA PSS\r | |
6199 | CryptoServiceRsaPssSign,\r | |
6200 | CryptoServiceRsaPssVerify,\r | |
6201 | /// Parallel hash\r | |
3f77ccb9 QZ |
6202 | CryptoServiceParallelHash256HashAll,\r |
6203 | /// HMAC SHA256 (continued)\r | |
6204 | CryptoServiceHmacSha256All,\r | |
6205 | /// HMAC SHA384\r | |
6206 | CryptoServiceHmacSha384New,\r | |
6207 | CryptoServiceHmacSha384Free,\r | |
6208 | CryptoServiceHmacSha384SetKey,\r | |
6209 | CryptoServiceHmacSha384Duplicate,\r | |
6210 | CryptoServiceHmacSha384Update,\r | |
6211 | CryptoServiceHmacSha384Final,\r | |
e919c390 QZ |
6212 | CryptoServiceHmacSha384All,\r |
6213 | /// HKDF (continued)\r | |
6214 | CryptoServiceHkdfSha256Extract,\r | |
6215 | CryptoServiceHkdfSha256Expand,\r | |
6216 | CryptoServiceHkdfSha384ExtractAndExpand,\r | |
6217 | CryptoServiceHkdfSha384Extract,\r | |
022787f8 QZ |
6218 | CryptoServiceHkdfSha384Expand,\r |
6219 | /// Aead Aes GCM\r | |
6220 | CryptoServiceAeadAesGcmEncrypt,\r | |
42951543 YL |
6221 | CryptoServiceAeadAesGcmDecrypt,\r |
6222 | /// Big Numbers\r | |
6223 | CryptoServiceBigNumInit,\r | |
6224 | CryptoServiceBigNumFromBin,\r | |
6225 | CryptoServiceBigNumToBin,\r | |
6226 | CryptoServiceBigNumFree,\r | |
6227 | CryptoServiceBigNumAdd,\r | |
6228 | CryptoServiceBigNumSub,\r | |
6229 | CryptoServiceBigNumMod,\r | |
6230 | CryptoServiceBigNumExpMod,\r | |
6231 | CryptoServiceBigNumInverseMod,\r | |
6232 | CryptoServiceBigNumDiv,\r | |
6233 | CryptoServiceBigNumMulMod,\r | |
6234 | CryptoServiceBigNumCmp,\r | |
6235 | CryptoServiceBigNumBits,\r | |
6236 | CryptoServiceBigNumBytes,\r | |
6237 | CryptoServiceBigNumIsWord,\r | |
6238 | CryptoServiceBigNumIsOdd,\r | |
6239 | CryptoServiceBigNumCopy,\r | |
6240 | CryptoServiceBigNumValueOne,\r | |
6241 | CryptoServiceBigNumRShift,\r | |
6242 | CryptoServiceBigNumConstTime,\r | |
6243 | CryptoServiceBigNumSqrMod,\r | |
6244 | CryptoServiceBigNumNewContext,\r | |
6245 | CryptoServiceBigNumContextFree,\r | |
6246 | CryptoServiceBigNumSetUint,\r | |
6247 | CryptoServiceBigNumAddMod,\r | |
3b382f5b YL |
6248 | /// EC\r |
6249 | CryptoServiceEcGroupInit,\r | |
6250 | CryptoServiceEcGroupGetCurve,\r | |
6251 | CryptoServiceEcGroupGetOrder,\r | |
6252 | CryptoServiceEcGroupFree,\r | |
6253 | CryptoServiceEcPointInit,\r | |
6254 | CryptoServiceEcPointDeInit,\r | |
6255 | CryptoServiceEcPointGetAffineCoordinates,\r | |
6256 | CryptoServiceEcPointSetAffineCoordinates,\r | |
6257 | CryptoServiceEcPointAdd,\r | |
6258 | CryptoServiceEcPointMul,\r | |
6259 | CryptoServiceEcPointInvert,\r | |
6260 | CryptoServiceEcPointIsOnCurve,\r | |
6261 | CryptoServiceEcPointIsAtInfinity,\r | |
6262 | CryptoServiceEcPointEqual,\r | |
6263 | CryptoServiceEcPointSetCompressedCoordinates,\r | |
6264 | CryptoServiceEcNewByNid,\r | |
6265 | CryptoServiceEcFree,\r | |
6266 | CryptoServiceEcGenerateKey,\r | |
6267 | CryptoServiceEcGetPubKey,\r | |
6268 | CryptoServiceEcDhComputeKey,\r | |
cc1d13c9 | 6269 | };\r |