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