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