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