]>
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 | |
22745df6 QZ |
3089 | /**\r |
3090 | Retrieve the version from one X.509 certificate.\r | |
3091 | \r | |
3092 | If Cert is NULL, then return FALSE.\r | |
3093 | If CertSize is 0, then return FALSE.\r | |
3094 | If this interface is not supported, then return FALSE.\r | |
3095 | \r | |
3096 | @param[in] Cert Pointer to the DER-encoded X509 certificate.\r | |
3097 | @param[in] CertSize Size of the X509 certificate in bytes.\r | |
3098 | @param[out] Version Pointer to the retrieved version integer.\r | |
3099 | \r | |
3100 | @retval TRUE The certificate version retrieved successfully.\r | |
3101 | @retval FALSE If Cert is NULL or CertSize is Zero.\r | |
3102 | @retval FALSE The operation is not supported.\r | |
3103 | \r | |
3104 | **/\r | |
3105 | BOOLEAN\r | |
3106 | EFIAPI\r | |
3107 | CryptoServiceX509GetVersion (\r | |
3108 | IN CONST UINT8 *Cert,\r | |
3109 | IN UINTN CertSize,\r | |
3110 | OUT UINTN *Version\r | |
3111 | )\r | |
3112 | {\r | |
3113 | return CALL_BASECRYPTLIB (X509.Services.GetVersion, X509GetVersion, (Cert, CertSize, Version), FALSE);\r | |
3114 | }\r | |
3115 | \r | |
3116 | /**\r | |
3117 | Retrieve the serialNumber from one X.509 certificate.\r | |
3118 | \r | |
3119 | If Cert is NULL, then return FALSE.\r | |
3120 | If CertSize is 0, then return FALSE.\r | |
3121 | If this interface is not supported, then return FALSE.\r | |
3122 | \r | |
3123 | @param[in] Cert Pointer to the DER-encoded X509 certificate.\r | |
3124 | @param[in] CertSize Size of the X509 certificate in bytes.\r | |
3125 | @param[out] SerialNumber Pointer to the retrieved certificate SerialNumber bytes.\r | |
3126 | @param[in, out] SerialNumberSize The size in bytes of the SerialNumber buffer on input,\r | |
3127 | and the size of buffer returned SerialNumber on output.\r | |
3128 | \r | |
3129 | @retval TRUE The certificate serialNumber retrieved successfully.\r | |
3130 | @retval FALSE If Cert is NULL or CertSize is Zero.\r | |
3131 | If SerialNumberSize is NULL.\r | |
3132 | If Certificate is invalid.\r | |
3133 | @retval FALSE If no SerialNumber exists.\r | |
3134 | @retval FALSE If the SerialNumber is NULL. The required buffer size\r | |
3135 | (including the final null) is returned in the\r | |
3136 | SerialNumberSize parameter.\r | |
3137 | @retval FALSE The operation is not supported.\r | |
3138 | **/\r | |
3139 | BOOLEAN\r | |
3140 | EFIAPI\r | |
3141 | CryptoServiceX509GetSerialNumber (\r | |
3142 | IN CONST UINT8 *Cert,\r | |
3143 | IN UINTN CertSize,\r | |
3144 | OUT UINT8 *SerialNumber, OPTIONAL\r | |
3145 | IN OUT UINTN *SerialNumberSize\r | |
3146 | )\r | |
3147 | {\r | |
3148 | return CALL_BASECRYPTLIB (X509.Services.GetSerialNumber, X509GetSerialNumber, (Cert, CertSize, SerialNumber, SerialNumberSize), FALSE);\r | |
3149 | }\r | |
3150 | \r | |
3151 | /**\r | |
3152 | Retrieve the issuer bytes from one X.509 certificate.\r | |
3153 | \r | |
3154 | If Cert is NULL, then return FALSE.\r | |
3155 | If CertIssuerSize is NULL, then return FALSE.\r | |
3156 | If this interface is not supported, then return FALSE.\r | |
3157 | \r | |
3158 | @param[in] Cert Pointer to the DER-encoded X509 certificate.\r | |
3159 | @param[in] CertSize Size of the X509 certificate in bytes.\r | |
3160 | @param[out] CertIssuer Pointer to the retrieved certificate subject bytes.\r | |
3161 | @param[in, out] CertIssuerSize The size in bytes of the CertIssuer buffer on input,\r | |
3162 | and the size of buffer returned CertSubject on output.\r | |
3163 | \r | |
3164 | @retval TRUE The certificate issuer retrieved successfully.\r | |
3165 | @retval FALSE Invalid certificate, or the CertIssuerSize is too small for the result.\r | |
3166 | The CertIssuerSize will be updated with the required size.\r | |
3167 | @retval FALSE This interface is not supported.\r | |
3168 | \r | |
3169 | **/\r | |
3170 | BOOLEAN\r | |
3171 | EFIAPI\r | |
3172 | CryptoServiceX509GetIssuerName (\r | |
3173 | IN CONST UINT8 *Cert,\r | |
3174 | IN UINTN CertSize,\r | |
3175 | OUT UINT8 *CertIssuer,\r | |
3176 | IN OUT UINTN *CertIssuerSize\r | |
3177 | )\r | |
3178 | {\r | |
3179 | return CALL_BASECRYPTLIB (X509.Services.GetIssuerName, X509GetIssuerName, (Cert, CertSize, CertIssuer, CertIssuerSize), FALSE);\r | |
3180 | }\r | |
3181 | \r | |
3182 | /**\r | |
3183 | Retrieve the Signature Algorithm from one X.509 certificate.\r | |
3184 | \r | |
3185 | @param[in] Cert Pointer to the DER-encoded X509 certificate.\r | |
3186 | @param[in] CertSize Size of the X509 certificate in bytes.\r | |
3187 | @param[out] Oid Signature Algorithm Object identifier buffer.\r | |
3188 | @param[in,out] OidSize Signature Algorithm Object identifier buffer size\r | |
3189 | \r | |
3190 | @retval TRUE The certificate Extension data retrieved successfully.\r | |
3191 | @retval FALSE If Cert is NULL.\r | |
3192 | If OidSize is NULL.\r | |
3193 | If Oid is not NULL and *OidSize is 0.\r | |
3194 | If Certificate is invalid.\r | |
3195 | @retval FALSE If no SignatureType.\r | |
3196 | @retval FALSE If the Oid is NULL. The required buffer size\r | |
3197 | is returned in the OidSize.\r | |
3198 | @retval FALSE The operation is not supported.\r | |
3199 | **/\r | |
3200 | BOOLEAN\r | |
3201 | EFIAPI\r | |
3202 | CryptoServiceX509GetSignatureAlgorithm (\r | |
3203 | IN CONST UINT8 *Cert,\r | |
3204 | IN UINTN CertSize,\r | |
3205 | OUT UINT8 *Oid, OPTIONAL\r | |
3206 | IN OUT UINTN *OidSize\r | |
3207 | )\r | |
3208 | {\r | |
3209 | return CALL_BASECRYPTLIB (X509.Services.GetSignatureAlgorithm, X509GetSignatureAlgorithm, (Cert, CertSize, Oid, OidSize), FALSE);\r | |
3210 | }\r | |
3211 | \r | |
3212 | /**\r | |
3213 | Retrieve Extension data from one X.509 certificate.\r | |
3214 | \r | |
3215 | @param[in] Cert Pointer to the DER-encoded X509 certificate.\r | |
3216 | @param[in] CertSize Size of the X509 certificate in bytes.\r | |
3217 | @param[in] Oid Object identifier buffer\r | |
3218 | @param[in] OidSize Object identifier buffer size\r | |
3219 | @param[out] ExtensionData Extension bytes.\r | |
3220 | @param[in, out] ExtensionDataSize Extension bytes size.\r | |
3221 | \r | |
3222 | @retval TRUE The certificate Extension data retrieved successfully.\r | |
3223 | @retval FALSE If Cert is NULL.\r | |
3224 | If ExtensionDataSize is NULL.\r | |
3225 | If ExtensionData is not NULL and *ExtensionDataSize is 0.\r | |
3226 | If Certificate is invalid.\r | |
3227 | @retval FALSE If no Extension entry match Oid.\r | |
3228 | @retval FALSE If the ExtensionData is NULL. The required buffer size\r | |
3229 | is returned in the ExtensionDataSize parameter.\r | |
3230 | @retval FALSE The operation is not supported.\r | |
3231 | **/\r | |
3232 | BOOLEAN\r | |
3233 | EFIAPI\r | |
3234 | CryptoServiceX509GetExtensionData (\r | |
3235 | IN CONST UINT8 *Cert,\r | |
3236 | IN UINTN CertSize,\r | |
3237 | IN CONST UINT8 *Oid,\r | |
3238 | IN UINTN OidSize,\r | |
3239 | OUT UINT8 *ExtensionData,\r | |
3240 | IN OUT UINTN *ExtensionDataSize\r | |
3241 | )\r | |
3242 | {\r | |
3243 | return CALL_BASECRYPTLIB (X509.Services.GetExtensionData, X509GetExtensionData, (Cert, CertSize, Oid, OidSize, ExtensionData, ExtensionDataSize), FALSE);\r | |
3244 | }\r | |
3245 | \r | |
3246 | /**\r | |
3247 | Retrieve the Extended Key Usage from one X.509 certificate.\r | |
3248 | \r | |
3249 | @param[in] Cert Pointer to the DER-encoded X509 certificate.\r | |
3250 | @param[in] CertSize Size of the X509 certificate in bytes.\r | |
3251 | @param[out] Usage Key Usage bytes.\r | |
3252 | @param[in, out] UsageSize Key Usage buffer sizs in bytes.\r | |
3253 | \r | |
3254 | @retval TRUE The Usage bytes retrieve successfully.\r | |
3255 | @retval FALSE If Cert is NULL.\r | |
3256 | If CertSize is NULL.\r | |
3257 | If Usage is not NULL and *UsageSize is 0.\r | |
3258 | If Cert is invalid.\r | |
3259 | @retval FALSE If the Usage is NULL. The required buffer size\r | |
3260 | is returned in the UsageSize parameter.\r | |
3261 | @retval FALSE The operation is not supported.\r | |
3262 | **/\r | |
3263 | BOOLEAN\r | |
3264 | EFIAPI\r | |
3265 | CryptoServiceX509GetExtendedKeyUsage (\r | |
3266 | IN CONST UINT8 *Cert,\r | |
3267 | IN UINTN CertSize,\r | |
3268 | OUT UINT8 *Usage,\r | |
3269 | IN OUT UINTN *UsageSize\r | |
3270 | )\r | |
3271 | {\r | |
3272 | return CALL_BASECRYPTLIB (X509.Services.GetExtendedKeyUsage, X509GetExtendedKeyUsage, (Cert, CertSize, Usage, UsageSize), FALSE);\r | |
3273 | }\r | |
3274 | \r | |
3275 | /**\r | |
3276 | Retrieve the Validity from one X.509 certificate\r | |
3277 | \r | |
3278 | If Cert is NULL, then return FALSE.\r | |
3279 | If CertIssuerSize is NULL, then return FALSE.\r | |
3280 | If this interface is not supported, then return FALSE.\r | |
3281 | \r | |
3282 | @param[in] Cert Pointer to the DER-encoded X509 certificate.\r | |
3283 | @param[in] CertSize Size of the X509 certificate in bytes.\r | |
3284 | @param[in] From notBefore Pointer to DateTime object.\r | |
3285 | @param[in,out] FromSize notBefore DateTime object size.\r | |
3286 | @param[in] To notAfter Pointer to DateTime object.\r | |
3287 | @param[in,out] ToSize notAfter DateTime object size.\r | |
3288 | \r | |
3289 | Note: X509CompareDateTime to compare DateTime oject\r | |
3290 | x509SetDateTime to get a DateTime object from a DateTimeStr\r | |
3291 | \r | |
3292 | @retval TRUE The certificate Validity retrieved successfully.\r | |
3293 | @retval FALSE Invalid certificate, or Validity retrieve failed.\r | |
3294 | @retval FALSE This interface is not supported.\r | |
3295 | **/\r | |
3296 | BOOLEAN\r | |
3297 | EFIAPI\r | |
3298 | CryptoServiceX509GetValidity (\r | |
3299 | IN CONST UINT8 *Cert,\r | |
3300 | IN UINTN CertSize,\r | |
3301 | IN UINT8 *From,\r | |
3302 | IN OUT UINTN *FromSize,\r | |
3303 | IN UINT8 *To,\r | |
3304 | IN OUT UINTN *ToSize\r | |
3305 | )\r | |
3306 | {\r | |
3307 | return CALL_BASECRYPTLIB (X509.Services.GetValidity, X509GetValidity, (Cert, CertSize, From, FromSize, To, ToSize), FALSE);\r | |
3308 | }\r | |
3309 | \r | |
3310 | /**\r | |
3311 | Format a DateTimeStr to DataTime object in DataTime Buffer\r | |
3312 | \r | |
3313 | If DateTimeStr is NULL, then return FALSE.\r | |
3314 | If DateTimeSize is NULL, then return FALSE.\r | |
3315 | If this interface is not supported, then return FALSE.\r | |
3316 | \r | |
3317 | @param[in] DateTimeStr DateTime string like YYYYMMDDhhmmssZ\r | |
3318 | Ref: https://www.w3.org/TR/NOTE-datetime\r | |
3319 | Z stand for UTC time\r | |
3320 | @param[out] DateTime Pointer to a DateTime object.\r | |
3321 | @param[in,out] DateTimeSize DateTime object buffer size.\r | |
3322 | \r | |
3323 | @retval TRUE The DateTime object create successfully.\r | |
3324 | @retval FALSE If DateTimeStr is NULL.\r | |
3325 | If DateTimeSize is NULL.\r | |
3326 | If DateTime is not NULL and *DateTimeSize is 0.\r | |
3327 | If Year Month Day Hour Minute Second combination is invalid datetime.\r | |
3328 | @retval FALSE If the DateTime is NULL. The required buffer size\r | |
3329 | (including the final null) is returned in the\r | |
3330 | DateTimeSize parameter.\r | |
3331 | @retval FALSE The operation is not supported.\r | |
3332 | **/\r | |
3333 | BOOLEAN\r | |
3334 | EFIAPI\r | |
3335 | CryptoServiceX509FormatDateTime (\r | |
3336 | IN CONST CHAR8 *DateTimeStr,\r | |
3337 | OUT VOID *DateTime,\r | |
3338 | IN OUT UINTN *DateTimeSize\r | |
3339 | )\r | |
3340 | {\r | |
3341 | return CALL_BASECRYPTLIB (X509.Services.FormatDateTime, X509FormatDateTime, (DateTimeStr, DateTime, DateTimeSize), FALSE);\r | |
3342 | }\r | |
3343 | \r | |
3344 | /**\r | |
3345 | Compare DateTime1 object and DateTime2 object.\r | |
3346 | \r | |
3347 | If DateTime1 is NULL, then return -2.\r | |
3348 | If DateTime2 is NULL, then return -2.\r | |
3349 | If DateTime1 == DateTime2, then return 0\r | |
3350 | If DateTime1 > DateTime2, then return 1\r | |
3351 | If DateTime1 < DateTime2, then return -1\r | |
3352 | \r | |
3353 | @param[in] DateTime1 Pointer to a DateTime Ojbect\r | |
3354 | @param[in] DateTime2 Pointer to a DateTime Object\r | |
3355 | \r | |
3356 | @retval 0 If DateTime1 == DateTime2\r | |
3357 | @retval 1 If DateTime1 > DateTime2\r | |
3358 | @retval -1 If DateTime1 < DateTime2\r | |
3359 | **/\r | |
3360 | INT32\r | |
3361 | EFIAPI\r | |
3362 | CryptoServiceX509CompareDateTime (\r | |
3363 | IN CONST VOID *DateTime1,\r | |
3364 | IN CONST VOID *DateTime2\r | |
3365 | )\r | |
3366 | {\r | |
3367 | return CALL_BASECRYPTLIB (X509.Services.CompareDateTime, X509CompareDateTime, (DateTime1, DateTime2), FALSE);\r | |
3368 | }\r | |
3369 | \r | |
3370 | /**\r | |
3371 | Retrieve the Key Usage from one X.509 certificate.\r | |
3372 | \r | |
3373 | @param[in] Cert Pointer to the DER-encoded X509 certificate.\r | |
3374 | @param[in] CertSize Size of the X509 certificate in bytes.\r | |
3375 | @param[out] Usage Key Usage (CRYPTO_X509_KU_*)\r | |
3376 | \r | |
3377 | @retval TRUE The certificate Key Usage retrieved successfully.\r | |
3378 | @retval FALSE Invalid certificate, or Usage is NULL\r | |
3379 | @retval FALSE This interface is not supported.\r | |
3380 | **/\r | |
3381 | BOOLEAN\r | |
3382 | EFIAPI\r | |
3383 | CryptoServiceX509GetKeyUsage (\r | |
3384 | IN CONST UINT8 *Cert,\r | |
3385 | IN UINTN CertSize,\r | |
3386 | OUT UINTN *Usage\r | |
3387 | )\r | |
3388 | {\r | |
3389 | return CALL_BASECRYPTLIB (X509.Services.GetKeyUsage, X509GetKeyUsage, (Cert, CertSize, Usage), FALSE);\r | |
3390 | }\r | |
3391 | \r | |
3392 | /**\r | |
3393 | Verify one X509 certificate was issued by the trusted CA.\r | |
3394 | @param[in] RootCert Trusted Root Certificate buffer\r | |
3395 | \r | |
3396 | @param[in] RootCertLength Trusted Root Certificate buffer length\r | |
3397 | @param[in] CertChain One or more ASN.1 DER-encoded X.509 certificates\r | |
3398 | where the first certificate is signed by the Root\r | |
3399 | Certificate or is the Root Cerificate itself. and\r | |
3400 | subsequent cerificate is signed by the preceding\r | |
3401 | cerificate.\r | |
3402 | @param[in] CertChainLength Total length of the certificate chain, in bytes.\r | |
3403 | \r | |
3404 | @retval TRUE All cerificates was issued by the first certificate in X509Certchain.\r | |
3405 | @retval FALSE Invalid certificate or the certificate was not issued by the given\r | |
3406 | trusted CA.\r | |
3407 | **/\r | |
3408 | BOOLEAN\r | |
3409 | EFIAPI\r | |
3410 | CryptoServiceX509VerifyCertChain (\r | |
3411 | IN CONST UINT8 *RootCert,\r | |
3412 | IN UINTN RootCertLength,\r | |
3413 | IN CONST UINT8 *CertChain,\r | |
3414 | IN UINTN CertChainLength\r | |
3415 | )\r | |
3416 | {\r | |
3417 | return CALL_BASECRYPTLIB (X509.Services.VerifyCertChain, X509VerifyCertChain, (RootCert, RootCertLength, CertChain, CertChainLength), FALSE);\r | |
3418 | }\r | |
3419 | \r | |
3420 | /**\r | |
3421 | Get one X509 certificate from CertChain.\r | |
3422 | \r | |
3423 | @param[in] CertChain One or more ASN.1 DER-encoded X.509 certificates\r | |
3424 | where the first certificate is signed by the Root\r | |
3425 | Certificate or is the Root Cerificate itself. and\r | |
3426 | subsequent cerificate is signed by the preceding\r | |
3427 | cerificate.\r | |
3428 | @param[in] CertChainLength Total length of the certificate chain, in bytes.\r | |
3429 | \r | |
3430 | @param[in] CertIndex Index of certificate.\r | |
3431 | \r | |
3432 | @param[out] Cert The certificate at the index of CertChain.\r | |
3433 | @param[out] CertLength The length certificate at the index of CertChain.\r | |
3434 | \r | |
3435 | @retval TRUE Success.\r | |
3436 | @retval FALSE Failed to get certificate from certificate chain.\r | |
3437 | **/\r | |
3438 | BOOLEAN\r | |
3439 | EFIAPI\r | |
3440 | CryptoServiceX509GetCertFromCertChain (\r | |
3441 | IN CONST UINT8 *CertChain,\r | |
3442 | IN UINTN CertChainLength,\r | |
3443 | IN CONST INT32 CertIndex,\r | |
3444 | OUT CONST UINT8 **Cert,\r | |
3445 | OUT UINTN *CertLength\r | |
3446 | )\r | |
3447 | {\r | |
3448 | return CALL_BASECRYPTLIB (X509.Services.GetCertFromCertChain, X509GetCertFromCertChain, (CertChain, CertChainLength, CertIndex, Cert, CertLength), FALSE);\r | |
3449 | }\r | |
3450 | \r | |
3451 | /**\r | |
3452 | Retrieve the tag and length of the tag.\r | |
3453 | \r | |
3454 | @param Ptr The position in the ASN.1 data\r | |
3455 | @param End End of data\r | |
3456 | @param Length The variable that will receive the length\r | |
3457 | @param Tag The expected tag\r | |
3458 | \r | |
3459 | @retval TRUE Get tag successful\r | |
3460 | @retval FALSe Failed to get tag or tag not match\r | |
3461 | **/\r | |
3462 | BOOLEAN\r | |
3463 | EFIAPI\r | |
3464 | CryptoServiceAsn1GetTag (\r | |
3465 | IN OUT UINT8 **Ptr,\r | |
3466 | IN CONST UINT8 *End,\r | |
3467 | OUT UINTN *Length,\r | |
3468 | IN UINT32 Tag\r | |
3469 | )\r | |
3470 | {\r | |
3471 | return CALL_BASECRYPTLIB (X509.Services.Asn1GetTag, Asn1GetTag, (Ptr, End, Length, Tag), FALSE);\r | |
3472 | }\r | |
3473 | \r | |
3474 | /**\r | |
3475 | Retrieve the basic constraints from one X.509 certificate.\r | |
3476 | \r | |
3477 | @param[in] Cert Pointer to the DER-encoded X509 certificate.\r | |
3478 | @param[in] CertSize size of the X509 certificate in bytes.\r | |
3479 | @param[out] BasicConstraints basic constraints bytes.\r | |
3480 | @param[in, out] BasicConstraintsSize basic constraints buffer sizs in bytes.\r | |
3481 | \r | |
3482 | @retval TRUE The basic constraints retrieve successfully.\r | |
3483 | @retval FALSE If cert is NULL.\r | |
3484 | If cert_size is NULL.\r | |
3485 | If basic_constraints is not NULL and *basic_constraints_size is 0.\r | |
3486 | If cert is invalid.\r | |
3487 | @retval FALSE The required buffer size is small.\r | |
3488 | The return buffer size is basic_constraints_size parameter.\r | |
3489 | @retval FALSE If no Extension entry match oid.\r | |
3490 | @retval FALSE The operation is not supported.\r | |
3491 | **/\r | |
3492 | BOOLEAN\r | |
3493 | EFIAPI\r | |
3494 | CryptoServiceX509GetExtendedBasicConstraints (\r | |
3495 | CONST UINT8 *Cert,\r | |
3496 | UINTN CertSize,\r | |
3497 | UINT8 *BasicConstraints,\r | |
3498 | UINTN *BasicConstraintsSize\r | |
3499 | )\r | |
3500 | {\r | |
3501 | return CALL_BASECRYPTLIB (X509.Services.GetExtendedBasicConstraints, X509GetExtendedBasicConstraints, (Cert, CertSize, BasicConstraints, BasicConstraintsSize), FALSE);\r | |
3502 | }\r | |
3503 | \r | |
cc1d13c9 MK |
3504 | /**\r |
3505 | Derives a key from a password using a salt and iteration count, based on PKCS#5 v2.0\r | |
3506 | password based encryption key derivation function PBKDF2, as specified in RFC 2898.\r | |
3507 | \r | |
3508 | If Password or Salt or OutKey is NULL, then return FALSE.\r | |
3509 | If the hash algorithm could not be determined, then return FALSE.\r | |
3510 | If this interface is not supported, then return FALSE.\r | |
3511 | \r | |
3512 | @param[in] PasswordLength Length of input password in bytes.\r | |
3513 | @param[in] Password Pointer to the array for the password.\r | |
3514 | @param[in] SaltLength Size of the Salt in bytes.\r | |
3515 | @param[in] Salt Pointer to the Salt.\r | |
3516 | @param[in] IterationCount Number of iterations to perform. Its value should be\r | |
3517 | greater than or equal to 1.\r | |
3518 | @param[in] DigestSize Size of the message digest to be used (eg. SHA256_DIGEST_SIZE).\r | |
3519 | NOTE: DigestSize will be used to determine the hash algorithm.\r | |
3520 | Only SHA1_DIGEST_SIZE or SHA256_DIGEST_SIZE is supported.\r | |
3521 | @param[in] KeyLength Size of the derived key buffer in bytes.\r | |
3522 | @param[out] OutKey Pointer to the output derived key buffer.\r | |
3523 | \r | |
3524 | @retval TRUE A key was derived successfully.\r | |
3525 | @retval FALSE One of the pointers was NULL or one of the sizes was too large.\r | |
3526 | @retval FALSE The hash algorithm could not be determined from the digest size.\r | |
3527 | @retval FALSE The key derivation operation failed.\r | |
3528 | @retval FALSE This interface is not supported.\r | |
3529 | \r | |
3530 | **/\r | |
3531 | BOOLEAN\r | |
3532 | EFIAPI\r | |
3533 | CryptoServicePkcs5HashPassword (\r | |
3534 | IN UINTN PasswordLength,\r | |
3535 | IN CONST CHAR8 *Password,\r | |
3536 | IN UINTN SaltLength,\r | |
3537 | IN CONST UINT8 *Salt,\r | |
3538 | IN UINTN IterationCount,\r | |
3539 | IN UINTN DigestSize,\r | |
3540 | IN UINTN KeyLength,\r | |
3541 | OUT UINT8 *OutKey\r | |
3542 | )\r | |
3543 | {\r | |
3544 | return CALL_BASECRYPTLIB (Pkcs.Services.Pkcs5HashPassword, Pkcs5HashPassword, (PasswordLength, Password, SaltLength, Salt, IterationCount, DigestSize, KeyLength, OutKey), FALSE);\r | |
3545 | }\r | |
3546 | \r | |
3547 | /**\r | |
3548 | Encrypts a blob using PKCS1v2 (RSAES-OAEP) schema. On success, will return the\r | |
3549 | encrypted message in a newly allocated buffer.\r | |
3550 | \r | |
3551 | Things that can cause a failure include:\r | |
3552 | - X509 key size does not match any known key size.\r | |
3553 | - Fail to parse X509 certificate.\r | |
3554 | - Fail to allocate an intermediate buffer.\r | |
3555 | - Null pointer provided for a non-optional parameter.\r | |
3556 | - Data size is too large for the provided key size (max size is a function of key size\r | |
3557 | and hash digest size).\r | |
3558 | \r | |
3559 | @param[in] PublicKey A pointer to the DER-encoded X509 certificate that\r | |
3560 | will be used to encrypt the data.\r | |
3561 | @param[in] PublicKeySize Size of the X509 cert buffer.\r | |
3562 | @param[in] InData Data to be encrypted.\r | |
3563 | @param[in] InDataSize Size of the data buffer.\r | |
3564 | @param[in] PrngSeed [Optional] If provided, a pointer to a random seed buffer\r | |
3565 | to be used when initializing the PRNG. NULL otherwise.\r | |
3566 | @param[in] PrngSeedSize [Optional] If provided, size of the random seed buffer.\r | |
3567 | 0 otherwise.\r | |
3568 | @param[out] EncryptedData Pointer to an allocated buffer containing the encrypted\r | |
3569 | message.\r | |
3570 | @param[out] EncryptedDataSize Size of the encrypted message buffer.\r | |
3571 | \r | |
3572 | @retval TRUE Encryption was successful.\r | |
3573 | @retval FALSE Encryption failed.\r | |
3574 | \r | |
3575 | **/\r | |
3576 | BOOLEAN\r | |
3577 | EFIAPI\r | |
3578 | CryptoServicePkcs1v2Encrypt (\r | |
3579 | IN CONST UINT8 *PublicKey,\r | |
3580 | IN UINTN PublicKeySize,\r | |
3581 | IN UINT8 *InData,\r | |
3582 | IN UINTN InDataSize,\r | |
c8f46130 MK |
3583 | IN CONST UINT8 *PrngSeed OPTIONAL,\r |
3584 | IN UINTN PrngSeedSize OPTIONAL,\r | |
cc1d13c9 MK |
3585 | OUT UINT8 **EncryptedData,\r |
3586 | OUT UINTN *EncryptedDataSize\r | |
3587 | )\r | |
3588 | {\r | |
3589 | return CALL_BASECRYPTLIB (Pkcs.Services.Pkcs1v2Encrypt, Pkcs1v2Encrypt, (PublicKey, PublicKeySize, InData, InDataSize, PrngSeed, PrngSeedSize, EncryptedData, EncryptedDataSize), FALSE);\r | |
3590 | }\r | |
3591 | \r | |
3592 | /**\r | |
3593 | Get the signer's certificates from PKCS#7 signed data as described in "PKCS #7:\r | |
3594 | Cryptographic Message Syntax Standard". The input signed data could be wrapped\r | |
3595 | in a ContentInfo structure.\r | |
3596 | \r | |
3597 | If P7Data, CertStack, StackLength, TrustedCert or CertLength is NULL, then\r | |
3598 | return FALSE. If P7Length overflow, then return FALSE.\r | |
3599 | If this interface is not supported, then return FALSE.\r | |
3600 | \r | |
3601 | @param[in] P7Data Pointer to the PKCS#7 message to verify.\r | |
3602 | @param[in] P7Length Length of the PKCS#7 message in bytes.\r | |
3603 | @param[out] CertStack Pointer to Signer's certificates retrieved from P7Data.\r | |
3604 | It's caller's responsibility to free the buffer with\r | |
3605 | Pkcs7FreeSigners().\r | |
3606 | This data structure is EFI_CERT_STACK type.\r | |
3607 | @param[out] StackLength Length of signer's certificates in bytes.\r | |
3608 | @param[out] TrustedCert Pointer to a trusted certificate from Signer's certificates.\r | |
3609 | It's caller's responsibility to free the buffer with\r | |
3610 | Pkcs7FreeSigners().\r | |
3611 | @param[out] CertLength Length of the trusted certificate in bytes.\r | |
3612 | \r | |
3613 | @retval TRUE The operation is finished successfully.\r | |
3614 | @retval FALSE Error occurs during the operation.\r | |
3615 | @retval FALSE This interface is not supported.\r | |
3616 | \r | |
3617 | **/\r | |
3618 | BOOLEAN\r | |
3619 | EFIAPI\r | |
3620 | CryptoServicePkcs7GetSigners (\r | |
3621 | IN CONST UINT8 *P7Data,\r | |
3622 | IN UINTN P7Length,\r | |
3623 | OUT UINT8 **CertStack,\r | |
3624 | OUT UINTN *StackLength,\r | |
3625 | OUT UINT8 **TrustedCert,\r | |
3626 | OUT UINTN *CertLength\r | |
3627 | )\r | |
3628 | {\r | |
3629 | return CALL_BASECRYPTLIB (Pkcs.Services.Pkcs7GetSigners, Pkcs7GetSigners, (P7Data, P7Length, CertStack, StackLength, TrustedCert, CertLength), FALSE);\r | |
3630 | }\r | |
3631 | \r | |
3632 | /**\r | |
3633 | Wrap function to use free() to free allocated memory for certificates.\r | |
3634 | \r | |
3635 | If this interface is not supported, then ASSERT().\r | |
3636 | \r | |
3637 | @param[in] Certs Pointer to the certificates to be freed.\r | |
3638 | \r | |
3639 | **/\r | |
3640 | VOID\r | |
3641 | EFIAPI\r | |
3642 | CryptoServicePkcs7FreeSigners (\r | |
7c342378 | 3643 | IN UINT8 *Certs\r |
cc1d13c9 MK |
3644 | )\r |
3645 | {\r | |
3646 | CALL_VOID_BASECRYPTLIB (Pkcs.Services.Pkcs7FreeSigners, Pkcs7FreeSigners, (Certs));\r | |
3647 | }\r | |
3648 | \r | |
3649 | /**\r | |
3650 | Retrieves all embedded certificates from PKCS#7 signed data as described in "PKCS #7:\r | |
3651 | Cryptographic Message Syntax Standard", and outputs two certificate lists chained and\r | |
3652 | unchained to the signer's certificates.\r | |
3653 | The input signed data could be wrapped in a ContentInfo structure.\r | |
3654 | \r | |
3655 | @param[in] P7Data Pointer to the PKCS#7 message.\r | |
3656 | @param[in] P7Length Length of the PKCS#7 message in bytes.\r | |
3657 | @param[out] SignerChainCerts Pointer to the certificates list chained to signer's\r | |
3658 | certificate. It's caller's responsibility to free the buffer\r | |
3659 | with Pkcs7FreeSigners().\r | |
3660 | This data structure is EFI_CERT_STACK type.\r | |
3661 | @param[out] ChainLength Length of the chained certificates list buffer in bytes.\r | |
3662 | @param[out] UnchainCerts Pointer to the unchained certificates lists. It's caller's\r | |
3663 | responsibility to free the buffer with Pkcs7FreeSigners().\r | |
3664 | This data structure is EFI_CERT_STACK type.\r | |
3665 | @param[out] UnchainLength Length of the unchained certificates list buffer in bytes.\r | |
3666 | \r | |
3667 | @retval TRUE The operation is finished successfully.\r | |
3668 | @retval FALSE Error occurs during the operation.\r | |
3669 | \r | |
3670 | **/\r | |
3671 | BOOLEAN\r | |
3672 | EFIAPI\r | |
3673 | CryptoServicePkcs7GetCertificatesList (\r | |
3674 | IN CONST UINT8 *P7Data,\r | |
3675 | IN UINTN P7Length,\r | |
3676 | OUT UINT8 **SignerChainCerts,\r | |
3677 | OUT UINTN *ChainLength,\r | |
3678 | OUT UINT8 **UnchainCerts,\r | |
3679 | OUT UINTN *UnchainLength\r | |
3680 | )\r | |
3681 | {\r | |
3682 | return CALL_BASECRYPTLIB (Pkcs.Services.Pkcs7GetCertificatesList, Pkcs7GetCertificatesList, (P7Data, P7Length, SignerChainCerts, ChainLength, UnchainCerts, UnchainLength), FALSE);\r | |
3683 | }\r | |
3684 | \r | |
3685 | /**\r | |
3686 | Creates a PKCS#7 signedData as described in "PKCS #7: Cryptographic Message\r | |
3687 | Syntax Standard, version 1.5". This interface is only intended to be used for\r | |
3688 | application to perform PKCS#7 functionality validation.\r | |
3689 | \r | |
3690 | If this interface is not supported, then return FALSE.\r | |
3691 | \r | |
3692 | @param[in] PrivateKey Pointer to the PEM-formatted private key data for\r | |
3693 | data signing.\r | |
3694 | @param[in] PrivateKeySize Size of the PEM private key data in bytes.\r | |
3695 | @param[in] KeyPassword NULL-terminated passphrase used for encrypted PEM\r | |
3696 | key data.\r | |
3697 | @param[in] InData Pointer to the content to be signed.\r | |
3698 | @param[in] InDataSize Size of InData in bytes.\r | |
3699 | @param[in] SignCert Pointer to signer's DER-encoded certificate to sign with.\r | |
3700 | @param[in] OtherCerts Pointer to an optional additional set of certificates to\r | |
3701 | include in the PKCS#7 signedData (e.g. any intermediate\r | |
3702 | CAs in the chain).\r | |
3703 | @param[out] SignedData Pointer to output PKCS#7 signedData. It's caller's\r | |
3704 | responsibility to free the buffer with FreePool().\r | |
3705 | @param[out] SignedDataSize Size of SignedData in bytes.\r | |
3706 | \r | |
3707 | @retval TRUE PKCS#7 data signing succeeded.\r | |
3708 | @retval FALSE PKCS#7 data signing failed.\r | |
3709 | @retval FALSE This interface is not supported.\r | |
3710 | \r | |
3711 | **/\r | |
3712 | BOOLEAN\r | |
3713 | EFIAPI\r | |
3714 | CryptoServicePkcs7Sign (\r | |
3715 | IN CONST UINT8 *PrivateKey,\r | |
3716 | IN UINTN PrivateKeySize,\r | |
3717 | IN CONST UINT8 *KeyPassword,\r | |
3718 | IN UINT8 *InData,\r | |
3719 | IN UINTN InDataSize,\r | |
3720 | IN UINT8 *SignCert,\r | |
3721 | IN UINT8 *OtherCerts OPTIONAL,\r | |
3722 | OUT UINT8 **SignedData,\r | |
3723 | OUT UINTN *SignedDataSize\r | |
3724 | )\r | |
3725 | {\r | |
3726 | return CALL_BASECRYPTLIB (Pkcs.Services.Pkcs7Sign, Pkcs7Sign, (PrivateKey, PrivateKeySize, KeyPassword, InData, InDataSize, SignCert, OtherCerts, SignedData, SignedDataSize), FALSE);\r | |
3727 | }\r | |
3728 | \r | |
3729 | /**\r | |
3730 | Verifies the validity of a PKCS#7 signed data as described in "PKCS #7:\r | |
3731 | Cryptographic Message Syntax Standard". The input signed data could be wrapped\r | |
3732 | in a ContentInfo structure.\r | |
3733 | \r | |
3734 | If P7Data, TrustedCert or InData is NULL, then return FALSE.\r | |
3735 | If P7Length, CertLength or DataLength overflow, then return FALSE.\r | |
3736 | If this interface is not supported, then return FALSE.\r | |
3737 | \r | |
3738 | @param[in] P7Data Pointer to the PKCS#7 message to verify.\r | |
3739 | @param[in] P7Length Length of the PKCS#7 message in bytes.\r | |
3740 | @param[in] TrustedCert Pointer to a trusted/root certificate encoded in DER, which\r | |
3741 | is used for certificate chain verification.\r | |
3742 | @param[in] CertLength Length of the trusted certificate in bytes.\r | |
3743 | @param[in] InData Pointer to the content to be verified.\r | |
3744 | @param[in] DataLength Length of InData in bytes.\r | |
3745 | \r | |
3746 | @retval TRUE The specified PKCS#7 signed data is valid.\r | |
3747 | @retval FALSE Invalid PKCS#7 signed data.\r | |
3748 | @retval FALSE This interface is not supported.\r | |
3749 | \r | |
3750 | **/\r | |
3751 | BOOLEAN\r | |
3752 | EFIAPI\r | |
3753 | CryptoServicePkcs7Verify (\r | |
3754 | IN CONST UINT8 *P7Data,\r | |
3755 | IN UINTN P7Length,\r | |
3756 | IN CONST UINT8 *TrustedCert,\r | |
3757 | IN UINTN CertLength,\r | |
3758 | IN CONST UINT8 *InData,\r | |
3759 | IN UINTN DataLength\r | |
3760 | )\r | |
3761 | {\r | |
3762 | return CALL_BASECRYPTLIB (Pkcs.Services.Pkcs7Verify, Pkcs7Verify, (P7Data, P7Length, TrustedCert, CertLength, InData, DataLength), FALSE);\r | |
3763 | }\r | |
3764 | \r | |
3765 | /**\r | |
3766 | This function receives a PKCS7 formatted signature, and then verifies that\r | |
3767 | the specified Enhanced or Extended Key Usages (EKU's) are present in the end-entity\r | |
3768 | leaf signing certificate.\r | |
3769 | Note that this function does not validate the certificate chain.\r | |
3770 | \r | |
3771 | Applications for custom EKU's are quite flexible. For example, a policy EKU\r | |
3772 | may be present in an Issuing Certificate Authority (CA), and any sub-ordinate\r | |
3773 | certificate issued might also contain this EKU, thus constraining the\r | |
3774 | sub-ordinate certificate. Other applications might allow a certificate\r | |
3775 | embedded in a device to specify that other Object Identifiers (OIDs) are\r | |
3776 | present which contains binary data specifying custom capabilities that\r | |
3777 | the device is able to do.\r | |
3778 | \r | |
3779 | @param[in] Pkcs7Signature The PKCS#7 signed information content block. An array\r | |
3780 | containing the content block with both the signature,\r | |
3781 | the signer's certificate, and any necessary intermediate\r | |
3782 | certificates.\r | |
3783 | @param[in] Pkcs7SignatureSize Number of bytes in Pkcs7Signature.\r | |
3784 | @param[in] RequiredEKUs Array of null-terminated strings listing OIDs of\r | |
3785 | required EKUs that must be present in the signature.\r | |
3786 | @param[in] RequiredEKUsSize Number of elements in the RequiredEKUs string array.\r | |
3787 | @param[in] RequireAllPresent If this is TRUE, then all of the specified EKU's\r | |
3788 | must be present in the leaf signer. If it is\r | |
3789 | FALSE, then we will succeed if we find any\r | |
3790 | of the specified EKU's.\r | |
3791 | \r | |
3792 | @retval EFI_SUCCESS The required EKUs were found in the signature.\r | |
3793 | @retval EFI_INVALID_PARAMETER A parameter was invalid.\r | |
3794 | @retval EFI_NOT_FOUND One or more EKU's were not found in the signature.\r | |
3795 | \r | |
3796 | **/\r | |
3797 | RETURN_STATUS\r | |
3798 | EFIAPI\r | |
3799 | CryptoServiceVerifyEKUsInPkcs7Signature (\r | |
3800 | IN CONST UINT8 *Pkcs7Signature,\r | |
3801 | IN CONST UINT32 SignatureSize,\r | |
3802 | IN CONST CHAR8 *RequiredEKUs[],\r | |
3803 | IN CONST UINT32 RequiredEKUsSize,\r | |
3804 | IN BOOLEAN RequireAllPresent\r | |
3805 | )\r | |
3806 | {\r | |
3807 | return CALL_BASECRYPTLIB (Pkcs.Services.VerifyEKUsInPkcs7Signature, VerifyEKUsInPkcs7Signature, (Pkcs7Signature, SignatureSize, RequiredEKUs, RequiredEKUsSize, RequireAllPresent), FALSE);\r | |
3808 | }\r | |
3809 | \r | |
cc1d13c9 MK |
3810 | /**\r |
3811 | Extracts the attached content from a PKCS#7 signed data if existed. The input signed\r | |
3812 | data could be wrapped in a ContentInfo structure.\r | |
3813 | \r | |
3814 | If P7Data, Content, or ContentSize is NULL, then return FALSE. If P7Length overflow,\r | |
3815 | then return FALSE. If the P7Data is not correctly formatted, then return FALSE.\r | |
3816 | \r | |
3817 | Caution: This function may receive untrusted input. So this function will do\r | |
3818 | basic check for PKCS#7 data structure.\r | |
3819 | \r | |
3820 | @param[in] P7Data Pointer to the PKCS#7 signed data to process.\r | |
3821 | @param[in] P7Length Length of the PKCS#7 signed data in bytes.\r | |
3822 | @param[out] Content Pointer to the extracted content from the PKCS#7 signedData.\r | |
3823 | It's caller's responsibility to free the buffer with FreePool().\r | |
3824 | @param[out] ContentSize The size of the extracted content in bytes.\r | |
3825 | \r | |
3826 | @retval TRUE The P7Data was correctly formatted for processing.\r | |
3827 | @retval FALSE The P7Data was not correctly formatted for processing.\r | |
3828 | \r | |
3829 | **/\r | |
3830 | BOOLEAN\r | |
3831 | EFIAPI\r | |
3832 | CryptoServicePkcs7GetAttachedContent (\r | |
3833 | IN CONST UINT8 *P7Data,\r | |
3834 | IN UINTN P7Length,\r | |
3835 | OUT VOID **Content,\r | |
3836 | OUT UINTN *ContentSize\r | |
3837 | )\r | |
3838 | {\r | |
3839 | return CALL_BASECRYPTLIB (Pkcs.Services.Pkcs7GetAttachedContent, Pkcs7GetAttachedContent, (P7Data, P7Length, Content, ContentSize), FALSE);\r | |
3840 | }\r | |
3841 | \r | |
3842 | /**\r | |
3843 | Verifies the validity of a PE/COFF Authenticode Signature as described in "Windows\r | |
3844 | Authenticode Portable Executable Signature Format".\r | |
3845 | \r | |
3846 | If AuthData is NULL, then return FALSE.\r | |
3847 | If ImageHash is NULL, then return FALSE.\r | |
3848 | If this interface is not supported, then return FALSE.\r | |
3849 | \r | |
3850 | @param[in] AuthData Pointer to the Authenticode Signature retrieved from signed\r | |
3851 | PE/COFF image to be verified.\r | |
3852 | @param[in] DataSize Size of the Authenticode Signature in bytes.\r | |
3853 | @param[in] TrustedCert Pointer to a trusted/root certificate encoded in DER, which\r | |
3854 | is used for certificate chain verification.\r | |
3855 | @param[in] CertSize Size of the trusted certificate in bytes.\r | |
3856 | @param[in] ImageHash Pointer to the original image file hash value. The procedure\r | |
3857 | for calculating the image hash value is described in Authenticode\r | |
3858 | specification.\r | |
3859 | @param[in] HashSize Size of Image hash value in bytes.\r | |
3860 | \r | |
3861 | @retval TRUE The specified Authenticode Signature is valid.\r | |
3862 | @retval FALSE Invalid Authenticode Signature.\r | |
3863 | @retval FALSE This interface is not supported.\r | |
3864 | \r | |
3865 | **/\r | |
3866 | BOOLEAN\r | |
3867 | EFIAPI\r | |
3868 | CryptoServiceAuthenticodeVerify (\r | |
3869 | IN CONST UINT8 *AuthData,\r | |
3870 | IN UINTN DataSize,\r | |
3871 | IN CONST UINT8 *TrustedCert,\r | |
3872 | IN UINTN CertSize,\r | |
3873 | IN CONST UINT8 *ImageHash,\r | |
3874 | IN UINTN HashSize\r | |
3875 | )\r | |
3876 | {\r | |
3877 | return CALL_BASECRYPTLIB (Pkcs.Services.AuthenticodeVerify, AuthenticodeVerify, (AuthData, DataSize, TrustedCert, CertSize, ImageHash, HashSize), FALSE);\r | |
3878 | }\r | |
3879 | \r | |
3880 | /**\r | |
3881 | Verifies the validity of a RFC3161 Timestamp CounterSignature embedded in PE/COFF Authenticode\r | |
3882 | signature.\r | |
3883 | \r | |
3884 | If AuthData is NULL, then return FALSE.\r | |
3885 | If this interface is not supported, then return FALSE.\r | |
3886 | \r | |
3887 | @param[in] AuthData Pointer to the Authenticode Signature retrieved from signed\r | |
3888 | PE/COFF image to be verified.\r | |
3889 | @param[in] DataSize Size of the Authenticode Signature in bytes.\r | |
3890 | @param[in] TsaCert Pointer to a trusted/root TSA certificate encoded in DER, which\r | |
3891 | is used for TSA certificate chain verification.\r | |
3892 | @param[in] CertSize Size of the trusted certificate in bytes.\r | |
3893 | @param[out] SigningTime Return the time of timestamp generation time if the timestamp\r | |
3894 | signature is valid.\r | |
3895 | \r | |
3896 | @retval TRUE The specified Authenticode includes a valid RFC3161 Timestamp CounterSignature.\r | |
3897 | @retval FALSE No valid RFC3161 Timestamp CounterSignature in the specified Authenticode data.\r | |
3898 | \r | |
3899 | **/\r | |
3900 | BOOLEAN\r | |
3901 | EFIAPI\r | |
3902 | CryptoServiceImageTimestampVerify (\r | |
3903 | IN CONST UINT8 *AuthData,\r | |
3904 | IN UINTN DataSize,\r | |
3905 | IN CONST UINT8 *TsaCert,\r | |
3906 | IN UINTN CertSize,\r | |
3907 | OUT EFI_TIME *SigningTime\r | |
3908 | )\r | |
3909 | {\r | |
3910 | return CALL_BASECRYPTLIB (Pkcs.Services.ImageTimestampVerify, ImageTimestampVerify, (AuthData, DataSize, TsaCert, CertSize, SigningTime), FALSE);\r | |
3911 | }\r | |
3912 | \r | |
7c342378 | 3913 | // =====================================================================================\r |
cc1d13c9 | 3914 | // DH Key Exchange Primitive\r |
7c342378 | 3915 | // =====================================================================================\r |
cc1d13c9 MK |
3916 | \r |
3917 | /**\r | |
3918 | Allocates and Initializes one Diffie-Hellman Context for subsequent use.\r | |
3919 | \r | |
3920 | @return Pointer to the Diffie-Hellman Context that has been initialized.\r | |
3921 | If the allocations fails, DhNew() returns NULL.\r | |
3922 | If the interface is not supported, DhNew() returns NULL.\r | |
3923 | \r | |
3924 | **/\r | |
3925 | VOID *\r | |
3926 | EFIAPI\r | |
3927 | CryptoServiceDhNew (\r | |
3928 | VOID\r | |
3929 | )\r | |
3930 | {\r | |
3931 | return CALL_BASECRYPTLIB (Dh.Services.New, DhNew, (), NULL);\r | |
3932 | }\r | |
3933 | \r | |
3934 | /**\r | |
3935 | Release the specified DH context.\r | |
3936 | \r | |
3937 | If the interface is not supported, then ASSERT().\r | |
3938 | \r | |
3939 | @param[in] DhContext Pointer to the DH context to be released.\r | |
3940 | \r | |
3941 | **/\r | |
3942 | VOID\r | |
3943 | EFIAPI\r | |
3944 | CryptoServiceDhFree (\r | |
3945 | IN VOID *DhContext\r | |
3946 | )\r | |
3947 | {\r | |
3948 | CALL_VOID_BASECRYPTLIB (Dh.Services.Free, DhFree, (DhContext));\r | |
3949 | }\r | |
3950 | \r | |
3951 | /**\r | |
3952 | Generates DH parameter.\r | |
3953 | \r | |
3954 | Given generator g, and length of prime number p in bits, this function generates p,\r | |
3955 | and sets DH context according to value of g and p.\r | |
3956 | \r | |
3957 | Before this function can be invoked, pseudorandom number generator must be correctly\r | |
3958 | initialized by RandomSeed().\r | |
3959 | \r | |
3960 | If DhContext is NULL, then return FALSE.\r | |
3961 | If Prime is NULL, then return FALSE.\r | |
3962 | If this interface is not supported, then return FALSE.\r | |
3963 | \r | |
3964 | @param[in, out] DhContext Pointer to the DH context.\r | |
3965 | @param[in] Generator Value of generator.\r | |
3966 | @param[in] PrimeLength Length in bits of prime to be generated.\r | |
3967 | @param[out] Prime Pointer to the buffer to receive the generated prime number.\r | |
3968 | \r | |
3969 | @retval TRUE DH parameter generation succeeded.\r | |
3970 | @retval FALSE Value of Generator is not supported.\r | |
3971 | @retval FALSE PRNG fails to generate random prime number with PrimeLength.\r | |
3972 | @retval FALSE This interface is not supported.\r | |
3973 | \r | |
3974 | **/\r | |
3975 | BOOLEAN\r | |
3976 | EFIAPI\r | |
3977 | CryptoServiceDhGenerateParameter (\r | |
3978 | IN OUT VOID *DhContext,\r | |
3979 | IN UINTN Generator,\r | |
3980 | IN UINTN PrimeLength,\r | |
3981 | OUT UINT8 *Prime\r | |
3982 | )\r | |
3983 | {\r | |
3984 | return CALL_BASECRYPTLIB (Dh.Services.GenerateParameter, DhGenerateParameter, (DhContext, Generator, PrimeLength, Prime), FALSE);\r | |
3985 | }\r | |
3986 | \r | |
3987 | /**\r | |
3988 | Sets generator and prime parameters for DH.\r | |
3989 | \r | |
3990 | Given generator g, and prime number p, this function and sets DH\r | |
3991 | context accordingly.\r | |
3992 | \r | |
3993 | If DhContext is NULL, then return FALSE.\r | |
3994 | If Prime is NULL, then return FALSE.\r | |
3995 | If this interface is not supported, then return FALSE.\r | |
3996 | \r | |
3997 | @param[in, out] DhContext Pointer to the DH context.\r | |
3998 | @param[in] Generator Value of generator.\r | |
3999 | @param[in] PrimeLength Length in bits of prime to be generated.\r | |
4000 | @param[in] Prime Pointer to the prime number.\r | |
4001 | \r | |
4002 | @retval TRUE DH parameter setting succeeded.\r | |
4003 | @retval FALSE Value of Generator is not supported.\r | |
4004 | @retval FALSE Value of Generator is not suitable for the Prime.\r | |
4005 | @retval FALSE Value of Prime is not a prime number.\r | |
4006 | @retval FALSE Value of Prime is not a safe prime number.\r | |
4007 | @retval FALSE This interface is not supported.\r | |
4008 | \r | |
4009 | **/\r | |
4010 | BOOLEAN\r | |
4011 | EFIAPI\r | |
4012 | CryptoServiceDhSetParameter (\r | |
4013 | IN OUT VOID *DhContext,\r | |
4014 | IN UINTN Generator,\r | |
4015 | IN UINTN PrimeLength,\r | |
4016 | IN CONST UINT8 *Prime\r | |
4017 | )\r | |
4018 | {\r | |
4019 | return CALL_BASECRYPTLIB (Dh.Services.SetParameter, DhSetParameter, (DhContext, Generator, PrimeLength, Prime), FALSE);\r | |
4020 | }\r | |
4021 | \r | |
4022 | /**\r | |
4023 | Generates DH public key.\r | |
4024 | \r | |
4025 | This function generates random secret exponent, and computes the public key, which is\r | |
4026 | returned via parameter PublicKey and PublicKeySize. DH context is updated accordingly.\r | |
4027 | If the PublicKey buffer is too small to hold the public key, FALSE is returned and\r | |
4028 | PublicKeySize is set to the required buffer size to obtain the public key.\r | |
4029 | \r | |
4030 | If DhContext is NULL, then return FALSE.\r | |
4031 | If PublicKeySize is NULL, then return FALSE.\r | |
4032 | If PublicKeySize is large enough but PublicKey is NULL, then return FALSE.\r | |
4033 | If this interface is not supported, then return FALSE.\r | |
4034 | \r | |
4035 | @param[in, out] DhContext Pointer to the DH context.\r | |
4036 | @param[out] PublicKey Pointer to the buffer to receive generated public key.\r | |
4037 | @param[in, out] PublicKeySize On input, the size of PublicKey buffer in bytes.\r | |
4038 | On output, the size of data returned in PublicKey buffer in bytes.\r | |
4039 | \r | |
4040 | @retval TRUE DH public key generation succeeded.\r | |
4041 | @retval FALSE DH public key generation failed.\r | |
4042 | @retval FALSE PublicKeySize is not large enough.\r | |
4043 | @retval FALSE This interface is not supported.\r | |
4044 | \r | |
4045 | **/\r | |
4046 | BOOLEAN\r | |
4047 | EFIAPI\r | |
4048 | CryptoServiceDhGenerateKey (\r | |
4049 | IN OUT VOID *DhContext,\r | |
4050 | OUT UINT8 *PublicKey,\r | |
4051 | IN OUT UINTN *PublicKeySize\r | |
4052 | )\r | |
4053 | {\r | |
4054 | return CALL_BASECRYPTLIB (Dh.Services.GenerateKey, DhGenerateKey, (DhContext, PublicKey, PublicKeySize), FALSE);\r | |
4055 | }\r | |
4056 | \r | |
4057 | /**\r | |
4058 | Computes exchanged common key.\r | |
4059 | \r | |
4060 | Given peer's public key, this function computes the exchanged common key, based on its own\r | |
4061 | context including value of prime modulus and random secret exponent.\r | |
4062 | \r | |
4063 | If DhContext is NULL, then return FALSE.\r | |
4064 | If PeerPublicKey is NULL, then return FALSE.\r | |
4065 | If KeySize is NULL, then return FALSE.\r | |
4066 | If Key is NULL, then return FALSE.\r | |
4067 | If KeySize is not large enough, then return FALSE.\r | |
4068 | If this interface is not supported, then return FALSE.\r | |
4069 | \r | |
4070 | @param[in, out] DhContext Pointer to the DH context.\r | |
4071 | @param[in] PeerPublicKey Pointer to the peer's public key.\r | |
4072 | @param[in] PeerPublicKeySize Size of peer's public key in bytes.\r | |
4073 | @param[out] Key Pointer to the buffer to receive generated key.\r | |
4074 | @param[in, out] KeySize On input, the size of Key buffer in bytes.\r | |
4075 | On output, the size of data returned in Key buffer in bytes.\r | |
4076 | \r | |
4077 | @retval TRUE DH exchanged key generation succeeded.\r | |
4078 | @retval FALSE DH exchanged key generation failed.\r | |
4079 | @retval FALSE KeySize is not large enough.\r | |
4080 | @retval FALSE This interface is not supported.\r | |
4081 | \r | |
4082 | **/\r | |
4083 | BOOLEAN\r | |
4084 | EFIAPI\r | |
4085 | CryptoServiceDhComputeKey (\r | |
4086 | IN OUT VOID *DhContext,\r | |
4087 | IN CONST UINT8 *PeerPublicKey,\r | |
4088 | IN UINTN PeerPublicKeySize,\r | |
4089 | OUT UINT8 *Key,\r | |
4090 | IN OUT UINTN *KeySize\r | |
4091 | )\r | |
4092 | {\r | |
4093 | return CALL_BASECRYPTLIB (Dh.Services.ComputeKey, DhComputeKey, (DhContext, PeerPublicKey, PeerPublicKeySize, Key, KeySize), FALSE);\r | |
4094 | }\r | |
4095 | \r | |
7c342378 | 4096 | // =====================================================================================\r |
cc1d13c9 | 4097 | // Pseudo-Random Generation Primitive\r |
7c342378 | 4098 | // =====================================================================================\r |
cc1d13c9 MK |
4099 | \r |
4100 | /**\r | |
4101 | Sets up the seed value for the pseudorandom number generator.\r | |
4102 | \r | |
4103 | This function sets up the seed value for the pseudorandom number generator.\r | |
4104 | If Seed is not NULL, then the seed passed in is used.\r | |
4105 | If Seed is NULL, then default seed is used.\r | |
4106 | If this interface is not supported, then return FALSE.\r | |
4107 | \r | |
4108 | @param[in] Seed Pointer to seed value.\r | |
4109 | If NULL, default seed is used.\r | |
4110 | @param[in] SeedSize Size of seed value.\r | |
4111 | If Seed is NULL, this parameter is ignored.\r | |
4112 | \r | |
4113 | @retval TRUE Pseudorandom number generator has enough entropy for random generation.\r | |
4114 | @retval FALSE Pseudorandom number generator does not have enough entropy for random generation.\r | |
4115 | @retval FALSE This interface is not supported.\r | |
4116 | \r | |
4117 | **/\r | |
4118 | BOOLEAN\r | |
4119 | EFIAPI\r | |
4120 | CryptoServiceRandomSeed (\r | |
4121 | IN CONST UINT8 *Seed OPTIONAL,\r | |
4122 | IN UINTN SeedSize\r | |
4123 | )\r | |
4124 | {\r | |
4125 | return CALL_BASECRYPTLIB (Random.Services.Seed, RandomSeed, (Seed, SeedSize), FALSE);\r | |
4126 | }\r | |
4127 | \r | |
4128 | /**\r | |
4129 | Generates a pseudorandom byte stream of the specified size.\r | |
4130 | \r | |
4131 | If Output is NULL, then return FALSE.\r | |
4132 | If this interface is not supported, then return FALSE.\r | |
4133 | \r | |
4134 | @param[out] Output Pointer to buffer to receive random value.\r | |
4135 | @param[in] Size Size of random bytes to generate.\r | |
4136 | \r | |
4137 | @retval TRUE Pseudorandom byte stream generated successfully.\r | |
4138 | @retval FALSE Pseudorandom number generator fails to generate due to lack of entropy.\r | |
4139 | @retval FALSE This interface is not supported.\r | |
4140 | \r | |
4141 | **/\r | |
4142 | BOOLEAN\r | |
4143 | EFIAPI\r | |
4144 | CryptoServiceRandomBytes (\r | |
4145 | OUT UINT8 *Output,\r | |
4146 | IN UINTN Size\r | |
4147 | )\r | |
4148 | {\r | |
4149 | return CALL_BASECRYPTLIB (Random.Services.Bytes, RandomBytes, (Output, Size), FALSE);\r | |
4150 | }\r | |
4151 | \r | |
7c342378 | 4152 | // =====================================================================================\r |
cc1d13c9 | 4153 | // Key Derivation Function Primitive\r |
7c342378 | 4154 | // =====================================================================================\r |
cc1d13c9 MK |
4155 | \r |
4156 | /**\r | |
4157 | Derive key data using HMAC-SHA256 based KDF.\r | |
4158 | \r | |
4159 | @param[in] Key Pointer to the user-supplied key.\r | |
4160 | @param[in] KeySize Key size in bytes.\r | |
4161 | @param[in] Salt Pointer to the salt(non-secret) value.\r | |
4162 | @param[in] SaltSize Salt size in bytes.\r | |
4163 | @param[in] Info Pointer to the application specific info.\r | |
4164 | @param[in] InfoSize Info size in bytes.\r | |
4165 | @param[out] Out Pointer to buffer to receive hkdf value.\r | |
4166 | @param[in] OutSize Size of hkdf bytes to generate.\r | |
4167 | \r | |
4168 | @retval TRUE Hkdf generated successfully.\r | |
4169 | @retval FALSE Hkdf generation failed.\r | |
4170 | \r | |
4171 | **/\r | |
4172 | BOOLEAN\r | |
4173 | EFIAPI\r | |
4174 | CryptoServiceHkdfSha256ExtractAndExpand (\r | |
4175 | IN CONST UINT8 *Key,\r | |
4176 | IN UINTN KeySize,\r | |
4177 | IN CONST UINT8 *Salt,\r | |
4178 | IN UINTN SaltSize,\r | |
4179 | IN CONST UINT8 *Info,\r | |
4180 | IN UINTN InfoSize,\r | |
4181 | OUT UINT8 *Out,\r | |
4182 | IN UINTN OutSize\r | |
4183 | )\r | |
4184 | {\r | |
4185 | return CALL_BASECRYPTLIB (Hkdf.Services.Sha256ExtractAndExpand, HkdfSha256ExtractAndExpand, (Key, KeySize, Salt, SaltSize, Info, InfoSize, Out, OutSize), FALSE);\r | |
4186 | }\r | |
4187 | \r | |
e919c390 QZ |
4188 | /**\r |
4189 | Derive SHA256 HMAC-based Extract key Derivation Function (HKDF).\r | |
4190 | \r | |
4191 | @param[in] Key Pointer to the user-supplied key.\r | |
4192 | @param[in] KeySize key size in bytes.\r | |
4193 | @param[in] Salt Pointer to the salt(non-secret) value.\r | |
4194 | @param[in] SaltSize salt size in bytes.\r | |
4195 | @param[out] PrkOut Pointer to buffer to receive hkdf value.\r | |
4196 | @param[in] PrkOutSize size of hkdf bytes to generate.\r | |
4197 | \r | |
4198 | @retval true Hkdf generated successfully.\r | |
4199 | @retval false Hkdf generation failed.\r | |
4200 | \r | |
4201 | **/\r | |
4202 | BOOLEAN\r | |
4203 | EFIAPI\r | |
4204 | CryptoServiceHkdfSha256Extract (\r | |
4205 | IN CONST UINT8 *Key,\r | |
4206 | IN UINTN KeySize,\r | |
4207 | IN CONST UINT8 *Salt,\r | |
4208 | IN UINTN SaltSize,\r | |
4209 | OUT UINT8 *PrkOut,\r | |
4210 | UINTN PrkOutSize\r | |
4211 | )\r | |
4212 | {\r | |
4213 | return CALL_BASECRYPTLIB (Hkdf.Services.Sha256Extract, HkdfSha256Extract, (Key, KeySize, Salt, SaltSize, PrkOut, PrkOutSize), FALSE);\r | |
4214 | }\r | |
4215 | \r | |
4216 | /**\r | |
4217 | Derive SHA256 HMAC-based Expand Key Derivation Function (HKDF).\r | |
4218 | \r | |
4219 | @param[in] Prk Pointer to the user-supplied key.\r | |
4220 | @param[in] PrkSize Key size in bytes.\r | |
4221 | @param[in] Info Pointer to the application specific info.\r | |
4222 | @param[in] InfoSize Info size in bytes.\r | |
4223 | @param[out] Out Pointer to buffer to receive hkdf value.\r | |
4224 | @param[in] OutSize Size of hkdf bytes to generate.\r | |
4225 | \r | |
4226 | @retval TRUE Hkdf generated successfully.\r | |
4227 | @retval FALSE Hkdf generation failed.\r | |
4228 | \r | |
4229 | **/\r | |
4230 | BOOLEAN\r | |
4231 | EFIAPI\r | |
4232 | CryptoServiceHkdfSha256Expand (\r | |
4233 | IN CONST UINT8 *Prk,\r | |
4234 | IN UINTN PrkSize,\r | |
4235 | IN CONST UINT8 *Info,\r | |
4236 | IN UINTN InfoSize,\r | |
4237 | OUT UINT8 *Out,\r | |
4238 | IN UINTN OutSize\r | |
4239 | )\r | |
4240 | {\r | |
4241 | return CALL_BASECRYPTLIB (Hkdf.Services.Sha256Expand, HkdfSha256Expand, (Prk, PrkSize, Info, InfoSize, Out, OutSize), FALSE);\r | |
4242 | }\r | |
4243 | \r | |
4244 | /**\r | |
4245 | Derive SHA384 HMAC-based Extract-and-Expand Key Derivation Function (HKDF).\r | |
4246 | \r | |
4247 | @param[in] Key Pointer to the user-supplied key.\r | |
4248 | @param[in] KeySize Key size in bytes.\r | |
4249 | @param[in] Salt Pointer to the salt(non-secret) value.\r | |
4250 | @param[in] SaltSize Salt size in bytes.\r | |
4251 | @param[in] Info Pointer to the application specific info.\r | |
4252 | @param[in] InfoSize Info size in bytes.\r | |
4253 | @param[out] Out Pointer to buffer to receive hkdf value.\r | |
4254 | @param[in] OutSize Size of hkdf bytes to generate.\r | |
4255 | \r | |
4256 | @retval TRUE Hkdf generated successfully.\r | |
4257 | @retval FALSE Hkdf generation failed.\r | |
4258 | \r | |
4259 | **/\r | |
4260 | BOOLEAN\r | |
4261 | EFIAPI\r | |
4262 | CryptoServiceHkdfSha384ExtractAndExpand (\r | |
4263 | IN CONST UINT8 *Key,\r | |
4264 | IN UINTN KeySize,\r | |
4265 | IN CONST UINT8 *Salt,\r | |
4266 | IN UINTN SaltSize,\r | |
4267 | IN CONST UINT8 *Info,\r | |
4268 | IN UINTN InfoSize,\r | |
4269 | OUT UINT8 *Out,\r | |
4270 | IN UINTN OutSize\r | |
4271 | )\r | |
4272 | {\r | |
4273 | return CALL_BASECRYPTLIB (Hkdf.Services.Sha384ExtractAndExpand, HkdfSha384ExtractAndExpand, (Key, KeySize, Salt, SaltSize, Info, InfoSize, Out, OutSize), FALSE);\r | |
4274 | }\r | |
4275 | \r | |
4276 | /**\r | |
4277 | Derive SHA384 HMAC-based Extract key Derivation Function (HKDF).\r | |
4278 | \r | |
4279 | @param[in] Key Pointer to the user-supplied key.\r | |
4280 | @param[in] KeySize key size in bytes.\r | |
4281 | @param[in] Salt Pointer to the salt(non-secret) value.\r | |
4282 | @param[in] SaltSize salt size in bytes.\r | |
4283 | @param[out] PrkOut Pointer to buffer to receive hkdf value.\r | |
4284 | @param[in] PrkOutSize size of hkdf bytes to generate.\r | |
4285 | \r | |
4286 | @retval true Hkdf generated successfully.\r | |
4287 | @retval false Hkdf generation failed.\r | |
4288 | \r | |
4289 | **/\r | |
4290 | BOOLEAN\r | |
4291 | EFIAPI\r | |
4292 | CryptoServiceHkdfSha384Extract (\r | |
4293 | IN CONST UINT8 *Key,\r | |
4294 | IN UINTN KeySize,\r | |
4295 | IN CONST UINT8 *Salt,\r | |
4296 | IN UINTN SaltSize,\r | |
4297 | OUT UINT8 *PrkOut,\r | |
4298 | UINTN PrkOutSize\r | |
4299 | )\r | |
4300 | {\r | |
4301 | return CALL_BASECRYPTLIB (Hkdf.Services.Sha384Extract, HkdfSha384Extract, (Key, KeySize, Salt, SaltSize, PrkOut, PrkOutSize), FALSE);\r | |
4302 | }\r | |
4303 | \r | |
4304 | /**\r | |
4305 | Derive SHA384 HMAC-based Expand Key Derivation Function (HKDF).\r | |
4306 | \r | |
4307 | @param[in] Prk Pointer to the user-supplied key.\r | |
4308 | @param[in] PrkSize Key size in bytes.\r | |
4309 | @param[in] Info Pointer to the application specific info.\r | |
4310 | @param[in] InfoSize Info size in bytes.\r | |
4311 | @param[out] Out Pointer to buffer to receive hkdf value.\r | |
4312 | @param[in] OutSize Size of hkdf bytes to generate.\r | |
4313 | \r | |
4314 | @retval TRUE Hkdf generated successfully.\r | |
4315 | @retval FALSE Hkdf generation failed.\r | |
4316 | \r | |
4317 | **/\r | |
4318 | BOOLEAN\r | |
4319 | EFIAPI\r | |
4320 | CryptoServiceHkdfSha384Expand (\r | |
4321 | IN CONST UINT8 *Prk,\r | |
4322 | IN UINTN PrkSize,\r | |
4323 | IN CONST UINT8 *Info,\r | |
4324 | IN UINTN InfoSize,\r | |
4325 | OUT UINT8 *Out,\r | |
4326 | IN UINTN OutSize\r | |
4327 | )\r | |
4328 | {\r | |
4329 | return CALL_BASECRYPTLIB (Hkdf.Services.Sha384Expand, HkdfSha384Expand, (Prk, PrkSize, Info, InfoSize, Out, OutSize), FALSE);\r | |
4330 | }\r | |
4331 | \r | |
cc1d13c9 MK |
4332 | /**\r |
4333 | Initializes the OpenSSL library.\r | |
4334 | \r | |
4335 | This function registers ciphers and digests used directly and indirectly\r | |
4336 | by SSL/TLS, and initializes the readable error messages.\r | |
4337 | This function must be called before any other action takes places.\r | |
4338 | \r | |
4339 | @retval TRUE The OpenSSL library has been initialized.\r | |
4340 | @retval FALSE Failed to initialize the OpenSSL library.\r | |
4341 | \r | |
4342 | **/\r | |
4343 | BOOLEAN\r | |
4344 | EFIAPI\r | |
4345 | CryptoServiceTlsInitialize (\r | |
4346 | VOID\r | |
4347 | )\r | |
4348 | {\r | |
4349 | return CALL_BASECRYPTLIB (Tls.Services.Initialize, TlsInitialize, (), FALSE);\r | |
4350 | }\r | |
4351 | \r | |
4352 | /**\r | |
4353 | Free an allocated SSL_CTX object.\r | |
4354 | \r | |
4355 | @param[in] TlsCtx Pointer to the SSL_CTX object to be released.\r | |
4356 | \r | |
4357 | **/\r | |
4358 | VOID\r | |
4359 | EFIAPI\r | |
4360 | CryptoServiceTlsCtxFree (\r | |
7c342378 | 4361 | IN VOID *TlsCtx\r |
cc1d13c9 MK |
4362 | )\r |
4363 | {\r | |
4364 | CALL_VOID_BASECRYPTLIB (Tls.Services.CtxFree, TlsCtxFree, (TlsCtx));\r | |
4365 | }\r | |
4366 | \r | |
4367 | /**\r | |
4368 | Creates a new SSL_CTX object as framework to establish TLS/SSL enabled\r | |
4369 | connections.\r | |
4370 | \r | |
4371 | @param[in] MajorVer Major Version of TLS/SSL Protocol.\r | |
4372 | @param[in] MinorVer Minor Version of TLS/SSL Protocol.\r | |
4373 | \r | |
4374 | @return Pointer to an allocated SSL_CTX object.\r | |
4375 | If the creation failed, TlsCtxNew() returns NULL.\r | |
4376 | \r | |
4377 | **/\r | |
4378 | VOID *\r | |
4379 | EFIAPI\r | |
4380 | CryptoServiceTlsCtxNew (\r | |
7c342378 MK |
4381 | IN UINT8 MajorVer,\r |
4382 | IN UINT8 MinorVer\r | |
cc1d13c9 MK |
4383 | )\r |
4384 | {\r | |
4385 | return CALL_BASECRYPTLIB (Tls.Services.CtxNew, TlsCtxNew, (MajorVer, MinorVer), NULL);\r | |
4386 | }\r | |
4387 | \r | |
4388 | /**\r | |
4389 | Free an allocated TLS object.\r | |
4390 | \r | |
4391 | This function removes the TLS object pointed to by Tls and frees up the\r | |
4392 | allocated memory. If Tls is NULL, nothing is done.\r | |
4393 | \r | |
4394 | @param[in] Tls Pointer to the TLS object to be freed.\r | |
4395 | \r | |
4396 | **/\r | |
4397 | VOID\r | |
4398 | EFIAPI\r | |
4399 | CryptoServiceTlsFree (\r | |
7c342378 | 4400 | IN VOID *Tls\r |
cc1d13c9 MK |
4401 | )\r |
4402 | {\r | |
4403 | CALL_VOID_BASECRYPTLIB (Tls.Services.Free, TlsFree, (Tls));\r | |
4404 | }\r | |
4405 | \r | |
4406 | /**\r | |
4407 | Create a new TLS object for a connection.\r | |
4408 | \r | |
4409 | This function creates a new TLS object for a connection. The new object\r | |
4410 | inherits the setting of the underlying context TlsCtx: connection method,\r | |
4411 | options, verification setting.\r | |
4412 | \r | |
4413 | @param[in] TlsCtx Pointer to the SSL_CTX object.\r | |
4414 | \r | |
4415 | @return Pointer to an allocated SSL object.\r | |
4416 | If the creation failed, TlsNew() returns NULL.\r | |
4417 | \r | |
4418 | **/\r | |
4419 | VOID *\r | |
4420 | EFIAPI\r | |
4421 | CryptoServiceTlsNew (\r | |
7c342378 | 4422 | IN VOID *TlsCtx\r |
cc1d13c9 MK |
4423 | )\r |
4424 | {\r | |
4425 | return CALL_BASECRYPTLIB (Tls.Services.New, TlsNew, (TlsCtx), NULL);\r | |
4426 | }\r | |
4427 | \r | |
4428 | /**\r | |
4429 | Checks if the TLS handshake was done.\r | |
4430 | \r | |
4431 | This function will check if the specified TLS handshake was done.\r | |
4432 | \r | |
4433 | @param[in] Tls Pointer to the TLS object for handshake state checking.\r | |
4434 | \r | |
4435 | @retval TRUE The TLS handshake was done.\r | |
4436 | @retval FALSE The TLS handshake was not done.\r | |
4437 | \r | |
4438 | **/\r | |
4439 | BOOLEAN\r | |
4440 | EFIAPI\r | |
4441 | CryptoServiceTlsInHandshake (\r | |
7c342378 | 4442 | IN VOID *Tls\r |
cc1d13c9 MK |
4443 | )\r |
4444 | {\r | |
4445 | return CALL_BASECRYPTLIB (Tls.Services.InHandshake, TlsInHandshake, (Tls), FALSE);\r | |
4446 | }\r | |
4447 | \r | |
4448 | /**\r | |
4449 | Perform a TLS/SSL handshake.\r | |
4450 | \r | |
4451 | This function will perform a TLS/SSL handshake.\r | |
4452 | \r | |
4453 | @param[in] Tls Pointer to the TLS object for handshake operation.\r | |
4454 | @param[in] BufferIn Pointer to the most recently received TLS Handshake packet.\r | |
4455 | @param[in] BufferInSize Packet size in bytes for the most recently received TLS\r | |
4456 | Handshake packet.\r | |
4457 | @param[out] BufferOut Pointer to the buffer to hold the built packet.\r | |
4458 | @param[in, out] BufferOutSize Pointer to the buffer size in bytes. On input, it is\r | |
4459 | the buffer size provided by the caller. On output, it\r | |
4460 | is the buffer size in fact needed to contain the\r | |
4461 | packet.\r | |
4462 | \r | |
4463 | @retval EFI_SUCCESS The required TLS packet is built successfully.\r | |
4464 | @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:\r | |
4465 | Tls is NULL.\r | |
4466 | BufferIn is NULL but BufferInSize is NOT 0.\r | |
4467 | BufferInSize is 0 but BufferIn is NOT NULL.\r | |
4468 | BufferOutSize is NULL.\r | |
4469 | BufferOut is NULL if *BufferOutSize is not zero.\r | |
4470 | @retval EFI_BUFFER_TOO_SMALL BufferOutSize is too small to hold the response packet.\r | |
4471 | @retval EFI_ABORTED Something wrong during handshake.\r | |
4472 | \r | |
4473 | **/\r | |
4474 | EFI_STATUS\r | |
4475 | EFIAPI\r | |
4476 | CryptoServiceTlsDoHandshake (\r | |
7c342378 MK |
4477 | IN VOID *Tls,\r |
4478 | IN UINT8 *BufferIn OPTIONAL,\r | |
4479 | IN UINTN BufferInSize OPTIONAL,\r | |
4480 | OUT UINT8 *BufferOut OPTIONAL,\r | |
4481 | IN OUT UINTN *BufferOutSize\r | |
cc1d13c9 MK |
4482 | )\r |
4483 | {\r | |
4484 | return CALL_BASECRYPTLIB (Tls.Services.DoHandshake, TlsDoHandshake, (Tls, BufferIn, BufferInSize, BufferOut, BufferOutSize), EFI_UNSUPPORTED);\r | |
4485 | }\r | |
4486 | \r | |
4487 | /**\r | |
4488 | Handle Alert message recorded in BufferIn. If BufferIn is NULL and BufferInSize is zero,\r | |
4489 | TLS session has errors and the response packet needs to be Alert message based on error type.\r | |
4490 | \r | |
4491 | @param[in] Tls Pointer to the TLS object for state checking.\r | |
4492 | @param[in] BufferIn Pointer to the most recently received TLS Alert packet.\r | |
4493 | @param[in] BufferInSize Packet size in bytes for the most recently received TLS\r | |
4494 | Alert packet.\r | |
4495 | @param[out] BufferOut Pointer to the buffer to hold the built packet.\r | |
4496 | @param[in, out] BufferOutSize Pointer to the buffer size in bytes. On input, it is\r | |
4497 | the buffer size provided by the caller. On output, it\r | |
4498 | is the buffer size in fact needed to contain the\r | |
4499 | packet.\r | |
4500 | \r | |
4501 | @retval EFI_SUCCESS The required TLS packet is built successfully.\r | |
4502 | @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:\r | |
4503 | Tls is NULL.\r | |
4504 | BufferIn is NULL but BufferInSize is NOT 0.\r | |
4505 | BufferInSize is 0 but BufferIn is NOT NULL.\r | |
4506 | BufferOutSize is NULL.\r | |
4507 | BufferOut is NULL if *BufferOutSize is not zero.\r | |
4508 | @retval EFI_ABORTED An error occurred.\r | |
4509 | @retval EFI_BUFFER_TOO_SMALL BufferOutSize is too small to hold the response packet.\r | |
4510 | \r | |
4511 | **/\r | |
4512 | EFI_STATUS\r | |
4513 | EFIAPI\r | |
4514 | CryptoServiceTlsHandleAlert (\r | |
7c342378 MK |
4515 | IN VOID *Tls,\r |
4516 | IN UINT8 *BufferIn OPTIONAL,\r | |
4517 | IN UINTN BufferInSize OPTIONAL,\r | |
4518 | OUT UINT8 *BufferOut OPTIONAL,\r | |
4519 | IN OUT UINTN *BufferOutSize\r | |
cc1d13c9 MK |
4520 | )\r |
4521 | {\r | |
4522 | return CALL_BASECRYPTLIB (Tls.Services.HandleAlert, TlsHandleAlert, (Tls, BufferIn, BufferInSize, BufferOut, BufferOutSize), EFI_UNSUPPORTED);\r | |
4523 | }\r | |
4524 | \r | |
4525 | /**\r | |
4526 | Build the CloseNotify packet.\r | |
4527 | \r | |
4528 | @param[in] Tls Pointer to the TLS object for state checking.\r | |
4529 | @param[in, out] Buffer Pointer to the buffer to hold the built packet.\r | |
4530 | @param[in, out] BufferSize Pointer to the buffer size in bytes. On input, it is\r | |
4531 | the buffer size provided by the caller. On output, it\r | |
4532 | is the buffer size in fact needed to contain the\r | |
4533 | packet.\r | |
4534 | \r | |
4535 | @retval EFI_SUCCESS The required TLS packet is built successfully.\r | |
4536 | @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:\r | |
4537 | Tls is NULL.\r | |
4538 | BufferSize is NULL.\r | |
4539 | Buffer is NULL if *BufferSize is not zero.\r | |
4540 | @retval EFI_BUFFER_TOO_SMALL BufferSize is too small to hold the response packet.\r | |
4541 | \r | |
4542 | **/\r | |
4543 | EFI_STATUS\r | |
4544 | EFIAPI\r | |
4545 | CryptoServiceTlsCloseNotify (\r | |
7c342378 MK |
4546 | IN VOID *Tls,\r |
4547 | IN OUT UINT8 *Buffer,\r | |
4548 | IN OUT UINTN *BufferSize\r | |
cc1d13c9 MK |
4549 | )\r |
4550 | {\r | |
4551 | return CALL_BASECRYPTLIB (Tls.Services.CloseNotify, TlsCloseNotify, (Tls, Buffer, BufferSize), EFI_UNSUPPORTED);\r | |
4552 | }\r | |
4553 | \r | |
4554 | /**\r | |
4555 | Attempts to read bytes from one TLS object and places the data in Buffer.\r | |
4556 | \r | |
4557 | This function will attempt to read BufferSize bytes from the TLS object\r | |
4558 | and places the data in Buffer.\r | |
4559 | \r | |
4560 | @param[in] Tls Pointer to the TLS object.\r | |
4561 | @param[in,out] Buffer Pointer to the buffer to store the data.\r | |
4562 | @param[in] BufferSize The size of Buffer in bytes.\r | |
4563 | \r | |
4564 | @retval >0 The amount of data successfully read from the TLS object.\r | |
4565 | @retval <=0 No data was successfully read.\r | |
4566 | \r | |
4567 | **/\r | |
4568 | INTN\r | |
4569 | EFIAPI\r | |
4570 | CryptoServiceTlsCtrlTrafficOut (\r | |
7c342378 MK |
4571 | IN VOID *Tls,\r |
4572 | IN OUT VOID *Buffer,\r | |
4573 | IN UINTN BufferSize\r | |
cc1d13c9 MK |
4574 | )\r |
4575 | {\r | |
4576 | return CALL_BASECRYPTLIB (Tls.Services.CtrlTrafficOut, TlsCtrlTrafficOut, (Tls, Buffer, BufferSize), 0);\r | |
4577 | }\r | |
4578 | \r | |
4579 | /**\r | |
4580 | Attempts to write data from the buffer to TLS object.\r | |
4581 | \r | |
4582 | This function will attempt to write BufferSize bytes data from the Buffer\r | |
4583 | to the TLS object.\r | |
4584 | \r | |
4585 | @param[in] Tls Pointer to the TLS object.\r | |
4586 | @param[in] Buffer Pointer to the data buffer.\r | |
4587 | @param[in] BufferSize The size of Buffer in bytes.\r | |
4588 | \r | |
4589 | @retval >0 The amount of data successfully written to the TLS object.\r | |
4590 | @retval <=0 No data was successfully written.\r | |
4591 | \r | |
4592 | **/\r | |
4593 | INTN\r | |
4594 | EFIAPI\r | |
4595 | CryptoServiceTlsCtrlTrafficIn (\r | |
7c342378 MK |
4596 | IN VOID *Tls,\r |
4597 | IN VOID *Buffer,\r | |
4598 | IN UINTN BufferSize\r | |
cc1d13c9 MK |
4599 | )\r |
4600 | {\r | |
4601 | return CALL_BASECRYPTLIB (Tls.Services.CtrlTrafficIn, TlsCtrlTrafficIn, (Tls, Buffer, BufferSize), 0);\r | |
4602 | }\r | |
4603 | \r | |
4604 | /**\r | |
4605 | Attempts to read bytes from the specified TLS connection into the buffer.\r | |
4606 | \r | |
4607 | This function tries to read BufferSize bytes data from the specified TLS\r | |
4608 | connection into the Buffer.\r | |
4609 | \r | |
4610 | @param[in] Tls Pointer to the TLS connection for data reading.\r | |
4611 | @param[in,out] Buffer Pointer to the data buffer.\r | |
4612 | @param[in] BufferSize The size of Buffer in bytes.\r | |
4613 | \r | |
4614 | @retval >0 The read operation was successful, and return value is the\r | |
4615 | number of bytes actually read from the TLS connection.\r | |
4616 | @retval <=0 The read operation was not successful.\r | |
4617 | \r | |
4618 | **/\r | |
4619 | INTN\r | |
4620 | EFIAPI\r | |
4621 | CryptoServiceTlsRead (\r | |
7c342378 MK |
4622 | IN VOID *Tls,\r |
4623 | IN OUT VOID *Buffer,\r | |
4624 | IN UINTN BufferSize\r | |
cc1d13c9 MK |
4625 | )\r |
4626 | {\r | |
4627 | return CALL_BASECRYPTLIB (Tls.Services.Read, TlsRead, (Tls, Buffer, BufferSize), 0);\r | |
4628 | }\r | |
4629 | \r | |
4630 | /**\r | |
4631 | Attempts to write data to a TLS connection.\r | |
4632 | \r | |
4633 | This function tries to write BufferSize bytes data from the Buffer into the\r | |
4634 | specified TLS connection.\r | |
4635 | \r | |
4636 | @param[in] Tls Pointer to the TLS connection for data writing.\r | |
4637 | @param[in] Buffer Pointer to the data buffer.\r | |
4638 | @param[in] BufferSize The size of Buffer in bytes.\r | |
4639 | \r | |
4640 | @retval >0 The write operation was successful, and return value is the\r | |
4641 | number of bytes actually written to the TLS connection.\r | |
4642 | @retval <=0 The write operation was not successful.\r | |
4643 | \r | |
4644 | **/\r | |
4645 | INTN\r | |
4646 | EFIAPI\r | |
4647 | CryptoServiceTlsWrite (\r | |
7c342378 MK |
4648 | IN VOID *Tls,\r |
4649 | IN VOID *Buffer,\r | |
4650 | IN UINTN BufferSize\r | |
cc1d13c9 MK |
4651 | )\r |
4652 | {\r | |
4653 | return CALL_BASECRYPTLIB (Tls.Services.Write, TlsWrite, (Tls, Buffer, BufferSize), 0);\r | |
4654 | }\r | |
4655 | \r | |
8db4e9f9 YL |
4656 | /**\r |
4657 | Shutdown a TLS connection.\r | |
4658 | \r | |
4659 | Shutdown the TLS connection without releasing the resources, meaning a new\r | |
4660 | connection can be started without calling TlsNew() and without setting\r | |
4661 | certificates etc.\r | |
4662 | \r | |
4663 | @param[in] Tls Pointer to the TLS object to shutdown.\r | |
4664 | \r | |
4665 | @retval EFI_SUCCESS The TLS is shutdown successfully.\r | |
4666 | @retval EFI_INVALID_PARAMETER Tls is NULL.\r | |
4667 | @retval EFI_PROTOCOL_ERROR Some other error occurred.\r | |
4668 | **/\r | |
4669 | EFI_STATUS\r | |
4670 | EFIAPI\r | |
4671 | CryptoServiceTlsShutdown (\r | |
4672 | IN VOID *Tls\r | |
4673 | )\r | |
4674 | {\r | |
4675 | return CALL_BASECRYPTLIB (Tls.Services.Shutdown, TlsShutdown, (Tls), EFI_UNSUPPORTED);\r | |
4676 | }\r | |
4677 | \r | |
cc1d13c9 MK |
4678 | /**\r |
4679 | Set a new TLS/SSL method for a particular TLS object.\r | |
4680 | \r | |
4681 | This function sets a new TLS/SSL method for a particular TLS object.\r | |
4682 | \r | |
4683 | @param[in] Tls Pointer to a TLS object.\r | |
4684 | @param[in] MajorVer Major Version of TLS/SSL Protocol.\r | |
4685 | @param[in] MinorVer Minor Version of TLS/SSL Protocol.\r | |
4686 | \r | |
4687 | @retval EFI_SUCCESS The TLS/SSL method was set successfully.\r | |
4688 | @retval EFI_INVALID_PARAMETER The parameter is invalid.\r | |
4689 | @retval EFI_UNSUPPORTED Unsupported TLS/SSL method.\r | |
4690 | \r | |
4691 | **/\r | |
4692 | EFI_STATUS\r | |
4693 | EFIAPI\r | |
4694 | CryptoServiceTlsSetVersion (\r | |
7c342378 MK |
4695 | IN VOID *Tls,\r |
4696 | IN UINT8 MajorVer,\r | |
4697 | IN UINT8 MinorVer\r | |
cc1d13c9 MK |
4698 | )\r |
4699 | {\r | |
4700 | return CALL_BASECRYPTLIB (TlsSet.Services.Version, TlsSetVersion, (Tls, MajorVer, MinorVer), EFI_UNSUPPORTED);\r | |
4701 | }\r | |
4702 | \r | |
4703 | /**\r | |
4704 | Set TLS object to work in client or server mode.\r | |
4705 | \r | |
4706 | This function prepares a TLS object to work in client or server mode.\r | |
4707 | \r | |
4708 | @param[in] Tls Pointer to a TLS object.\r | |
4709 | @param[in] IsServer Work in server mode.\r | |
4710 | \r | |
4711 | @retval EFI_SUCCESS The TLS/SSL work mode was set successfully.\r | |
4712 | @retval EFI_INVALID_PARAMETER The parameter is invalid.\r | |
4713 | @retval EFI_UNSUPPORTED Unsupported TLS/SSL work mode.\r | |
4714 | \r | |
4715 | **/\r | |
4716 | EFI_STATUS\r | |
4717 | EFIAPI\r | |
4718 | CryptoServiceTlsSetConnectionEnd (\r | |
7c342378 MK |
4719 | IN VOID *Tls,\r |
4720 | IN BOOLEAN IsServer\r | |
cc1d13c9 MK |
4721 | )\r |
4722 | {\r | |
4723 | return CALL_BASECRYPTLIB (TlsSet.Services.ConnectionEnd, TlsSetConnectionEnd, (Tls, IsServer), EFI_UNSUPPORTED);\r | |
4724 | }\r | |
4725 | \r | |
4726 | /**\r | |
4727 | Set the ciphers list to be used by the TLS object.\r | |
4728 | \r | |
4729 | This function sets the ciphers for use by a specified TLS object.\r | |
4730 | \r | |
4731 | @param[in] Tls Pointer to a TLS object.\r | |
4732 | @param[in] CipherId Array of UINT16 cipher identifiers. Each UINT16\r | |
4733 | cipher identifier comes from the TLS Cipher Suite\r | |
4734 | Registry of the IANA, interpreting Byte1 and Byte2\r | |
4735 | in network (big endian) byte order.\r | |
4736 | @param[in] CipherNum The number of cipher in the list.\r | |
4737 | \r | |
4738 | @retval EFI_SUCCESS The ciphers list was set successfully.\r | |
4739 | @retval EFI_INVALID_PARAMETER The parameter is invalid.\r | |
4740 | @retval EFI_UNSUPPORTED No supported TLS cipher was found in CipherId.\r | |
4741 | @retval EFI_OUT_OF_RESOURCES Memory allocation failed.\r | |
4742 | \r | |
4743 | **/\r | |
4744 | EFI_STATUS\r | |
4745 | EFIAPI\r | |
4746 | CryptoServiceTlsSetCipherList (\r | |
7c342378 MK |
4747 | IN VOID *Tls,\r |
4748 | IN UINT16 *CipherId,\r | |
4749 | IN UINTN CipherNum\r | |
cc1d13c9 MK |
4750 | )\r |
4751 | {\r | |
4752 | return CALL_BASECRYPTLIB (TlsSet.Services.CipherList, TlsSetCipherList, (Tls, CipherId, CipherNum), EFI_UNSUPPORTED);\r | |
4753 | }\r | |
4754 | \r | |
4755 | /**\r | |
4756 | Set the compression method for TLS/SSL operations.\r | |
4757 | \r | |
4758 | This function handles TLS/SSL integrated compression methods.\r | |
4759 | \r | |
4760 | @param[in] CompMethod The compression method ID.\r | |
4761 | \r | |
4762 | @retval EFI_SUCCESS The compression method for the communication was\r | |
4763 | set successfully.\r | |
4764 | @retval EFI_UNSUPPORTED Unsupported compression method.\r | |
4765 | \r | |
4766 | **/\r | |
4767 | EFI_STATUS\r | |
4768 | EFIAPI\r | |
4769 | CryptoServiceTlsSetCompressionMethod (\r | |
7c342378 | 4770 | IN UINT8 CompMethod\r |
cc1d13c9 MK |
4771 | )\r |
4772 | {\r | |
4773 | return CALL_BASECRYPTLIB (TlsSet.Services.CompressionMethod, TlsSetCompressionMethod, (CompMethod), EFI_UNSUPPORTED);\r | |
4774 | }\r | |
4775 | \r | |
4776 | /**\r | |
4777 | Set peer certificate verification mode for the TLS connection.\r | |
4778 | \r | |
4779 | This function sets the verification mode flags for the TLS connection.\r | |
4780 | \r | |
4781 | @param[in] Tls Pointer to the TLS object.\r | |
4782 | @param[in] VerifyMode A set of logically or'ed verification mode flags.\r | |
4783 | \r | |
4784 | **/\r | |
4785 | VOID\r | |
4786 | EFIAPI\r | |
4787 | CryptoServiceTlsSetVerify (\r | |
7c342378 MK |
4788 | IN VOID *Tls,\r |
4789 | IN UINT32 VerifyMode\r | |
cc1d13c9 MK |
4790 | )\r |
4791 | {\r | |
4792 | CALL_VOID_BASECRYPTLIB (TlsSet.Services.Verify, TlsSetVerify, (Tls, VerifyMode));\r | |
4793 | }\r | |
4794 | \r | |
4795 | /**\r | |
4796 | Set the specified host name to be verified.\r | |
4797 | \r | |
4798 | @param[in] Tls Pointer to the TLS object.\r | |
4799 | @param[in] Flags The setting flags during the validation.\r | |
4800 | @param[in] HostName The specified host name to be verified.\r | |
4801 | \r | |
4802 | @retval EFI_SUCCESS The HostName setting was set successfully.\r | |
4803 | @retval EFI_INVALID_PARAMETER The parameter is invalid.\r | |
4804 | @retval EFI_ABORTED Invalid HostName setting.\r | |
4805 | \r | |
4806 | **/\r | |
4807 | EFI_STATUS\r | |
4808 | EFIAPI\r | |
4809 | CryptoServiceTlsSetVerifyHost (\r | |
7c342378 MK |
4810 | IN VOID *Tls,\r |
4811 | IN UINT32 Flags,\r | |
4812 | IN CHAR8 *HostName\r | |
cc1d13c9 MK |
4813 | )\r |
4814 | {\r | |
4815 | return CALL_BASECRYPTLIB (TlsSet.Services.VerifyHost, TlsSetVerifyHost, (Tls, Flags, HostName), EFI_UNSUPPORTED);\r | |
4816 | }\r | |
4817 | \r | |
4818 | /**\r | |
4819 | Sets a TLS/SSL session ID to be used during TLS/SSL connect.\r | |
4820 | \r | |
4821 | This function sets a session ID to be used when the TLS/SSL connection is\r | |
4822 | to be established.\r | |
4823 | \r | |
4824 | @param[in] Tls Pointer to the TLS object.\r | |
4825 | @param[in] SessionId Session ID data used for session resumption.\r | |
4826 | @param[in] SessionIdLen Length of Session ID in bytes.\r | |
4827 | \r | |
4828 | @retval EFI_SUCCESS Session ID was set successfully.\r | |
4829 | @retval EFI_INVALID_PARAMETER The parameter is invalid.\r | |
4830 | @retval EFI_UNSUPPORTED No available session for ID setting.\r | |
4831 | \r | |
4832 | **/\r | |
4833 | EFI_STATUS\r | |
4834 | EFIAPI\r | |
4835 | CryptoServiceTlsSetSessionId (\r | |
7c342378 MK |
4836 | IN VOID *Tls,\r |
4837 | IN UINT8 *SessionId,\r | |
4838 | IN UINT16 SessionIdLen\r | |
cc1d13c9 MK |
4839 | )\r |
4840 | {\r | |
4841 | return CALL_BASECRYPTLIB (TlsSet.Services.SessionId, TlsSetSessionId, (Tls, SessionId, SessionIdLen), EFI_UNSUPPORTED);\r | |
4842 | }\r | |
4843 | \r | |
4844 | /**\r | |
4845 | Adds the CA to the cert store when requesting Server or Client authentication.\r | |
4846 | \r | |
4847 | This function adds the CA certificate to the list of CAs when requesting\r | |
4848 | Server or Client authentication for the chosen TLS connection.\r | |
4849 | \r | |
4850 | @param[in] Tls Pointer to the TLS object.\r | |
4851 | @param[in] Data Pointer to the data buffer of a DER-encoded binary\r | |
4852 | X.509 certificate or PEM-encoded X.509 certificate.\r | |
4853 | @param[in] DataSize The size of data buffer in bytes.\r | |
4854 | \r | |
4855 | @retval EFI_SUCCESS The operation succeeded.\r | |
4856 | @retval EFI_INVALID_PARAMETER The parameter is invalid.\r | |
4857 | @retval EFI_OUT_OF_RESOURCES Required resources could not be allocated.\r | |
4858 | @retval EFI_ABORTED Invalid X.509 certificate.\r | |
4859 | \r | |
4860 | **/\r | |
4861 | EFI_STATUS\r | |
4862 | EFIAPI\r | |
4863 | CryptoServiceTlsSetCaCertificate (\r | |
7c342378 MK |
4864 | IN VOID *Tls,\r |
4865 | IN VOID *Data,\r | |
4866 | IN UINTN DataSize\r | |
cc1d13c9 MK |
4867 | )\r |
4868 | {\r | |
4869 | return CALL_BASECRYPTLIB (TlsSet.Services.CaCertificate, TlsSetCaCertificate, (Tls, Data, DataSize), EFI_UNSUPPORTED);\r | |
4870 | }\r | |
4871 | \r | |
4872 | /**\r | |
4873 | Loads the local public certificate into the specified TLS object.\r | |
4874 | \r | |
4875 | This function loads the X.509 certificate into the specified TLS object\r | |
4876 | for TLS negotiation.\r | |
4877 | \r | |
4878 | @param[in] Tls Pointer to the TLS object.\r | |
4879 | @param[in] Data Pointer to the data buffer of a DER-encoded binary\r | |
4880 | X.509 certificate or PEM-encoded X.509 certificate.\r | |
4881 | @param[in] DataSize The size of data buffer in bytes.\r | |
4882 | \r | |
4883 | @retval EFI_SUCCESS The operation succeeded.\r | |
4884 | @retval EFI_INVALID_PARAMETER The parameter is invalid.\r | |
4885 | @retval EFI_OUT_OF_RESOURCES Required resources could not be allocated.\r | |
4886 | @retval EFI_ABORTED Invalid X.509 certificate.\r | |
4887 | \r | |
4888 | **/\r | |
4889 | EFI_STATUS\r | |
4890 | EFIAPI\r | |
4891 | CryptoServiceTlsSetHostPublicCert (\r | |
7c342378 MK |
4892 | IN VOID *Tls,\r |
4893 | IN VOID *Data,\r | |
4894 | IN UINTN DataSize\r | |
cc1d13c9 MK |
4895 | )\r |
4896 | {\r | |
4897 | return CALL_BASECRYPTLIB (TlsSet.Services.HostPublicCert, TlsSetHostPublicCert, (Tls, Data, DataSize), EFI_UNSUPPORTED);\r | |
4898 | }\r | |
4899 | \r | |
4900 | /**\r | |
4901 | Adds the local private key to the specified TLS object.\r | |
4902 | \r | |
8db4e9f9 YL |
4903 | This function adds the local private key (DER-encoded or PEM-encoded or PKCS#8 private\r |
4904 | key) into the specified TLS object for TLS negotiation.\r | |
4905 | \r | |
4906 | @param[in] Tls Pointer to the TLS object.\r | |
4907 | @param[in] Data Pointer to the data buffer of a DER-encoded or PEM-encoded\r | |
4908 | or PKCS#8 private key.\r | |
4909 | @param[in] DataSize The size of data buffer in bytes.\r | |
4910 | @param[in] Password Pointer to NULL-terminated private key password, set it to NULL\r | |
4911 | if private key not encrypted.\r | |
4912 | \r | |
4913 | @retval EFI_SUCCESS The operation succeeded.\r | |
4914 | @retval EFI_UNSUPPORTED This function is not supported.\r | |
4915 | @retval EFI_ABORTED Invalid private key data.\r | |
4916 | \r | |
4917 | **/\r | |
4918 | EFI_STATUS\r | |
4919 | EFIAPI\r | |
4920 | CryptoServiceTlsSetHostPrivateKeyEx (\r | |
4921 | IN VOID *Tls,\r | |
4922 | IN VOID *Data,\r | |
4923 | IN UINTN DataSize,\r | |
4924 | IN VOID *Password OPTIONAL\r | |
4925 | )\r | |
4926 | {\r | |
4927 | return CALL_BASECRYPTLIB (TlsSet.Services.HostPrivateKeyEx, TlsSetHostPrivateKeyEx, (Tls, Data, DataSize, Password), EFI_UNSUPPORTED);\r | |
4928 | }\r | |
4929 | \r | |
4930 | /**\r | |
4931 | Adds the local private key to the specified TLS object.\r | |
4932 | \r | |
4933 | This function adds the local private key (DER-encoded or PEM-encoded or PKCS#8 private\r | |
cc1d13c9 MK |
4934 | key) into the specified TLS object for TLS negotiation.\r |
4935 | \r | |
4936 | @param[in] Tls Pointer to the TLS object.\r | |
8db4e9f9 | 4937 | @param[in] Data Pointer to the data buffer of a DER-encoded or PEM-encoded\r |
cc1d13c9 MK |
4938 | or PKCS#8 private key.\r |
4939 | @param[in] DataSize The size of data buffer in bytes.\r | |
4940 | \r | |
4941 | @retval EFI_SUCCESS The operation succeeded.\r | |
4942 | @retval EFI_UNSUPPORTED This function is not supported.\r | |
4943 | @retval EFI_ABORTED Invalid private key data.\r | |
4944 | \r | |
4945 | **/\r | |
4946 | EFI_STATUS\r | |
4947 | EFIAPI\r | |
4948 | CryptoServiceTlsSetHostPrivateKey (\r | |
7c342378 MK |
4949 | IN VOID *Tls,\r |
4950 | IN VOID *Data,\r | |
4951 | IN UINTN DataSize\r | |
cc1d13c9 MK |
4952 | )\r |
4953 | {\r | |
4954 | return CALL_BASECRYPTLIB (TlsSet.Services.HostPrivateKey, TlsSetHostPrivateKey, (Tls, Data, DataSize), EFI_UNSUPPORTED);\r | |
4955 | }\r | |
4956 | \r | |
4957 | /**\r | |
4958 | Adds the CA-supplied certificate revocation list for certificate validation.\r | |
4959 | \r | |
4960 | This function adds the CA-supplied certificate revocation list data for\r | |
4961 | certificate validity checking.\r | |
4962 | \r | |
4963 | @param[in] Data Pointer to the data buffer of a DER-encoded CRL data.\r | |
4964 | @param[in] DataSize The size of data buffer in bytes.\r | |
4965 | \r | |
4966 | @retval EFI_SUCCESS The operation succeeded.\r | |
4967 | @retval EFI_UNSUPPORTED This function is not supported.\r | |
4968 | @retval EFI_ABORTED Invalid CRL data.\r | |
4969 | \r | |
4970 | **/\r | |
4971 | EFI_STATUS\r | |
4972 | EFIAPI\r | |
4973 | CryptoServiceTlsSetCertRevocationList (\r | |
7c342378 MK |
4974 | IN VOID *Data,\r |
4975 | IN UINTN DataSize\r | |
cc1d13c9 MK |
4976 | )\r |
4977 | {\r | |
4978 | return CALL_BASECRYPTLIB (TlsSet.Services.CertRevocationList, TlsSetCertRevocationList, (Data, DataSize), EFI_UNSUPPORTED);\r | |
4979 | }\r | |
4980 | \r | |
8db4e9f9 YL |
4981 | /**\r |
4982 | Set the signature algorithm list to used by the TLS object.\r | |
4983 | \r | |
4984 | This function sets the signature algorithms for use by a specified TLS object.\r | |
4985 | \r | |
4986 | @param[in] Tls Pointer to a TLS object.\r | |
4987 | @param[in] Data Array of UINT8 of signature algorithms. The array consists of\r | |
4988 | pairs of the hash algorithm and the signature algorithm as defined\r | |
4989 | in RFC 5246\r | |
4990 | @param[in] DataSize The length the SignatureAlgoList. Must be divisible by 2.\r | |
4991 | \r | |
4992 | @retval EFI_SUCCESS The signature algorithm list was set successfully.\r | |
4993 | @retval EFI_INVALID_PARAMETER The parameters are invalid.\r | |
4994 | @retval EFI_UNSUPPORTED No supported TLS signature algorithm was found in SignatureAlgoList\r | |
4995 | @retval EFI_OUT_OF_RESOURCES Memory allocation failed.\r | |
4996 | \r | |
4997 | **/\r | |
4998 | EFI_STATUS\r | |
4999 | EFIAPI\r | |
5000 | CryptoServiceTlsSetSignatureAlgoList (\r | |
5001 | IN VOID *Tls,\r | |
5002 | IN UINT8 *Data,\r | |
5003 | IN UINTN DataSize\r | |
5004 | )\r | |
5005 | {\r | |
5006 | return CALL_BASECRYPTLIB (TlsSet.Services.SignatureAlgoList, TlsSetSignatureAlgoList, (Tls, Data, DataSize), EFI_UNSUPPORTED);\r | |
5007 | }\r | |
5008 | \r | |
5009 | /**\r | |
5010 | Set the EC curve to be used for TLS flows\r | |
5011 | \r | |
5012 | This function sets the EC curve to be used for TLS flows.\r | |
5013 | \r | |
5014 | @param[in] Tls Pointer to a TLS object.\r | |
5015 | @param[in] Data An EC named curve as defined in section 5.1.1 of RFC 4492.\r | |
5016 | @param[in] DataSize Size of Data, it should be sizeof (UINT32)\r | |
5017 | \r | |
5018 | @retval EFI_SUCCESS The EC curve was set successfully.\r | |
5019 | @retval EFI_INVALID_PARAMETER The parameters are invalid.\r | |
5020 | @retval EFI_UNSUPPORTED The requested TLS EC curve is not supported\r | |
5021 | \r | |
5022 | **/\r | |
5023 | EFI_STATUS\r | |
5024 | EFIAPI\r | |
5025 | CryptoServiceTlsSetEcCurve (\r | |
5026 | IN VOID *Tls,\r | |
5027 | IN UINT8 *Data,\r | |
5028 | IN UINTN DataSize\r | |
5029 | )\r | |
5030 | {\r | |
5031 | return CALL_BASECRYPTLIB (TlsSet.Services.EcCurve, TlsSetEcCurve, (Tls, Data, DataSize), EFI_UNSUPPORTED);\r | |
5032 | }\r | |
5033 | \r | |
cc1d13c9 MK |
5034 | /**\r |
5035 | Gets the protocol version used by the specified TLS connection.\r | |
5036 | \r | |
5037 | This function returns the protocol version used by the specified TLS\r | |
5038 | connection.\r | |
5039 | \r | |
5040 | If Tls is NULL, then ASSERT().\r | |
5041 | \r | |
5042 | @param[in] Tls Pointer to the TLS object.\r | |
5043 | \r | |
5044 | @return The protocol version of the specified TLS connection.\r | |
5045 | \r | |
5046 | **/\r | |
5047 | UINT16\r | |
5048 | EFIAPI\r | |
5049 | CryptoServiceTlsGetVersion (\r | |
7c342378 | 5050 | IN VOID *Tls\r |
cc1d13c9 MK |
5051 | )\r |
5052 | {\r | |
5053 | return CALL_BASECRYPTLIB (TlsGet.Services.Version, TlsGetVersion, (Tls), 0);\r | |
5054 | }\r | |
5055 | \r | |
5056 | /**\r | |
5057 | Gets the connection end of the specified TLS connection.\r | |
5058 | \r | |
5059 | This function returns the connection end (as client or as server) used by\r | |
5060 | the specified TLS connection.\r | |
5061 | \r | |
5062 | If Tls is NULL, then ASSERT().\r | |
5063 | \r | |
5064 | @param[in] Tls Pointer to the TLS object.\r | |
5065 | \r | |
5066 | @return The connection end used by the specified TLS connection.\r | |
5067 | \r | |
5068 | **/\r | |
5069 | UINT8\r | |
5070 | EFIAPI\r | |
5071 | CryptoServiceTlsGetConnectionEnd (\r | |
7c342378 | 5072 | IN VOID *Tls\r |
cc1d13c9 MK |
5073 | )\r |
5074 | {\r | |
5075 | return CALL_BASECRYPTLIB (TlsGet.Services.ConnectionEnd, TlsGetConnectionEnd, (Tls), 0);\r | |
5076 | }\r | |
5077 | \r | |
5078 | /**\r | |
5079 | Gets the cipher suite used by the specified TLS connection.\r | |
5080 | \r | |
5081 | This function returns current cipher suite used by the specified\r | |
5082 | TLS connection.\r | |
5083 | \r | |
5084 | @param[in] Tls Pointer to the TLS object.\r | |
5085 | @param[in,out] CipherId The cipher suite used by the TLS object.\r | |
5086 | \r | |
5087 | @retval EFI_SUCCESS The cipher suite was returned successfully.\r | |
5088 | @retval EFI_INVALID_PARAMETER The parameter is invalid.\r | |
5089 | @retval EFI_UNSUPPORTED Unsupported cipher suite.\r | |
5090 | \r | |
5091 | **/\r | |
5092 | EFI_STATUS\r | |
5093 | EFIAPI\r | |
5094 | CryptoServiceTlsGetCurrentCipher (\r | |
7c342378 MK |
5095 | IN VOID *Tls,\r |
5096 | IN OUT UINT16 *CipherId\r | |
cc1d13c9 MK |
5097 | )\r |
5098 | {\r | |
5099 | return CALL_BASECRYPTLIB (TlsGet.Services.CurrentCipher, TlsGetCurrentCipher, (Tls, CipherId), EFI_UNSUPPORTED);\r | |
5100 | }\r | |
5101 | \r | |
5102 | /**\r | |
5103 | Gets the compression methods used by the specified TLS connection.\r | |
5104 | \r | |
5105 | This function returns current integrated compression methods used by\r | |
5106 | the specified TLS connection.\r | |
5107 | \r | |
5108 | @param[in] Tls Pointer to the TLS object.\r | |
5109 | @param[in,out] CompressionId The current compression method used by\r | |
5110 | the TLS object.\r | |
5111 | \r | |
5112 | @retval EFI_SUCCESS The compression method was returned successfully.\r | |
5113 | @retval EFI_INVALID_PARAMETER The parameter is invalid.\r | |
5114 | @retval EFI_ABORTED Invalid Compression method.\r | |
5115 | @retval EFI_UNSUPPORTED This function is not supported.\r | |
5116 | \r | |
5117 | **/\r | |
5118 | EFI_STATUS\r | |
5119 | EFIAPI\r | |
5120 | CryptoServiceTlsGetCurrentCompressionId (\r | |
7c342378 MK |
5121 | IN VOID *Tls,\r |
5122 | IN OUT UINT8 *CompressionId\r | |
cc1d13c9 MK |
5123 | )\r |
5124 | {\r | |
5125 | return CALL_BASECRYPTLIB (TlsGet.Services.CurrentCompressionId, TlsGetCurrentCompressionId, (Tls, CompressionId), EFI_UNSUPPORTED);\r | |
5126 | }\r | |
5127 | \r | |
5128 | /**\r | |
5129 | Gets the verification mode currently set in the TLS connection.\r | |
5130 | \r | |
5131 | This function returns the peer verification mode currently set in the\r | |
5132 | specified TLS connection.\r | |
5133 | \r | |
5134 | If Tls is NULL, then ASSERT().\r | |
5135 | \r | |
5136 | @param[in] Tls Pointer to the TLS object.\r | |
5137 | \r | |
5138 | @return The verification mode set in the specified TLS connection.\r | |
5139 | \r | |
5140 | **/\r | |
5141 | UINT32\r | |
5142 | EFIAPI\r | |
5143 | CryptoServiceTlsGetVerify (\r | |
7c342378 | 5144 | IN VOID *Tls\r |
cc1d13c9 MK |
5145 | )\r |
5146 | {\r | |
5147 | return CALL_BASECRYPTLIB (TlsGet.Services.Verify, TlsGetVerify, (Tls), 0);\r | |
5148 | }\r | |
5149 | \r | |
5150 | /**\r | |
5151 | Gets the session ID used by the specified TLS connection.\r | |
5152 | \r | |
5153 | This function returns the TLS/SSL session ID currently used by the\r | |
5154 | specified TLS connection.\r | |
5155 | \r | |
5156 | @param[in] Tls Pointer to the TLS object.\r | |
5157 | @param[in,out] SessionId Buffer to contain the returned session ID.\r | |
5158 | @param[in,out] SessionIdLen The length of Session ID in bytes.\r | |
5159 | \r | |
5160 | @retval EFI_SUCCESS The Session ID was returned successfully.\r | |
5161 | @retval EFI_INVALID_PARAMETER The parameter is invalid.\r | |
5162 | @retval EFI_UNSUPPORTED Invalid TLS/SSL session.\r | |
5163 | \r | |
5164 | **/\r | |
5165 | EFI_STATUS\r | |
5166 | EFIAPI\r | |
5167 | CryptoServiceTlsGetSessionId (\r | |
7c342378 MK |
5168 | IN VOID *Tls,\r |
5169 | IN OUT UINT8 *SessionId,\r | |
5170 | IN OUT UINT16 *SessionIdLen\r | |
cc1d13c9 MK |
5171 | )\r |
5172 | {\r | |
5173 | return CALL_BASECRYPTLIB (TlsGet.Services.SessionId, TlsGetSessionId, (Tls, SessionId, SessionIdLen), EFI_UNSUPPORTED);\r | |
5174 | }\r | |
5175 | \r | |
5176 | /**\r | |
5177 | Gets the client random data used in the specified TLS connection.\r | |
5178 | \r | |
5179 | This function returns the TLS/SSL client random data currently used in\r | |
5180 | the specified TLS connection.\r | |
5181 | \r | |
5182 | @param[in] Tls Pointer to the TLS object.\r | |
5183 | @param[in,out] ClientRandom Buffer to contain the returned client\r | |
5184 | random data (32 bytes).\r | |
5185 | \r | |
5186 | **/\r | |
5187 | VOID\r | |
5188 | EFIAPI\r | |
5189 | CryptoServiceTlsGetClientRandom (\r | |
7c342378 MK |
5190 | IN VOID *Tls,\r |
5191 | IN OUT UINT8 *ClientRandom\r | |
cc1d13c9 MK |
5192 | )\r |
5193 | {\r | |
5194 | CALL_VOID_BASECRYPTLIB (TlsGet.Services.ClientRandom, TlsGetClientRandom, (Tls, ClientRandom));\r | |
5195 | }\r | |
5196 | \r | |
5197 | /**\r | |
5198 | Gets the server random data used in the specified TLS connection.\r | |
5199 | \r | |
5200 | This function returns the TLS/SSL server random data currently used in\r | |
5201 | the specified TLS connection.\r | |
5202 | \r | |
5203 | @param[in] Tls Pointer to the TLS object.\r | |
5204 | @param[in,out] ServerRandom Buffer to contain the returned server\r | |
5205 | random data (32 bytes).\r | |
5206 | \r | |
5207 | **/\r | |
5208 | VOID\r | |
5209 | EFIAPI\r | |
5210 | CryptoServiceTlsGetServerRandom (\r | |
7c342378 MK |
5211 | IN VOID *Tls,\r |
5212 | IN OUT UINT8 *ServerRandom\r | |
cc1d13c9 MK |
5213 | )\r |
5214 | {\r | |
5215 | CALL_VOID_BASECRYPTLIB (TlsGet.Services.ServerRandom, TlsGetServerRandom, (Tls, ServerRandom));\r | |
5216 | }\r | |
5217 | \r | |
5218 | /**\r | |
5219 | Gets the master key data used in the specified TLS connection.\r | |
5220 | \r | |
5221 | This function returns the TLS/SSL master key material currently used in\r | |
5222 | the specified TLS connection.\r | |
5223 | \r | |
5224 | @param[in] Tls Pointer to the TLS object.\r | |
5225 | @param[in,out] KeyMaterial Buffer to contain the returned key material.\r | |
5226 | \r | |
5227 | @retval EFI_SUCCESS Key material was returned successfully.\r | |
5228 | @retval EFI_INVALID_PARAMETER The parameter is invalid.\r | |
5229 | @retval EFI_UNSUPPORTED Invalid TLS/SSL session.\r | |
5230 | \r | |
5231 | **/\r | |
5232 | EFI_STATUS\r | |
5233 | EFIAPI\r | |
5234 | CryptoServiceTlsGetKeyMaterial (\r | |
7c342378 MK |
5235 | IN VOID *Tls,\r |
5236 | IN OUT UINT8 *KeyMaterial\r | |
cc1d13c9 MK |
5237 | )\r |
5238 | {\r | |
5239 | return CALL_BASECRYPTLIB (TlsGet.Services.KeyMaterial, TlsGetKeyMaterial, (Tls, KeyMaterial), EFI_UNSUPPORTED);\r | |
5240 | }\r | |
5241 | \r | |
5242 | /**\r | |
5243 | Gets the CA Certificate from the cert store.\r | |
5244 | \r | |
5245 | This function returns the CA certificate for the chosen\r | |
5246 | TLS connection.\r | |
5247 | \r | |
5248 | @param[in] Tls Pointer to the TLS object.\r | |
5249 | @param[out] Data Pointer to the data buffer to receive the CA\r | |
5250 | certificate data sent to the client.\r | |
5251 | @param[in,out] DataSize The size of data buffer in bytes.\r | |
5252 | \r | |
5253 | @retval EFI_SUCCESS The operation succeeded.\r | |
5254 | @retval EFI_UNSUPPORTED This function is not supported.\r | |
5255 | @retval EFI_BUFFER_TOO_SMALL The Data is too small to hold the data.\r | |
5256 | \r | |
5257 | **/\r | |
5258 | EFI_STATUS\r | |
5259 | EFIAPI\r | |
5260 | CryptoServiceTlsGetCaCertificate (\r | |
7c342378 MK |
5261 | IN VOID *Tls,\r |
5262 | OUT VOID *Data,\r | |
5263 | IN OUT UINTN *DataSize\r | |
cc1d13c9 MK |
5264 | )\r |
5265 | {\r | |
5266 | return CALL_BASECRYPTLIB (TlsGet.Services.CaCertificate, TlsGetCaCertificate, (Tls, Data, DataSize), EFI_UNSUPPORTED);\r | |
5267 | }\r | |
5268 | \r | |
5269 | /**\r | |
5270 | Gets the local public Certificate set in the specified TLS object.\r | |
5271 | \r | |
5272 | This function returns the local public certificate which was currently set\r | |
5273 | in the specified TLS object.\r | |
5274 | \r | |
5275 | @param[in] Tls Pointer to the TLS object.\r | |
5276 | @param[out] Data Pointer to the data buffer to receive the local\r | |
5277 | public certificate.\r | |
5278 | @param[in,out] DataSize The size of data buffer in bytes.\r | |
5279 | \r | |
5280 | @retval EFI_SUCCESS The operation succeeded.\r | |
5281 | @retval EFI_INVALID_PARAMETER The parameter is invalid.\r | |
5282 | @retval EFI_NOT_FOUND The certificate is not found.\r | |
5283 | @retval EFI_BUFFER_TOO_SMALL The Data is too small to hold the data.\r | |
5284 | \r | |
5285 | **/\r | |
5286 | EFI_STATUS\r | |
5287 | EFIAPI\r | |
5288 | CryptoServiceTlsGetHostPublicCert (\r | |
7c342378 MK |
5289 | IN VOID *Tls,\r |
5290 | OUT VOID *Data,\r | |
5291 | IN OUT UINTN *DataSize\r | |
cc1d13c9 MK |
5292 | )\r |
5293 | {\r | |
5294 | return CALL_BASECRYPTLIB (TlsGet.Services.HostPublicCert, TlsGetHostPublicCert, (Tls, Data, DataSize), EFI_UNSUPPORTED);\r | |
5295 | }\r | |
5296 | \r | |
5297 | /**\r | |
5298 | Gets the local private key set in the specified TLS object.\r | |
5299 | \r | |
5300 | This function returns the local private key data which was currently set\r | |
5301 | in the specified TLS object.\r | |
5302 | \r | |
5303 | @param[in] Tls Pointer to the TLS object.\r | |
5304 | @param[out] Data Pointer to the data buffer to receive the local\r | |
5305 | private key data.\r | |
5306 | @param[in,out] DataSize The size of data buffer in bytes.\r | |
5307 | \r | |
5308 | @retval EFI_SUCCESS The operation succeeded.\r | |
5309 | @retval EFI_UNSUPPORTED This function is not supported.\r | |
5310 | @retval EFI_BUFFER_TOO_SMALL The Data is too small to hold the data.\r | |
5311 | \r | |
5312 | **/\r | |
5313 | EFI_STATUS\r | |
5314 | EFIAPI\r | |
5315 | CryptoServiceTlsGetHostPrivateKey (\r | |
7c342378 MK |
5316 | IN VOID *Tls,\r |
5317 | OUT VOID *Data,\r | |
5318 | IN OUT UINTN *DataSize\r | |
cc1d13c9 MK |
5319 | )\r |
5320 | {\r | |
5321 | return CALL_BASECRYPTLIB (TlsGet.Services.HostPrivateKey, TlsGetHostPrivateKey, (Tls, Data, DataSize), EFI_UNSUPPORTED);\r | |
5322 | }\r | |
5323 | \r | |
5324 | /**\r | |
5325 | Gets the CA-supplied certificate revocation list data set in the specified\r | |
5326 | TLS object.\r | |
5327 | \r | |
5328 | This function returns the CA-supplied certificate revocation list data which\r | |
5329 | was currently set in the specified TLS object.\r | |
5330 | \r | |
5331 | @param[out] Data Pointer to the data buffer to receive the CRL data.\r | |
5332 | @param[in,out] DataSize The size of data buffer in bytes.\r | |
5333 | \r | |
5334 | @retval EFI_SUCCESS The operation succeeded.\r | |
5335 | @retval EFI_UNSUPPORTED This function is not supported.\r | |
5336 | @retval EFI_BUFFER_TOO_SMALL The Data is too small to hold the data.\r | |
5337 | \r | |
5338 | **/\r | |
5339 | EFI_STATUS\r | |
5340 | EFIAPI\r | |
5341 | CryptoServiceTlsGetCertRevocationList (\r | |
7c342378 MK |
5342 | OUT VOID *Data,\r |
5343 | IN OUT UINTN *DataSize\r | |
cc1d13c9 MK |
5344 | )\r |
5345 | {\r | |
5346 | return CALL_BASECRYPTLIB (TlsGet.Services.CertRevocationList, TlsGetCertRevocationList, (Data, DataSize), EFI_UNSUPPORTED);\r | |
5347 | }\r | |
5348 | \r | |
8db4e9f9 YL |
5349 | /**\r |
5350 | Derive keying material from a TLS connection.\r | |
5351 | \r | |
5352 | This function exports keying material using the mechanism described in RFC\r | |
5353 | 5705.\r | |
5354 | \r | |
5355 | @param[in] Tls Pointer to the TLS object\r | |
5356 | @param[in] Label Description of the key for the PRF function\r | |
5357 | @param[in] Context Optional context\r | |
5358 | @param[in] ContextLen The length of the context value in bytes\r | |
5359 | @param[out] KeyBuffer Buffer to hold the output of the TLS-PRF\r | |
5360 | @param[in] KeyBufferLen The length of the KeyBuffer\r | |
5361 | \r | |
5362 | @retval EFI_SUCCESS The operation succeeded.\r | |
5363 | @retval EFI_INVALID_PARAMETER The TLS object is invalid.\r | |
5364 | @retval EFI_PROTOCOL_ERROR Some other error occurred.\r | |
5365 | \r | |
5366 | **/\r | |
5367 | EFI_STATUS\r | |
5368 | EFIAPI\r | |
5369 | CryptoServiceTlsGetExportKey (\r | |
5370 | IN VOID *Tls,\r | |
5371 | IN CONST VOID *Label,\r | |
5372 | IN CONST VOID *Context,\r | |
5373 | IN UINTN ContextLen,\r | |
5374 | OUT VOID *KeyBuffer,\r | |
5375 | IN UINTN KeyBufferLen\r | |
5376 | )\r | |
5377 | {\r | |
5378 | return CALL_BASECRYPTLIB (\r | |
5379 | TlsGet.Services.ExportKey,\r | |
5380 | TlsGetExportKey,\r | |
5381 | (Tls, Label, Context, ContextLen,\r | |
5382 | KeyBuffer, KeyBufferLen),\r | |
5383 | EFI_UNSUPPORTED\r | |
5384 | );\r | |
5385 | }\r | |
5386 | \r | |
c1e66210 ZL |
5387 | /**\r |
5388 | Carries out the RSA-SSA signature generation with EMSA-PSS encoding scheme.\r | |
5389 | \r | |
5390 | This function carries out the RSA-SSA signature generation with EMSA-PSS encoding scheme defined in\r | |
5391 | RFC 8017.\r | |
5392 | Mask generation function is the same as the message digest algorithm.\r | |
5393 | If the Signature buffer is too small to hold the contents of signature, FALSE\r | |
5394 | is returned and SigSize is set to the required buffer size to obtain the signature.\r | |
5395 | \r | |
5396 | If RsaContext is NULL, then return FALSE.\r | |
5397 | If Message is NULL, then return FALSE.\r | |
5398 | If MsgSize is zero or > INT_MAX, then return FALSE.\r | |
5399 | If DigestLen is NOT 32, 48 or 64, return FALSE.\r | |
5400 | If SaltLen is not equal to DigestLen, then return FALSE.\r | |
5401 | If SigSize is large enough but Signature is NULL, then return FALSE.\r | |
5402 | If this interface is not supported, then return FALSE.\r | |
5403 | \r | |
5404 | @param[in] RsaContext Pointer to RSA context for signature generation.\r | |
5405 | @param[in] Message Pointer to octet message to be signed.\r | |
5406 | @param[in] MsgSize Size of the message in bytes.\r | |
5407 | @param[in] DigestLen Length of the digest in bytes to be used for RSA signature operation.\r | |
5408 | @param[in] SaltLen Length of the salt in bytes to be used for PSS encoding.\r | |
5409 | @param[out] Signature Pointer to buffer to receive RSA PSS signature.\r | |
5410 | @param[in, out] SigSize On input, the size of Signature buffer in bytes.\r | |
5411 | On output, the size of data returned in Signature buffer in bytes.\r | |
5412 | \r | |
5413 | @retval TRUE Signature successfully generated in RSASSA-PSS.\r | |
5414 | @retval FALSE Signature generation failed.\r | |
5415 | @retval FALSE SigSize is too small.\r | |
5416 | @retval FALSE This interface is not supported.\r | |
5417 | \r | |
5418 | **/\r | |
5419 | BOOLEAN\r | |
5420 | EFIAPI\r | |
5421 | CryptoServiceRsaPssSign (\r | |
5422 | IN VOID *RsaContext,\r | |
5423 | IN CONST UINT8 *Message,\r | |
5424 | IN UINTN MsgSize,\r | |
5425 | IN UINT16 DigestLen,\r | |
5426 | IN UINT16 SaltLen,\r | |
5427 | OUT UINT8 *Signature,\r | |
5428 | IN OUT UINTN *SigSize\r | |
5429 | )\r | |
5430 | {\r | |
5431 | return CALL_BASECRYPTLIB (RsaPss.Services.Sign, RsaPssSign, (RsaContext, Message, MsgSize, DigestLen, SaltLen, Signature, SigSize), FALSE);\r | |
5432 | }\r | |
5433 | \r | |
5434 | /**\r | |
5435 | Verifies the RSA signature with RSASSA-PSS signature scheme defined in RFC 8017.\r | |
5436 | Implementation determines salt length automatically from the signature encoding.\r | |
5437 | Mask generation function is the same as the message digest algorithm.\r | |
5438 | Salt length should be equal to digest length.\r | |
5439 | \r | |
5440 | @param[in] RsaContext Pointer to RSA context for signature verification.\r | |
5441 | @param[in] Message Pointer to octet message to be verified.\r | |
5442 | @param[in] MsgSize Size of the message in bytes.\r | |
5443 | @param[in] Signature Pointer to RSASSA-PSS signature to be verified.\r | |
5444 | @param[in] SigSize Size of signature in bytes.\r | |
5445 | @param[in] DigestLen Length of digest for RSA operation.\r | |
5446 | @param[in] SaltLen Salt length for PSS encoding.\r | |
5447 | \r | |
5448 | @retval TRUE Valid signature encoded in RSASSA-PSS.\r | |
5449 | @retval FALSE Invalid signature or invalid RSA context.\r | |
5450 | \r | |
5451 | **/\r | |
5452 | BOOLEAN\r | |
5453 | EFIAPI\r | |
5454 | CryptoServiceRsaPssVerify (\r | |
5455 | IN VOID *RsaContext,\r | |
5456 | IN CONST UINT8 *Message,\r | |
5457 | IN UINTN MsgSize,\r | |
5458 | IN CONST UINT8 *Signature,\r | |
5459 | IN UINTN SigSize,\r | |
5460 | IN UINT16 DigestLen,\r | |
5461 | IN UINT16 SaltLen\r | |
5462 | )\r | |
5463 | {\r | |
5464 | return CALL_BASECRYPTLIB (RsaPss.Services.Verify, RsaPssVerify, (RsaContext, Message, MsgSize, Signature, SigSize, DigestLen, SaltLen), FALSE);\r | |
5465 | }\r | |
5466 | \r | |
5467 | /**\r | |
5468 | Parallel hash function ParallelHash256, as defined in NIST's Special Publication 800-185,\r | |
5469 | published December 2016.\r | |
5470 | \r | |
5471 | @param[in] Input Pointer to the input message (X).\r | |
5472 | @param[in] InputByteLen The number(>0) of input bytes provided for the input data.\r | |
5473 | @param[in] BlockSize The size of each block (B).\r | |
5474 | @param[out] Output Pointer to the output buffer.\r | |
5475 | @param[in] OutputByteLen The desired number of output bytes (L).\r | |
5476 | @param[in] Customization Pointer to the customization string (S).\r | |
5477 | @param[in] CustomByteLen The length of the customization string in bytes.\r | |
5478 | \r | |
5479 | @retval TRUE ParallelHash256 digest computation succeeded.\r | |
5480 | @retval FALSE ParallelHash256 digest computation failed.\r | |
5481 | @retval FALSE This interface is not supported.\r | |
5482 | \r | |
5483 | **/\r | |
5484 | BOOLEAN\r | |
5485 | EFIAPI\r | |
5486 | CryptoServiceParallelHash256HashAll (\r | |
5487 | IN CONST VOID *Input,\r | |
5488 | IN UINTN InputByteLen,\r | |
5489 | IN UINTN BlockSize,\r | |
5490 | OUT VOID *Output,\r | |
5491 | IN UINTN OutputByteLen,\r | |
5492 | IN CONST VOID *Customization,\r | |
5493 | IN UINTN CustomByteLen\r | |
5494 | )\r | |
5495 | {\r | |
5496 | return CALL_BASECRYPTLIB (ParallelHash.Services.HashAll, ParallelHash256HashAll, (Input, InputByteLen, BlockSize, Output, OutputByteLen, Customization, CustomByteLen), FALSE);\r | |
5497 | }\r | |
5498 | \r | |
022787f8 QZ |
5499 | /**\r |
5500 | Performs AEAD AES-GCM authenticated encryption on a data buffer and additional authenticated data (AAD).\r | |
5501 | \r | |
5502 | IvSize must be 12, otherwise FALSE is returned.\r | |
5503 | KeySize must be 16, 24 or 32, otherwise FALSE is returned.\r | |
5504 | TagSize must be 12, 13, 14, 15, 16, otherwise FALSE is returned.\r | |
5505 | \r | |
5506 | @param[in] Key Pointer to the encryption key.\r | |
5507 | @param[in] KeySize Size of the encryption key in bytes.\r | |
5508 | @param[in] Iv Pointer to the IV value.\r | |
5509 | @param[in] IvSize Size of the IV value in bytes.\r | |
5510 | @param[in] AData Pointer to the additional authenticated data (AAD).\r | |
5511 | @param[in] ADataSize Size of the additional authenticated data (AAD) in bytes.\r | |
5512 | @param[in] DataIn Pointer to the input data buffer to be encrypted.\r | |
5513 | @param[in] DataInSize Size of the input data buffer in bytes.\r | |
5514 | @param[out] TagOut Pointer to a buffer that receives the authentication tag output.\r | |
5515 | @param[in] TagSize Size of the authentication tag in bytes.\r | |
5516 | @param[out] DataOut Pointer to a buffer that receives the encryption output.\r | |
5517 | @param[out] DataOutSize Size of the output data buffer in bytes.\r | |
5518 | \r | |
5519 | @retval TRUE AEAD AES-GCM authenticated encryption succeeded.\r | |
5520 | @retval FALSE AEAD AES-GCM authenticated encryption failed.\r | |
5521 | \r | |
5522 | **/\r | |
5523 | BOOLEAN\r | |
5524 | EFIAPI\r | |
5525 | CryptoServiceAeadAesGcmEncrypt (\r | |
5526 | IN CONST UINT8 *Key,\r | |
5527 | IN UINTN KeySize,\r | |
5528 | IN CONST UINT8 *Iv,\r | |
5529 | IN UINTN IvSize,\r | |
5530 | IN CONST UINT8 *AData,\r | |
5531 | IN UINTN ADataSize,\r | |
5532 | IN CONST UINT8 *DataIn,\r | |
5533 | IN UINTN DataInSize,\r | |
5534 | OUT UINT8 *TagOut,\r | |
5535 | IN UINTN TagSize,\r | |
5536 | OUT UINT8 *DataOut,\r | |
5537 | OUT UINTN *DataOutSize\r | |
5538 | )\r | |
5539 | {\r | |
5540 | return CALL_BASECRYPTLIB (AeadAesGcm.Services.Encrypt, AeadAesGcmEncrypt, (Key, KeySize, Iv, IvSize, AData, ADataSize, DataIn, DataInSize, TagOut, TagSize, DataOut, DataOutSize), FALSE);\r | |
5541 | }\r | |
5542 | \r | |
5543 | /**\r | |
5544 | Performs AEAD AES-GCM authenticated decryption on a data buffer and additional authenticated data (AAD).\r | |
5545 | \r | |
5546 | IvSize must be 12, otherwise FALSE is returned.\r | |
5547 | KeySize must be 16, 24 or 32, otherwise FALSE is returned.\r | |
5548 | TagSize must be 12, 13, 14, 15, 16, otherwise FALSE is returned.\r | |
5549 | If additional authenticated data verification fails, FALSE is returned.\r | |
5550 | \r | |
5551 | @param[in] Key Pointer to the encryption key.\r | |
5552 | @param[in] KeySize Size of the encryption key in bytes.\r | |
5553 | @param[in] Iv Pointer to the IV value.\r | |
5554 | @param[in] IvSize Size of the IV value in bytes.\r | |
5555 | @param[in] AData Pointer to the additional authenticated data (AAD).\r | |
5556 | @param[in] ADataSize Size of the additional authenticated data (AAD) in bytes.\r | |
5557 | @param[in] DataIn Pointer to the input data buffer to be decrypted.\r | |
5558 | @param[in] DataInSize Size of the input data buffer in bytes.\r | |
5559 | @param[in] Tag Pointer to a buffer that contains the authentication tag.\r | |
5560 | @param[in] TagSize Size of the authentication tag in bytes.\r | |
5561 | @param[out] DataOut Pointer to a buffer that receives the decryption output.\r | |
5562 | @param[out] DataOutSize Size of the output data buffer in bytes.\r | |
5563 | \r | |
5564 | @retval TRUE AEAD AES-GCM authenticated decryption succeeded.\r | |
5565 | @retval FALSE AEAD AES-GCM authenticated decryption failed.\r | |
5566 | \r | |
5567 | **/\r | |
5568 | BOOLEAN\r | |
5569 | EFIAPI\r | |
5570 | CryptoServiceAeadAesGcmDecrypt (\r | |
5571 | IN CONST UINT8 *Key,\r | |
5572 | IN UINTN KeySize,\r | |
5573 | IN CONST UINT8 *Iv,\r | |
5574 | IN UINTN IvSize,\r | |
5575 | IN CONST UINT8 *AData,\r | |
5576 | IN UINTN ADataSize,\r | |
5577 | IN CONST UINT8 *DataIn,\r | |
5578 | IN UINTN DataInSize,\r | |
5579 | IN CONST UINT8 *Tag,\r | |
5580 | IN UINTN TagSize,\r | |
5581 | OUT UINT8 *DataOut,\r | |
5582 | OUT UINTN *DataOutSize\r | |
5583 | )\r | |
5584 | {\r | |
5585 | return CALL_BASECRYPTLIB (AeadAesGcm.Services.Decrypt, AeadAesGcmDecrypt, (Key, KeySize, Iv, IvSize, AData, ADataSize, DataIn, DataInSize, Tag, TagSize, DataOut, DataOutSize), FALSE);\r | |
5586 | }\r | |
5587 | \r | |
42951543 YL |
5588 | // =====================================================================================\r |
5589 | // Big number primitives\r | |
5590 | // =====================================================================================\r | |
5591 | \r | |
5592 | /**\r | |
5593 | Allocate new Big Number.\r | |
5594 | \r | |
5595 | @retval New BigNum opaque structure or NULL on failure.\r | |
5596 | **/\r | |
5597 | VOID *\r | |
5598 | EFIAPI\r | |
5599 | CryptoServiceBigNumInit (\r | |
5600 | VOID\r | |
5601 | )\r | |
5602 | {\r | |
5603 | return CALL_BASECRYPTLIB (Bn.Services.Init, BigNumInit, (), NULL);\r | |
5604 | }\r | |
5605 | \r | |
5606 | /**\r | |
5607 | Allocate new Big Number and assign the provided value to it.\r | |
5608 | \r | |
5609 | @param[in] Buf Big endian encoded buffer.\r | |
5610 | @param[in] Len Buffer length.\r | |
5611 | \r | |
5612 | @retval New BigNum opaque structure or NULL on failure.\r | |
5613 | **/\r | |
5614 | VOID *\r | |
5615 | EFIAPI\r | |
5616 | CryptoServiceBigNumFromBin (\r | |
5617 | IN CONST UINT8 *Buf,\r | |
5618 | IN UINTN Len\r | |
5619 | )\r | |
5620 | {\r | |
5621 | return CALL_BASECRYPTLIB (Bn.Services.FromBin, BigNumFromBin, (Buf, Len), NULL);\r | |
5622 | }\r | |
5623 | \r | |
5624 | /**\r | |
5625 | Convert the absolute value of Bn into big-endian form and store it at Buf.\r | |
5626 | The Buf array should have at least BigNumBytes() in it.\r | |
5627 | \r | |
5628 | @param[in] Bn Big number to convert.\r | |
5629 | @param[out] Buf Output buffer.\r | |
5630 | \r | |
5631 | @retval The length of the big-endian number placed at Buf or -1 on error.\r | |
5632 | **/\r | |
5633 | INTN\r | |
5634 | EFIAPI\r | |
5635 | CryptoServiceBigNumToBin (\r | |
5636 | IN CONST VOID *Bn,\r | |
5637 | OUT UINT8 *Buf\r | |
5638 | )\r | |
5639 | {\r | |
5640 | return CALL_BASECRYPTLIB (Bn.Services.ToBin, BigNumToBin, (Bn, Buf), -1);\r | |
5641 | }\r | |
5642 | \r | |
5643 | /**\r | |
5644 | Free the Big Number.\r | |
5645 | \r | |
5646 | @param[in] Bn Big number to free.\r | |
5647 | @param[in] Clear TRUE if the buffer should be cleared.\r | |
5648 | **/\r | |
5649 | VOID\r | |
5650 | EFIAPI\r | |
5651 | CryptoServiceBigNumFree (\r | |
5652 | IN VOID *Bn,\r | |
5653 | IN BOOLEAN Clear\r | |
5654 | )\r | |
5655 | {\r | |
5656 | CALL_VOID_BASECRYPTLIB (Bn.Services.Free, BigNumFree, (Bn, Clear));\r | |
5657 | }\r | |
5658 | \r | |
5659 | /**\r | |
5660 | Calculate the sum of two Big Numbers.\r | |
5661 | Please note, all "out" Big number arguments should be properly initialized\r | |
5662 | by calling to BigNumInit() or BigNumFromBin() functions.\r | |
5663 | \r | |
5664 | @param[in] BnA Big number.\r | |
5665 | @param[in] BnB Big number.\r | |
5666 | @param[out] BnRes The result of BnA + BnB.\r | |
5667 | \r | |
5668 | @retval TRUE On success.\r | |
5669 | @retval FALSE Otherwise.\r | |
5670 | **/\r | |
5671 | BOOLEAN\r | |
5672 | EFIAPI\r | |
5673 | CryptoServiceBigNumAdd (\r | |
5674 | IN CONST VOID *BnA,\r | |
5675 | IN CONST VOID *BnB,\r | |
5676 | OUT VOID *BnRes\r | |
5677 | )\r | |
5678 | {\r | |
5679 | return CALL_BASECRYPTLIB (Bn.Services.Add, BigNumAdd, (BnA, BnB, BnRes), FALSE);\r | |
5680 | }\r | |
5681 | \r | |
5682 | /**\r | |
5683 | Subtract two Big Numbers.\r | |
5684 | Please note, all "out" Big number arguments should be properly initialized\r | |
5685 | by calling to BigNumInit() or BigNumFromBin() functions.\r | |
5686 | \r | |
5687 | @param[in] BnA Big number.\r | |
5688 | @param[in] BnB Big number.\r | |
5689 | @param[out] BnRes The result of BnA - BnB.\r | |
5690 | \r | |
5691 | @retval TRUE On success.\r | |
5692 | @retval FALSE Otherwise.\r | |
5693 | **/\r | |
5694 | BOOLEAN\r | |
5695 | EFIAPI\r | |
5696 | CryptoServiceBigNumSub (\r | |
5697 | IN CONST VOID *BnA,\r | |
5698 | IN CONST VOID *BnB,\r | |
5699 | OUT VOID *BnRes\r | |
5700 | )\r | |
5701 | {\r | |
5702 | return CALL_BASECRYPTLIB (Bn.Services.Sub, BigNumSub, (BnA, BnB, BnRes), FALSE);\r | |
5703 | }\r | |
5704 | \r | |
5705 | /**\r | |
5706 | Calculate remainder: BnRes = BnA % BnB.\r | |
5707 | Please note, all "out" Big number arguments should be properly initialized\r | |
5708 | by calling to BigNumInit() or BigNumFromBin() functions.\r | |
5709 | \r | |
5710 | @param[in] BnA Big number.\r | |
5711 | @param[in] BnB Big number.\r | |
5712 | @param[out] BnRes The result of BnA % BnB.\r | |
5713 | \r | |
5714 | @retval TRUE On success.\r | |
5715 | @retval FALSE Otherwise.\r | |
5716 | **/\r | |
5717 | BOOLEAN\r | |
5718 | EFIAPI\r | |
5719 | CryptoServiceBigNumMod (\r | |
5720 | IN CONST VOID *BnA,\r | |
5721 | IN CONST VOID *BnB,\r | |
5722 | OUT VOID *BnRes\r | |
5723 | )\r | |
5724 | {\r | |
5725 | return CALL_BASECRYPTLIB (Bn.Services.Mod, BigNumMod, (BnA, BnB, BnRes), FALSE);\r | |
5726 | }\r | |
5727 | \r | |
5728 | /**\r | |
5729 | Compute BnA to the BnP-th power modulo BnM.\r | |
5730 | Please note, all "out" Big number arguments should be properly initialized.\r | |
5731 | by calling to BigNumInit() or BigNumFromBin() functions.\r | |
5732 | \r | |
5733 | @param[in] BnA Big number.\r | |
5734 | @param[in] BnP Big number (power).\r | |
5735 | @param[in] BnM Big number (modulo).\r | |
5736 | @param[out] BnRes The result of (BnA ^ BnP) % BnM.\r | |
5737 | \r | |
5738 | @retval TRUE On success.\r | |
5739 | @retval FALSE Otherwise.\r | |
5740 | **/\r | |
5741 | BOOLEAN\r | |
5742 | EFIAPI\r | |
5743 | CryptoServiceBigNumExpMod (\r | |
5744 | IN CONST VOID *BnA,\r | |
5745 | IN CONST VOID *BnP,\r | |
5746 | IN CONST VOID *BnM,\r | |
5747 | OUT VOID *BnRes\r | |
5748 | )\r | |
5749 | {\r | |
5750 | return CALL_BASECRYPTLIB (Bn.Services.ExpMod, BigNumExpMod, (BnA, BnP, BnM, BnRes), FALSE);\r | |
5751 | }\r | |
5752 | \r | |
5753 | /**\r | |
5754 | Compute BnA inverse modulo BnM.\r | |
5755 | Please note, all "out" Big number arguments should be properly initialized\r | |
5756 | by calling to BigNumInit() or BigNumFromBin() functions.\r | |
5757 | \r | |
5758 | @param[in] BnA Big number.\r | |
5759 | @param[in] BnM Big number (modulo).\r | |
5760 | @param[out] BnRes The result, such that (BnA * BnRes) % BnM == 1.\r | |
5761 | \r | |
5762 | @retval TRUE On success.\r | |
5763 | @retval FALSE Otherwise.\r | |
5764 | **/\r | |
5765 | BOOLEAN\r | |
5766 | EFIAPI\r | |
5767 | CryptoServiceBigNumInverseMod (\r | |
5768 | IN CONST VOID *BnA,\r | |
5769 | IN CONST VOID *BnM,\r | |
5770 | OUT VOID *BnRes\r | |
5771 | )\r | |
5772 | {\r | |
5773 | return CALL_BASECRYPTLIB (Bn.Services.InverseMod, BigNumInverseMod, (BnA, BnM, BnRes), FALSE);\r | |
5774 | }\r | |
5775 | \r | |
5776 | /**\r | |
5777 | Divide two Big Numbers.\r | |
5778 | Please note, all "out" Big number arguments should be properly initialized\r | |
5779 | by calling to BigNumInit() or BigNumFromBin() functions.\r | |
5780 | \r | |
5781 | @param[in] BnA Big number.\r | |
5782 | @param[in] BnB Big number.\r | |
5783 | @param[out] BnRes The result, such that BnA / BnB.\r | |
5784 | \r | |
5785 | @retval TRUE On success.\r | |
5786 | @retval FALSE Otherwise.\r | |
5787 | **/\r | |
5788 | BOOLEAN\r | |
5789 | EFIAPI\r | |
5790 | CryptoServiceBigNumDiv (\r | |
5791 | IN CONST VOID *BnA,\r | |
5792 | IN CONST VOID *BnB,\r | |
5793 | OUT VOID *BnRes\r | |
5794 | )\r | |
5795 | {\r | |
5796 | return CALL_BASECRYPTLIB (Bn.Services.Div, BigNumDiv, (BnA, BnB, BnRes), FALSE);\r | |
5797 | }\r | |
5798 | \r | |
5799 | /**\r | |
5800 | Multiply two Big Numbers modulo BnM.\r | |
5801 | Please note, all "out" Big number arguments should be properly initialized\r | |
5802 | by calling to BigNumInit() or BigNumFromBin() functions.\r | |
5803 | \r | |
5804 | @param[in] BnA Big number.\r | |
5805 | @param[in] BnB Big number.\r | |
5806 | @param[in] BnM Big number (modulo).\r | |
5807 | @param[out] BnRes The result, such that (BnA * BnB) % BnM.\r | |
5808 | \r | |
5809 | @retval TRUE On success.\r | |
5810 | @retval FALSE Otherwise.\r | |
5811 | **/\r | |
5812 | BOOLEAN\r | |
5813 | EFIAPI\r | |
5814 | CryptoServiceBigNumMulMod (\r | |
5815 | IN CONST VOID *BnA,\r | |
5816 | IN CONST VOID *BnB,\r | |
5817 | IN CONST VOID *BnM,\r | |
5818 | OUT VOID *BnRes\r | |
5819 | )\r | |
5820 | {\r | |
5821 | return CALL_BASECRYPTLIB (Bn.Services.MulMod, BigNumMulMod, (BnA, BnB, BnM, BnRes), FALSE);\r | |
5822 | }\r | |
5823 | \r | |
5824 | /**\r | |
5825 | Compare two Big Numbers.\r | |
5826 | \r | |
5827 | @param[in] BnA Big number.\r | |
5828 | @param[in] BnB Big number.\r | |
5829 | \r | |
5830 | @retval 0 BnA == BnB.\r | |
5831 | @retval 1 BnA > BnB.\r | |
5832 | @retval -1 BnA < BnB.\r | |
5833 | **/\r | |
5834 | INTN\r | |
5835 | EFIAPI\r | |
5836 | CryptoServiceBigNumCmp (\r | |
5837 | IN CONST VOID *BnA,\r | |
5838 | IN CONST VOID *BnB\r | |
5839 | )\r | |
5840 | {\r | |
5841 | return CALL_BASECRYPTLIB (Bn.Services.Cmp, BigNumCmp, (BnA, BnB), 0);\r | |
5842 | }\r | |
5843 | \r | |
5844 | /**\r | |
5845 | Get number of bits in Bn.\r | |
5846 | \r | |
5847 | @param[in] Bn Big number.\r | |
5848 | \r | |
5849 | @retval Number of bits.\r | |
5850 | **/\r | |
5851 | UINTN\r | |
5852 | EFIAPI\r | |
5853 | CryptoServiceBigNumBits (\r | |
5854 | IN CONST VOID *Bn\r | |
5855 | )\r | |
5856 | {\r | |
5857 | return CALL_BASECRYPTLIB (Bn.Services.Bits, BigNumBits, (Bn), 0);\r | |
5858 | }\r | |
5859 | \r | |
5860 | /**\r | |
5861 | Get number of bytes in Bn.\r | |
5862 | \r | |
5863 | @param[in] Bn Big number.\r | |
5864 | \r | |
5865 | @retval Number of bytes.\r | |
5866 | **/\r | |
5867 | UINTN\r | |
5868 | EFIAPI\r | |
5869 | CryptoServiceBigNumBytes (\r | |
5870 | IN CONST VOID *Bn\r | |
5871 | )\r | |
5872 | {\r | |
5873 | return CALL_BASECRYPTLIB (Bn.Services.Bytes, BigNumBytes, (Bn), 0);\r | |
5874 | }\r | |
5875 | \r | |
5876 | /**\r | |
5877 | Checks if Big Number equals to the given Num.\r | |
5878 | \r | |
5879 | @param[in] Bn Big number.\r | |
5880 | @param[in] Num Number.\r | |
5881 | \r | |
5882 | @retval TRUE iff Bn == Num.\r | |
5883 | @retval FALSE otherwise.\r | |
5884 | **/\r | |
5885 | BOOLEAN\r | |
5886 | EFIAPI\r | |
5887 | CryptoServiceBigNumIsWord (\r | |
5888 | IN CONST VOID *Bn,\r | |
5889 | IN UINTN Num\r | |
5890 | )\r | |
5891 | {\r | |
5892 | return CALL_BASECRYPTLIB (Bn.Services.IsWord, BigNumIsWord, (Bn, Num), FALSE);\r | |
5893 | }\r | |
5894 | \r | |
5895 | /**\r | |
5896 | Checks if Big Number is odd.\r | |
5897 | \r | |
5898 | @param[in] Bn Big number.\r | |
5899 | \r | |
5900 | @retval TRUE Bn is odd (Bn % 2 == 1).\r | |
5901 | @retval FALSE otherwise.\r | |
5902 | **/\r | |
5903 | BOOLEAN\r | |
5904 | EFIAPI\r | |
5905 | CryptoServiceBigNumIsOdd (\r | |
5906 | IN CONST VOID *Bn\r | |
5907 | )\r | |
5908 | {\r | |
5909 | return CALL_BASECRYPTLIB (Bn.Services.IsOdd, BigNumIsOdd, (Bn), FALSE);\r | |
5910 | }\r | |
5911 | \r | |
5912 | /**\r | |
5913 | Copy Big number.\r | |
5914 | \r | |
5915 | @param[out] BnDst Destination.\r | |
5916 | @param[in] BnSrc Source.\r | |
5917 | \r | |
5918 | @retval BnDst on success.\r | |
5919 | @retval NULL otherwise.\r | |
5920 | **/\r | |
5921 | VOID *\r | |
5922 | EFIAPI\r | |
5923 | CryptoServiceBigNumCopy (\r | |
5924 | OUT VOID *BnDst,\r | |
5925 | IN CONST VOID *BnSrc\r | |
5926 | )\r | |
5927 | {\r | |
5928 | return CALL_BASECRYPTLIB (Bn.Services.Copy, BigNumCopy, (BnDst, BnSrc), NULL);\r | |
5929 | }\r | |
5930 | \r | |
5931 | /**\r | |
5932 | Get constant Big number with value of "1".\r | |
5933 | This may be used to save expensive allocations.\r | |
5934 | \r | |
5935 | @retval Big Number with value of 1.\r | |
5936 | **/\r | |
5937 | CONST VOID *\r | |
5938 | EFIAPI\r | |
5939 | CryptoServiceBigNumValueOne (\r | |
5940 | VOID\r | |
5941 | )\r | |
5942 | {\r | |
5943 | return CALL_BASECRYPTLIB (Bn.Services.ValueOne, BigNumValueOne, (), NULL);\r | |
5944 | }\r | |
5945 | \r | |
5946 | /**\r | |
5947 | Shift right Big Number.\r | |
5948 | Please note, all "out" Big number arguments should be properly initialized\r | |
5949 | by calling to BigNumInit() or BigNumFromBin() functions.\r | |
5950 | \r | |
5951 | @param[in] Bn Big number.\r | |
5952 | @param[in] N Number of bits to shift.\r | |
5953 | @param[out] BnRes The result.\r | |
5954 | \r | |
5955 | @retval TRUE On success.\r | |
5956 | @retval FALSE Otherwise.\r | |
5957 | **/\r | |
5958 | BOOLEAN\r | |
5959 | EFIAPI\r | |
5960 | CryptoServiceBigNumRShift (\r | |
5961 | IN CONST VOID *Bn,\r | |
5962 | IN UINTN N,\r | |
5963 | OUT VOID *BnRes\r | |
5964 | )\r | |
5965 | {\r | |
5966 | return CALL_BASECRYPTLIB (Bn.Services.RShift, BigNumRShift, (Bn, N, BnRes), FALSE);\r | |
5967 | }\r | |
5968 | \r | |
5969 | /**\r | |
5970 | Mark Big Number for constant time computations.\r | |
5971 | This function should be called before any constant time computations are\r | |
5972 | performed on the given Big number.\r | |
5973 | \r | |
5974 | @param[in] Bn Big number.\r | |
5975 | **/\r | |
5976 | VOID\r | |
5977 | EFIAPI\r | |
5978 | CryptoServiceBigNumConstTime (\r | |
5979 | IN VOID *Bn\r | |
5980 | )\r | |
5981 | {\r | |
5982 | CALL_VOID_BASECRYPTLIB (Bn.Services.ConstTime, BigNumConstTime, (Bn));\r | |
5983 | }\r | |
5984 | \r | |
5985 | /**\r | |
5986 | Calculate square modulo.\r | |
5987 | Please note, all "out" Big number arguments should be properly initialized\r | |
5988 | by calling to BigNumInit() or BigNumFromBin() functions.\r | |
5989 | \r | |
5990 | @param[in] BnA Big number.\r | |
5991 | @param[in] BnM Big number (modulo).\r | |
5992 | @param[out] BnRes The result, such that (BnA ^ 2) % BnM.\r | |
5993 | \r | |
5994 | @retval TRUE On success.\r | |
5995 | @retval FALSE Otherwise.\r | |
5996 | **/\r | |
5997 | BOOLEAN\r | |
5998 | EFIAPI\r | |
5999 | CryptoServiceBigNumSqrMod (\r | |
6000 | IN CONST VOID *BnA,\r | |
6001 | IN CONST VOID *BnM,\r | |
6002 | OUT VOID *BnRes\r | |
6003 | )\r | |
6004 | {\r | |
6005 | return CALL_BASECRYPTLIB (Bn.Services.SqrMod, BigNumSqrMod, (BnA, BnM, BnRes), FALSE);\r | |
6006 | }\r | |
6007 | \r | |
6008 | /**\r | |
6009 | Create new Big Number computation context. This is an opaque structure\r | |
6010 | which should be passed to any function that requires it. The BN context is\r | |
6011 | needed to optimize calculations and expensive allocations.\r | |
6012 | \r | |
6013 | @retval Big Number context struct or NULL on failure.\r | |
6014 | **/\r | |
6015 | VOID *\r | |
6016 | EFIAPI\r | |
6017 | CryptoServiceBigNumNewContext (\r | |
6018 | VOID\r | |
6019 | )\r | |
6020 | {\r | |
6021 | return CALL_BASECRYPTLIB (Bn.Services.NewContext, BigNumNewContext, (), NULL);\r | |
6022 | }\r | |
6023 | \r | |
6024 | /**\r | |
6025 | Free Big Number context that was allocated with BigNumNewContext().\r | |
6026 | \r | |
6027 | @param[in] BnCtx Big number context to free.\r | |
6028 | **/\r | |
6029 | VOID\r | |
6030 | EFIAPI\r | |
6031 | CryptoServiceBigNumContextFree (\r | |
6032 | IN VOID *BnCtx\r | |
6033 | )\r | |
6034 | {\r | |
6035 | CALL_VOID_BASECRYPTLIB (Bn.Services.ContextFree, BigNumContextFree, (BnCtx));\r | |
6036 | }\r | |
6037 | \r | |
6038 | /**\r | |
6039 | Set Big Number to a given value.\r | |
6040 | \r | |
6041 | @param[in] Bn Big number to set.\r | |
6042 | @param[in] Val Value to set.\r | |
6043 | \r | |
6044 | @retval TRUE On success.\r | |
6045 | @retval FALSE Otherwise.\r | |
6046 | **/\r | |
6047 | BOOLEAN\r | |
6048 | EFIAPI\r | |
6049 | CryptoServiceBigNumSetUint (\r | |
6050 | IN VOID *Bn,\r | |
6051 | IN UINTN Val\r | |
6052 | )\r | |
6053 | {\r | |
6054 | return CALL_BASECRYPTLIB (Bn.Services.SetUint, BigNumSetUint, (Bn, Val), FALSE);\r | |
6055 | }\r | |
6056 | \r | |
6057 | /**\r | |
6058 | Add two Big Numbers modulo BnM.\r | |
6059 | \r | |
6060 | @param[in] BnA Big number.\r | |
6061 | @param[in] BnB Big number.\r | |
6062 | @param[in] BnM Big number (modulo).\r | |
6063 | @param[out] BnRes The result, such that (BnA + BnB) % BnM.\r | |
6064 | \r | |
6065 | @retval TRUE On success.\r | |
6066 | @retval FALSE Otherwise.\r | |
6067 | **/\r | |
6068 | BOOLEAN\r | |
6069 | EFIAPI\r | |
6070 | CryptoServiceBigNumAddMod (\r | |
6071 | IN CONST VOID *BnA,\r | |
6072 | IN CONST VOID *BnB,\r | |
6073 | IN CONST VOID *BnM,\r | |
6074 | OUT VOID *BnRes\r | |
6075 | )\r | |
6076 | {\r | |
6077 | return CALL_BASECRYPTLIB (Bn.Services.AddMod, BigNumAddMod, (BnA, BnB, BnM, BnRes), FALSE);\r | |
6078 | }\r | |
6079 | \r | |
3b382f5b YL |
6080 | // =====================================================================================\r |
6081 | // Basic Elliptic Curve Primitives\r | |
6082 | // =====================================================================================\r | |
6083 | \r | |
6084 | /**\r | |
6085 | Initialize new opaque EcGroup object. This object represents an EC curve and\r | |
6086 | and is used for calculation within this group. This object should be freed\r | |
6087 | using EcGroupFree() function.\r | |
6088 | \r | |
6089 | @param[in] CryptoNid Identifying number for the ECC curve (Defined in\r | |
6090 | BaseCryptLib.h).\r | |
6091 | \r | |
6092 | @retval EcGroup object On success.\r | |
6093 | @retval NULL On failure.\r | |
6094 | **/\r | |
6095 | VOID *\r | |
6096 | EFIAPI\r | |
6097 | CryptoServiceEcGroupInit (\r | |
6098 | IN UINTN CryptoNid\r | |
6099 | )\r | |
6100 | {\r | |
6101 | return CALL_BASECRYPTLIB (Ec.Services.GroupInit, EcGroupInit, (CryptoNid), NULL);\r | |
6102 | }\r | |
6103 | \r | |
6104 | /**\r | |
6105 | Get EC curve parameters. While elliptic curve equation is Y^2 mod P = (X^3 + AX + B) Mod P.\r | |
6106 | This function will set the provided Big Number objects to the corresponding\r | |
6107 | values. The caller needs to make sure all the "out" BigNumber parameters\r | |
6108 | are properly initialized.\r | |
6109 | @param[in] EcGroup EC group object.\r | |
6110 | @param[out] BnPrime Group prime number.\r | |
6111 | @param[out] BnA A coefficient.\r | |
6112 | @param[out] BnB B coefficient.\r | |
6113 | @param[in] BnCtx BN context.\r | |
6114 | \r | |
6115 | @retval TRUE On success.\r | |
6116 | @retval FALSE Otherwise.\r | |
6117 | **/\r | |
6118 | BOOLEAN\r | |
6119 | EFIAPI\r | |
6120 | CryptoServiceEcGroupGetCurve (\r | |
6121 | IN CONST VOID *EcGroup,\r | |
6122 | OUT VOID *BnPrime,\r | |
6123 | OUT VOID *BnA,\r | |
6124 | OUT VOID *BnB,\r | |
6125 | IN VOID *BnCtx\r | |
6126 | )\r | |
6127 | {\r | |
6128 | return CALL_BASECRYPTLIB (Ec.Services.GroupGetCurve, EcGroupGetCurve, (EcGroup, BnPrime, BnA, BnB, BnCtx), FALSE);\r | |
6129 | }\r | |
6130 | \r | |
6131 | /**\r | |
6132 | Get EC group order.\r | |
6133 | This function will set the provided Big Number object to the corresponding\r | |
6134 | value. The caller needs to make sure that the "out" BigNumber parameter\r | |
6135 | is properly initialized.\r | |
6136 | \r | |
6137 | @param[in] EcGroup EC group object.\r | |
6138 | @param[out] BnOrder Group prime number.\r | |
6139 | \r | |
6140 | @retval TRUE On success.\r | |
6141 | @retval FALSE Otherwise.\r | |
6142 | **/\r | |
6143 | BOOLEAN\r | |
6144 | EFIAPI\r | |
6145 | CryptoServiceEcGroupGetOrder (\r | |
6146 | IN VOID *EcGroup,\r | |
6147 | OUT VOID *BnOrder\r | |
6148 | )\r | |
6149 | {\r | |
6150 | return CALL_BASECRYPTLIB (Ec.Services.GroupGetOrder, EcGroupGetOrder, (EcGroup, BnOrder), FALSE);\r | |
6151 | }\r | |
6152 | \r | |
6153 | /**\r | |
6154 | Free previously allocated EC group object using EcGroupInit().\r | |
6155 | \r | |
6156 | @param[in] EcGroup EC group object to free.\r | |
6157 | **/\r | |
6158 | VOID\r | |
6159 | EFIAPI\r | |
6160 | CryptoServiceEcGroupFree (\r | |
6161 | IN VOID *EcGroup\r | |
6162 | )\r | |
6163 | {\r | |
6164 | CALL_VOID_BASECRYPTLIB (Ec.Services.GroupFree, EcGroupFree, (EcGroup));\r | |
6165 | }\r | |
6166 | \r | |
6167 | /**\r | |
6168 | Initialize new opaque EC Point object. This object represents an EC point\r | |
6169 | within the given EC group (curve).\r | |
6170 | \r | |
6171 | @param[in] EC Group, properly initialized using EcGroupInit().\r | |
6172 | \r | |
6173 | @retval EC Point object On success.\r | |
6174 | @retval NULL On failure.\r | |
6175 | **/\r | |
6176 | VOID *\r | |
6177 | EFIAPI\r | |
6178 | CryptoServiceEcPointInit (\r | |
6179 | IN CONST VOID *EcGroup\r | |
6180 | )\r | |
6181 | {\r | |
6182 | return CALL_BASECRYPTLIB (Ec.Services.PointInit, EcPointInit, (EcGroup), NULL);\r | |
6183 | }\r | |
6184 | \r | |
6185 | /**\r | |
6186 | Free previously allocated EC Point object using EcPointInit().\r | |
6187 | \r | |
6188 | @param[in] EcPoint EC Point to free.\r | |
6189 | @param[in] Clear TRUE iff the memory should be cleared.\r | |
6190 | **/\r | |
6191 | VOID\r | |
6192 | EFIAPI\r | |
6193 | CryptoServiceEcPointDeInit (\r | |
6194 | IN VOID *EcPoint,\r | |
6195 | IN BOOLEAN Clear\r | |
6196 | )\r | |
6197 | {\r | |
6198 | CALL_VOID_BASECRYPTLIB (Ec.Services.PointDeInit, EcPointDeInit, (EcPoint, Clear));\r | |
6199 | }\r | |
6200 | \r | |
6201 | /**\r | |
6202 | Get EC point affine (x,y) coordinates.\r | |
6203 | This function will set the provided Big Number objects to the corresponding\r | |
6204 | values. The caller needs to make sure all the "out" BigNumber parameters\r | |
6205 | are properly initialized.\r | |
6206 | \r | |
6207 | @param[in] EcGroup EC group object.\r | |
6208 | @param[in] EcPoint EC point object.\r | |
6209 | @param[out] BnX X coordinate.\r | |
6210 | @param[out] BnY Y coordinate.\r | |
6211 | @param[in] BnCtx BN context, created with BigNumNewContext().\r | |
6212 | \r | |
6213 | @retval TRUE On success.\r | |
6214 | @retval FALSE Otherwise.\r | |
6215 | **/\r | |
6216 | BOOLEAN\r | |
6217 | EFIAPI\r | |
6218 | CryptoServiceEcPointGetAffineCoordinates (\r | |
6219 | IN CONST VOID *EcGroup,\r | |
6220 | IN CONST VOID *EcPoint,\r | |
6221 | OUT VOID *BnX,\r | |
6222 | OUT VOID *BnY,\r | |
6223 | IN VOID *BnCtx\r | |
6224 | )\r | |
6225 | {\r | |
6226 | return CALL_BASECRYPTLIB (Ec.Services.PointGetAffineCoordinates, EcPointGetAffineCoordinates, (EcGroup, EcPoint, BnX, BnY, BnCtx), FALSE);\r | |
6227 | }\r | |
6228 | \r | |
6229 | /**\r | |
6230 | Set EC point affine (x,y) coordinates.\r | |
6231 | \r | |
6232 | @param[in] EcGroup EC group object.\r | |
6233 | @param[in] EcPoint EC point object.\r | |
6234 | @param[in] BnX X coordinate.\r | |
6235 | @param[in] BnY Y coordinate.\r | |
6236 | @param[in] BnCtx BN context, created with BigNumNewContext().\r | |
6237 | \r | |
6238 | @retval TRUE On success.\r | |
6239 | @retval FALSE Otherwise.\r | |
6240 | **/\r | |
6241 | BOOLEAN\r | |
6242 | EFIAPI\r | |
6243 | CryptoServiceEcPointSetAffineCoordinates (\r | |
6244 | IN CONST VOID *EcGroup,\r | |
6245 | IN VOID *EcPoint,\r | |
6246 | IN CONST VOID *BnX,\r | |
6247 | IN CONST VOID *BnY,\r | |
6248 | IN VOID *BnCtx\r | |
6249 | )\r | |
6250 | {\r | |
6251 | return CALL_BASECRYPTLIB (Ec.Services.PointSetAffineCoordinates, EcPointSetAffineCoordinates, (EcGroup, EcPoint, BnX, BnY, BnCtx), FALSE);\r | |
6252 | }\r | |
6253 | \r | |
6254 | /**\r | |
6255 | EC Point addition. EcPointResult = EcPointA + EcPointB.\r | |
6256 | @param[in] EcGroup EC group object.\r | |
6257 | @param[out] EcPointResult EC point to hold the result. The point should\r | |
6258 | be properly initialized.\r | |
6259 | @param[in] EcPointA EC Point.\r | |
6260 | @param[in] EcPointB EC Point.\r | |
6261 | @param[in] BnCtx BN context, created with BigNumNewContext().\r | |
6262 | \r | |
6263 | @retval TRUE On success.\r | |
6264 | @retval FALSE Otherwise.\r | |
6265 | **/\r | |
6266 | BOOLEAN\r | |
6267 | EFIAPI\r | |
6268 | CryptoServiceEcPointAdd (\r | |
6269 | IN CONST VOID *EcGroup,\r | |
6270 | OUT VOID *EcPointResult,\r | |
6271 | IN CONST VOID *EcPointA,\r | |
6272 | IN CONST VOID *EcPointB,\r | |
6273 | IN VOID *BnCtx\r | |
6274 | )\r | |
6275 | {\r | |
6276 | return CALL_BASECRYPTLIB (Ec.Services.PointAdd, EcPointAdd, (EcGroup, EcPointResult, EcPointA, EcPointB, BnCtx), FALSE);\r | |
6277 | }\r | |
6278 | \r | |
6279 | /**\r | |
6280 | Variable EC point multiplication. EcPointResult = EcPoint * BnPScalar.\r | |
6281 | \r | |
6282 | @param[in] EcGroup EC group object.\r | |
6283 | @param[out] EcPointResult EC point to hold the result. The point should\r | |
6284 | be properly initialized.\r | |
6285 | @param[in] EcPoint EC Point.\r | |
6286 | @param[in] BnPScalar P Scalar.\r | |
6287 | @param[in] BnCtx BN context, created with BigNumNewContext().\r | |
6288 | \r | |
6289 | @retval TRUE On success.\r | |
6290 | @retval FALSE Otherwise.\r | |
6291 | **/\r | |
6292 | BOOLEAN\r | |
6293 | EFIAPI\r | |
6294 | CryptoServiceEcPointMul (\r | |
6295 | IN CONST VOID *EcGroup,\r | |
6296 | OUT VOID *EcPointResult,\r | |
6297 | IN CONST VOID *EcPoint,\r | |
6298 | IN CONST VOID *BnPScalar,\r | |
6299 | IN VOID *BnCtx\r | |
6300 | )\r | |
6301 | {\r | |
6302 | return CALL_BASECRYPTLIB (Ec.Services.PointMul, EcPointMul, (EcGroup, EcPointResult, EcPoint, BnPScalar, BnCtx), FALSE);\r | |
6303 | }\r | |
6304 | \r | |
6305 | /**\r | |
6306 | Calculate the inverse of the supplied EC point.\r | |
6307 | \r | |
6308 | @param[in] EcGroup EC group object.\r | |
6309 | @param[in,out] EcPoint EC point to invert.\r | |
6310 | @param[in] BnCtx BN context, created with BigNumNewContext().\r | |
6311 | \r | |
6312 | @retval TRUE On success.\r | |
6313 | @retval FALSE Otherwise.\r | |
6314 | **/\r | |
6315 | BOOLEAN\r | |
6316 | EFIAPI\r | |
6317 | CryptoServiceEcPointInvert (\r | |
6318 | IN CONST VOID *EcGroup,\r | |
6319 | IN OUT VOID *EcPoint,\r | |
6320 | IN VOID *BnCtx\r | |
6321 | )\r | |
6322 | {\r | |
6323 | return CALL_BASECRYPTLIB (Ec.Services.PointInvert, EcPointInvert, (EcGroup, EcPoint, BnCtx), FALSE);\r | |
6324 | }\r | |
6325 | \r | |
6326 | /**\r | |
6327 | Check if the supplied point is on EC curve.\r | |
6328 | \r | |
6329 | @param[in] EcGroup EC group object.\r | |
6330 | @param[in] EcPoint EC point to check.\r | |
6331 | @param[in] BnCtx BN context, created with BigNumNewContext().\r | |
6332 | \r | |
6333 | @retval TRUE On curve.\r | |
6334 | @retval FALSE Otherwise.\r | |
6335 | **/\r | |
6336 | BOOLEAN\r | |
6337 | EFIAPI\r | |
6338 | CryptoServiceEcPointIsOnCurve (\r | |
6339 | IN CONST VOID *EcGroup,\r | |
6340 | IN CONST VOID *EcPoint,\r | |
6341 | IN VOID *BnCtx\r | |
6342 | )\r | |
6343 | {\r | |
6344 | return CALL_BASECRYPTLIB (Ec.Services.PointIsOnCurve, EcPointIsOnCurve, (EcGroup, EcPoint, BnCtx), FALSE);\r | |
6345 | }\r | |
6346 | \r | |
6347 | /**\r | |
6348 | Check if the supplied point is at infinity.\r | |
6349 | \r | |
6350 | @param[in] EcGroup EC group object.\r | |
6351 | @param[in] EcPoint EC point to check.\r | |
6352 | \r | |
6353 | @retval TRUE At infinity.\r | |
6354 | @retval FALSE Otherwise.\r | |
6355 | **/\r | |
6356 | BOOLEAN\r | |
6357 | EFIAPI\r | |
6358 | CryptoServiceEcPointIsAtInfinity (\r | |
6359 | IN CONST VOID *EcGroup,\r | |
6360 | IN CONST VOID *EcPoint\r | |
6361 | )\r | |
6362 | {\r | |
6363 | return CALL_BASECRYPTLIB (Ec.Services.PointIsAtInfinity, EcPointIsAtInfinity, (EcGroup, EcPoint), FALSE);\r | |
6364 | }\r | |
6365 | \r | |
6366 | /**\r | |
6367 | Check if EC points are equal.\r | |
6368 | \r | |
6369 | @param[in] EcGroup EC group object.\r | |
6370 | @param[in] EcPointA EC point A.\r | |
6371 | @param[in] EcPointB EC point B.\r | |
6372 | @param[in] BnCtx BN context, created with BigNumNewContext().\r | |
6373 | \r | |
6374 | @retval TRUE A == B.\r | |
6375 | @retval FALSE Otherwise.\r | |
6376 | **/\r | |
6377 | BOOLEAN\r | |
6378 | EFIAPI\r | |
6379 | CryptoServiceEcPointEqual (\r | |
6380 | IN CONST VOID *EcGroup,\r | |
6381 | IN CONST VOID *EcPointA,\r | |
6382 | IN CONST VOID *EcPointB,\r | |
6383 | IN VOID *BnCtx\r | |
6384 | )\r | |
6385 | {\r | |
6386 | return CALL_BASECRYPTLIB (Ec.Services.PointEqual, EcPointEqual, (EcGroup, EcPointA, EcPointB, BnCtx), FALSE);\r | |
6387 | }\r | |
6388 | \r | |
6389 | /**\r | |
6390 | Set EC point compressed coordinates. Points can be described in terms of\r | |
6391 | their compressed coordinates. For a point (x, y), for any given value for x\r | |
6392 | such that the point is on the curve there will only ever be two possible\r | |
6393 | values for y. Therefore, a point can be set using this function where BnX is\r | |
6394 | the x coordinate and YBit is a value 0 or 1 to identify which of the two\r | |
6395 | possible values for y should be used.\r | |
6396 | \r | |
6397 | @param[in] EcGroup EC group object.\r | |
6398 | @param[in] EcPoint EC Point.\r | |
6399 | @param[in] BnX X coordinate.\r | |
6400 | @param[in] YBit 0 or 1 to identify which Y value is used.\r | |
6401 | @param[in] BnCtx BN context, created with BigNumNewContext().\r | |
6402 | \r | |
6403 | @retval TRUE On success.\r | |
6404 | @retval FALSE Otherwise.\r | |
6405 | **/\r | |
6406 | BOOLEAN\r | |
6407 | EFIAPI\r | |
6408 | CryptoServiceEcPointSetCompressedCoordinates (\r | |
6409 | IN CONST VOID *EcGroup,\r | |
6410 | IN VOID *EcPoint,\r | |
6411 | IN CONST VOID *BnX,\r | |
6412 | IN UINT8 YBit,\r | |
6413 | IN VOID *BnCtx\r | |
6414 | )\r | |
6415 | {\r | |
6416 | return CALL_BASECRYPTLIB (Ec.Services.PointSetCompressedCoordinates, EcPointSetCompressedCoordinates, (EcGroup, EcPoint, BnX, YBit, BnCtx), FALSE);\r | |
6417 | }\r | |
6418 | \r | |
6419 | // =====================================================================================\r | |
6420 | // Elliptic Curve Diffie Hellman Primitives\r | |
6421 | // =====================================================================================\r | |
6422 | \r | |
6423 | /**\r | |
6424 | Allocates and Initializes one Elliptic Curve Context for subsequent use\r | |
6425 | with the NID.\r | |
6426 | \r | |
6427 | @param[in] Nid cipher NID\r | |
6428 | @return Pointer to the Elliptic Curve Context that has been initialized.\r | |
6429 | If the allocations fails, EcNewByNid() returns NULL.\r | |
6430 | **/\r | |
6431 | VOID *\r | |
6432 | EFIAPI\r | |
6433 | CryptoServiceEcNewByNid (\r | |
6434 | IN UINTN Nid\r | |
6435 | )\r | |
6436 | {\r | |
6437 | return CALL_BASECRYPTLIB (Ec.Services.NewByNid, EcNewByNid, (Nid), NULL);\r | |
6438 | }\r | |
6439 | \r | |
6440 | /**\r | |
6441 | Release the specified EC context.\r | |
6442 | \r | |
6443 | @param[in] EcContext Pointer to the EC context to be released.\r | |
6444 | **/\r | |
6445 | VOID\r | |
6446 | EFIAPI\r | |
6447 | CryptoServiceEcFree (\r | |
6448 | IN VOID *EcContext\r | |
6449 | )\r | |
6450 | {\r | |
6451 | CALL_VOID_BASECRYPTLIB (Ec.Services.Free, EcFree, (EcContext));\r | |
6452 | }\r | |
6453 | \r | |
6454 | /**\r | |
6455 | Generates EC key and returns EC public key (X, Y), Please note, this function uses\r | |
6456 | pseudo random number generator. The caller must make sure RandomSeed()\r | |
6457 | function was properly called before.\r | |
6458 | The Ec context should be correctly initialized by EcNewByNid.\r | |
6459 | This function generates random secret, and computes the public key (X, Y), which is\r | |
6460 | returned via parameter Public, PublicSize.\r | |
6461 | X is the first half of Public with size being PublicSize / 2,\r | |
6462 | Y is the second half of Public with size being PublicSize / 2.\r | |
6463 | EC context is updated accordingly.\r | |
6464 | If the Public buffer is too small to hold the public X, Y, FALSE is returned and\r | |
6465 | PublicSize is set to the required buffer size to obtain the public X, Y.\r | |
6466 | For P-256, the PublicSize is 64. First 32-byte is X, Second 32-byte is Y.\r | |
6467 | For P-384, the PublicSize is 96. First 48-byte is X, Second 48-byte is Y.\r | |
6468 | For P-521, the PublicSize is 132. First 66-byte is X, Second 66-byte is Y.\r | |
6469 | If EcContext is NULL, then return FALSE.\r | |
6470 | If PublicSize is NULL, then return FALSE.\r | |
6471 | If PublicSize is large enough but Public is NULL, then return FALSE.\r | |
6472 | @param[in, out] EcContext Pointer to the EC context.\r | |
6473 | @param[out] PublicKey Pointer to t buffer to receive generated public X,Y.\r | |
6474 | @param[in, out] PublicKeySize On input, the size of Public buffer in bytes.\r | |
6475 | On output, the size of data returned in Public buffer in bytes.\r | |
6476 | @retval TRUE EC public X,Y generation succeeded.\r | |
6477 | @retval FALSE EC public X,Y generation failed.\r | |
6478 | @retval FALSE PublicKeySize is not large enough.\r | |
6479 | **/\r | |
6480 | BOOLEAN\r | |
6481 | EFIAPI\r | |
6482 | CryptoServiceEcGenerateKey (\r | |
6483 | IN OUT VOID *EcContext,\r | |
6484 | OUT UINT8 *PublicKey,\r | |
6485 | IN OUT UINTN *PublicKeySize\r | |
6486 | )\r | |
6487 | {\r | |
6488 | return CALL_BASECRYPTLIB (Ec.Services.GenerateKey, EcGenerateKey, (EcContext, PublicKey, PublicKeySize), FALSE);\r | |
6489 | }\r | |
6490 | \r | |
6491 | /**\r | |
6492 | Gets the public key component from the established EC context.\r | |
6493 | The Ec context should be correctly initialized by EcNewByNid, and successfully\r | |
6494 | generate key pair from EcGenerateKey().\r | |
6495 | For P-256, the PublicSize is 64. First 32-byte is X, Second 32-byte is Y.\r | |
6496 | For P-384, the PublicSize is 96. First 48-byte is X, Second 48-byte is Y.\r | |
6497 | For P-521, the PublicSize is 132. First 66-byte is X, Second 66-byte is Y.\r | |
6498 | @param[in, out] EcContext Pointer to EC context being set.\r | |
6499 | @param[out] PublicKey Pointer to t buffer to receive generated public X,Y.\r | |
6500 | @param[in, out] PublicKeySize On input, the size of Public buffer in bytes.\r | |
6501 | On output, the size of data returned in Public buffer in bytes.\r | |
6502 | @retval TRUE EC key component was retrieved successfully.\r | |
6503 | @retval FALSE Invalid EC key component.\r | |
6504 | **/\r | |
6505 | BOOLEAN\r | |
6506 | EFIAPI\r | |
6507 | CryptoServiceEcGetPubKey (\r | |
6508 | IN OUT VOID *EcContext,\r | |
6509 | OUT UINT8 *PublicKey,\r | |
6510 | IN OUT UINTN *PublicKeySize\r | |
6511 | )\r | |
6512 | {\r | |
6513 | return CALL_BASECRYPTLIB (Ec.Services.GetPubKey, EcGetPubKey, (EcContext, PublicKey, PublicKeySize), FALSE);\r | |
6514 | }\r | |
6515 | \r | |
6516 | /**\r | |
6517 | Computes exchanged common key.\r | |
6518 | Given peer's public key (X, Y), this function computes the exchanged common key,\r | |
6519 | based on its own context including value of curve parameter and random secret.\r | |
6520 | X is the first half of PeerPublic with size being PeerPublicSize / 2,\r | |
6521 | Y is the second half of PeerPublic with size being PeerPublicSize / 2.\r | |
6522 | If EcContext is NULL, then return FALSE.\r | |
6523 | If PeerPublic is NULL, then return FALSE.\r | |
6524 | If PeerPublicSize is 0, then return FALSE.\r | |
6525 | If Key is NULL, then return FALSE.\r | |
6526 | If KeySize is not large enough, then return FALSE.\r | |
6527 | For P-256, the PeerPublicSize is 64. First 32-byte is X, Second 32-byte is Y.\r | |
6528 | For P-384, the PeerPublicSize is 96. First 48-byte is X, Second 48-byte is Y.\r | |
6529 | For P-521, the PeerPublicSize is 132. First 66-byte is X, Second 66-byte is Y.\r | |
6530 | @param[in, out] EcContext Pointer to the EC context.\r | |
6531 | @param[in] PeerPublic Pointer to the peer's public X,Y.\r | |
6532 | @param[in] PeerPublicSize Size of peer's public X,Y in bytes.\r | |
6533 | @param[in] CompressFlag Flag of PeerPublic is compressed or not.\r | |
6534 | @param[out] Key Pointer to the buffer to receive generated key.\r | |
6535 | @param[in, out] KeySize On input, the size of Key buffer in bytes.\r | |
6536 | On output, the size of data returned in Key buffer in bytes.\r | |
6537 | @retval TRUE EC exchanged key generation succeeded.\r | |
6538 | @retval FALSE EC exchanged key generation failed.\r | |
6539 | @retval FALSE KeySize is not large enough.\r | |
6540 | **/\r | |
6541 | BOOLEAN\r | |
6542 | EFIAPI\r | |
6543 | CryptoServiceEcDhComputeKey (\r | |
6544 | IN OUT VOID *EcContext,\r | |
6545 | IN CONST UINT8 *PeerPublic,\r | |
6546 | IN UINTN PeerPublicSize,\r | |
6547 | IN CONST INT32 *CompressFlag,\r | |
6548 | OUT UINT8 *Key,\r | |
6549 | IN OUT UINTN *KeySize\r | |
6550 | )\r | |
6551 | {\r | |
6552 | return CALL_BASECRYPTLIB (Ec.Services.DhComputeKey, EcDhComputeKey, (EcContext, PeerPublic, PeerPublicSize, CompressFlag, Key, KeySize), FALSE);\r | |
6553 | }\r | |
6554 | \r | |
69a50a24 QZ |
6555 | /**\r |
6556 | Retrieve the EC Public Key from one DER-encoded X509 certificate.\r | |
6557 | \r | |
6558 | @param[in] Cert Pointer to the DER-encoded X509 certificate.\r | |
6559 | @param[in] CertSize Size of the X509 certificate in bytes.\r | |
6560 | @param[out] EcContext Pointer to new-generated EC DSA context which contain the retrieved\r | |
6561 | EC public key component. Use EcFree() function to free the\r | |
6562 | resource.\r | |
6563 | \r | |
6564 | If Cert is NULL, then return FALSE.\r | |
6565 | If EcContext is NULL, then return FALSE.\r | |
6566 | \r | |
6567 | @retval TRUE EC Public Key was retrieved successfully.\r | |
6568 | @retval FALSE Fail to retrieve EC public key from X509 certificate.\r | |
6569 | \r | |
6570 | **/\r | |
6571 | BOOLEAN\r | |
6572 | EFIAPI\r | |
6573 | CryptoServiceEcGetPublicKeyFromX509 (\r | |
6574 | IN CONST UINT8 *Cert,\r | |
6575 | IN UINTN CertSize,\r | |
6576 | OUT VOID **EcContext\r | |
6577 | )\r | |
6578 | {\r | |
6579 | return CALL_BASECRYPTLIB (Ec.Services.GetPublicKeyFromX509, EcGetPublicKeyFromX509, (Cert, CertSize, EcContext), FALSE);\r | |
6580 | }\r | |
6581 | \r | |
6582 | /**\r | |
6583 | Retrieve the EC Private Key from the password-protected PEM key data.\r | |
6584 | \r | |
6585 | @param[in] PemData Pointer to the PEM-encoded key data to be retrieved.\r | |
6586 | @param[in] PemSize Size of the PEM key data in bytes.\r | |
6587 | @param[in] Password NULL-terminated passphrase used for encrypted PEM key data.\r | |
6588 | @param[out] EcContext Pointer to new-generated EC DSA context which contain the retrieved\r | |
6589 | EC private key component. Use EcFree() function to free the\r | |
6590 | resource.\r | |
6591 | \r | |
6592 | If PemData is NULL, then return FALSE.\r | |
6593 | If EcContext is NULL, then return FALSE.\r | |
6594 | \r | |
6595 | @retval TRUE EC Private Key was retrieved successfully.\r | |
6596 | @retval FALSE Invalid PEM key data or incorrect password.\r | |
6597 | \r | |
6598 | **/\r | |
6599 | BOOLEAN\r | |
6600 | EFIAPI\r | |
6601 | CryptoServiceEcGetPrivateKeyFromPem (\r | |
6602 | IN CONST UINT8 *PemData,\r | |
6603 | IN UINTN PemSize,\r | |
6604 | IN CONST CHAR8 *Password,\r | |
6605 | OUT VOID **EcContext\r | |
6606 | )\r | |
6607 | {\r | |
6608 | return CALL_BASECRYPTLIB (Ec.Services.GetPrivateKeyFromPem, EcGetPrivateKeyFromPem, (PemData, PemSize, Password, EcContext), FALSE);\r | |
6609 | }\r | |
6610 | \r | |
6611 | /**\r | |
6612 | Carries out the EC-DSA signature.\r | |
6613 | \r | |
6614 | This function carries out the EC-DSA signature.\r | |
6615 | If the Signature buffer is too small to hold the contents of signature, FALSE\r | |
6616 | is returned and SigSize is set to the required buffer size to obtain the signature.\r | |
6617 | \r | |
6618 | If EcContext is NULL, then return FALSE.\r | |
6619 | If MessageHash is NULL, then return FALSE.\r | |
6620 | If HashSize need match the HashNid. HashNid could be SHA256, SHA384, SHA512, SHA3_256, SHA3_384, SHA3_512.\r | |
6621 | If SigSize is large enough but Signature is NULL, then return FALSE.\r | |
6622 | \r | |
6623 | For P-256, the SigSize is 64. First 32-byte is R, Second 32-byte is S.\r | |
6624 | For P-384, the SigSize is 96. First 48-byte is R, Second 48-byte is S.\r | |
6625 | For P-521, the SigSize is 132. First 66-byte is R, Second 66-byte is S.\r | |
6626 | \r | |
6627 | @param[in] EcContext Pointer to EC context for signature generation.\r | |
6628 | @param[in] HashNid hash NID\r | |
6629 | @param[in] MessageHash Pointer to octet message hash to be signed.\r | |
6630 | @param[in] HashSize Size of the message hash in bytes.\r | |
6631 | @param[out] Signature Pointer to buffer to receive EC-DSA signature.\r | |
6632 | @param[in, out] SigSize On input, the size of Signature buffer in bytes.\r | |
6633 | On output, the size of data returned in Signature buffer in bytes.\r | |
6634 | \r | |
6635 | @retval TRUE Signature successfully generated in EC-DSA.\r | |
6636 | @retval FALSE Signature generation failed.\r | |
6637 | @retval FALSE SigSize is too small.\r | |
6638 | \r | |
6639 | **/\r | |
6640 | BOOLEAN\r | |
6641 | EFIAPI\r | |
6642 | CryptoServiceEcDsaSign (\r | |
6643 | IN VOID *EcContext,\r | |
6644 | IN UINTN HashNid,\r | |
6645 | IN CONST UINT8 *MessageHash,\r | |
6646 | IN UINTN HashSize,\r | |
6647 | OUT UINT8 *Signature,\r | |
6648 | IN OUT UINTN *SigSize\r | |
6649 | )\r | |
6650 | {\r | |
6651 | return CALL_BASECRYPTLIB (Ec.Services.DsaSign, EcDsaSign, (EcContext, HashNid, MessageHash, HashSize, Signature, SigSize), FALSE);\r | |
6652 | }\r | |
6653 | \r | |
6654 | /**\r | |
6655 | Verifies the EC-DSA signature.\r | |
6656 | \r | |
6657 | If EcContext is NULL, then return FALSE.\r | |
6658 | If MessageHash is NULL, then return FALSE.\r | |
6659 | If Signature is NULL, then return FALSE.\r | |
6660 | If HashSize need match the HashNid. HashNid could be SHA256, SHA384, SHA512, SHA3_256, SHA3_384, SHA3_512.\r | |
6661 | \r | |
6662 | For P-256, the SigSize is 64. First 32-byte is R, Second 32-byte is S.\r | |
6663 | For P-384, the SigSize is 96. First 48-byte is R, Second 48-byte is S.\r | |
6664 | For P-521, the SigSize is 132. First 66-byte is R, Second 66-byte is S.\r | |
6665 | \r | |
6666 | @param[in] EcContext Pointer to EC context for signature verification.\r | |
6667 | @param[in] HashNid hash NID\r | |
6668 | @param[in] MessageHash Pointer to octet message hash to be checked.\r | |
6669 | @param[in] HashSize Size of the message hash in bytes.\r | |
6670 | @param[in] Signature Pointer to EC-DSA signature to be verified.\r | |
6671 | @param[in] SigSize Size of signature in bytes.\r | |
6672 | \r | |
6673 | @retval TRUE Valid signature encoded in EC-DSA.\r | |
6674 | @retval FALSE Invalid signature or invalid EC context.\r | |
6675 | \r | |
6676 | **/\r | |
6677 | BOOLEAN\r | |
6678 | EFIAPI\r | |
6679 | CryptoServiceEcDsaVerify (\r | |
6680 | IN VOID *EcContext,\r | |
6681 | IN UINTN HashNid,\r | |
6682 | IN CONST UINT8 *MessageHash,\r | |
6683 | IN UINTN HashSize,\r | |
6684 | IN CONST UINT8 *Signature,\r | |
6685 | IN UINTN SigSize\r | |
6686 | )\r | |
6687 | {\r | |
6688 | return CALL_BASECRYPTLIB (Ec.Services.DsaVerify, EcDsaVerify, (EcContext, HashNid, MessageHash, HashSize, Signature, SigSize), FALSE);\r | |
6689 | }\r | |
6690 | \r | |
7c342378 | 6691 | const EDKII_CRYPTO_PROTOCOL mEdkiiCrypto = {\r |
cc1d13c9 MK |
6692 | /// Version\r |
6693 | CryptoServiceGetCryptoVersion,\r | |
b6174e2d ZG |
6694 | /// HMAC MD5 - deprecated and unsupported\r |
6695 | DeprecatedCryptoServiceHmacMd5New,\r | |
6696 | DeprecatedCryptoServiceHmacMd5Free,\r | |
6697 | DeprecatedCryptoServiceHmacMd5SetKey,\r | |
6698 | DeprecatedCryptoServiceHmacMd5Duplicate,\r | |
6699 | DeprecatedCryptoServiceHmacMd5Update,\r | |
6700 | DeprecatedCryptoServiceHmacMd5Final,\r | |
c812d320 ZG |
6701 | /// HMAC SHA1 - deprecated and unsupported\r |
6702 | DeprecatedCryptoServiceHmacSha1New,\r | |
6703 | DeprecatedCryptoServiceHmacSha1Free,\r | |
6704 | DeprecatedCryptoServiceHmacSha1SetKey,\r | |
6705 | DeprecatedCryptoServiceHmacSha1Duplicate,\r | |
6706 | DeprecatedCryptoServiceHmacSha1Update,\r | |
6707 | DeprecatedCryptoServiceHmacSha1Final,\r | |
cc1d13c9 MK |
6708 | /// HMAC SHA256\r |
6709 | CryptoServiceHmacSha256New,\r | |
6710 | CryptoServiceHmacSha256Free,\r | |
6711 | CryptoServiceHmacSha256SetKey,\r | |
6712 | CryptoServiceHmacSha256Duplicate,\r | |
6713 | CryptoServiceHmacSha256Update,\r | |
6714 | CryptoServiceHmacSha256Final,\r | |
0a6fc3d0 ZG |
6715 | /// Md4 - deprecated and unsupported\r |
6716 | DeprecatedCryptoServiceMd4GetContextSize,\r | |
6717 | DeprecatedCryptoServiceMd4Init,\r | |
6718 | DeprecatedCryptoServiceMd4Duplicate,\r | |
6719 | DeprecatedCryptoServiceMd4Update,\r | |
6720 | DeprecatedCryptoServiceMd4Final,\r | |
6721 | DeprecatedCryptoServiceMd4HashAll,\r | |
7c342378 | 6722 | #ifndef ENABLE_MD5_DEPRECATED_INTERFACES\r |
acfd5557 ZG |
6723 | /// Md5 - deprecated and unsupported\r |
6724 | DeprecatedCryptoServiceMd5GetContextSize,\r | |
6725 | DeprecatedCryptoServiceMd5Init,\r | |
6726 | DeprecatedCryptoServiceMd5Duplicate,\r | |
6727 | DeprecatedCryptoServiceMd5Update,\r | |
6728 | DeprecatedCryptoServiceMd5Final,\r | |
6729 | DeprecatedCryptoServiceMd5HashAll,\r | |
7c342378 | 6730 | #else\r |
cc1d13c9 MK |
6731 | /// Md5\r |
6732 | CryptoServiceMd5GetContextSize,\r | |
6733 | CryptoServiceMd5Init,\r | |
6734 | CryptoServiceMd5Duplicate,\r | |
6735 | CryptoServiceMd5Update,\r | |
6736 | CryptoServiceMd5Final,\r | |
6737 | CryptoServiceMd5HashAll,\r | |
7c342378 | 6738 | #endif\r |
cc1d13c9 MK |
6739 | /// Pkcs\r |
6740 | CryptoServicePkcs1v2Encrypt,\r | |
6741 | CryptoServicePkcs5HashPassword,\r | |
6742 | CryptoServicePkcs7Verify,\r | |
6743 | CryptoServiceVerifyEKUsInPkcs7Signature,\r | |
6744 | CryptoServicePkcs7GetSigners,\r | |
6745 | CryptoServicePkcs7FreeSigners,\r | |
6746 | CryptoServicePkcs7Sign,\r | |
6747 | CryptoServicePkcs7GetAttachedContent,\r | |
6748 | CryptoServicePkcs7GetCertificatesList,\r | |
6749 | CryptoServiceAuthenticodeVerify,\r | |
6750 | CryptoServiceImageTimestampVerify,\r | |
6751 | /// DH\r | |
6752 | CryptoServiceDhNew,\r | |
6753 | CryptoServiceDhFree,\r | |
6754 | CryptoServiceDhGenerateParameter,\r | |
6755 | CryptoServiceDhSetParameter,\r | |
6756 | CryptoServiceDhGenerateKey,\r | |
6757 | CryptoServiceDhComputeKey,\r | |
6758 | /// Random\r | |
6759 | CryptoServiceRandomSeed,\r | |
6760 | CryptoServiceRandomBytes,\r | |
6761 | /// RSA\r | |
6762 | CryptoServiceRsaPkcs1Verify,\r | |
6763 | CryptoServiceRsaNew,\r | |
6764 | CryptoServiceRsaFree,\r | |
6765 | CryptoServiceRsaSetKey,\r | |
6766 | CryptoServiceRsaGetKey,\r | |
6767 | CryptoServiceRsaGenerateKey,\r | |
6768 | CryptoServiceRsaCheckKey,\r | |
6769 | CryptoServiceRsaPkcs1Sign,\r | |
6770 | CryptoServiceRsaPkcs1Verify,\r | |
6771 | CryptoServiceRsaGetPrivateKeyFromPem,\r | |
6772 | CryptoServiceRsaGetPublicKeyFromX509,\r | |
7c342378 | 6773 | #ifdef DISABLE_SHA1_DEPRECATED_INTERFACES\r |
0f01cec5 ZG |
6774 | /// Sha1 - deprecated and unsupported\r |
6775 | DeprecatedCryptoServiceSha1GetContextSize,\r | |
6776 | DeprecatedCryptoServiceSha1Init,\r | |
6777 | DeprecatedCryptoServiceSha1Duplicate,\r | |
6778 | DeprecatedCryptoServiceSha1Update,\r | |
6779 | DeprecatedCryptoServiceSha1Final,\r | |
6780 | DeprecatedCryptoServiceSha1HashAll,\r | |
7c342378 | 6781 | #else\r |
cc1d13c9 MK |
6782 | /// Sha1\r |
6783 | CryptoServiceSha1GetContextSize,\r | |
6784 | CryptoServiceSha1Init,\r | |
6785 | CryptoServiceSha1Duplicate,\r | |
6786 | CryptoServiceSha1Update,\r | |
6787 | CryptoServiceSha1Final,\r | |
6788 | CryptoServiceSha1HashAll,\r | |
7c342378 | 6789 | #endif\r |
cc1d13c9 MK |
6790 | /// Sha256\r |
6791 | CryptoServiceSha256GetContextSize,\r | |
6792 | CryptoServiceSha256Init,\r | |
6793 | CryptoServiceSha256Duplicate,\r | |
6794 | CryptoServiceSha256Update,\r | |
6795 | CryptoServiceSha256Final,\r | |
6796 | CryptoServiceSha256HashAll,\r | |
6797 | /// Sha384\r | |
6798 | CryptoServiceSha384GetContextSize,\r | |
6799 | CryptoServiceSha384Init,\r | |
6800 | CryptoServiceSha384Duplicate,\r | |
6801 | CryptoServiceSha384Update,\r | |
6802 | CryptoServiceSha384Final,\r | |
6803 | CryptoServiceSha384HashAll,\r | |
6804 | /// Sha512\r | |
6805 | CryptoServiceSha512GetContextSize,\r | |
6806 | CryptoServiceSha512Init,\r | |
6807 | CryptoServiceSha512Duplicate,\r | |
6808 | CryptoServiceSha512Update,\r | |
6809 | CryptoServiceSha512Final,\r | |
6810 | CryptoServiceSha512HashAll,\r | |
6811 | /// X509\r | |
6812 | CryptoServiceX509GetSubjectName,\r | |
6813 | CryptoServiceX509GetCommonName,\r | |
6814 | CryptoServiceX509GetOrganizationName,\r | |
6815 | CryptoServiceX509VerifyCert,\r | |
6816 | CryptoServiceX509ConstructCertificate,\r | |
6817 | CryptoServiceX509ConstructCertificateStack,\r | |
6818 | CryptoServiceX509Free,\r | |
6819 | CryptoServiceX509StackFree,\r | |
6820 | CryptoServiceX509GetTBSCert,\r | |
b8af2c9e ZG |
6821 | /// TDES - deprecated and unsupported\r |
6822 | DeprecatedCryptoServiceTdesGetContextSize,\r | |
6823 | DeprecatedCryptoServiceTdesInit,\r | |
6824 | DeprecatedCryptoServiceTdesEcbEncrypt,\r | |
6825 | DeprecatedCryptoServiceTdesEcbDecrypt,\r | |
6826 | DeprecatedCryptoServiceTdesCbcEncrypt,\r | |
6827 | DeprecatedCryptoServiceTdesCbcDecrypt,\r | |
80e28dce | 6828 | /// AES - ECB mode is deprecated and unsupported\r |
cc1d13c9 MK |
6829 | CryptoServiceAesGetContextSize,\r |
6830 | CryptoServiceAesInit,\r | |
80e28dce ZG |
6831 | DeprecatedCryptoServiceAesEcbEncrypt,\r |
6832 | DeprecatedCryptoServiceAesEcbDecrypt,\r | |
cc1d13c9 MK |
6833 | CryptoServiceAesCbcEncrypt,\r |
6834 | CryptoServiceAesCbcDecrypt,\r | |
c22a32e1 ZG |
6835 | /// Arc4 - deprecated and unsupported\r |
6836 | DeprecatedCryptoServiceArc4GetContextSize,\r | |
6837 | DeprecatedCryptoServiceArc4Init,\r | |
6838 | DeprecatedCryptoServiceArc4Encrypt,\r | |
6839 | DeprecatedCryptoServiceArc4Decrypt,\r | |
6840 | DeprecatedCryptoServiceArc4Reset,\r | |
cc1d13c9 MK |
6841 | /// SM3\r |
6842 | CryptoServiceSm3GetContextSize,\r | |
6843 | CryptoServiceSm3Init,\r | |
6844 | CryptoServiceSm3Duplicate,\r | |
6845 | CryptoServiceSm3Update,\r | |
6846 | CryptoServiceSm3Final,\r | |
6847 | CryptoServiceSm3HashAll,\r | |
6848 | /// HKDF\r | |
6849 | CryptoServiceHkdfSha256ExtractAndExpand,\r | |
6850 | /// X509 (Continued)\r | |
6851 | CryptoServiceX509ConstructCertificateStackV,\r | |
6852 | /// TLS\r | |
6853 | CryptoServiceTlsInitialize,\r | |
6854 | CryptoServiceTlsCtxFree,\r | |
6855 | CryptoServiceTlsCtxNew,\r | |
6856 | CryptoServiceTlsFree,\r | |
6857 | CryptoServiceTlsNew,\r | |
6858 | CryptoServiceTlsInHandshake,\r | |
6859 | CryptoServiceTlsDoHandshake,\r | |
6860 | CryptoServiceTlsHandleAlert,\r | |
6861 | CryptoServiceTlsCloseNotify,\r | |
6862 | CryptoServiceTlsCtrlTrafficOut,\r | |
6863 | CryptoServiceTlsCtrlTrafficIn,\r | |
6864 | CryptoServiceTlsRead,\r | |
6865 | CryptoServiceTlsWrite,\r | |
6866 | /// TLS Set\r | |
6867 | CryptoServiceTlsSetVersion,\r | |
6868 | CryptoServiceTlsSetConnectionEnd,\r | |
6869 | CryptoServiceTlsSetCipherList,\r | |
6870 | CryptoServiceTlsSetCompressionMethod,\r | |
6871 | CryptoServiceTlsSetVerify,\r | |
6872 | CryptoServiceTlsSetVerifyHost,\r | |
6873 | CryptoServiceTlsSetSessionId,\r | |
6874 | CryptoServiceTlsSetCaCertificate,\r | |
6875 | CryptoServiceTlsSetHostPublicCert,\r | |
6876 | CryptoServiceTlsSetHostPrivateKey,\r | |
6877 | CryptoServiceTlsSetCertRevocationList,\r | |
6878 | /// TLS Get\r | |
6879 | CryptoServiceTlsGetVersion,\r | |
6880 | CryptoServiceTlsGetConnectionEnd,\r | |
6881 | CryptoServiceTlsGetCurrentCipher,\r | |
6882 | CryptoServiceTlsGetCurrentCompressionId,\r | |
6883 | CryptoServiceTlsGetVerify,\r | |
6884 | CryptoServiceTlsGetSessionId,\r | |
6885 | CryptoServiceTlsGetClientRandom,\r | |
6886 | CryptoServiceTlsGetServerRandom,\r | |
6887 | CryptoServiceTlsGetKeyMaterial,\r | |
6888 | CryptoServiceTlsGetCaCertificate,\r | |
6889 | CryptoServiceTlsGetHostPublicCert,\r | |
6890 | CryptoServiceTlsGetHostPrivateKey,\r | |
c1e66210 ZL |
6891 | CryptoServiceTlsGetCertRevocationList,\r |
6892 | /// RSA PSS\r | |
6893 | CryptoServiceRsaPssSign,\r | |
6894 | CryptoServiceRsaPssVerify,\r | |
6895 | /// Parallel hash\r | |
3f77ccb9 QZ |
6896 | CryptoServiceParallelHash256HashAll,\r |
6897 | /// HMAC SHA256 (continued)\r | |
6898 | CryptoServiceHmacSha256All,\r | |
6899 | /// HMAC SHA384\r | |
6900 | CryptoServiceHmacSha384New,\r | |
6901 | CryptoServiceHmacSha384Free,\r | |
6902 | CryptoServiceHmacSha384SetKey,\r | |
6903 | CryptoServiceHmacSha384Duplicate,\r | |
6904 | CryptoServiceHmacSha384Update,\r | |
6905 | CryptoServiceHmacSha384Final,\r | |
e919c390 QZ |
6906 | CryptoServiceHmacSha384All,\r |
6907 | /// HKDF (continued)\r | |
6908 | CryptoServiceHkdfSha256Extract,\r | |
6909 | CryptoServiceHkdfSha256Expand,\r | |
6910 | CryptoServiceHkdfSha384ExtractAndExpand,\r | |
6911 | CryptoServiceHkdfSha384Extract,\r | |
022787f8 QZ |
6912 | CryptoServiceHkdfSha384Expand,\r |
6913 | /// Aead Aes GCM\r | |
6914 | CryptoServiceAeadAesGcmEncrypt,\r | |
42951543 YL |
6915 | CryptoServiceAeadAesGcmDecrypt,\r |
6916 | /// Big Numbers\r | |
6917 | CryptoServiceBigNumInit,\r | |
6918 | CryptoServiceBigNumFromBin,\r | |
6919 | CryptoServiceBigNumToBin,\r | |
6920 | CryptoServiceBigNumFree,\r | |
6921 | CryptoServiceBigNumAdd,\r | |
6922 | CryptoServiceBigNumSub,\r | |
6923 | CryptoServiceBigNumMod,\r | |
6924 | CryptoServiceBigNumExpMod,\r | |
6925 | CryptoServiceBigNumInverseMod,\r | |
6926 | CryptoServiceBigNumDiv,\r | |
6927 | CryptoServiceBigNumMulMod,\r | |
6928 | CryptoServiceBigNumCmp,\r | |
6929 | CryptoServiceBigNumBits,\r | |
6930 | CryptoServiceBigNumBytes,\r | |
6931 | CryptoServiceBigNumIsWord,\r | |
6932 | CryptoServiceBigNumIsOdd,\r | |
6933 | CryptoServiceBigNumCopy,\r | |
6934 | CryptoServiceBigNumValueOne,\r | |
6935 | CryptoServiceBigNumRShift,\r | |
6936 | CryptoServiceBigNumConstTime,\r | |
6937 | CryptoServiceBigNumSqrMod,\r | |
6938 | CryptoServiceBigNumNewContext,\r | |
6939 | CryptoServiceBigNumContextFree,\r | |
6940 | CryptoServiceBigNumSetUint,\r | |
6941 | CryptoServiceBigNumAddMod,\r | |
3b382f5b YL |
6942 | /// EC\r |
6943 | CryptoServiceEcGroupInit,\r | |
6944 | CryptoServiceEcGroupGetCurve,\r | |
6945 | CryptoServiceEcGroupGetOrder,\r | |
6946 | CryptoServiceEcGroupFree,\r | |
6947 | CryptoServiceEcPointInit,\r | |
6948 | CryptoServiceEcPointDeInit,\r | |
6949 | CryptoServiceEcPointGetAffineCoordinates,\r | |
6950 | CryptoServiceEcPointSetAffineCoordinates,\r | |
6951 | CryptoServiceEcPointAdd,\r | |
6952 | CryptoServiceEcPointMul,\r | |
6953 | CryptoServiceEcPointInvert,\r | |
6954 | CryptoServiceEcPointIsOnCurve,\r | |
6955 | CryptoServiceEcPointIsAtInfinity,\r | |
6956 | CryptoServiceEcPointEqual,\r | |
6957 | CryptoServiceEcPointSetCompressedCoordinates,\r | |
6958 | CryptoServiceEcNewByNid,\r | |
6959 | CryptoServiceEcFree,\r | |
6960 | CryptoServiceEcGenerateKey,\r | |
6961 | CryptoServiceEcGetPubKey,\r | |
6962 | CryptoServiceEcDhComputeKey,\r | |
8db4e9f9 YL |
6963 | /// TLS (continued)\r |
6964 | CryptoServiceTlsShutdown,\r | |
6965 | /// TLS Set (continued)\r | |
6966 | CryptoServiceTlsSetHostPrivateKeyEx,\r | |
6967 | CryptoServiceTlsSetSignatureAlgoList,\r | |
6968 | CryptoServiceTlsSetEcCurve,\r | |
6969 | /// TLS Get (continued)\r | |
69a50a24 QZ |
6970 | CryptoServiceTlsGetExportKey,\r |
6971 | /// Ec (Continued)\r | |
6972 | CryptoServiceEcGetPublicKeyFromX509,\r | |
6973 | CryptoServiceEcGetPrivateKeyFromPem,\r | |
6974 | CryptoServiceEcDsaSign,\r | |
22745df6 QZ |
6975 | CryptoServiceEcDsaVerify,\r |
6976 | /// X509 (Continued)\r | |
6977 | CryptoServiceX509GetVersion,\r | |
6978 | CryptoServiceX509GetSerialNumber,\r | |
6979 | CryptoServiceX509GetIssuerName,\r | |
6980 | CryptoServiceX509GetSignatureAlgorithm,\r | |
6981 | CryptoServiceX509GetExtensionData,\r | |
6982 | CryptoServiceX509GetExtendedKeyUsage,\r | |
6983 | CryptoServiceX509GetValidity,\r | |
6984 | CryptoServiceX509FormatDateTime,\r | |
6985 | CryptoServiceX509CompareDateTime,\r | |
6986 | CryptoServiceX509GetKeyUsage,\r | |
6987 | CryptoServiceX509VerifyCertChain,\r | |
6988 | CryptoServiceX509GetCertFromCertChain,\r | |
6989 | CryptoServiceAsn1GetTag,\r | |
6990 | CryptoServiceX509GetExtendedBasicConstraints\r | |
cc1d13c9 | 6991 | };\r |