]>
Commit | Line | Data |
---|---|---|
cd70de1c MK |
1 | /** @file\r |
2 | Implements the BaseCryptLib and TlsLib using the services of the EDK II Crypto\r | |
3 | Protocol/PPI.\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 | \r | |
11 | #include <Base.h>\r | |
12 | #include <Library/BaseLib.h>\r | |
13 | #include <Library/DebugLib.h>\r | |
14 | #include <Library/BaseCryptLib.h>\r | |
15 | #include <Library/TlsLib.h>\r | |
16 | #include <Protocol/Crypto.h>\r | |
17 | \r | |
18 | /**\r | |
19 | A macro used to call a non-void service in an EDK II Crypto Protocol.\r | |
20 | If the protocol is NULL or the service in the protocol is NULL, then a debug\r | |
21 | message and assert is generated and an appropriate return value is returned.\r | |
22 | \r | |
23 | @param Function Name of the EDK II Crypto Protocol service to call.\r | |
24 | @param Args The argument list to pass to Function.\r | |
25 | @param ErrorReturnValue The value to return if the protocol is NULL or the\r | |
26 | service in the protocol is NULL.\r | |
27 | \r | |
28 | **/\r | |
29 | #define CALL_CRYPTO_SERVICE(Function, Args, ErrorReturnValue) \\r | |
30 | do { \\r | |
31 | EDKII_CRYPTO_PROTOCOL *CryptoServices; \\r | |
32 | \\r | |
33 | CryptoServices = (EDKII_CRYPTO_PROTOCOL *)GetCryptoServices (); \\r | |
34 | if (CryptoServices != NULL && CryptoServices->Function != NULL) { \\r | |
35 | return (CryptoServices->Function) Args; \\r | |
36 | } \\r | |
37 | CryptoServiceNotAvailable (#Function); \\r | |
38 | return ErrorReturnValue; \\r | |
39 | } while (FALSE);\r | |
40 | \r | |
41 | /**\r | |
42 | A macro used to call a void service in an EDK II Crypto Protocol.\r | |
43 | If the protocol is NULL or the service in the protocol is NULL, then a debug\r | |
44 | message and assert is generated.\r | |
45 | \r | |
46 | @param Function Name of the EDK II Crypto Protocol service to call.\r | |
47 | @param Args The argument list to pass to Function.\r | |
48 | \r | |
49 | **/\r | |
50 | #define CALL_VOID_CRYPTO_SERVICE(Function, Args) \\r | |
51 | do { \\r | |
52 | EDKII_CRYPTO_PROTOCOL *CryptoServices; \\r | |
53 | \\r | |
54 | CryptoServices = (EDKII_CRYPTO_PROTOCOL *)GetCryptoServices (); \\r | |
55 | if (CryptoServices != NULL && CryptoServices->Function != NULL) { \\r | |
56 | (CryptoServices->Function) Args; \\r | |
57 | return; \\r | |
58 | } \\r | |
59 | CryptoServiceNotAvailable (#Function); \\r | |
60 | return; \\r | |
61 | } while (FALSE);\r | |
62 | \r | |
63 | /**\r | |
64 | Internal worker function that returns the pointer to an EDK II Crypto\r | |
65 | Protocol/PPI. The layout of the PPI, DXE Protocol, and SMM Protocol are\r | |
66 | identical which allows the implementation of the BaseCryptLib functions that\r | |
67 | call through a Protocol/PPI to be shared for the PEI, DXE, and SMM\r | |
68 | implementations.\r | |
69 | **/\r | |
70 | VOID *\r | |
71 | GetCryptoServices (\r | |
72 | VOID\r | |
73 | );\r | |
74 | \r | |
75 | /**\r | |
76 | Internal worker function that prints a debug message and asserts if a crypto\r | |
77 | service is not available. This should never occur because library instances\r | |
78 | have a dependency expression for the for the EDK II Crypto Protocol/PPI so\r | |
79 | a module that uses these library instances are not dispatched until the EDK II\r | |
80 | Crypto Protocol/PPI is available. The only case that this function handles is\r | |
81 | if the EDK II Crypto Protocol/PPI installed is NULL or a function pointer in\r | |
82 | the EDK II Protocol/PPI is NULL.\r | |
83 | \r | |
84 | @param[in] FunctionName Null-terminated ASCII string that is the name of an\r | |
85 | EDK II Crypto service.\r | |
86 | \r | |
87 | **/\r | |
88 | static\r | |
89 | VOID\r | |
90 | CryptoServiceNotAvailable (\r | |
91 | IN CONST CHAR8 *FunctionName\r | |
92 | )\r | |
93 | {\r | |
94 | DEBUG ((DEBUG_ERROR, "[%a] Function %a is not available\n", gEfiCallerBaseName, FunctionName));\r | |
95 | ASSERT_EFI_ERROR (EFI_UNSUPPORTED);\r | |
96 | }\r | |
97 | \r | |
98 | //=====================================================================================\r | |
99 | // One-Way Cryptographic Hash Primitives\r | |
100 | //=====================================================================================\r | |
101 | \r | |
acfd5557 | 102 | #ifndef DISABLE_MD5_DEPRECATED_INTERFACES\r |
cd70de1c MK |
103 | /**\r |
104 | Retrieves the size, in bytes, of the context buffer required for MD5 hash operations.\r | |
105 | \r | |
106 | If this interface is not supported, then return zero.\r | |
107 | \r | |
108 | @return The size, in bytes, of the context buffer required for MD5 hash operations.\r | |
109 | @retval 0 This interface is not supported.\r | |
110 | \r | |
111 | **/\r | |
112 | UINTN\r | |
113 | EFIAPI\r | |
114 | Md5GetContextSize (\r | |
115 | VOID\r | |
116 | )\r | |
117 | {\r | |
118 | CALL_CRYPTO_SERVICE (Md5GetContextSize, (), 0);\r | |
119 | }\r | |
120 | \r | |
121 | /**\r | |
122 | Initializes user-supplied memory pointed by Md5Context as MD5 hash context for\r | |
123 | subsequent use.\r | |
124 | \r | |
125 | If Md5Context is NULL, then return FALSE.\r | |
126 | If this interface is not supported, then return FALSE.\r | |
127 | \r | |
128 | @param[out] Md5Context Pointer to MD5 context being initialized.\r | |
129 | \r | |
130 | @retval TRUE MD5 context initialization succeeded.\r | |
131 | @retval FALSE MD5 context initialization failed.\r | |
132 | @retval FALSE This interface is not supported.\r | |
133 | \r | |
134 | **/\r | |
135 | BOOLEAN\r | |
136 | EFIAPI\r | |
137 | Md5Init (\r | |
138 | OUT VOID *Md5Context\r | |
139 | )\r | |
140 | {\r | |
141 | CALL_CRYPTO_SERVICE (Md5Init, (Md5Context), FALSE);\r | |
142 | }\r | |
143 | \r | |
144 | /**\r | |
145 | Makes a copy of an existing MD5 context.\r | |
146 | \r | |
147 | If Md5Context is NULL, then return FALSE.\r | |
148 | If NewMd5Context is NULL, then return FALSE.\r | |
149 | If this interface is not supported, then return FALSE.\r | |
150 | \r | |
151 | @param[in] Md5Context Pointer to MD5 context being copied.\r | |
152 | @param[out] NewMd5Context Pointer to new MD5 context.\r | |
153 | \r | |
154 | @retval TRUE MD5 context copy succeeded.\r | |
155 | @retval FALSE MD5 context copy failed.\r | |
156 | @retval FALSE This interface is not supported.\r | |
157 | \r | |
158 | **/\r | |
159 | BOOLEAN\r | |
160 | EFIAPI\r | |
161 | Md5Duplicate (\r | |
162 | IN CONST VOID *Md5Context,\r | |
163 | OUT VOID *NewMd5Context\r | |
164 | )\r | |
165 | {\r | |
166 | CALL_CRYPTO_SERVICE (Md5Duplicate, (Md5Context, NewMd5Context), FALSE);\r | |
167 | }\r | |
168 | \r | |
169 | /**\r | |
170 | Digests the input data and updates MD5 context.\r | |
171 | \r | |
172 | This function performs MD5 digest on a data buffer of the specified size.\r | |
173 | It can be called multiple times to compute the digest of long or discontinuous data streams.\r | |
174 | MD5 context should be already correctly initialized by Md5Init(), and should not be finalized\r | |
175 | by Md5Final(). Behavior with invalid context is undefined.\r | |
176 | \r | |
177 | If Md5Context is NULL, then return FALSE.\r | |
178 | If this interface is not supported, then return FALSE.\r | |
179 | \r | |
180 | @param[in, out] Md5Context Pointer to the MD5 context.\r | |
181 | @param[in] Data Pointer to the buffer containing the data to be hashed.\r | |
182 | @param[in] DataSize Size of Data buffer in bytes.\r | |
183 | \r | |
184 | @retval TRUE MD5 data digest succeeded.\r | |
185 | @retval FALSE MD5 data digest failed.\r | |
186 | @retval FALSE This interface is not supported.\r | |
187 | \r | |
188 | **/\r | |
189 | BOOLEAN\r | |
190 | EFIAPI\r | |
191 | Md5Update (\r | |
192 | IN OUT VOID *Md5Context,\r | |
193 | IN CONST VOID *Data,\r | |
194 | IN UINTN DataSize\r | |
195 | )\r | |
196 | {\r | |
197 | CALL_CRYPTO_SERVICE (Md5Update, (Md5Context, Data, DataSize), FALSE);\r | |
198 | }\r | |
199 | \r | |
200 | /**\r | |
201 | Completes computation of the MD5 digest value.\r | |
202 | \r | |
203 | This function completes MD5 hash computation and retrieves the digest value into\r | |
204 | the specified memory. After this function has been called, the MD5 context cannot\r | |
205 | be used again.\r | |
206 | MD5 context should be already correctly initialized by Md5Init(), and should not be\r | |
207 | finalized by Md5Final(). Behavior with invalid MD5 context is undefined.\r | |
208 | \r | |
209 | If Md5Context is NULL, then return FALSE.\r | |
210 | If HashValue is NULL, then return FALSE.\r | |
211 | If this interface is not supported, then return FALSE.\r | |
212 | \r | |
213 | @param[in, out] Md5Context Pointer to the MD5 context.\r | |
214 | @param[out] HashValue Pointer to a buffer that receives the MD5 digest\r | |
215 | value (16 bytes).\r | |
216 | \r | |
217 | @retval TRUE MD5 digest computation succeeded.\r | |
218 | @retval FALSE MD5 digest computation failed.\r | |
219 | @retval FALSE This interface is not supported.\r | |
220 | \r | |
221 | **/\r | |
222 | BOOLEAN\r | |
223 | EFIAPI\r | |
224 | Md5Final (\r | |
225 | IN OUT VOID *Md5Context,\r | |
226 | OUT UINT8 *HashValue\r | |
227 | )\r | |
228 | {\r | |
229 | CALL_CRYPTO_SERVICE (Md5Final, (Md5Context, HashValue), FALSE);\r | |
230 | }\r | |
231 | \r | |
232 | /**\r | |
233 | Computes the MD5 message digest of a input data buffer.\r | |
234 | \r | |
235 | This function performs the MD5 message digest of a given data buffer, and places\r | |
236 | the digest value into the specified memory.\r | |
237 | \r | |
238 | If this interface is not supported, then return FALSE.\r | |
239 | \r | |
240 | @param[in] Data Pointer to the buffer containing the data to be hashed.\r | |
241 | @param[in] DataSize Size of Data buffer in bytes.\r | |
242 | @param[out] HashValue Pointer to a buffer that receives the MD5 digest\r | |
243 | value (16 bytes).\r | |
244 | \r | |
245 | @retval TRUE MD5 digest computation succeeded.\r | |
246 | @retval FALSE MD5 digest computation failed.\r | |
247 | @retval FALSE This interface is not supported.\r | |
248 | \r | |
249 | **/\r | |
250 | BOOLEAN\r | |
251 | EFIAPI\r | |
252 | Md5HashAll (\r | |
253 | IN CONST VOID *Data,\r | |
254 | IN UINTN DataSize,\r | |
255 | OUT UINT8 *HashValue\r | |
256 | )\r | |
257 | {\r | |
258 | CALL_CRYPTO_SERVICE (Md5HashAll, (Data, DataSize, HashValue), FALSE);\r | |
259 | }\r | |
acfd5557 | 260 | #endif\r |
cd70de1c MK |
261 | \r |
262 | /**\r | |
263 | Retrieves the size, in bytes, of the context buffer required for SHA-1 hash operations.\r | |
264 | \r | |
265 | If this interface is not supported, then return zero.\r | |
266 | \r | |
267 | @return The size, in bytes, of the context buffer required for SHA-1 hash operations.\r | |
268 | @retval 0 This interface is not supported.\r | |
269 | \r | |
270 | **/\r | |
271 | UINTN\r | |
272 | EFIAPI\r | |
273 | Sha1GetContextSize (\r | |
274 | VOID\r | |
275 | )\r | |
276 | {\r | |
277 | CALL_CRYPTO_SERVICE (Sha1GetContextSize, (), 0);\r | |
278 | }\r | |
279 | \r | |
280 | /**\r | |
281 | Initializes user-supplied memory pointed by Sha1Context as SHA-1 hash context for\r | |
282 | subsequent use.\r | |
283 | \r | |
284 | If Sha1Context is NULL, then return FALSE.\r | |
285 | If this interface is not supported, then return FALSE.\r | |
286 | \r | |
287 | @param[out] Sha1Context Pointer to SHA-1 context being initialized.\r | |
288 | \r | |
289 | @retval TRUE SHA-1 context initialization succeeded.\r | |
290 | @retval FALSE SHA-1 context initialization failed.\r | |
291 | @retval FALSE This interface is not supported.\r | |
292 | \r | |
293 | **/\r | |
294 | BOOLEAN\r | |
295 | EFIAPI\r | |
296 | Sha1Init (\r | |
297 | OUT VOID *Sha1Context\r | |
298 | )\r | |
299 | {\r | |
300 | CALL_CRYPTO_SERVICE (Sha1Init, (Sha1Context), FALSE);\r | |
301 | }\r | |
302 | \r | |
303 | /**\r | |
304 | Makes a copy of an existing SHA-1 context.\r | |
305 | \r | |
306 | If Sha1Context is NULL, then return FALSE.\r | |
307 | If NewSha1Context is NULL, then return FALSE.\r | |
308 | If this interface is not supported, then return FALSE.\r | |
309 | \r | |
310 | @param[in] Sha1Context Pointer to SHA-1 context being copied.\r | |
311 | @param[out] NewSha1Context Pointer to new SHA-1 context.\r | |
312 | \r | |
313 | @retval TRUE SHA-1 context copy succeeded.\r | |
314 | @retval FALSE SHA-1 context copy failed.\r | |
315 | @retval FALSE This interface is not supported.\r | |
316 | \r | |
317 | **/\r | |
318 | BOOLEAN\r | |
319 | EFIAPI\r | |
320 | Sha1Duplicate (\r | |
321 | IN CONST VOID *Sha1Context,\r | |
322 | OUT VOID *NewSha1Context\r | |
323 | )\r | |
324 | {\r | |
325 | CALL_CRYPTO_SERVICE (Sha1Duplicate, (Sha1Context, NewSha1Context), FALSE);\r | |
326 | }\r | |
327 | \r | |
328 | /**\r | |
329 | Digests the input data and updates SHA-1 context.\r | |
330 | \r | |
331 | This function performs SHA-1 digest on a data buffer of the specified size.\r | |
332 | It can be called multiple times to compute the digest of long or discontinuous data streams.\r | |
333 | SHA-1 context should be already correctly initialized by Sha1Init(), and should not be finalized\r | |
334 | by Sha1Final(). Behavior with invalid context is undefined.\r | |
335 | \r | |
336 | If Sha1Context is NULL, then return FALSE.\r | |
337 | If this interface is not supported, then return FALSE.\r | |
338 | \r | |
339 | @param[in, out] Sha1Context Pointer to the SHA-1 context.\r | |
340 | @param[in] Data Pointer to the buffer containing the data to be hashed.\r | |
341 | @param[in] DataSize Size of Data buffer in bytes.\r | |
342 | \r | |
343 | @retval TRUE SHA-1 data digest succeeded.\r | |
344 | @retval FALSE SHA-1 data digest failed.\r | |
345 | @retval FALSE This interface is not supported.\r | |
346 | \r | |
347 | **/\r | |
348 | BOOLEAN\r | |
349 | EFIAPI\r | |
350 | Sha1Update (\r | |
351 | IN OUT VOID *Sha1Context,\r | |
352 | IN CONST VOID *Data,\r | |
353 | IN UINTN DataSize\r | |
354 | )\r | |
355 | {\r | |
356 | CALL_CRYPTO_SERVICE (Sha1Update, (Sha1Context, Data, DataSize), FALSE);\r | |
357 | }\r | |
358 | \r | |
359 | /**\r | |
360 | Completes computation of the SHA-1 digest value.\r | |
361 | \r | |
362 | This function completes SHA-1 hash computation and retrieves the digest value into\r | |
363 | the specified memory. After this function has been called, the SHA-1 context cannot\r | |
364 | be used again.\r | |
365 | SHA-1 context should be already correctly initialized by Sha1Init(), and should not be\r | |
366 | finalized by Sha1Final(). Behavior with invalid SHA-1 context is undefined.\r | |
367 | \r | |
368 | If Sha1Context is NULL, then return FALSE.\r | |
369 | If HashValue is NULL, then return FALSE.\r | |
370 | If this interface is not supported, then return FALSE.\r | |
371 | \r | |
372 | @param[in, out] Sha1Context Pointer to the SHA-1 context.\r | |
373 | @param[out] HashValue Pointer to a buffer that receives the SHA-1 digest\r | |
374 | value (20 bytes).\r | |
375 | \r | |
376 | @retval TRUE SHA-1 digest computation succeeded.\r | |
377 | @retval FALSE SHA-1 digest computation failed.\r | |
378 | @retval FALSE This interface is not supported.\r | |
379 | \r | |
380 | **/\r | |
381 | BOOLEAN\r | |
382 | EFIAPI\r | |
383 | Sha1Final (\r | |
384 | IN OUT VOID *Sha1Context,\r | |
385 | OUT UINT8 *HashValue\r | |
386 | )\r | |
387 | {\r | |
388 | CALL_CRYPTO_SERVICE (Sha1Final, (Sha1Context, HashValue), FALSE);\r | |
389 | }\r | |
390 | \r | |
391 | /**\r | |
392 | Computes the SHA-1 message digest of a input data buffer.\r | |
393 | \r | |
394 | This function performs the SHA-1 message digest of a given data buffer, and places\r | |
395 | the digest value into the specified memory.\r | |
396 | \r | |
397 | If this interface is not supported, then return FALSE.\r | |
398 | \r | |
399 | @param[in] Data Pointer to the buffer containing the data to be hashed.\r | |
400 | @param[in] DataSize Size of Data buffer in bytes.\r | |
401 | @param[out] HashValue Pointer to a buffer that receives the SHA-1 digest\r | |
402 | value (20 bytes).\r | |
403 | \r | |
404 | @retval TRUE SHA-1 digest computation succeeded.\r | |
405 | @retval FALSE SHA-1 digest computation failed.\r | |
406 | @retval FALSE This interface is not supported.\r | |
407 | \r | |
408 | **/\r | |
409 | BOOLEAN\r | |
410 | EFIAPI\r | |
411 | Sha1HashAll (\r | |
412 | IN CONST VOID *Data,\r | |
413 | IN UINTN DataSize,\r | |
414 | OUT UINT8 *HashValue\r | |
415 | )\r | |
416 | {\r | |
417 | CALL_CRYPTO_SERVICE (Sha1HashAll, (Data, DataSize, HashValue), FALSE);\r | |
418 | }\r | |
419 | \r | |
420 | /**\r | |
421 | Retrieves the size, in bytes, of the context buffer required for SHA-256 hash operations.\r | |
422 | \r | |
423 | @return The size, in bytes, of the context buffer required for SHA-256 hash operations.\r | |
424 | \r | |
425 | **/\r | |
426 | UINTN\r | |
427 | EFIAPI\r | |
428 | Sha256GetContextSize (\r | |
429 | VOID\r | |
430 | )\r | |
431 | {\r | |
432 | CALL_CRYPTO_SERVICE (Sha256GetContextSize, (), 0);\r | |
433 | }\r | |
434 | \r | |
435 | /**\r | |
436 | Initializes user-supplied memory pointed by Sha256Context as SHA-256 hash context for\r | |
437 | subsequent use.\r | |
438 | \r | |
439 | If Sha256Context is NULL, then return FALSE.\r | |
440 | \r | |
441 | @param[out] Sha256Context Pointer to SHA-256 context being initialized.\r | |
442 | \r | |
443 | @retval TRUE SHA-256 context initialization succeeded.\r | |
444 | @retval FALSE SHA-256 context initialization failed.\r | |
445 | \r | |
446 | **/\r | |
447 | BOOLEAN\r | |
448 | EFIAPI\r | |
449 | Sha256Init (\r | |
450 | OUT VOID *Sha256Context\r | |
451 | )\r | |
452 | {\r | |
453 | CALL_CRYPTO_SERVICE (Sha256Init, (Sha256Context), FALSE);\r | |
454 | }\r | |
455 | \r | |
456 | /**\r | |
457 | Makes a copy of an existing SHA-256 context.\r | |
458 | \r | |
459 | If Sha256Context is NULL, then return FALSE.\r | |
460 | If NewSha256Context is NULL, then return FALSE.\r | |
461 | If this interface is not supported, then return FALSE.\r | |
462 | \r | |
463 | @param[in] Sha256Context Pointer to SHA-256 context being copied.\r | |
464 | @param[out] NewSha256Context Pointer to new SHA-256 context.\r | |
465 | \r | |
466 | @retval TRUE SHA-256 context copy succeeded.\r | |
467 | @retval FALSE SHA-256 context copy failed.\r | |
468 | @retval FALSE This interface is not supported.\r | |
469 | \r | |
470 | **/\r | |
471 | BOOLEAN\r | |
472 | EFIAPI\r | |
473 | Sha256Duplicate (\r | |
474 | IN CONST VOID *Sha256Context,\r | |
475 | OUT VOID *NewSha256Context\r | |
476 | )\r | |
477 | {\r | |
478 | CALL_CRYPTO_SERVICE (Sha256Duplicate, (Sha256Context, NewSha256Context), FALSE);\r | |
479 | }\r | |
480 | \r | |
481 | /**\r | |
482 | Digests the input data and updates SHA-256 context.\r | |
483 | \r | |
484 | This function performs SHA-256 digest on a data buffer of the specified size.\r | |
485 | It can be called multiple times to compute the digest of long or discontinuous data streams.\r | |
486 | SHA-256 context should be already correctly initialized by Sha256Init(), and should not be finalized\r | |
487 | by Sha256Final(). Behavior with invalid context is undefined.\r | |
488 | \r | |
489 | If Sha256Context is NULL, then return FALSE.\r | |
490 | \r | |
491 | @param[in, out] Sha256Context Pointer to the SHA-256 context.\r | |
492 | @param[in] Data Pointer to the buffer containing the data to be hashed.\r | |
493 | @param[in] DataSize Size of Data buffer in bytes.\r | |
494 | \r | |
495 | @retval TRUE SHA-256 data digest succeeded.\r | |
496 | @retval FALSE SHA-256 data digest failed.\r | |
497 | \r | |
498 | **/\r | |
499 | BOOLEAN\r | |
500 | EFIAPI\r | |
501 | Sha256Update (\r | |
502 | IN OUT VOID *Sha256Context,\r | |
503 | IN CONST VOID *Data,\r | |
504 | IN UINTN DataSize\r | |
505 | )\r | |
506 | {\r | |
507 | CALL_CRYPTO_SERVICE (Sha256Update, (Sha256Context, Data, DataSize), FALSE);\r | |
508 | }\r | |
509 | \r | |
510 | /**\r | |
511 | Completes computation of the SHA-256 digest value.\r | |
512 | \r | |
513 | This function completes SHA-256 hash computation and retrieves the digest value into\r | |
514 | the specified memory. After this function has been called, the SHA-256 context cannot\r | |
515 | be used again.\r | |
516 | SHA-256 context should be already correctly initialized by Sha256Init(), and should not be\r | |
517 | finalized by Sha256Final(). Behavior with invalid SHA-256 context is undefined.\r | |
518 | \r | |
519 | If Sha256Context is NULL, then return FALSE.\r | |
520 | If HashValue is NULL, then return FALSE.\r | |
521 | \r | |
522 | @param[in, out] Sha256Context Pointer to the SHA-256 context.\r | |
523 | @param[out] HashValue Pointer to a buffer that receives the SHA-256 digest\r | |
524 | value (32 bytes).\r | |
525 | \r | |
526 | @retval TRUE SHA-256 digest computation succeeded.\r | |
527 | @retval FALSE SHA-256 digest computation failed.\r | |
528 | \r | |
529 | **/\r | |
530 | BOOLEAN\r | |
531 | EFIAPI\r | |
532 | Sha256Final (\r | |
533 | IN OUT VOID *Sha256Context,\r | |
534 | OUT UINT8 *HashValue\r | |
535 | )\r | |
536 | {\r | |
537 | CALL_CRYPTO_SERVICE (Sha256Final, (Sha256Context, HashValue), FALSE);\r | |
538 | }\r | |
539 | \r | |
540 | /**\r | |
541 | Computes the SHA-256 message digest of a input data buffer.\r | |
542 | \r | |
543 | This function performs the SHA-256 message digest of a given data buffer, and places\r | |
544 | the digest value into the specified memory.\r | |
545 | \r | |
546 | If this interface is not supported, then return FALSE.\r | |
547 | \r | |
548 | @param[in] Data Pointer to the buffer containing the data to be hashed.\r | |
549 | @param[in] DataSize Size of Data buffer in bytes.\r | |
550 | @param[out] HashValue Pointer to a buffer that receives the SHA-256 digest\r | |
551 | value (32 bytes).\r | |
552 | \r | |
553 | @retval TRUE SHA-256 digest computation succeeded.\r | |
554 | @retval FALSE SHA-256 digest computation failed.\r | |
555 | @retval FALSE This interface is not supported.\r | |
556 | \r | |
557 | **/\r | |
558 | BOOLEAN\r | |
559 | EFIAPI\r | |
560 | Sha256HashAll (\r | |
561 | IN CONST VOID *Data,\r | |
562 | IN UINTN DataSize,\r | |
563 | OUT UINT8 *HashValue\r | |
564 | )\r | |
565 | {\r | |
566 | CALL_CRYPTO_SERVICE (Sha256HashAll, (Data, DataSize, HashValue), FALSE);\r | |
567 | }\r | |
568 | \r | |
569 | /**\r | |
570 | Retrieves the size, in bytes, of the context buffer required for SHA-384 hash operations.\r | |
571 | \r | |
572 | @return The size, in bytes, of the context buffer required for SHA-384 hash operations.\r | |
573 | \r | |
574 | **/\r | |
575 | UINTN\r | |
576 | EFIAPI\r | |
577 | Sha384GetContextSize (\r | |
578 | VOID\r | |
579 | )\r | |
580 | {\r | |
581 | CALL_CRYPTO_SERVICE (Sha384GetContextSize, (), 0);\r | |
582 | }\r | |
583 | \r | |
584 | /**\r | |
585 | Initializes user-supplied memory pointed by Sha384Context as SHA-384 hash context for\r | |
586 | subsequent use.\r | |
587 | \r | |
588 | If Sha384Context is NULL, then return FALSE.\r | |
589 | \r | |
590 | @param[out] Sha384Context Pointer to SHA-384 context being initialized.\r | |
591 | \r | |
592 | @retval TRUE SHA-384 context initialization succeeded.\r | |
593 | @retval FALSE SHA-384 context initialization failed.\r | |
594 | \r | |
595 | **/\r | |
596 | BOOLEAN\r | |
597 | EFIAPI\r | |
598 | Sha384Init (\r | |
599 | OUT VOID *Sha384Context\r | |
600 | )\r | |
601 | {\r | |
602 | CALL_CRYPTO_SERVICE (Sha384Init, (Sha384Context), FALSE);\r | |
603 | }\r | |
604 | \r | |
605 | /**\r | |
606 | Makes a copy of an existing SHA-384 context.\r | |
607 | \r | |
608 | If Sha384Context is NULL, then return FALSE.\r | |
609 | If NewSha384Context is NULL, then return FALSE.\r | |
610 | If this interface is not supported, then return FALSE.\r | |
611 | \r | |
612 | @param[in] Sha384Context Pointer to SHA-384 context being copied.\r | |
613 | @param[out] NewSha384Context Pointer to new SHA-384 context.\r | |
614 | \r | |
615 | @retval TRUE SHA-384 context copy succeeded.\r | |
616 | @retval FALSE SHA-384 context copy failed.\r | |
617 | @retval FALSE This interface is not supported.\r | |
618 | \r | |
619 | **/\r | |
620 | BOOLEAN\r | |
621 | EFIAPI\r | |
622 | Sha384Duplicate (\r | |
623 | IN CONST VOID *Sha384Context,\r | |
624 | OUT VOID *NewSha384Context\r | |
625 | )\r | |
626 | {\r | |
627 | CALL_CRYPTO_SERVICE (Sha384Duplicate, (Sha384Context, NewSha384Context), FALSE);\r | |
628 | }\r | |
629 | \r | |
630 | /**\r | |
631 | Digests the input data and updates SHA-384 context.\r | |
632 | \r | |
633 | This function performs SHA-384 digest on a data buffer of the specified size.\r | |
634 | It can be called multiple times to compute the digest of long or discontinuous data streams.\r | |
635 | SHA-384 context should be already correctly initialized by Sha384Init(), and should not be finalized\r | |
636 | by Sha384Final(). Behavior with invalid context is undefined.\r | |
637 | \r | |
638 | If Sha384Context is NULL, then return FALSE.\r | |
639 | \r | |
640 | @param[in, out] Sha384Context Pointer to the SHA-384 context.\r | |
641 | @param[in] Data Pointer to the buffer containing the data to be hashed.\r | |
642 | @param[in] DataSize Size of Data buffer in bytes.\r | |
643 | \r | |
644 | @retval TRUE SHA-384 data digest succeeded.\r | |
645 | @retval FALSE SHA-384 data digest failed.\r | |
646 | \r | |
647 | **/\r | |
648 | BOOLEAN\r | |
649 | EFIAPI\r | |
650 | Sha384Update (\r | |
651 | IN OUT VOID *Sha384Context,\r | |
652 | IN CONST VOID *Data,\r | |
653 | IN UINTN DataSize\r | |
654 | )\r | |
655 | {\r | |
656 | CALL_CRYPTO_SERVICE (Sha384Update, (Sha384Context, Data, DataSize), FALSE);\r | |
657 | }\r | |
658 | \r | |
659 | /**\r | |
660 | Completes computation of the SHA-384 digest value.\r | |
661 | \r | |
662 | This function completes SHA-384 hash computation and retrieves the digest value into\r | |
663 | the specified memory. After this function has been called, the SHA-384 context cannot\r | |
664 | be used again.\r | |
665 | SHA-384 context should be already correctly initialized by Sha384Init(), and should not be\r | |
666 | finalized by Sha384Final(). Behavior with invalid SHA-384 context is undefined.\r | |
667 | \r | |
668 | If Sha384Context is NULL, then return FALSE.\r | |
669 | If HashValue is NULL, then return FALSE.\r | |
670 | \r | |
671 | @param[in, out] Sha384Context Pointer to the SHA-384 context.\r | |
672 | @param[out] HashValue Pointer to a buffer that receives the SHA-384 digest\r | |
673 | value (48 bytes).\r | |
674 | \r | |
675 | @retval TRUE SHA-384 digest computation succeeded.\r | |
676 | @retval FALSE SHA-384 digest computation failed.\r | |
677 | \r | |
678 | **/\r | |
679 | BOOLEAN\r | |
680 | EFIAPI\r | |
681 | Sha384Final (\r | |
682 | IN OUT VOID *Sha384Context,\r | |
683 | OUT UINT8 *HashValue\r | |
684 | )\r | |
685 | {\r | |
686 | CALL_CRYPTO_SERVICE (Sha384Final, (Sha384Context, HashValue), FALSE);\r | |
687 | }\r | |
688 | \r | |
689 | /**\r | |
690 | Computes the SHA-384 message digest of a input data buffer.\r | |
691 | \r | |
692 | This function performs the SHA-384 message digest of a given data buffer, and places\r | |
693 | the digest value into the specified memory.\r | |
694 | \r | |
695 | If this interface is not supported, then return FALSE.\r | |
696 | \r | |
697 | @param[in] Data Pointer to the buffer containing the data to be hashed.\r | |
698 | @param[in] DataSize Size of Data buffer in bytes.\r | |
699 | @param[out] HashValue Pointer to a buffer that receives the SHA-384 digest\r | |
700 | value (48 bytes).\r | |
701 | \r | |
702 | @retval TRUE SHA-384 digest computation succeeded.\r | |
703 | @retval FALSE SHA-384 digest computation failed.\r | |
704 | @retval FALSE This interface is not supported.\r | |
705 | \r | |
706 | **/\r | |
707 | BOOLEAN\r | |
708 | EFIAPI\r | |
709 | Sha384HashAll (\r | |
710 | IN CONST VOID *Data,\r | |
711 | IN UINTN DataSize,\r | |
712 | OUT UINT8 *HashValue\r | |
713 | )\r | |
714 | {\r | |
715 | CALL_CRYPTO_SERVICE (Sha384HashAll, (Data, DataSize, HashValue), FALSE);\r | |
716 | }\r | |
717 | \r | |
718 | /**\r | |
719 | Retrieves the size, in bytes, of the context buffer required for SHA-512 hash operations.\r | |
720 | \r | |
721 | @return The size, in bytes, of the context buffer required for SHA-512 hash operations.\r | |
722 | \r | |
723 | **/\r | |
724 | UINTN\r | |
725 | EFIAPI\r | |
726 | Sha512GetContextSize (\r | |
727 | VOID\r | |
728 | )\r | |
729 | {\r | |
730 | CALL_CRYPTO_SERVICE (Sha512GetContextSize, (), 0);\r | |
731 | }\r | |
732 | \r | |
733 | /**\r | |
734 | Initializes user-supplied memory pointed by Sha512Context as SHA-512 hash context for\r | |
735 | subsequent use.\r | |
736 | \r | |
737 | If Sha512Context is NULL, then return FALSE.\r | |
738 | \r | |
739 | @param[out] Sha512Context Pointer to SHA-512 context being initialized.\r | |
740 | \r | |
741 | @retval TRUE SHA-512 context initialization succeeded.\r | |
742 | @retval FALSE SHA-512 context initialization failed.\r | |
743 | \r | |
744 | **/\r | |
745 | BOOLEAN\r | |
746 | EFIAPI\r | |
747 | Sha512Init (\r | |
748 | OUT VOID *Sha512Context\r | |
749 | )\r | |
750 | {\r | |
751 | CALL_CRYPTO_SERVICE (Sha512Init, (Sha512Context), FALSE);\r | |
752 | }\r | |
753 | \r | |
754 | /**\r | |
755 | Makes a copy of an existing SHA-512 context.\r | |
756 | \r | |
757 | If Sha512Context is NULL, then return FALSE.\r | |
758 | If NewSha512Context is NULL, then return FALSE.\r | |
759 | If this interface is not supported, then return FALSE.\r | |
760 | \r | |
761 | @param[in] Sha512Context Pointer to SHA-512 context being copied.\r | |
762 | @param[out] NewSha512Context Pointer to new SHA-512 context.\r | |
763 | \r | |
764 | @retval TRUE SHA-512 context copy succeeded.\r | |
765 | @retval FALSE SHA-512 context copy failed.\r | |
766 | @retval FALSE This interface is not supported.\r | |
767 | \r | |
768 | **/\r | |
769 | BOOLEAN\r | |
770 | EFIAPI\r | |
771 | Sha512Duplicate (\r | |
772 | IN CONST VOID *Sha512Context,\r | |
773 | OUT VOID *NewSha512Context\r | |
774 | )\r | |
775 | {\r | |
776 | CALL_CRYPTO_SERVICE (Sha512Duplicate, (Sha512Context, NewSha512Context), FALSE);\r | |
777 | }\r | |
778 | \r | |
779 | /**\r | |
780 | Digests the input data and updates SHA-512 context.\r | |
781 | \r | |
782 | This function performs SHA-512 digest on a data buffer of the specified size.\r | |
783 | It can be called multiple times to compute the digest of long or discontinuous data streams.\r | |
784 | SHA-512 context should be already correctly initialized by Sha512Init(), and should not be finalized\r | |
785 | by Sha512Final(). Behavior with invalid context is undefined.\r | |
786 | \r | |
787 | If Sha512Context is NULL, then return FALSE.\r | |
788 | \r | |
789 | @param[in, out] Sha512Context Pointer to the SHA-512 context.\r | |
790 | @param[in] Data Pointer to the buffer containing the data to be hashed.\r | |
791 | @param[in] DataSize Size of Data buffer in bytes.\r | |
792 | \r | |
793 | @retval TRUE SHA-512 data digest succeeded.\r | |
794 | @retval FALSE SHA-512 data digest failed.\r | |
795 | \r | |
796 | **/\r | |
797 | BOOLEAN\r | |
798 | EFIAPI\r | |
799 | Sha512Update (\r | |
800 | IN OUT VOID *Sha512Context,\r | |
801 | IN CONST VOID *Data,\r | |
802 | IN UINTN DataSize\r | |
803 | )\r | |
804 | {\r | |
805 | CALL_CRYPTO_SERVICE (Sha512Update, (Sha512Context, Data, DataSize), FALSE);\r | |
806 | }\r | |
807 | \r | |
808 | /**\r | |
809 | Completes computation of the SHA-512 digest value.\r | |
810 | \r | |
811 | This function completes SHA-512 hash computation and retrieves the digest value into\r | |
812 | the specified memory. After this function has been called, the SHA-512 context cannot\r | |
813 | be used again.\r | |
814 | SHA-512 context should be already correctly initialized by Sha512Init(), and should not be\r | |
815 | finalized by Sha512Final(). Behavior with invalid SHA-512 context is undefined.\r | |
816 | \r | |
817 | If Sha512Context is NULL, then return FALSE.\r | |
818 | If HashValue is NULL, then return FALSE.\r | |
819 | \r | |
820 | @param[in, out] Sha512Context Pointer to the SHA-512 context.\r | |
821 | @param[out] HashValue Pointer to a buffer that receives the SHA-512 digest\r | |
822 | value (64 bytes).\r | |
823 | \r | |
824 | @retval TRUE SHA-512 digest computation succeeded.\r | |
825 | @retval FALSE SHA-512 digest computation failed.\r | |
826 | \r | |
827 | **/\r | |
828 | BOOLEAN\r | |
829 | EFIAPI\r | |
830 | Sha512Final (\r | |
831 | IN OUT VOID *Sha512Context,\r | |
832 | OUT UINT8 *HashValue\r | |
833 | )\r | |
834 | {\r | |
835 | CALL_CRYPTO_SERVICE (Sha512Final, (Sha512Context, HashValue), FALSE);\r | |
836 | }\r | |
837 | \r | |
838 | /**\r | |
839 | Computes the SHA-512 message digest of a input data buffer.\r | |
840 | \r | |
841 | This function performs the SHA-512 message digest of a given data buffer, and places\r | |
842 | the digest value into the specified memory.\r | |
843 | \r | |
844 | If this interface is not supported, then return FALSE.\r | |
845 | \r | |
846 | @param[in] Data Pointer to the buffer containing the data to be hashed.\r | |
847 | @param[in] DataSize Size of Data buffer in bytes.\r | |
848 | @param[out] HashValue Pointer to a buffer that receives the SHA-512 digest\r | |
849 | value (64 bytes).\r | |
850 | \r | |
851 | @retval TRUE SHA-512 digest computation succeeded.\r | |
852 | @retval FALSE SHA-512 digest computation failed.\r | |
853 | @retval FALSE This interface is not supported.\r | |
854 | \r | |
855 | **/\r | |
856 | BOOLEAN\r | |
857 | EFIAPI\r | |
858 | Sha512HashAll (\r | |
859 | IN CONST VOID *Data,\r | |
860 | IN UINTN DataSize,\r | |
861 | OUT UINT8 *HashValue\r | |
862 | )\r | |
863 | {\r | |
864 | CALL_CRYPTO_SERVICE (Sha512HashAll, (Data, DataSize, HashValue), FALSE);\r | |
865 | }\r | |
866 | \r | |
867 | /**\r | |
868 | Retrieves the size, in bytes, of the context buffer required for SM3 hash operations.\r | |
869 | \r | |
870 | @return The size, in bytes, of the context buffer required for SM3 hash operations.\r | |
871 | \r | |
872 | **/\r | |
873 | UINTN\r | |
874 | EFIAPI\r | |
875 | Sm3GetContextSize (\r | |
876 | VOID\r | |
877 | )\r | |
878 | {\r | |
879 | CALL_CRYPTO_SERVICE (Sm3GetContextSize, (), 0);\r | |
880 | }\r | |
881 | \r | |
882 | /**\r | |
883 | Initializes user-supplied memory pointed by Sm3Context as SM3 hash context for\r | |
884 | subsequent use.\r | |
885 | \r | |
886 | If Sm3Context is NULL, then return FALSE.\r | |
887 | \r | |
888 | @param[out] Sm3Context Pointer to SM3 context being initialized.\r | |
889 | \r | |
890 | @retval TRUE SM3 context initialization succeeded.\r | |
891 | @retval FALSE SM3 context initialization failed.\r | |
892 | \r | |
893 | **/\r | |
894 | BOOLEAN\r | |
895 | EFIAPI\r | |
896 | Sm3Init (\r | |
897 | OUT VOID *Sm3Context\r | |
898 | )\r | |
899 | {\r | |
900 | CALL_CRYPTO_SERVICE (Sm3Init, (Sm3Context), FALSE);\r | |
901 | }\r | |
902 | \r | |
903 | /**\r | |
904 | Makes a copy of an existing SM3 context.\r | |
905 | \r | |
906 | If Sm3Context is NULL, then return FALSE.\r | |
907 | If NewSm3Context is NULL, then return FALSE.\r | |
908 | If this interface is not supported, then return FALSE.\r | |
909 | \r | |
910 | @param[in] Sm3Context Pointer to SM3 context being copied.\r | |
911 | @param[out] NewSm3Context Pointer to new SM3 context.\r | |
912 | \r | |
913 | @retval TRUE SM3 context copy succeeded.\r | |
914 | @retval FALSE SM3 context copy failed.\r | |
915 | @retval FALSE This interface is not supported.\r | |
916 | \r | |
917 | **/\r | |
918 | BOOLEAN\r | |
919 | EFIAPI\r | |
920 | Sm3Duplicate (\r | |
921 | IN CONST VOID *Sm3Context,\r | |
922 | OUT VOID *NewSm3Context\r | |
923 | )\r | |
924 | {\r | |
925 | CALL_CRYPTO_SERVICE (Sm3Duplicate, (Sm3Context, NewSm3Context), FALSE);\r | |
926 | }\r | |
927 | \r | |
928 | /**\r | |
929 | Digests the input data and updates SM3 context.\r | |
930 | \r | |
931 | This function performs SM3 digest on a data buffer of the specified size.\r | |
932 | It can be called multiple times to compute the digest of long or discontinuous data streams.\r | |
933 | SM3 context should be already correctly initialized by Sm3Init(), and should not be finalized\r | |
934 | by Sm3Final(). Behavior with invalid context is undefined.\r | |
935 | \r | |
936 | If Sm3Context is NULL, then return FALSE.\r | |
937 | \r | |
938 | @param[in, out] Sm3Context Pointer to the SM3 context.\r | |
939 | @param[in] Data Pointer to the buffer containing the data to be hashed.\r | |
940 | @param[in] DataSize Size of Data buffer in bytes.\r | |
941 | \r | |
942 | @retval TRUE SM3 data digest succeeded.\r | |
943 | @retval FALSE SM3 data digest failed.\r | |
944 | \r | |
945 | **/\r | |
946 | BOOLEAN\r | |
947 | EFIAPI\r | |
948 | Sm3Update (\r | |
949 | IN OUT VOID *Sm3Context,\r | |
950 | IN CONST VOID *Data,\r | |
951 | IN UINTN DataSize\r | |
952 | )\r | |
953 | {\r | |
954 | CALL_CRYPTO_SERVICE (Sm3Update, (Sm3Context, Data, DataSize), FALSE);\r | |
955 | }\r | |
956 | \r | |
957 | /**\r | |
958 | Completes computation of the SM3 digest value.\r | |
959 | \r | |
960 | This function completes SM3 hash computation and retrieves the digest value into\r | |
961 | the specified memory. After this function has been called, the SM3 context cannot\r | |
962 | be used again.\r | |
963 | SM3 context should be already correctly initialized by Sm3Init(), and should not be\r | |
964 | finalized by Sm3Final(). Behavior with invalid SM3 context is undefined.\r | |
965 | \r | |
966 | If Sm3Context is NULL, then return FALSE.\r | |
967 | If HashValue is NULL, then return FALSE.\r | |
968 | \r | |
969 | @param[in, out] Sm3Context Pointer to the SM3 context.\r | |
970 | @param[out] HashValue Pointer to a buffer that receives the SM3 digest\r | |
971 | value (32 bytes).\r | |
972 | \r | |
973 | @retval TRUE SM3 digest computation succeeded.\r | |
974 | @retval FALSE SM3 digest computation failed.\r | |
975 | \r | |
976 | **/\r | |
977 | BOOLEAN\r | |
978 | EFIAPI\r | |
979 | Sm3Final (\r | |
980 | IN OUT VOID *Sm3Context,\r | |
981 | OUT UINT8 *HashValue\r | |
982 | )\r | |
983 | {\r | |
984 | CALL_CRYPTO_SERVICE (Sm3Final, (Sm3Context, HashValue), FALSE);\r | |
985 | }\r | |
986 | \r | |
987 | /**\r | |
988 | Computes the SM3 message digest of a input data buffer.\r | |
989 | \r | |
990 | This function performs the SM3 message digest of a given data buffer, and places\r | |
991 | the digest value into the specified memory.\r | |
992 | \r | |
993 | If this interface is not supported, then return FALSE.\r | |
994 | \r | |
995 | @param[in] Data Pointer to the buffer containing the data to be hashed.\r | |
996 | @param[in] DataSize Size of Data buffer in bytes.\r | |
997 | @param[out] HashValue Pointer to a buffer that receives the SM3 digest\r | |
998 | value (32 bytes).\r | |
999 | \r | |
1000 | @retval TRUE SM3 digest computation succeeded.\r | |
1001 | @retval FALSE SM3 digest computation failed.\r | |
1002 | @retval FALSE This interface is not supported.\r | |
1003 | \r | |
1004 | **/\r | |
1005 | BOOLEAN\r | |
1006 | EFIAPI\r | |
1007 | Sm3HashAll (\r | |
1008 | IN CONST VOID *Data,\r | |
1009 | IN UINTN DataSize,\r | |
1010 | OUT UINT8 *HashValue\r | |
1011 | )\r | |
1012 | {\r | |
1013 | CALL_CRYPTO_SERVICE (Sm3HashAll, (Data, DataSize, HashValue), FALSE);\r | |
1014 | }\r | |
1015 | \r | |
1016 | //=====================================================================================\r | |
1017 | // MAC (Message Authentication Code) Primitive\r | |
1018 | //=====================================================================================\r | |
1019 | \r | |
cd70de1c MK |
1020 | /**\r |
1021 | Allocates and initializes one HMAC_CTX context for subsequent HMAC-SHA256 use.\r | |
1022 | \r | |
1023 | @return Pointer to the HMAC_CTX context that has been initialized.\r | |
1024 | If the allocations fails, HmacSha256New() returns NULL.\r | |
1025 | \r | |
1026 | **/\r | |
1027 | VOID *\r | |
1028 | EFIAPI\r | |
1029 | HmacSha256New (\r | |
1030 | VOID\r | |
1031 | )\r | |
1032 | {\r | |
1033 | CALL_CRYPTO_SERVICE (HmacSha256New, (), NULL);\r | |
1034 | }\r | |
1035 | \r | |
1036 | /**\r | |
1037 | Release the specified HMAC_CTX context.\r | |
1038 | \r | |
1039 | @param[in] HmacSha256Ctx Pointer to the HMAC_CTX context to be released.\r | |
1040 | \r | |
1041 | **/\r | |
1042 | VOID\r | |
1043 | EFIAPI\r | |
1044 | HmacSha256Free (\r | |
1045 | IN VOID *HmacSha256Ctx\r | |
1046 | )\r | |
1047 | {\r | |
1048 | CALL_VOID_CRYPTO_SERVICE (HmacSha256Free, (HmacSha256Ctx));\r | |
1049 | }\r | |
1050 | \r | |
1051 | /**\r | |
1052 | Set user-supplied key for subsequent use. It must be done before any\r | |
1053 | calling to HmacSha256Update().\r | |
1054 | \r | |
1055 | If HmacSha256Context is NULL, then return FALSE.\r | |
1056 | If this interface is not supported, then return FALSE.\r | |
1057 | \r | |
1058 | @param[out] HmacSha256Context Pointer to HMAC-SHA256 context.\r | |
1059 | @param[in] Key Pointer to the user-supplied key.\r | |
1060 | @param[in] KeySize Key size in bytes.\r | |
1061 | \r | |
1062 | @retval TRUE The Key is set successfully.\r | |
1063 | @retval FALSE The Key is set unsuccessfully.\r | |
1064 | @retval FALSE This interface is not supported.\r | |
1065 | \r | |
1066 | **/\r | |
1067 | BOOLEAN\r | |
1068 | EFIAPI\r | |
1069 | HmacSha256SetKey (\r | |
1070 | OUT VOID *HmacSha256Context,\r | |
1071 | IN CONST UINT8 *Key,\r | |
1072 | IN UINTN KeySize\r | |
1073 | )\r | |
1074 | {\r | |
1075 | CALL_CRYPTO_SERVICE (HmacSha256SetKey, (HmacSha256Context, Key, KeySize), FALSE);\r | |
1076 | }\r | |
1077 | \r | |
1078 | /**\r | |
1079 | Makes a copy of an existing HMAC-SHA256 context.\r | |
1080 | \r | |
1081 | If HmacSha256Context is NULL, then return FALSE.\r | |
1082 | If NewHmacSha256Context is NULL, then return FALSE.\r | |
1083 | If this interface is not supported, then return FALSE.\r | |
1084 | \r | |
1085 | @param[in] HmacSha256Context Pointer to HMAC-SHA256 context being copied.\r | |
1086 | @param[out] NewHmacSha256Context Pointer to new HMAC-SHA256 context.\r | |
1087 | \r | |
1088 | @retval TRUE HMAC-SHA256 context copy succeeded.\r | |
1089 | @retval FALSE HMAC-SHA256 context copy failed.\r | |
1090 | @retval FALSE This interface is not supported.\r | |
1091 | \r | |
1092 | **/\r | |
1093 | BOOLEAN\r | |
1094 | EFIAPI\r | |
1095 | HmacSha256Duplicate (\r | |
1096 | IN CONST VOID *HmacSha256Context,\r | |
1097 | OUT VOID *NewHmacSha256Context\r | |
1098 | )\r | |
1099 | {\r | |
1100 | CALL_CRYPTO_SERVICE (HmacSha256Duplicate, (HmacSha256Context, NewHmacSha256Context), FALSE);\r | |
1101 | }\r | |
1102 | \r | |
1103 | /**\r | |
1104 | Digests the input data and updates HMAC-SHA256 context.\r | |
1105 | \r | |
1106 | This function performs HMAC-SHA256 digest on a data buffer of the specified size.\r | |
1107 | It can be called multiple times to compute the digest of long or discontinuous data streams.\r | |
1108 | HMAC-SHA256 context should be initialized by HmacSha256New(), and should not be finalized\r | |
1109 | by HmacSha256Final(). Behavior with invalid context is undefined.\r | |
1110 | \r | |
1111 | If HmacSha256Context is NULL, then return FALSE.\r | |
1112 | If this interface is not supported, then return FALSE.\r | |
1113 | \r | |
1114 | @param[in, out] HmacSha256Context Pointer to the HMAC-SHA256 context.\r | |
1115 | @param[in] Data Pointer to the buffer containing the data to be digested.\r | |
1116 | @param[in] DataSize Size of Data buffer in bytes.\r | |
1117 | \r | |
1118 | @retval TRUE HMAC-SHA256 data digest succeeded.\r | |
1119 | @retval FALSE HMAC-SHA256 data digest failed.\r | |
1120 | @retval FALSE This interface is not supported.\r | |
1121 | \r | |
1122 | **/\r | |
1123 | BOOLEAN\r | |
1124 | EFIAPI\r | |
1125 | HmacSha256Update (\r | |
1126 | IN OUT VOID *HmacSha256Context,\r | |
1127 | IN CONST VOID *Data,\r | |
1128 | IN UINTN DataSize\r | |
1129 | )\r | |
1130 | {\r | |
1131 | CALL_CRYPTO_SERVICE (HmacSha256Update, (HmacSha256Context, Data, DataSize), FALSE);\r | |
1132 | }\r | |
1133 | \r | |
1134 | /**\r | |
1135 | Completes computation of the HMAC-SHA256 digest value.\r | |
1136 | \r | |
1137 | This function completes HMAC-SHA256 hash computation and retrieves the digest value into\r | |
1138 | the specified memory. After this function has been called, the HMAC-SHA256 context cannot\r | |
1139 | be used again.\r | |
1140 | HMAC-SHA256 context should be initialized by HmacSha256New(), and should not be finalized\r | |
1141 | by HmacSha256Final(). Behavior with invalid HMAC-SHA256 context is undefined.\r | |
1142 | \r | |
1143 | If HmacSha256Context is NULL, then return FALSE.\r | |
1144 | If HmacValue is NULL, then return FALSE.\r | |
1145 | If this interface is not supported, then return FALSE.\r | |
1146 | \r | |
1147 | @param[in, out] HmacSha256Context Pointer to the HMAC-SHA256 context.\r | |
1148 | @param[out] HmacValue Pointer to a buffer that receives the HMAC-SHA256 digest\r | |
1149 | value (32 bytes).\r | |
1150 | \r | |
1151 | @retval TRUE HMAC-SHA256 digest computation succeeded.\r | |
1152 | @retval FALSE HMAC-SHA256 digest computation failed.\r | |
1153 | @retval FALSE This interface is not supported.\r | |
1154 | \r | |
1155 | **/\r | |
1156 | BOOLEAN\r | |
1157 | EFIAPI\r | |
1158 | HmacSha256Final (\r | |
1159 | IN OUT VOID *HmacSha256Context,\r | |
1160 | OUT UINT8 *HmacValue\r | |
1161 | )\r | |
1162 | {\r | |
1163 | CALL_CRYPTO_SERVICE (HmacSha256Final, (HmacSha256Context, HmacValue), FALSE);\r | |
1164 | }\r | |
1165 | \r | |
1166 | //=====================================================================================\r | |
1167 | // Symmetric Cryptography Primitive\r | |
1168 | //=====================================================================================\r | |
1169 | \r | |
cd70de1c MK |
1170 | /**\r |
1171 | Retrieves the size, in bytes, of the context buffer required for AES operations.\r | |
1172 | \r | |
1173 | If this interface is not supported, then return zero.\r | |
1174 | \r | |
1175 | @return The size, in bytes, of the context buffer required for AES operations.\r | |
1176 | @retval 0 This interface is not supported.\r | |
1177 | \r | |
1178 | **/\r | |
1179 | UINTN\r | |
1180 | EFIAPI\r | |
1181 | AesGetContextSize (\r | |
1182 | VOID\r | |
1183 | )\r | |
1184 | {\r | |
1185 | CALL_CRYPTO_SERVICE (AesGetContextSize, (), 0);\r | |
1186 | }\r | |
1187 | \r | |
1188 | /**\r | |
1189 | Initializes user-supplied memory as AES context for subsequent use.\r | |
1190 | \r | |
1191 | This function initializes user-supplied memory pointed by AesContext as AES context.\r | |
1192 | In addition, it sets up all AES key materials for subsequent encryption and decryption\r | |
1193 | operations.\r | |
1194 | There are 3 options for key length, 128 bits, 192 bits, and 256 bits.\r | |
1195 | \r | |
1196 | If AesContext is NULL, then return FALSE.\r | |
1197 | If Key is NULL, then return FALSE.\r | |
1198 | If KeyLength is not valid, then return FALSE.\r | |
1199 | If this interface is not supported, then return FALSE.\r | |
1200 | \r | |
1201 | @param[out] AesContext Pointer to AES context being initialized.\r | |
1202 | @param[in] Key Pointer to the user-supplied AES key.\r | |
1203 | @param[in] KeyLength Length of AES key in bits.\r | |
1204 | \r | |
1205 | @retval TRUE AES context initialization succeeded.\r | |
1206 | @retval FALSE AES context initialization failed.\r | |
1207 | @retval FALSE This interface is not supported.\r | |
1208 | \r | |
1209 | **/\r | |
1210 | BOOLEAN\r | |
1211 | EFIAPI\r | |
1212 | AesInit (\r | |
1213 | OUT VOID *AesContext,\r | |
1214 | IN CONST UINT8 *Key,\r | |
1215 | IN UINTN KeyLength\r | |
1216 | )\r | |
1217 | {\r | |
1218 | CALL_CRYPTO_SERVICE (AesInit, (AesContext, Key, KeyLength), FALSE);\r | |
1219 | }\r | |
1220 | \r | |
cd70de1c MK |
1221 | /**\r |
1222 | Performs AES encryption on a data buffer of the specified size in CBC mode.\r | |
1223 | \r | |
1224 | This function performs AES encryption on data buffer pointed by Input, of specified\r | |
1225 | size of InputSize, in CBC mode.\r | |
1226 | InputSize must be multiple of block size (16 bytes). This function does not perform\r | |
1227 | padding. Caller must perform padding, if necessary, to ensure valid input data size.\r | |
1228 | Initialization vector should be one block size (16 bytes).\r | |
1229 | AesContext should be already correctly initialized by AesInit(). Behavior with\r | |
1230 | invalid AES context is undefined.\r | |
1231 | \r | |
1232 | If AesContext is NULL, then return FALSE.\r | |
1233 | If Input is NULL, then return FALSE.\r | |
1234 | If InputSize is not multiple of block size (16 bytes), then return FALSE.\r | |
1235 | If Ivec is NULL, then return FALSE.\r | |
1236 | If Output is NULL, then return FALSE.\r | |
1237 | If this interface is not supported, then return FALSE.\r | |
1238 | \r | |
1239 | @param[in] AesContext Pointer to the AES context.\r | |
1240 | @param[in] Input Pointer to the buffer containing the data to be encrypted.\r | |
1241 | @param[in] InputSize Size of the Input buffer in bytes.\r | |
1242 | @param[in] Ivec Pointer to initialization vector.\r | |
1243 | @param[out] Output Pointer to a buffer that receives the AES encryption output.\r | |
1244 | \r | |
1245 | @retval TRUE AES encryption succeeded.\r | |
1246 | @retval FALSE AES encryption failed.\r | |
1247 | @retval FALSE This interface is not supported.\r | |
1248 | \r | |
1249 | **/\r | |
1250 | BOOLEAN\r | |
1251 | EFIAPI\r | |
1252 | AesCbcEncrypt (\r | |
1253 | IN VOID *AesContext,\r | |
1254 | IN CONST UINT8 *Input,\r | |
1255 | IN UINTN InputSize,\r | |
1256 | IN CONST UINT8 *Ivec,\r | |
1257 | OUT UINT8 *Output\r | |
1258 | )\r | |
1259 | {\r | |
1260 | CALL_CRYPTO_SERVICE (AesCbcEncrypt, (AesContext, Input, InputSize, Ivec, Output), FALSE);\r | |
1261 | }\r | |
1262 | \r | |
1263 | /**\r | |
1264 | Performs AES decryption on a data buffer of the specified size in CBC mode.\r | |
1265 | \r | |
1266 | This function performs AES decryption on data buffer pointed by Input, of specified\r | |
1267 | size of InputSize, in CBC mode.\r | |
1268 | InputSize must be multiple of block size (16 bytes). This function does not perform\r | |
1269 | padding. Caller must perform padding, if necessary, to ensure valid input data size.\r | |
1270 | Initialization vector should be one block size (16 bytes).\r | |
1271 | AesContext should be already correctly initialized by AesInit(). Behavior with\r | |
1272 | invalid AES context is undefined.\r | |
1273 | \r | |
1274 | If AesContext is NULL, then return FALSE.\r | |
1275 | If Input is NULL, then return FALSE.\r | |
1276 | If InputSize is not multiple of block size (16 bytes), then return FALSE.\r | |
1277 | If Ivec is NULL, then return FALSE.\r | |
1278 | If Output is NULL, then return FALSE.\r | |
1279 | If this interface is not supported, then return FALSE.\r | |
1280 | \r | |
1281 | @param[in] AesContext Pointer to the AES context.\r | |
1282 | @param[in] Input Pointer to the buffer containing the data to be encrypted.\r | |
1283 | @param[in] InputSize Size of the Input buffer in bytes.\r | |
1284 | @param[in] Ivec Pointer to initialization vector.\r | |
1285 | @param[out] Output Pointer to a buffer that receives the AES encryption output.\r | |
1286 | \r | |
1287 | @retval TRUE AES decryption succeeded.\r | |
1288 | @retval FALSE AES decryption failed.\r | |
1289 | @retval FALSE This interface is not supported.\r | |
1290 | \r | |
1291 | **/\r | |
1292 | BOOLEAN\r | |
1293 | EFIAPI\r | |
1294 | AesCbcDecrypt (\r | |
1295 | IN VOID *AesContext,\r | |
1296 | IN CONST UINT8 *Input,\r | |
1297 | IN UINTN InputSize,\r | |
1298 | IN CONST UINT8 *Ivec,\r | |
1299 | OUT UINT8 *Output\r | |
1300 | )\r | |
1301 | {\r | |
1302 | CALL_CRYPTO_SERVICE (AesCbcDecrypt, (AesContext, Input, InputSize, Ivec, Output), FALSE);\r | |
1303 | }\r | |
1304 | \r | |
cd70de1c MK |
1305 | //=====================================================================================\r |
1306 | // Asymmetric Cryptography Primitive\r | |
1307 | //=====================================================================================\r | |
1308 | \r | |
1309 | /**\r | |
1310 | Allocates and initializes one RSA context for subsequent use.\r | |
1311 | \r | |
1312 | @return Pointer to the RSA context that has been initialized.\r | |
1313 | If the allocations fails, RsaNew() returns NULL.\r | |
1314 | \r | |
1315 | **/\r | |
1316 | VOID *\r | |
1317 | EFIAPI\r | |
1318 | RsaNew (\r | |
1319 | VOID\r | |
1320 | )\r | |
1321 | {\r | |
1322 | CALL_CRYPTO_SERVICE (RsaNew, (), NULL);\r | |
1323 | }\r | |
1324 | \r | |
1325 | /**\r | |
1326 | Release the specified RSA context.\r | |
1327 | \r | |
1328 | If RsaContext is NULL, then return FALSE.\r | |
1329 | \r | |
1330 | @param[in] RsaContext Pointer to the RSA context to be released.\r | |
1331 | \r | |
1332 | **/\r | |
1333 | VOID\r | |
1334 | EFIAPI\r | |
1335 | RsaFree (\r | |
1336 | IN VOID *RsaContext\r | |
1337 | )\r | |
1338 | {\r | |
1339 | CALL_VOID_CRYPTO_SERVICE (RsaFree, (RsaContext));\r | |
1340 | }\r | |
1341 | \r | |
1342 | /**\r | |
1343 | Sets the tag-designated key component into the established RSA context.\r | |
1344 | \r | |
1345 | This function sets the tag-designated RSA key component into the established\r | |
1346 | RSA context from the user-specified non-negative integer (octet string format\r | |
1347 | represented in RSA PKCS#1).\r | |
1348 | If BigNumber is NULL, then the specified key component in RSA context is cleared.\r | |
1349 | \r | |
1350 | If RsaContext is NULL, then return FALSE.\r | |
1351 | \r | |
1352 | @param[in, out] RsaContext Pointer to RSA context being set.\r | |
1353 | @param[in] KeyTag Tag of RSA key component being set.\r | |
1354 | @param[in] BigNumber Pointer to octet integer buffer.\r | |
1355 | If NULL, then the specified key component in RSA\r | |
1356 | context is cleared.\r | |
1357 | @param[in] BnSize Size of big number buffer in bytes.\r | |
1358 | If BigNumber is NULL, then it is ignored.\r | |
1359 | \r | |
1360 | @retval TRUE RSA key component was set successfully.\r | |
1361 | @retval FALSE Invalid RSA key component tag.\r | |
1362 | \r | |
1363 | **/\r | |
1364 | BOOLEAN\r | |
1365 | EFIAPI\r | |
1366 | RsaSetKey (\r | |
1367 | IN OUT VOID *RsaContext,\r | |
1368 | IN RSA_KEY_TAG KeyTag,\r | |
1369 | IN CONST UINT8 *BigNumber,\r | |
1370 | IN UINTN BnSize\r | |
1371 | )\r | |
1372 | {\r | |
1373 | CALL_CRYPTO_SERVICE (RsaSetKey, (RsaContext, KeyTag, BigNumber, BnSize), FALSE);\r | |
1374 | }\r | |
1375 | \r | |
1376 | /**\r | |
1377 | Gets the tag-designated RSA key component from the established RSA context.\r | |
1378 | \r | |
1379 | This function retrieves the tag-designated RSA key component from the\r | |
1380 | established RSA context as a non-negative integer (octet string format\r | |
1381 | represented in RSA PKCS#1).\r | |
1382 | If specified key component has not been set or has been cleared, then returned\r | |
1383 | BnSize is set to 0.\r | |
1384 | If the BigNumber buffer is too small to hold the contents of the key, FALSE\r | |
1385 | is returned and BnSize is set to the required buffer size to obtain the key.\r | |
1386 | \r | |
1387 | If RsaContext is NULL, then return FALSE.\r | |
1388 | If BnSize is NULL, then return FALSE.\r | |
1389 | If BnSize is large enough but BigNumber is NULL, then return FALSE.\r | |
1390 | If this interface is not supported, then return FALSE.\r | |
1391 | \r | |
1392 | @param[in, out] RsaContext Pointer to RSA context being set.\r | |
1393 | @param[in] KeyTag Tag of RSA key component being set.\r | |
1394 | @param[out] BigNumber Pointer to octet integer buffer.\r | |
1395 | @param[in, out] BnSize On input, the size of big number buffer in bytes.\r | |
1396 | On output, the size of data returned in big number buffer in bytes.\r | |
1397 | \r | |
1398 | @retval TRUE RSA key component was retrieved successfully.\r | |
1399 | @retval FALSE Invalid RSA key component tag.\r | |
1400 | @retval FALSE BnSize is too small.\r | |
1401 | @retval FALSE This interface is not supported.\r | |
1402 | \r | |
1403 | **/\r | |
1404 | BOOLEAN\r | |
1405 | EFIAPI\r | |
1406 | RsaGetKey (\r | |
1407 | IN OUT VOID *RsaContext,\r | |
1408 | IN RSA_KEY_TAG KeyTag,\r | |
1409 | OUT UINT8 *BigNumber,\r | |
1410 | IN OUT UINTN *BnSize\r | |
1411 | )\r | |
1412 | {\r | |
1413 | CALL_CRYPTO_SERVICE (RsaGetKey, (RsaContext, KeyTag, BigNumber, BnSize), FALSE);\r | |
1414 | }\r | |
1415 | \r | |
1416 | /**\r | |
1417 | Generates RSA key components.\r | |
1418 | \r | |
1419 | This function generates RSA key components. It takes RSA public exponent E and\r | |
1420 | length in bits of RSA modulus N as input, and generates all key components.\r | |
1421 | If PublicExponent is NULL, the default RSA public exponent (0x10001) will be used.\r | |
1422 | \r | |
1423 | Before this function can be invoked, pseudorandom number generator must be correctly\r | |
1424 | initialized by RandomSeed().\r | |
1425 | \r | |
1426 | If RsaContext is NULL, then return FALSE.\r | |
1427 | If this interface is not supported, then return FALSE.\r | |
1428 | \r | |
1429 | @param[in, out] RsaContext Pointer to RSA context being set.\r | |
1430 | @param[in] ModulusLength Length of RSA modulus N in bits.\r | |
1431 | @param[in] PublicExponent Pointer to RSA public exponent.\r | |
1432 | @param[in] PublicExponentSize Size of RSA public exponent buffer in bytes.\r | |
1433 | \r | |
1434 | @retval TRUE RSA key component was generated successfully.\r | |
1435 | @retval FALSE Invalid RSA key component tag.\r | |
1436 | @retval FALSE This interface is not supported.\r | |
1437 | \r | |
1438 | **/\r | |
1439 | BOOLEAN\r | |
1440 | EFIAPI\r | |
1441 | RsaGenerateKey (\r | |
1442 | IN OUT VOID *RsaContext,\r | |
1443 | IN UINTN ModulusLength,\r | |
1444 | IN CONST UINT8 *PublicExponent,\r | |
1445 | IN UINTN PublicExponentSize\r | |
1446 | )\r | |
1447 | {\r | |
1448 | CALL_CRYPTO_SERVICE (RsaGenerateKey, (RsaContext, ModulusLength, PublicExponent, PublicExponentSize), FALSE);\r | |
1449 | }\r | |
1450 | \r | |
1451 | /**\r | |
1452 | Validates key components of RSA context.\r | |
1453 | NOTE: This function performs integrity checks on all the RSA key material, so\r | |
1454 | the RSA key structure must contain all the private key data.\r | |
1455 | \r | |
1456 | This function validates key components of RSA context in following aspects:\r | |
1457 | - Whether p is a prime\r | |
1458 | - Whether q is a prime\r | |
1459 | - Whether n = p * q\r | |
1460 | - Whether d*e = 1 mod lcm(p-1,q-1)\r | |
1461 | \r | |
1462 | If RsaContext is NULL, then return FALSE.\r | |
1463 | If this interface is not supported, then return FALSE.\r | |
1464 | \r | |
1465 | @param[in] RsaContext Pointer to RSA context to check.\r | |
1466 | \r | |
1467 | @retval TRUE RSA key components are valid.\r | |
1468 | @retval FALSE RSA key components are not valid.\r | |
1469 | @retval FALSE This interface is not supported.\r | |
1470 | \r | |
1471 | **/\r | |
1472 | BOOLEAN\r | |
1473 | EFIAPI\r | |
1474 | RsaCheckKey (\r | |
1475 | IN VOID *RsaContext\r | |
1476 | )\r | |
1477 | {\r | |
1478 | CALL_CRYPTO_SERVICE (RsaCheckKey, (RsaContext), FALSE);\r | |
1479 | }\r | |
1480 | \r | |
1481 | /**\r | |
1482 | Carries out the RSA-SSA signature generation with EMSA-PKCS1-v1_5 encoding scheme.\r | |
1483 | \r | |
1484 | This function carries out the RSA-SSA signature generation with EMSA-PKCS1-v1_5 encoding scheme defined in\r | |
1485 | RSA PKCS#1.\r | |
1486 | If the Signature buffer is too small to hold the contents of signature, FALSE\r | |
1487 | is returned and SigSize is set to the required buffer size to obtain the signature.\r | |
1488 | \r | |
1489 | If RsaContext is NULL, then return FALSE.\r | |
1490 | If MessageHash is NULL, then return FALSE.\r | |
1491 | If HashSize is not equal to the size of MD5, SHA-1 or SHA-256 digest, then return FALSE.\r | |
1492 | If SigSize is large enough but Signature is NULL, then return FALSE.\r | |
1493 | If this interface is not supported, then return FALSE.\r | |
1494 | \r | |
1495 | @param[in] RsaContext Pointer to RSA context for signature generation.\r | |
1496 | @param[in] MessageHash Pointer to octet message hash to be signed.\r | |
1497 | @param[in] HashSize Size of the message hash in bytes.\r | |
1498 | @param[out] Signature Pointer to buffer to receive RSA PKCS1-v1_5 signature.\r | |
1499 | @param[in, out] SigSize On input, the size of Signature buffer in bytes.\r | |
1500 | On output, the size of data returned in Signature buffer in bytes.\r | |
1501 | \r | |
1502 | @retval TRUE Signature successfully generated in PKCS1-v1_5.\r | |
1503 | @retval FALSE Signature generation failed.\r | |
1504 | @retval FALSE SigSize is too small.\r | |
1505 | @retval FALSE This interface is not supported.\r | |
1506 | \r | |
1507 | **/\r | |
1508 | BOOLEAN\r | |
1509 | EFIAPI\r | |
1510 | RsaPkcs1Sign (\r | |
1511 | IN VOID *RsaContext,\r | |
1512 | IN CONST UINT8 *MessageHash,\r | |
1513 | IN UINTN HashSize,\r | |
1514 | OUT UINT8 *Signature,\r | |
1515 | IN OUT UINTN *SigSize\r | |
1516 | )\r | |
1517 | {\r | |
1518 | CALL_CRYPTO_SERVICE (RsaPkcs1Sign, (RsaContext, MessageHash, HashSize, Signature, SigSize), FALSE);\r | |
1519 | }\r | |
1520 | \r | |
1521 | /**\r | |
1522 | Verifies the RSA-SSA signature with EMSA-PKCS1-v1_5 encoding scheme defined in\r | |
1523 | RSA PKCS#1.\r | |
1524 | \r | |
1525 | If RsaContext is NULL, then return FALSE.\r | |
1526 | If MessageHash is NULL, then return FALSE.\r | |
1527 | If Signature is NULL, then return FALSE.\r | |
1528 | If HashSize is not equal to the size of MD5, SHA-1, SHA-256 digest, then return FALSE.\r | |
1529 | \r | |
1530 | @param[in] RsaContext Pointer to RSA context for signature verification.\r | |
1531 | @param[in] MessageHash Pointer to octet message hash to be checked.\r | |
1532 | @param[in] HashSize Size of the message hash in bytes.\r | |
1533 | @param[in] Signature Pointer to RSA PKCS1-v1_5 signature to be verified.\r | |
1534 | @param[in] SigSize Size of signature in bytes.\r | |
1535 | \r | |
1536 | @retval TRUE Valid signature encoded in PKCS1-v1_5.\r | |
1537 | @retval FALSE Invalid signature or invalid RSA context.\r | |
1538 | \r | |
1539 | **/\r | |
1540 | BOOLEAN\r | |
1541 | EFIAPI\r | |
1542 | RsaPkcs1Verify (\r | |
1543 | IN VOID *RsaContext,\r | |
1544 | IN CONST UINT8 *MessageHash,\r | |
1545 | IN UINTN HashSize,\r | |
1546 | IN CONST UINT8 *Signature,\r | |
1547 | IN UINTN SigSize\r | |
1548 | )\r | |
1549 | {\r | |
1550 | CALL_CRYPTO_SERVICE (RsaPkcs1Verify, (RsaContext, MessageHash, HashSize, Signature, SigSize), FALSE);\r | |
1551 | }\r | |
1552 | \r | |
1553 | /**\r | |
1554 | Retrieve the RSA Private Key from the password-protected PEM key data.\r | |
1555 | \r | |
1556 | If PemData is NULL, then return FALSE.\r | |
1557 | If RsaContext is NULL, then return FALSE.\r | |
1558 | If this interface is not supported, then return FALSE.\r | |
1559 | \r | |
1560 | @param[in] PemData Pointer to the PEM-encoded key data to be retrieved.\r | |
1561 | @param[in] PemSize Size of the PEM key data in bytes.\r | |
1562 | @param[in] Password NULL-terminated passphrase used for encrypted PEM key data.\r | |
1563 | @param[out] RsaContext Pointer to new-generated RSA context which contain the retrieved\r | |
1564 | RSA private key component. Use RsaFree() function to free the\r | |
1565 | resource.\r | |
1566 | \r | |
1567 | @retval TRUE RSA Private Key was retrieved successfully.\r | |
1568 | @retval FALSE Invalid PEM key data or incorrect password.\r | |
1569 | @retval FALSE This interface is not supported.\r | |
1570 | \r | |
1571 | **/\r | |
1572 | BOOLEAN\r | |
1573 | EFIAPI\r | |
1574 | RsaGetPrivateKeyFromPem (\r | |
1575 | IN CONST UINT8 *PemData,\r | |
1576 | IN UINTN PemSize,\r | |
1577 | IN CONST CHAR8 *Password,\r | |
1578 | OUT VOID **RsaContext\r | |
1579 | )\r | |
1580 | {\r | |
1581 | CALL_CRYPTO_SERVICE (RsaGetPrivateKeyFromPem, (PemData, PemSize, Password, RsaContext), FALSE);\r | |
1582 | }\r | |
1583 | \r | |
1584 | /**\r | |
1585 | Retrieve the RSA Public Key from one DER-encoded X509 certificate.\r | |
1586 | \r | |
1587 | If Cert is NULL, then return FALSE.\r | |
1588 | If RsaContext is NULL, then return FALSE.\r | |
1589 | If this interface is not supported, then return FALSE.\r | |
1590 | \r | |
1591 | @param[in] Cert Pointer to the DER-encoded X509 certificate.\r | |
1592 | @param[in] CertSize Size of the X509 certificate in bytes.\r | |
1593 | @param[out] RsaContext Pointer to new-generated RSA context which contain the retrieved\r | |
1594 | RSA public key component. Use RsaFree() function to free the\r | |
1595 | resource.\r | |
1596 | \r | |
1597 | @retval TRUE RSA Public Key was retrieved successfully.\r | |
1598 | @retval FALSE Fail to retrieve RSA public key from X509 certificate.\r | |
1599 | @retval FALSE This interface is not supported.\r | |
1600 | \r | |
1601 | **/\r | |
1602 | BOOLEAN\r | |
1603 | EFIAPI\r | |
1604 | RsaGetPublicKeyFromX509 (\r | |
1605 | IN CONST UINT8 *Cert,\r | |
1606 | IN UINTN CertSize,\r | |
1607 | OUT VOID **RsaContext\r | |
1608 | )\r | |
1609 | {\r | |
1610 | CALL_CRYPTO_SERVICE (RsaGetPublicKeyFromX509, (Cert, CertSize, RsaContext), FALSE);\r | |
1611 | }\r | |
1612 | \r | |
1613 | /**\r | |
1614 | Retrieve the subject bytes from one X.509 certificate.\r | |
1615 | \r | |
1616 | If Cert is NULL, then return FALSE.\r | |
1617 | If SubjectSize is NULL, then return FALSE.\r | |
1618 | If this interface is not supported, then return FALSE.\r | |
1619 | \r | |
1620 | @param[in] Cert Pointer to the DER-encoded X509 certificate.\r | |
1621 | @param[in] CertSize Size of the X509 certificate in bytes.\r | |
1622 | @param[out] CertSubject Pointer to the retrieved certificate subject bytes.\r | |
1623 | @param[in, out] SubjectSize The size in bytes of the CertSubject buffer on input,\r | |
1624 | and the size of buffer returned CertSubject on output.\r | |
1625 | \r | |
1626 | @retval TRUE The certificate subject retrieved successfully.\r | |
1627 | @retval FALSE Invalid certificate, or the SubjectSize is too small for the result.\r | |
1628 | The SubjectSize will be updated with the required size.\r | |
1629 | @retval FALSE This interface is not supported.\r | |
1630 | \r | |
1631 | **/\r | |
1632 | BOOLEAN\r | |
1633 | EFIAPI\r | |
1634 | X509GetSubjectName (\r | |
1635 | IN CONST UINT8 *Cert,\r | |
1636 | IN UINTN CertSize,\r | |
1637 | OUT UINT8 *CertSubject,\r | |
1638 | IN OUT UINTN *SubjectSize\r | |
1639 | )\r | |
1640 | {\r | |
1641 | CALL_CRYPTO_SERVICE (X509GetSubjectName, (Cert, CertSize, CertSubject, SubjectSize), FALSE);\r | |
1642 | }\r | |
1643 | \r | |
1644 | /**\r | |
1645 | Retrieve the common name (CN) string from one X.509 certificate.\r | |
1646 | \r | |
1647 | @param[in] Cert Pointer to the DER-encoded X509 certificate.\r | |
1648 | @param[in] CertSize Size of the X509 certificate in bytes.\r | |
1649 | @param[out] CommonName Buffer to contain the retrieved certificate common\r | |
1650 | name string (UTF8). At most CommonNameSize bytes will be\r | |
1651 | written and the string will be null terminated. May be\r | |
1652 | NULL in order to determine the size buffer needed.\r | |
1653 | @param[in,out] CommonNameSize The size in bytes of the CommonName buffer on input,\r | |
1654 | and the size of buffer returned CommonName on output.\r | |
1655 | If CommonName is NULL then the amount of space needed\r | |
1656 | in buffer (including the final null) is returned.\r | |
1657 | \r | |
1658 | @retval RETURN_SUCCESS The certificate CommonName retrieved successfully.\r | |
1659 | @retval RETURN_INVALID_PARAMETER If Cert is NULL.\r | |
1660 | If CommonNameSize is NULL.\r | |
1661 | If CommonName is not NULL and *CommonNameSize is 0.\r | |
1662 | If Certificate is invalid.\r | |
1663 | @retval RETURN_NOT_FOUND If no CommonName entry exists.\r | |
1664 | @retval RETURN_BUFFER_TOO_SMALL If the CommonName is NULL. The required buffer size\r | |
1665 | (including the final null) is returned in the\r | |
1666 | CommonNameSize parameter.\r | |
1667 | @retval RETURN_UNSUPPORTED The operation is not supported.\r | |
1668 | \r | |
1669 | **/\r | |
1670 | RETURN_STATUS\r | |
1671 | EFIAPI\r | |
1672 | X509GetCommonName (\r | |
1673 | IN CONST UINT8 *Cert,\r | |
1674 | IN UINTN CertSize,\r | |
1675 | OUT CHAR8 *CommonName, OPTIONAL\r | |
1676 | IN OUT UINTN *CommonNameSize\r | |
1677 | )\r | |
1678 | {\r | |
1679 | CALL_CRYPTO_SERVICE (X509GetCommonName, (Cert, CertSize, CommonName, CommonNameSize), RETURN_UNSUPPORTED);\r | |
1680 | }\r | |
1681 | \r | |
1682 | /**\r | |
1683 | Retrieve the organization name (O) string from one X.509 certificate.\r | |
1684 | \r | |
1685 | @param[in] Cert Pointer to the DER-encoded X509 certificate.\r | |
1686 | @param[in] CertSize Size of the X509 certificate in bytes.\r | |
1687 | @param[out] NameBuffer Buffer to contain the retrieved certificate organization\r | |
1688 | name string. At most NameBufferSize bytes will be\r | |
1689 | written and the string will be null terminated. May be\r | |
1690 | NULL in order to determine the size buffer needed.\r | |
1691 | @param[in,out] NameBufferSize The size in bytes of the Name buffer on input,\r | |
1692 | and the size of buffer returned Name on output.\r | |
1693 | If NameBuffer is NULL then the amount of space needed\r | |
1694 | in buffer (including the final null) is returned.\r | |
1695 | \r | |
1696 | @retval RETURN_SUCCESS The certificate Organization Name retrieved successfully.\r | |
1697 | @retval RETURN_INVALID_PARAMETER If Cert is NULL.\r | |
1698 | If NameBufferSize is NULL.\r | |
1699 | If NameBuffer is not NULL and *CommonNameSize is 0.\r | |
1700 | If Certificate is invalid.\r | |
1701 | @retval RETURN_NOT_FOUND If no Organization Name entry exists.\r | |
1702 | @retval RETURN_BUFFER_TOO_SMALL If the NameBuffer is NULL. The required buffer size\r | |
1703 | (including the final null) is returned in the\r | |
1704 | CommonNameSize parameter.\r | |
1705 | @retval RETURN_UNSUPPORTED The operation is not supported.\r | |
1706 | \r | |
1707 | **/\r | |
1708 | RETURN_STATUS\r | |
1709 | EFIAPI\r | |
1710 | X509GetOrganizationName (\r | |
1711 | IN CONST UINT8 *Cert,\r | |
1712 | IN UINTN CertSize,\r | |
1713 | OUT CHAR8 *NameBuffer, OPTIONAL\r | |
1714 | IN OUT UINTN *NameBufferSize\r | |
1715 | )\r | |
1716 | {\r | |
1717 | CALL_CRYPTO_SERVICE (X509GetOrganizationName, (Cert, CertSize, NameBuffer, NameBufferSize), RETURN_UNSUPPORTED);\r | |
1718 | }\r | |
1719 | \r | |
1720 | /**\r | |
1721 | Verify one X509 certificate was issued by the trusted CA.\r | |
1722 | \r | |
1723 | If Cert is NULL, then return FALSE.\r | |
1724 | If CACert is NULL, then return FALSE.\r | |
1725 | If this interface is not supported, then return FALSE.\r | |
1726 | \r | |
1727 | @param[in] Cert Pointer to the DER-encoded X509 certificate to be verified.\r | |
1728 | @param[in] CertSize Size of the X509 certificate in bytes.\r | |
1729 | @param[in] CACert Pointer to the DER-encoded trusted CA certificate.\r | |
1730 | @param[in] CACertSize Size of the CA Certificate in bytes.\r | |
1731 | \r | |
1732 | @retval TRUE The certificate was issued by the trusted CA.\r | |
1733 | @retval FALSE Invalid certificate or the certificate was not issued by the given\r | |
1734 | trusted CA.\r | |
1735 | @retval FALSE This interface is not supported.\r | |
1736 | \r | |
1737 | **/\r | |
1738 | BOOLEAN\r | |
1739 | EFIAPI\r | |
1740 | X509VerifyCert (\r | |
1741 | IN CONST UINT8 *Cert,\r | |
1742 | IN UINTN CertSize,\r | |
1743 | IN CONST UINT8 *CACert,\r | |
1744 | IN UINTN CACertSize\r | |
1745 | )\r | |
1746 | {\r | |
1747 | CALL_CRYPTO_SERVICE (X509VerifyCert, (Cert, CertSize, CACert, CACertSize), FALSE);\r | |
1748 | }\r | |
1749 | \r | |
1750 | /**\r | |
1751 | Construct a X509 object from DER-encoded certificate data.\r | |
1752 | \r | |
1753 | If Cert is NULL, then return FALSE.\r | |
1754 | If SingleX509Cert is NULL, then return FALSE.\r | |
1755 | If this interface is not supported, then return FALSE.\r | |
1756 | \r | |
1757 | @param[in] Cert Pointer to the DER-encoded certificate data.\r | |
1758 | @param[in] CertSize The size of certificate data in bytes.\r | |
1759 | @param[out] SingleX509Cert The generated X509 object.\r | |
1760 | \r | |
1761 | @retval TRUE The X509 object generation succeeded.\r | |
1762 | @retval FALSE The operation failed.\r | |
1763 | @retval FALSE This interface is not supported.\r | |
1764 | \r | |
1765 | **/\r | |
1766 | BOOLEAN\r | |
1767 | EFIAPI\r | |
1768 | X509ConstructCertificate (\r | |
1769 | IN CONST UINT8 *Cert,\r | |
1770 | IN UINTN CertSize,\r | |
1771 | OUT UINT8 **SingleX509Cert\r | |
1772 | )\r | |
1773 | {\r | |
1774 | CALL_CRYPTO_SERVICE (X509ConstructCertificate, (Cert, CertSize, SingleX509Cert), FALSE);\r | |
1775 | }\r | |
1776 | \r | |
1777 | /**\r | |
1778 | Construct a X509 stack object from a list of DER-encoded certificate data.\r | |
1779 | \r | |
1780 | If X509Stack is NULL, then return FALSE.\r | |
1781 | If this interface is not supported, then return FALSE.\r | |
1782 | \r | |
1783 | @param[in, out] X509Stack On input, pointer to an existing or NULL X509 stack object.\r | |
1784 | On output, pointer to the X509 stack object with new\r | |
1785 | inserted X509 certificate.\r | |
1786 | @param[in] Args VA_LIST marker for the variable argument list.\r | |
1787 | ... A list of DER-encoded single certificate data followed\r | |
1788 | by certificate size. A NULL terminates the list. The\r | |
1789 | pairs are the arguments to X509ConstructCertificate().\r | |
1790 | \r | |
1791 | @retval TRUE The X509 stack construction succeeded.\r | |
1792 | @retval FALSE The construction operation failed.\r | |
1793 | @retval FALSE This interface is not supported.\r | |
1794 | \r | |
1795 | **/\r | |
1796 | BOOLEAN\r | |
1797 | EFIAPI\r | |
1798 | X509ConstructCertificateStack (\r | |
1799 | IN OUT UINT8 **X509Stack,\r | |
1800 | ...\r | |
1801 | )\r | |
1802 | {\r | |
1803 | VA_LIST Args;\r | |
1804 | BOOLEAN Result;\r | |
1805 | \r | |
1806 | VA_START (Args, X509Stack);\r | |
1807 | Result = X509ConstructCertificateStackV (X509Stack, Args);\r | |
1808 | VA_END (Args);\r | |
1809 | return Result;\r | |
1810 | }\r | |
1811 | \r | |
1812 | /**\r | |
1813 | Construct a X509 stack object from a list of DER-encoded certificate data.\r | |
1814 | \r | |
1815 | If X509Stack is NULL, then return FALSE.\r | |
1816 | If this interface is not supported, then return FALSE.\r | |
1817 | \r | |
1818 | @param[in, out] X509Stack On input, pointer to an existing or NULL X509 stack object.\r | |
1819 | On output, pointer to the X509 stack object with new\r | |
1820 | inserted X509 certificate.\r | |
1821 | @param[in] Args VA_LIST marker for the variable argument list.\r | |
1822 | A list of DER-encoded single certificate data followed\r | |
1823 | by certificate size. A NULL terminates the list. The\r | |
1824 | pairs are the arguments to X509ConstructCertificate().\r | |
1825 | \r | |
1826 | @retval TRUE The X509 stack construction succeeded.\r | |
1827 | @retval FALSE The construction operation failed.\r | |
1828 | @retval FALSE This interface is not supported.\r | |
1829 | \r | |
1830 | **/\r | |
1831 | BOOLEAN\r | |
1832 | EFIAPI\r | |
1833 | X509ConstructCertificateStackV (\r | |
1834 | IN OUT UINT8 **X509Stack,\r | |
1835 | IN VA_LIST Args\r | |
1836 | )\r | |
1837 | {\r | |
1838 | CALL_CRYPTO_SERVICE (X509ConstructCertificateStackV, (X509Stack, Args), FALSE);\r | |
1839 | }\r | |
1840 | \r | |
1841 | /**\r | |
1842 | Release the specified X509 object.\r | |
1843 | \r | |
1844 | If the interface is not supported, then ASSERT().\r | |
1845 | \r | |
1846 | @param[in] X509Cert Pointer to the X509 object to be released.\r | |
1847 | \r | |
1848 | **/\r | |
1849 | VOID\r | |
1850 | EFIAPI\r | |
1851 | X509Free (\r | |
1852 | IN VOID *X509Cert\r | |
1853 | )\r | |
1854 | {\r | |
1855 | CALL_VOID_CRYPTO_SERVICE (X509Free, (X509Cert));\r | |
1856 | }\r | |
1857 | \r | |
1858 | /**\r | |
1859 | Release the specified X509 stack object.\r | |
1860 | \r | |
1861 | If the interface is not supported, then ASSERT().\r | |
1862 | \r | |
1863 | @param[in] X509Stack Pointer to the X509 stack object to be released.\r | |
1864 | \r | |
1865 | **/\r | |
1866 | VOID\r | |
1867 | EFIAPI\r | |
1868 | X509StackFree (\r | |
1869 | IN VOID *X509Stack\r | |
1870 | )\r | |
1871 | {\r | |
1872 | CALL_VOID_CRYPTO_SERVICE (X509StackFree, (X509Stack));\r | |
1873 | }\r | |
1874 | \r | |
1875 | /**\r | |
1876 | Retrieve the TBSCertificate from one given X.509 certificate.\r | |
1877 | \r | |
1878 | @param[in] Cert Pointer to the given DER-encoded X509 certificate.\r | |
1879 | @param[in] CertSize Size of the X509 certificate in bytes.\r | |
1880 | @param[out] TBSCert DER-Encoded To-Be-Signed certificate.\r | |
1881 | @param[out] TBSCertSize Size of the TBS certificate in bytes.\r | |
1882 | \r | |
1883 | If Cert is NULL, then return FALSE.\r | |
1884 | If TBSCert is NULL, then return FALSE.\r | |
1885 | If TBSCertSize is NULL, then return FALSE.\r | |
1886 | If this interface is not supported, then return FALSE.\r | |
1887 | \r | |
1888 | @retval TRUE The TBSCertificate was retrieved successfully.\r | |
1889 | @retval FALSE Invalid X.509 certificate.\r | |
1890 | \r | |
1891 | **/\r | |
1892 | BOOLEAN\r | |
1893 | EFIAPI\r | |
1894 | X509GetTBSCert (\r | |
1895 | IN CONST UINT8 *Cert,\r | |
1896 | IN UINTN CertSize,\r | |
1897 | OUT UINT8 **TBSCert,\r | |
1898 | OUT UINTN *TBSCertSize\r | |
1899 | )\r | |
1900 | {\r | |
1901 | CALL_CRYPTO_SERVICE (X509GetTBSCert, (Cert, CertSize, TBSCert, TBSCertSize), FALSE);\r | |
1902 | }\r | |
1903 | \r | |
1904 | /**\r | |
1905 | Derives a key from a password using a salt and iteration count, based on PKCS#5 v2.0\r | |
1906 | password based encryption key derivation function PBKDF2, as specified in RFC 2898.\r | |
1907 | \r | |
1908 | If Password or Salt or OutKey is NULL, then return FALSE.\r | |
1909 | If the hash algorithm could not be determined, then return FALSE.\r | |
1910 | If this interface is not supported, then return FALSE.\r | |
1911 | \r | |
1912 | @param[in] PasswordLength Length of input password in bytes.\r | |
1913 | @param[in] Password Pointer to the array for the password.\r | |
1914 | @param[in] SaltLength Size of the Salt in bytes.\r | |
1915 | @param[in] Salt Pointer to the Salt.\r | |
1916 | @param[in] IterationCount Number of iterations to perform. Its value should be\r | |
1917 | greater than or equal to 1.\r | |
1918 | @param[in] DigestSize Size of the message digest to be used (eg. SHA256_DIGEST_SIZE).\r | |
1919 | NOTE: DigestSize will be used to determine the hash algorithm.\r | |
1920 | Only SHA1_DIGEST_SIZE or SHA256_DIGEST_SIZE is supported.\r | |
1921 | @param[in] KeyLength Size of the derived key buffer in bytes.\r | |
1922 | @param[out] OutKey Pointer to the output derived key buffer.\r | |
1923 | \r | |
1924 | @retval TRUE A key was derived successfully.\r | |
1925 | @retval FALSE One of the pointers was NULL or one of the sizes was too large.\r | |
1926 | @retval FALSE The hash algorithm could not be determined from the digest size.\r | |
1927 | @retval FALSE The key derivation operation failed.\r | |
1928 | @retval FALSE This interface is not supported.\r | |
1929 | \r | |
1930 | **/\r | |
1931 | BOOLEAN\r | |
1932 | EFIAPI\r | |
1933 | Pkcs5HashPassword (\r | |
1934 | IN UINTN PasswordLength,\r | |
1935 | IN CONST CHAR8 *Password,\r | |
1936 | IN UINTN SaltLength,\r | |
1937 | IN CONST UINT8 *Salt,\r | |
1938 | IN UINTN IterationCount,\r | |
1939 | IN UINTN DigestSize,\r | |
1940 | IN UINTN KeyLength,\r | |
1941 | OUT UINT8 *OutKey\r | |
1942 | )\r | |
1943 | {\r | |
1944 | CALL_CRYPTO_SERVICE (Pkcs5HashPassword, (PasswordLength, Password, SaltLength, Salt, IterationCount, DigestSize, KeyLength, OutKey), FALSE);\r | |
1945 | }\r | |
1946 | \r | |
1947 | /**\r | |
1948 | Encrypts a blob using PKCS1v2 (RSAES-OAEP) schema. On success, will return the\r | |
1949 | encrypted message in a newly allocated buffer.\r | |
1950 | \r | |
1951 | Things that can cause a failure include:\r | |
1952 | - X509 key size does not match any known key size.\r | |
1953 | - Fail to parse X509 certificate.\r | |
1954 | - Fail to allocate an intermediate buffer.\r | |
1955 | - Null pointer provided for a non-optional parameter.\r | |
1956 | - Data size is too large for the provided key size (max size is a function of key size\r | |
1957 | and hash digest size).\r | |
1958 | \r | |
1959 | @param[in] PublicKey A pointer to the DER-encoded X509 certificate that\r | |
1960 | will be used to encrypt the data.\r | |
1961 | @param[in] PublicKeySize Size of the X509 cert buffer.\r | |
1962 | @param[in] InData Data to be encrypted.\r | |
1963 | @param[in] InDataSize Size of the data buffer.\r | |
1964 | @param[in] PrngSeed [Optional] If provided, a pointer to a random seed buffer\r | |
1965 | to be used when initializing the PRNG. NULL otherwise.\r | |
1966 | @param[in] PrngSeedSize [Optional] If provided, size of the random seed buffer.\r | |
1967 | 0 otherwise.\r | |
1968 | @param[out] EncryptedData Pointer to an allocated buffer containing the encrypted\r | |
1969 | message.\r | |
1970 | @param[out] EncryptedDataSize Size of the encrypted message buffer.\r | |
1971 | \r | |
1972 | @retval TRUE Encryption was successful.\r | |
1973 | @retval FALSE Encryption failed.\r | |
1974 | \r | |
1975 | **/\r | |
1976 | BOOLEAN\r | |
1977 | EFIAPI\r | |
1978 | Pkcs1v2Encrypt (\r | |
1979 | IN CONST UINT8 *PublicKey,\r | |
1980 | IN UINTN PublicKeySize,\r | |
1981 | IN UINT8 *InData,\r | |
1982 | IN UINTN InDataSize,\r | |
1983 | IN CONST UINT8 *PrngSeed, OPTIONAL\r | |
1984 | IN UINTN PrngSeedSize, OPTIONAL\r | |
1985 | OUT UINT8 **EncryptedData,\r | |
1986 | OUT UINTN *EncryptedDataSize\r | |
1987 | )\r | |
1988 | {\r | |
1989 | CALL_CRYPTO_SERVICE (Pkcs1v2Encrypt, (PublicKey, PublicKeySize, InData, InDataSize, PrngSeed, PrngSeedSize, EncryptedData, EncryptedDataSize), FALSE);\r | |
1990 | }\r | |
1991 | \r | |
1992 | /**\r | |
1993 | Get the signer's certificates from PKCS#7 signed data as described in "PKCS #7:\r | |
1994 | Cryptographic Message Syntax Standard". The input signed data could be wrapped\r | |
1995 | in a ContentInfo structure.\r | |
1996 | \r | |
1997 | If P7Data, CertStack, StackLength, TrustedCert or CertLength is NULL, then\r | |
1998 | return FALSE. If P7Length overflow, then return FALSE.\r | |
1999 | If this interface is not supported, then return FALSE.\r | |
2000 | \r | |
2001 | @param[in] P7Data Pointer to the PKCS#7 message to verify.\r | |
2002 | @param[in] P7Length Length of the PKCS#7 message in bytes.\r | |
2003 | @param[out] CertStack Pointer to Signer's certificates retrieved from P7Data.\r | |
2004 | It's caller's responsibility to free the buffer with\r | |
2005 | Pkcs7FreeSigners().\r | |
2006 | This data structure is EFI_CERT_STACK type.\r | |
2007 | @param[out] StackLength Length of signer's certificates in bytes.\r | |
2008 | @param[out] TrustedCert Pointer to a trusted certificate from Signer's certificates.\r | |
2009 | It's caller's responsibility to free the buffer with\r | |
2010 | Pkcs7FreeSigners().\r | |
2011 | @param[out] CertLength Length of the trusted certificate in bytes.\r | |
2012 | \r | |
2013 | @retval TRUE The operation is finished successfully.\r | |
2014 | @retval FALSE Error occurs during the operation.\r | |
2015 | @retval FALSE This interface is not supported.\r | |
2016 | \r | |
2017 | **/\r | |
2018 | BOOLEAN\r | |
2019 | EFIAPI\r | |
2020 | Pkcs7GetSigners (\r | |
2021 | IN CONST UINT8 *P7Data,\r | |
2022 | IN UINTN P7Length,\r | |
2023 | OUT UINT8 **CertStack,\r | |
2024 | OUT UINTN *StackLength,\r | |
2025 | OUT UINT8 **TrustedCert,\r | |
2026 | OUT UINTN *CertLength\r | |
2027 | )\r | |
2028 | {\r | |
2029 | CALL_CRYPTO_SERVICE (Pkcs7GetSigners, (P7Data, P7Length, CertStack, StackLength, TrustedCert, CertLength), FALSE);\r | |
2030 | }\r | |
2031 | \r | |
2032 | /**\r | |
2033 | Wrap function to use free() to free allocated memory for certificates.\r | |
2034 | \r | |
2035 | If this interface is not supported, then ASSERT().\r | |
2036 | \r | |
2037 | @param[in] Certs Pointer to the certificates to be freed.\r | |
2038 | \r | |
2039 | **/\r | |
2040 | VOID\r | |
2041 | EFIAPI\r | |
2042 | Pkcs7FreeSigners (\r | |
2043 | IN UINT8 *Certs\r | |
2044 | )\r | |
2045 | {\r | |
2046 | CALL_VOID_CRYPTO_SERVICE (Pkcs7FreeSigners, (Certs));\r | |
2047 | }\r | |
2048 | \r | |
2049 | /**\r | |
2050 | Retrieves all embedded certificates from PKCS#7 signed data as described in "PKCS #7:\r | |
2051 | Cryptographic Message Syntax Standard", and outputs two certificate lists chained and\r | |
2052 | unchained to the signer's certificates.\r | |
2053 | The input signed data could be wrapped in a ContentInfo structure.\r | |
2054 | \r | |
2055 | @param[in] P7Data Pointer to the PKCS#7 message.\r | |
2056 | @param[in] P7Length Length of the PKCS#7 message in bytes.\r | |
2057 | @param[out] SignerChainCerts Pointer to the certificates list chained to signer's\r | |
2058 | certificate. It's caller's responsibility to free the buffer\r | |
2059 | with Pkcs7FreeSigners().\r | |
2060 | This data structure is EFI_CERT_STACK type.\r | |
2061 | @param[out] ChainLength Length of the chained certificates list buffer in bytes.\r | |
2062 | @param[out] UnchainCerts Pointer to the unchained certificates lists. It's caller's\r | |
2063 | responsibility to free the buffer with Pkcs7FreeSigners().\r | |
2064 | This data structure is EFI_CERT_STACK type.\r | |
2065 | @param[out] UnchainLength Length of the unchained certificates list buffer in bytes.\r | |
2066 | \r | |
2067 | @retval TRUE The operation is finished successfully.\r | |
2068 | @retval FALSE Error occurs during the operation.\r | |
2069 | \r | |
2070 | **/\r | |
2071 | BOOLEAN\r | |
2072 | EFIAPI\r | |
2073 | Pkcs7GetCertificatesList (\r | |
2074 | IN CONST UINT8 *P7Data,\r | |
2075 | IN UINTN P7Length,\r | |
2076 | OUT UINT8 **SignerChainCerts,\r | |
2077 | OUT UINTN *ChainLength,\r | |
2078 | OUT UINT8 **UnchainCerts,\r | |
2079 | OUT UINTN *UnchainLength\r | |
2080 | )\r | |
2081 | {\r | |
2082 | CALL_CRYPTO_SERVICE (Pkcs7GetCertificatesList, (P7Data, P7Length, SignerChainCerts, ChainLength, UnchainCerts, UnchainLength), FALSE);\r | |
2083 | }\r | |
2084 | \r | |
2085 | /**\r | |
2086 | Creates a PKCS#7 signedData as described in "PKCS #7: Cryptographic Message\r | |
2087 | Syntax Standard, version 1.5". This interface is only intended to be used for\r | |
2088 | application to perform PKCS#7 functionality validation.\r | |
2089 | \r | |
2090 | If this interface is not supported, then return FALSE.\r | |
2091 | \r | |
2092 | @param[in] PrivateKey Pointer to the PEM-formatted private key data for\r | |
2093 | data signing.\r | |
2094 | @param[in] PrivateKeySize Size of the PEM private key data in bytes.\r | |
2095 | @param[in] KeyPassword NULL-terminated passphrase used for encrypted PEM\r | |
2096 | key data.\r | |
2097 | @param[in] InData Pointer to the content to be signed.\r | |
2098 | @param[in] InDataSize Size of InData in bytes.\r | |
2099 | @param[in] SignCert Pointer to signer's DER-encoded certificate to sign with.\r | |
2100 | @param[in] OtherCerts Pointer to an optional additional set of certificates to\r | |
2101 | include in the PKCS#7 signedData (e.g. any intermediate\r | |
2102 | CAs in the chain).\r | |
2103 | @param[out] SignedData Pointer to output PKCS#7 signedData. It's caller's\r | |
2104 | responsibility to free the buffer with FreePool().\r | |
2105 | @param[out] SignedDataSize Size of SignedData in bytes.\r | |
2106 | \r | |
2107 | @retval TRUE PKCS#7 data signing succeeded.\r | |
2108 | @retval FALSE PKCS#7 data signing failed.\r | |
2109 | @retval FALSE This interface is not supported.\r | |
2110 | \r | |
2111 | **/\r | |
2112 | BOOLEAN\r | |
2113 | EFIAPI\r | |
2114 | Pkcs7Sign (\r | |
2115 | IN CONST UINT8 *PrivateKey,\r | |
2116 | IN UINTN PrivateKeySize,\r | |
2117 | IN CONST UINT8 *KeyPassword,\r | |
2118 | IN UINT8 *InData,\r | |
2119 | IN UINTN InDataSize,\r | |
2120 | IN UINT8 *SignCert,\r | |
2121 | IN UINT8 *OtherCerts OPTIONAL,\r | |
2122 | OUT UINT8 **SignedData,\r | |
2123 | OUT UINTN *SignedDataSize\r | |
2124 | )\r | |
2125 | {\r | |
2126 | CALL_CRYPTO_SERVICE (Pkcs7Sign, (PrivateKey, PrivateKeySize, KeyPassword, InData, InDataSize, SignCert, OtherCerts, SignedData, SignedDataSize), FALSE);\r | |
2127 | }\r | |
2128 | \r | |
2129 | /**\r | |
2130 | Verifies the validity of a PKCS#7 signed data as described in "PKCS #7:\r | |
2131 | Cryptographic Message Syntax Standard". The input signed data could be wrapped\r | |
2132 | in a ContentInfo structure.\r | |
2133 | \r | |
2134 | If P7Data, TrustedCert or InData is NULL, then return FALSE.\r | |
2135 | If P7Length, CertLength or DataLength overflow, then return FALSE.\r | |
2136 | If this interface is not supported, then return FALSE.\r | |
2137 | \r | |
2138 | @param[in] P7Data Pointer to the PKCS#7 message to verify.\r | |
2139 | @param[in] P7Length Length of the PKCS#7 message in bytes.\r | |
2140 | @param[in] TrustedCert Pointer to a trusted/root certificate encoded in DER, which\r | |
2141 | is used for certificate chain verification.\r | |
2142 | @param[in] CertLength Length of the trusted certificate in bytes.\r | |
2143 | @param[in] InData Pointer to the content to be verified.\r | |
2144 | @param[in] DataLength Length of InData in bytes.\r | |
2145 | \r | |
2146 | @retval TRUE The specified PKCS#7 signed data is valid.\r | |
2147 | @retval FALSE Invalid PKCS#7 signed data.\r | |
2148 | @retval FALSE This interface is not supported.\r | |
2149 | \r | |
2150 | **/\r | |
2151 | BOOLEAN\r | |
2152 | EFIAPI\r | |
2153 | Pkcs7Verify (\r | |
2154 | IN CONST UINT8 *P7Data,\r | |
2155 | IN UINTN P7Length,\r | |
2156 | IN CONST UINT8 *TrustedCert,\r | |
2157 | IN UINTN CertLength,\r | |
2158 | IN CONST UINT8 *InData,\r | |
2159 | IN UINTN DataLength\r | |
2160 | )\r | |
2161 | {\r | |
2162 | CALL_CRYPTO_SERVICE (Pkcs7Verify, (P7Data, P7Length, TrustedCert, CertLength, InData, DataLength), FALSE);\r | |
2163 | }\r | |
2164 | \r | |
2165 | /**\r | |
2166 | This function receives a PKCS7 formatted signature, and then verifies that\r | |
2167 | the specified Enhanced or Extended Key Usages (EKU's) are present in the end-entity\r | |
2168 | leaf signing certificate.\r | |
2169 | Note that this function does not validate the certificate chain.\r | |
2170 | \r | |
2171 | Applications for custom EKU's are quite flexible. For example, a policy EKU\r | |
2172 | may be present in an Issuing Certificate Authority (CA), and any sub-ordinate\r | |
2173 | certificate issued might also contain this EKU, thus constraining the\r | |
2174 | sub-ordinate certificate. Other applications might allow a certificate\r | |
2175 | embedded in a device to specify that other Object Identifiers (OIDs) are\r | |
2176 | present which contains binary data specifying custom capabilities that\r | |
2177 | the device is able to do.\r | |
2178 | \r | |
2179 | @param[in] Pkcs7Signature The PKCS#7 signed information content block. An array\r | |
2180 | containing the content block with both the signature,\r | |
2181 | the signer's certificate, and any necessary intermediate\r | |
2182 | certificates.\r | |
2183 | @param[in] Pkcs7SignatureSize Number of bytes in Pkcs7Signature.\r | |
2184 | @param[in] RequiredEKUs Array of null-terminated strings listing OIDs of\r | |
2185 | required EKUs that must be present in the signature.\r | |
2186 | @param[in] RequiredEKUsSize Number of elements in the RequiredEKUs string array.\r | |
2187 | @param[in] RequireAllPresent If this is TRUE, then all of the specified EKU's\r | |
2188 | must be present in the leaf signer. If it is\r | |
2189 | FALSE, then we will succeed if we find any\r | |
2190 | of the specified EKU's.\r | |
2191 | \r | |
2192 | @retval EFI_SUCCESS The required EKUs were found in the signature.\r | |
2193 | @retval EFI_INVALID_PARAMETER A parameter was invalid.\r | |
2194 | @retval EFI_NOT_FOUND One or more EKU's were not found in the signature.\r | |
2195 | \r | |
2196 | **/\r | |
2197 | RETURN_STATUS\r | |
2198 | EFIAPI\r | |
2199 | VerifyEKUsInPkcs7Signature (\r | |
2200 | IN CONST UINT8 *Pkcs7Signature,\r | |
2201 | IN CONST UINT32 SignatureSize,\r | |
2202 | IN CONST CHAR8 *RequiredEKUs[],\r | |
2203 | IN CONST UINT32 RequiredEKUsSize,\r | |
2204 | IN BOOLEAN RequireAllPresent\r | |
2205 | )\r | |
2206 | {\r | |
2207 | CALL_CRYPTO_SERVICE (VerifyEKUsInPkcs7Signature, (Pkcs7Signature, SignatureSize, RequiredEKUs, RequiredEKUsSize, RequireAllPresent), FALSE);\r | |
2208 | }\r | |
2209 | \r | |
2210 | \r | |
2211 | /**\r | |
2212 | Extracts the attached content from a PKCS#7 signed data if existed. The input signed\r | |
2213 | data could be wrapped in a ContentInfo structure.\r | |
2214 | \r | |
2215 | If P7Data, Content, or ContentSize is NULL, then return FALSE. If P7Length overflow,\r | |
2216 | then return FALSE. If the P7Data is not correctly formatted, then return FALSE.\r | |
2217 | \r | |
2218 | Caution: This function may receive untrusted input. So this function will do\r | |
2219 | basic check for PKCS#7 data structure.\r | |
2220 | \r | |
2221 | @param[in] P7Data Pointer to the PKCS#7 signed data to process.\r | |
2222 | @param[in] P7Length Length of the PKCS#7 signed data in bytes.\r | |
2223 | @param[out] Content Pointer to the extracted content from the PKCS#7 signedData.\r | |
2224 | It's caller's responsibility to free the buffer with FreePool().\r | |
2225 | @param[out] ContentSize The size of the extracted content in bytes.\r | |
2226 | \r | |
2227 | @retval TRUE The P7Data was correctly formatted for processing.\r | |
2228 | @retval FALSE The P7Data was not correctly formatted for processing.\r | |
2229 | \r | |
2230 | **/\r | |
2231 | BOOLEAN\r | |
2232 | EFIAPI\r | |
2233 | Pkcs7GetAttachedContent (\r | |
2234 | IN CONST UINT8 *P7Data,\r | |
2235 | IN UINTN P7Length,\r | |
2236 | OUT VOID **Content,\r | |
2237 | OUT UINTN *ContentSize\r | |
2238 | )\r | |
2239 | {\r | |
2240 | CALL_CRYPTO_SERVICE (Pkcs7GetAttachedContent, (P7Data, P7Length, Content, ContentSize), FALSE);\r | |
2241 | }\r | |
2242 | \r | |
2243 | /**\r | |
2244 | Verifies the validity of a PE/COFF Authenticode Signature as described in "Windows\r | |
2245 | Authenticode Portable Executable Signature Format".\r | |
2246 | \r | |
2247 | If AuthData is NULL, then return FALSE.\r | |
2248 | If ImageHash is NULL, then return FALSE.\r | |
2249 | If this interface is not supported, then return FALSE.\r | |
2250 | \r | |
2251 | @param[in] AuthData Pointer to the Authenticode Signature retrieved from signed\r | |
2252 | PE/COFF image to be verified.\r | |
2253 | @param[in] DataSize Size of the Authenticode Signature in bytes.\r | |
2254 | @param[in] TrustedCert Pointer to a trusted/root certificate encoded in DER, which\r | |
2255 | is used for certificate chain verification.\r | |
2256 | @param[in] CertSize Size of the trusted certificate in bytes.\r | |
2257 | @param[in] ImageHash Pointer to the original image file hash value. The procedure\r | |
2258 | for calculating the image hash value is described in Authenticode\r | |
2259 | specification.\r | |
2260 | @param[in] HashSize Size of Image hash value in bytes.\r | |
2261 | \r | |
2262 | @retval TRUE The specified Authenticode Signature is valid.\r | |
2263 | @retval FALSE Invalid Authenticode Signature.\r | |
2264 | @retval FALSE This interface is not supported.\r | |
2265 | \r | |
2266 | **/\r | |
2267 | BOOLEAN\r | |
2268 | EFIAPI\r | |
2269 | AuthenticodeVerify (\r | |
2270 | IN CONST UINT8 *AuthData,\r | |
2271 | IN UINTN DataSize,\r | |
2272 | IN CONST UINT8 *TrustedCert,\r | |
2273 | IN UINTN CertSize,\r | |
2274 | IN CONST UINT8 *ImageHash,\r | |
2275 | IN UINTN HashSize\r | |
2276 | )\r | |
2277 | {\r | |
2278 | CALL_CRYPTO_SERVICE (AuthenticodeVerify, (AuthData, DataSize, TrustedCert, CertSize, ImageHash, HashSize), FALSE);\r | |
2279 | }\r | |
2280 | \r | |
2281 | /**\r | |
2282 | Verifies the validity of a RFC3161 Timestamp CounterSignature embedded in PE/COFF Authenticode\r | |
2283 | signature.\r | |
2284 | \r | |
2285 | If AuthData is NULL, then return FALSE.\r | |
2286 | If this interface is not supported, then return FALSE.\r | |
2287 | \r | |
2288 | @param[in] AuthData Pointer to the Authenticode Signature retrieved from signed\r | |
2289 | PE/COFF image to be verified.\r | |
2290 | @param[in] DataSize Size of the Authenticode Signature in bytes.\r | |
2291 | @param[in] TsaCert Pointer to a trusted/root TSA certificate encoded in DER, which\r | |
2292 | is used for TSA certificate chain verification.\r | |
2293 | @param[in] CertSize Size of the trusted certificate in bytes.\r | |
2294 | @param[out] SigningTime Return the time of timestamp generation time if the timestamp\r | |
2295 | signature is valid.\r | |
2296 | \r | |
2297 | @retval TRUE The specified Authenticode includes a valid RFC3161 Timestamp CounterSignature.\r | |
2298 | @retval FALSE No valid RFC3161 Timestamp CounterSignature in the specified Authenticode data.\r | |
2299 | \r | |
2300 | **/\r | |
2301 | BOOLEAN\r | |
2302 | EFIAPI\r | |
2303 | ImageTimestampVerify (\r | |
2304 | IN CONST UINT8 *AuthData,\r | |
2305 | IN UINTN DataSize,\r | |
2306 | IN CONST UINT8 *TsaCert,\r | |
2307 | IN UINTN CertSize,\r | |
2308 | OUT EFI_TIME *SigningTime\r | |
2309 | )\r | |
2310 | {\r | |
2311 | CALL_CRYPTO_SERVICE (ImageTimestampVerify, (AuthData, DataSize, TsaCert, CertSize, SigningTime), FALSE);\r | |
2312 | }\r | |
2313 | \r | |
2314 | //=====================================================================================\r | |
2315 | // DH Key Exchange Primitive\r | |
2316 | //=====================================================================================\r | |
2317 | \r | |
2318 | /**\r | |
2319 | Allocates and Initializes one Diffie-Hellman Context for subsequent use.\r | |
2320 | \r | |
2321 | @return Pointer to the Diffie-Hellman Context that has been initialized.\r | |
2322 | If the allocations fails, DhNew() returns NULL.\r | |
2323 | If the interface is not supported, DhNew() returns NULL.\r | |
2324 | \r | |
2325 | **/\r | |
2326 | VOID *\r | |
2327 | EFIAPI\r | |
2328 | DhNew (\r | |
2329 | VOID\r | |
2330 | )\r | |
2331 | {\r | |
2332 | CALL_CRYPTO_SERVICE (DhNew, (), NULL);\r | |
2333 | }\r | |
2334 | \r | |
2335 | /**\r | |
2336 | Release the specified DH context.\r | |
2337 | \r | |
2338 | If the interface is not supported, then ASSERT().\r | |
2339 | \r | |
2340 | @param[in] DhContext Pointer to the DH context to be released.\r | |
2341 | \r | |
2342 | **/\r | |
2343 | VOID\r | |
2344 | EFIAPI\r | |
2345 | DhFree (\r | |
2346 | IN VOID *DhContext\r | |
2347 | )\r | |
2348 | {\r | |
2349 | CALL_VOID_CRYPTO_SERVICE (DhFree, (DhContext));\r | |
2350 | }\r | |
2351 | \r | |
2352 | /**\r | |
2353 | Generates DH parameter.\r | |
2354 | \r | |
2355 | Given generator g, and length of prime number p in bits, this function generates p,\r | |
2356 | and sets DH context according to value of g and p.\r | |
2357 | \r | |
2358 | Before this function can be invoked, pseudorandom number generator must be correctly\r | |
2359 | initialized by RandomSeed().\r | |
2360 | \r | |
2361 | If DhContext is NULL, then return FALSE.\r | |
2362 | If Prime is NULL, then return FALSE.\r | |
2363 | If this interface is not supported, then return FALSE.\r | |
2364 | \r | |
2365 | @param[in, out] DhContext Pointer to the DH context.\r | |
2366 | @param[in] Generator Value of generator.\r | |
2367 | @param[in] PrimeLength Length in bits of prime to be generated.\r | |
2368 | @param[out] Prime Pointer to the buffer to receive the generated prime number.\r | |
2369 | \r | |
2370 | @retval TRUE DH parameter generation succeeded.\r | |
2371 | @retval FALSE Value of Generator is not supported.\r | |
2372 | @retval FALSE PRNG fails to generate random prime number with PrimeLength.\r | |
2373 | @retval FALSE This interface is not supported.\r | |
2374 | \r | |
2375 | **/\r | |
2376 | BOOLEAN\r | |
2377 | EFIAPI\r | |
2378 | DhGenerateParameter (\r | |
2379 | IN OUT VOID *DhContext,\r | |
2380 | IN UINTN Generator,\r | |
2381 | IN UINTN PrimeLength,\r | |
2382 | OUT UINT8 *Prime\r | |
2383 | )\r | |
2384 | {\r | |
2385 | CALL_CRYPTO_SERVICE (DhGenerateParameter, (DhContext, Generator, PrimeLength, Prime), FALSE);\r | |
2386 | }\r | |
2387 | \r | |
2388 | /**\r | |
2389 | Sets generator and prime parameters for DH.\r | |
2390 | \r | |
2391 | Given generator g, and prime number p, this function and sets DH\r | |
2392 | context accordingly.\r | |
2393 | \r | |
2394 | If DhContext is NULL, then return FALSE.\r | |
2395 | If Prime is NULL, then return FALSE.\r | |
2396 | If this interface is not supported, then return FALSE.\r | |
2397 | \r | |
2398 | @param[in, out] DhContext Pointer to the DH context.\r | |
2399 | @param[in] Generator Value of generator.\r | |
2400 | @param[in] PrimeLength Length in bits of prime to be generated.\r | |
2401 | @param[in] Prime Pointer to the prime number.\r | |
2402 | \r | |
2403 | @retval TRUE DH parameter setting succeeded.\r | |
2404 | @retval FALSE Value of Generator is not supported.\r | |
2405 | @retval FALSE Value of Generator is not suitable for the Prime.\r | |
2406 | @retval FALSE Value of Prime is not a prime number.\r | |
2407 | @retval FALSE Value of Prime is not a safe prime number.\r | |
2408 | @retval FALSE This interface is not supported.\r | |
2409 | \r | |
2410 | **/\r | |
2411 | BOOLEAN\r | |
2412 | EFIAPI\r | |
2413 | DhSetParameter (\r | |
2414 | IN OUT VOID *DhContext,\r | |
2415 | IN UINTN Generator,\r | |
2416 | IN UINTN PrimeLength,\r | |
2417 | IN CONST UINT8 *Prime\r | |
2418 | )\r | |
2419 | {\r | |
2420 | CALL_CRYPTO_SERVICE (DhSetParameter, (DhContext, Generator, PrimeLength, Prime), FALSE);\r | |
2421 | }\r | |
2422 | \r | |
2423 | /**\r | |
2424 | Generates DH public key.\r | |
2425 | \r | |
2426 | This function generates random secret exponent, and computes the public key, which is\r | |
2427 | returned via parameter PublicKey and PublicKeySize. DH context is updated accordingly.\r | |
2428 | If the PublicKey buffer is too small to hold the public key, FALSE is returned and\r | |
2429 | PublicKeySize is set to the required buffer size to obtain the public key.\r | |
2430 | \r | |
2431 | If DhContext is NULL, then return FALSE.\r | |
2432 | If PublicKeySize is NULL, then return FALSE.\r | |
2433 | If PublicKeySize is large enough but PublicKey is NULL, then return FALSE.\r | |
2434 | If this interface is not supported, then return FALSE.\r | |
2435 | \r | |
2436 | @param[in, out] DhContext Pointer to the DH context.\r | |
2437 | @param[out] PublicKey Pointer to the buffer to receive generated public key.\r | |
2438 | @param[in, out] PublicKeySize On input, the size of PublicKey buffer in bytes.\r | |
2439 | On output, the size of data returned in PublicKey buffer in bytes.\r | |
2440 | \r | |
2441 | @retval TRUE DH public key generation succeeded.\r | |
2442 | @retval FALSE DH public key generation failed.\r | |
2443 | @retval FALSE PublicKeySize is not large enough.\r | |
2444 | @retval FALSE This interface is not supported.\r | |
2445 | \r | |
2446 | **/\r | |
2447 | BOOLEAN\r | |
2448 | EFIAPI\r | |
2449 | DhGenerateKey (\r | |
2450 | IN OUT VOID *DhContext,\r | |
2451 | OUT UINT8 *PublicKey,\r | |
2452 | IN OUT UINTN *PublicKeySize\r | |
2453 | )\r | |
2454 | {\r | |
2455 | CALL_CRYPTO_SERVICE (DhGenerateKey, (DhContext, PublicKey, PublicKeySize), FALSE);\r | |
2456 | }\r | |
2457 | \r | |
2458 | /**\r | |
2459 | Computes exchanged common key.\r | |
2460 | \r | |
2461 | Given peer's public key, this function computes the exchanged common key, based on its own\r | |
2462 | context including value of prime modulus and random secret exponent.\r | |
2463 | \r | |
2464 | If DhContext is NULL, then return FALSE.\r | |
2465 | If PeerPublicKey is NULL, then return FALSE.\r | |
2466 | If KeySize is NULL, then return FALSE.\r | |
2467 | If Key is NULL, then return FALSE.\r | |
2468 | If KeySize is not large enough, then return FALSE.\r | |
2469 | If this interface is not supported, then return FALSE.\r | |
2470 | \r | |
2471 | @param[in, out] DhContext Pointer to the DH context.\r | |
2472 | @param[in] PeerPublicKey Pointer to the peer's public key.\r | |
2473 | @param[in] PeerPublicKeySize Size of peer's public key in bytes.\r | |
2474 | @param[out] Key Pointer to the buffer to receive generated key.\r | |
2475 | @param[in, out] KeySize On input, the size of Key buffer in bytes.\r | |
2476 | On output, the size of data returned in Key buffer in bytes.\r | |
2477 | \r | |
2478 | @retval TRUE DH exchanged key generation succeeded.\r | |
2479 | @retval FALSE DH exchanged key generation failed.\r | |
2480 | @retval FALSE KeySize is not large enough.\r | |
2481 | @retval FALSE This interface is not supported.\r | |
2482 | \r | |
2483 | **/\r | |
2484 | BOOLEAN\r | |
2485 | EFIAPI\r | |
2486 | DhComputeKey (\r | |
2487 | IN OUT VOID *DhContext,\r | |
2488 | IN CONST UINT8 *PeerPublicKey,\r | |
2489 | IN UINTN PeerPublicKeySize,\r | |
2490 | OUT UINT8 *Key,\r | |
2491 | IN OUT UINTN *KeySize\r | |
2492 | )\r | |
2493 | {\r | |
2494 | CALL_CRYPTO_SERVICE (DhComputeKey, (DhContext, PeerPublicKey, PeerPublicKeySize, Key, KeySize), FALSE);\r | |
2495 | }\r | |
2496 | \r | |
2497 | //=====================================================================================\r | |
2498 | // Pseudo-Random Generation Primitive\r | |
2499 | //=====================================================================================\r | |
2500 | \r | |
2501 | /**\r | |
2502 | Sets up the seed value for the pseudorandom number generator.\r | |
2503 | \r | |
2504 | This function sets up the seed value for the pseudorandom number generator.\r | |
2505 | If Seed is not NULL, then the seed passed in is used.\r | |
2506 | If Seed is NULL, then default seed is used.\r | |
2507 | If this interface is not supported, then return FALSE.\r | |
2508 | \r | |
2509 | @param[in] Seed Pointer to seed value.\r | |
2510 | If NULL, default seed is used.\r | |
2511 | @param[in] SeedSize Size of seed value.\r | |
2512 | If Seed is NULL, this parameter is ignored.\r | |
2513 | \r | |
2514 | @retval TRUE Pseudorandom number generator has enough entropy for random generation.\r | |
2515 | @retval FALSE Pseudorandom number generator does not have enough entropy for random generation.\r | |
2516 | @retval FALSE This interface is not supported.\r | |
2517 | \r | |
2518 | **/\r | |
2519 | BOOLEAN\r | |
2520 | EFIAPI\r | |
2521 | RandomSeed (\r | |
2522 | IN CONST UINT8 *Seed OPTIONAL,\r | |
2523 | IN UINTN SeedSize\r | |
2524 | )\r | |
2525 | {\r | |
2526 | CALL_CRYPTO_SERVICE (RandomSeed, (Seed, SeedSize), FALSE);\r | |
2527 | }\r | |
2528 | \r | |
2529 | /**\r | |
2530 | Generates a pseudorandom byte stream of the specified size.\r | |
2531 | \r | |
2532 | If Output is NULL, then return FALSE.\r | |
2533 | If this interface is not supported, then return FALSE.\r | |
2534 | \r | |
2535 | @param[out] Output Pointer to buffer to receive random value.\r | |
2536 | @param[in] Size Size of random bytes to generate.\r | |
2537 | \r | |
2538 | @retval TRUE Pseudorandom byte stream generated successfully.\r | |
2539 | @retval FALSE Pseudorandom number generator fails to generate due to lack of entropy.\r | |
2540 | @retval FALSE This interface is not supported.\r | |
2541 | \r | |
2542 | **/\r | |
2543 | BOOLEAN\r | |
2544 | EFIAPI\r | |
2545 | RandomBytes (\r | |
2546 | OUT UINT8 *Output,\r | |
2547 | IN UINTN Size\r | |
2548 | )\r | |
2549 | {\r | |
2550 | CALL_CRYPTO_SERVICE (RandomBytes, (Output, Size), FALSE);\r | |
2551 | }\r | |
2552 | \r | |
2553 | //=====================================================================================\r | |
2554 | // Key Derivation Function Primitive\r | |
2555 | //=====================================================================================\r | |
2556 | \r | |
2557 | /**\r | |
2558 | Derive key data using HMAC-SHA256 based KDF.\r | |
2559 | \r | |
2560 | @param[in] Key Pointer to the user-supplied key.\r | |
2561 | @param[in] KeySize Key size in bytes.\r | |
2562 | @param[in] Salt Pointer to the salt(non-secret) value.\r | |
2563 | @param[in] SaltSize Salt size in bytes.\r | |
2564 | @param[in] Info Pointer to the application specific info.\r | |
2565 | @param[in] InfoSize Info size in bytes.\r | |
2566 | @param[out] Out Pointer to buffer to receive hkdf value.\r | |
2567 | @param[in] OutSize Size of hkdf bytes to generate.\r | |
2568 | \r | |
2569 | @retval TRUE Hkdf generated successfully.\r | |
2570 | @retval FALSE Hkdf generation failed.\r | |
2571 | \r | |
2572 | **/\r | |
2573 | BOOLEAN\r | |
2574 | EFIAPI\r | |
2575 | HkdfSha256ExtractAndExpand (\r | |
2576 | IN CONST UINT8 *Key,\r | |
2577 | IN UINTN KeySize,\r | |
2578 | IN CONST UINT8 *Salt,\r | |
2579 | IN UINTN SaltSize,\r | |
2580 | IN CONST UINT8 *Info,\r | |
2581 | IN UINTN InfoSize,\r | |
2582 | OUT UINT8 *Out,\r | |
2583 | IN UINTN OutSize\r | |
2584 | )\r | |
2585 | {\r | |
2586 | CALL_CRYPTO_SERVICE (HkdfSha256ExtractAndExpand, (Key, KeySize, Salt, SaltSize, Info, InfoSize, Out, OutSize), FALSE);\r | |
2587 | }\r | |
2588 | \r | |
2589 | /**\r | |
2590 | Initializes the OpenSSL library.\r | |
2591 | \r | |
2592 | This function registers ciphers and digests used directly and indirectly\r | |
2593 | by SSL/TLS, and initializes the readable error messages.\r | |
2594 | This function must be called before any other action takes places.\r | |
2595 | \r | |
2596 | @retval TRUE The OpenSSL library has been initialized.\r | |
2597 | @retval FALSE Failed to initialize the OpenSSL library.\r | |
2598 | \r | |
2599 | **/\r | |
2600 | BOOLEAN\r | |
2601 | EFIAPI\r | |
2602 | TlsInitialize (\r | |
2603 | VOID\r | |
2604 | )\r | |
2605 | {\r | |
2606 | CALL_CRYPTO_SERVICE (TlsInitialize, (), FALSE);\r | |
2607 | }\r | |
2608 | \r | |
2609 | /**\r | |
2610 | Free an allocated SSL_CTX object.\r | |
2611 | \r | |
2612 | @param[in] TlsCtx Pointer to the SSL_CTX object to be released.\r | |
2613 | \r | |
2614 | **/\r | |
2615 | VOID\r | |
2616 | EFIAPI\r | |
2617 | TlsCtxFree (\r | |
2618 | IN VOID *TlsCtx\r | |
2619 | )\r | |
2620 | {\r | |
2621 | CALL_VOID_CRYPTO_SERVICE (TlsCtxFree, (TlsCtx));\r | |
2622 | }\r | |
2623 | \r | |
2624 | /**\r | |
2625 | Creates a new SSL_CTX object as framework to establish TLS/SSL enabled\r | |
2626 | connections.\r | |
2627 | \r | |
2628 | @param[in] MajorVer Major Version of TLS/SSL Protocol.\r | |
2629 | @param[in] MinorVer Minor Version of TLS/SSL Protocol.\r | |
2630 | \r | |
2631 | @return Pointer to an allocated SSL_CTX object.\r | |
2632 | If the creation failed, TlsCtxNew() returns NULL.\r | |
2633 | \r | |
2634 | **/\r | |
2635 | VOID *\r | |
2636 | EFIAPI\r | |
2637 | TlsCtxNew (\r | |
2638 | IN UINT8 MajorVer,\r | |
2639 | IN UINT8 MinorVer\r | |
2640 | )\r | |
2641 | {\r | |
2642 | CALL_CRYPTO_SERVICE (TlsCtxNew, (MajorVer, MinorVer), NULL);\r | |
2643 | }\r | |
2644 | \r | |
2645 | /**\r | |
2646 | Free an allocated TLS object.\r | |
2647 | \r | |
2648 | This function removes the TLS object pointed to by Tls and frees up the\r | |
2649 | allocated memory. If Tls is NULL, nothing is done.\r | |
2650 | \r | |
2651 | @param[in] Tls Pointer to the TLS object to be freed.\r | |
2652 | \r | |
2653 | **/\r | |
2654 | VOID\r | |
2655 | EFIAPI\r | |
2656 | TlsFree (\r | |
2657 | IN VOID *Tls\r | |
2658 | )\r | |
2659 | {\r | |
2660 | CALL_VOID_CRYPTO_SERVICE (TlsFree, (Tls));\r | |
2661 | }\r | |
2662 | \r | |
2663 | /**\r | |
2664 | Create a new TLS object for a connection.\r | |
2665 | \r | |
2666 | This function creates a new TLS object for a connection. The new object\r | |
2667 | inherits the setting of the underlying context TlsCtx: connection method,\r | |
2668 | options, verification setting.\r | |
2669 | \r | |
2670 | @param[in] TlsCtx Pointer to the SSL_CTX object.\r | |
2671 | \r | |
2672 | @return Pointer to an allocated SSL object.\r | |
2673 | If the creation failed, TlsNew() returns NULL.\r | |
2674 | \r | |
2675 | **/\r | |
2676 | VOID *\r | |
2677 | EFIAPI\r | |
2678 | TlsNew (\r | |
2679 | IN VOID *TlsCtx\r | |
2680 | )\r | |
2681 | {\r | |
2682 | CALL_CRYPTO_SERVICE (TlsNew, (TlsCtx), NULL);\r | |
2683 | }\r | |
2684 | \r | |
2685 | /**\r | |
2686 | Checks if the TLS handshake was done.\r | |
2687 | \r | |
2688 | This function will check if the specified TLS handshake was done.\r | |
2689 | \r | |
2690 | @param[in] Tls Pointer to the TLS object for handshake state checking.\r | |
2691 | \r | |
2692 | @retval TRUE The TLS handshake was done.\r | |
2693 | @retval FALSE The TLS handshake was not done.\r | |
2694 | \r | |
2695 | **/\r | |
2696 | BOOLEAN\r | |
2697 | EFIAPI\r | |
2698 | TlsInHandshake (\r | |
2699 | IN VOID *Tls\r | |
2700 | )\r | |
2701 | {\r | |
2702 | CALL_CRYPTO_SERVICE (TlsInHandshake, (Tls), FALSE);\r | |
2703 | }\r | |
2704 | \r | |
2705 | /**\r | |
2706 | Perform a TLS/SSL handshake.\r | |
2707 | \r | |
2708 | This function will perform a TLS/SSL handshake.\r | |
2709 | \r | |
2710 | @param[in] Tls Pointer to the TLS object for handshake operation.\r | |
2711 | @param[in] BufferIn Pointer to the most recently received TLS Handshake packet.\r | |
2712 | @param[in] BufferInSize Packet size in bytes for the most recently received TLS\r | |
2713 | Handshake packet.\r | |
2714 | @param[out] BufferOut Pointer to the buffer to hold the built packet.\r | |
2715 | @param[in, out] BufferOutSize Pointer to the buffer size in bytes. On input, it is\r | |
2716 | the buffer size provided by the caller. On output, it\r | |
2717 | is the buffer size in fact needed to contain the\r | |
2718 | packet.\r | |
2719 | \r | |
2720 | @retval EFI_SUCCESS The required TLS packet is built successfully.\r | |
2721 | @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:\r | |
2722 | Tls is NULL.\r | |
2723 | BufferIn is NULL but BufferInSize is NOT 0.\r | |
2724 | BufferInSize is 0 but BufferIn is NOT NULL.\r | |
2725 | BufferOutSize is NULL.\r | |
2726 | BufferOut is NULL if *BufferOutSize is not zero.\r | |
2727 | @retval EFI_BUFFER_TOO_SMALL BufferOutSize is too small to hold the response packet.\r | |
2728 | @retval EFI_ABORTED Something wrong during handshake.\r | |
2729 | \r | |
2730 | **/\r | |
2731 | EFI_STATUS\r | |
2732 | EFIAPI\r | |
2733 | TlsDoHandshake (\r | |
2734 | IN VOID *Tls,\r | |
2735 | IN UINT8 *BufferIn, OPTIONAL\r | |
2736 | IN UINTN BufferInSize, OPTIONAL\r | |
2737 | OUT UINT8 *BufferOut, OPTIONAL\r | |
2738 | IN OUT UINTN *BufferOutSize\r | |
2739 | )\r | |
2740 | {\r | |
2741 | CALL_CRYPTO_SERVICE (TlsDoHandshake, (Tls, BufferIn, BufferInSize, BufferOut, BufferOutSize), EFI_UNSUPPORTED);\r | |
2742 | }\r | |
2743 | \r | |
2744 | /**\r | |
2745 | Handle Alert message recorded in BufferIn. If BufferIn is NULL and BufferInSize is zero,\r | |
2746 | TLS session has errors and the response packet needs to be Alert message based on error type.\r | |
2747 | \r | |
2748 | @param[in] Tls Pointer to the TLS object for state checking.\r | |
2749 | @param[in] BufferIn Pointer to the most recently received TLS Alert packet.\r | |
2750 | @param[in] BufferInSize Packet size in bytes for the most recently received TLS\r | |
2751 | Alert packet.\r | |
2752 | @param[out] BufferOut Pointer to the buffer to hold the built packet.\r | |
2753 | @param[in, out] BufferOutSize Pointer to the buffer size in bytes. On input, it is\r | |
2754 | the buffer size provided by the caller. On output, it\r | |
2755 | is the buffer size in fact needed to contain the\r | |
2756 | packet.\r | |
2757 | \r | |
2758 | @retval EFI_SUCCESS The required TLS packet is built successfully.\r | |
2759 | @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:\r | |
2760 | Tls is NULL.\r | |
2761 | BufferIn is NULL but BufferInSize is NOT 0.\r | |
2762 | BufferInSize is 0 but BufferIn is NOT NULL.\r | |
2763 | BufferOutSize is NULL.\r | |
2764 | BufferOut is NULL if *BufferOutSize is not zero.\r | |
2765 | @retval EFI_ABORTED An error occurred.\r | |
2766 | @retval EFI_BUFFER_TOO_SMALL BufferOutSize is too small to hold the response packet.\r | |
2767 | \r | |
2768 | **/\r | |
2769 | EFI_STATUS\r | |
2770 | EFIAPI\r | |
2771 | TlsHandleAlert (\r | |
2772 | IN VOID *Tls,\r | |
2773 | IN UINT8 *BufferIn, OPTIONAL\r | |
2774 | IN UINTN BufferInSize, OPTIONAL\r | |
2775 | OUT UINT8 *BufferOut, OPTIONAL\r | |
2776 | IN OUT UINTN *BufferOutSize\r | |
2777 | )\r | |
2778 | {\r | |
2779 | CALL_CRYPTO_SERVICE (TlsHandleAlert, (Tls, BufferIn, BufferInSize, BufferOut, BufferOutSize), EFI_UNSUPPORTED);\r | |
2780 | }\r | |
2781 | \r | |
2782 | /**\r | |
2783 | Build the CloseNotify packet.\r | |
2784 | \r | |
2785 | @param[in] Tls Pointer to the TLS object for state checking.\r | |
2786 | @param[in, out] Buffer Pointer to the buffer to hold the built packet.\r | |
2787 | @param[in, out] BufferSize Pointer to the buffer size in bytes. On input, it is\r | |
2788 | the buffer size provided by the caller. On output, it\r | |
2789 | is the buffer size in fact needed to contain the\r | |
2790 | packet.\r | |
2791 | \r | |
2792 | @retval EFI_SUCCESS The required TLS packet is built successfully.\r | |
2793 | @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:\r | |
2794 | Tls is NULL.\r | |
2795 | BufferSize is NULL.\r | |
2796 | Buffer is NULL if *BufferSize is not zero.\r | |
2797 | @retval EFI_BUFFER_TOO_SMALL BufferSize is too small to hold the response packet.\r | |
2798 | \r | |
2799 | **/\r | |
2800 | EFI_STATUS\r | |
2801 | EFIAPI\r | |
2802 | TlsCloseNotify (\r | |
2803 | IN VOID *Tls,\r | |
2804 | IN OUT UINT8 *Buffer,\r | |
2805 | IN OUT UINTN *BufferSize\r | |
2806 | )\r | |
2807 | {\r | |
2808 | CALL_CRYPTO_SERVICE (TlsCloseNotify, (Tls, Buffer, BufferSize), EFI_UNSUPPORTED);\r | |
2809 | }\r | |
2810 | \r | |
2811 | /**\r | |
2812 | Attempts to read bytes from one TLS object and places the data in Buffer.\r | |
2813 | \r | |
2814 | This function will attempt to read BufferSize bytes from the TLS object\r | |
2815 | and places the data in Buffer.\r | |
2816 | \r | |
2817 | @param[in] Tls Pointer to the TLS object.\r | |
2818 | @param[in,out] Buffer Pointer to the buffer to store the data.\r | |
2819 | @param[in] BufferSize The size of Buffer in bytes.\r | |
2820 | \r | |
2821 | @retval >0 The amount of data successfully read from the TLS object.\r | |
2822 | @retval <=0 No data was successfully read.\r | |
2823 | \r | |
2824 | **/\r | |
2825 | INTN\r | |
2826 | EFIAPI\r | |
2827 | TlsCtrlTrafficOut (\r | |
2828 | IN VOID *Tls,\r | |
2829 | IN OUT VOID *Buffer,\r | |
2830 | IN UINTN BufferSize\r | |
2831 | )\r | |
2832 | {\r | |
2833 | CALL_CRYPTO_SERVICE (TlsCtrlTrafficOut, (Tls, Buffer, BufferSize), 0);\r | |
2834 | }\r | |
2835 | \r | |
2836 | /**\r | |
2837 | Attempts to write data from the buffer to TLS object.\r | |
2838 | \r | |
2839 | This function will attempt to write BufferSize bytes data from the Buffer\r | |
2840 | to the TLS object.\r | |
2841 | \r | |
2842 | @param[in] Tls Pointer to the TLS object.\r | |
2843 | @param[in] Buffer Pointer to the data buffer.\r | |
2844 | @param[in] BufferSize The size of Buffer in bytes.\r | |
2845 | \r | |
2846 | @retval >0 The amount of data successfully written to the TLS object.\r | |
2847 | @retval <=0 No data was successfully written.\r | |
2848 | \r | |
2849 | **/\r | |
2850 | INTN\r | |
2851 | EFIAPI\r | |
2852 | TlsCtrlTrafficIn (\r | |
2853 | IN VOID *Tls,\r | |
2854 | IN VOID *Buffer,\r | |
2855 | IN UINTN BufferSize\r | |
2856 | )\r | |
2857 | {\r | |
2858 | CALL_CRYPTO_SERVICE (TlsCtrlTrafficIn, (Tls, Buffer, BufferSize), 0);\r | |
2859 | }\r | |
2860 | \r | |
2861 | /**\r | |
2862 | Attempts to read bytes from the specified TLS connection into the buffer.\r | |
2863 | \r | |
2864 | This function tries to read BufferSize bytes data from the specified TLS\r | |
2865 | connection into the Buffer.\r | |
2866 | \r | |
2867 | @param[in] Tls Pointer to the TLS connection for data reading.\r | |
2868 | @param[in,out] Buffer Pointer to the data buffer.\r | |
2869 | @param[in] BufferSize The size of Buffer in bytes.\r | |
2870 | \r | |
2871 | @retval >0 The read operation was successful, and return value is the\r | |
2872 | number of bytes actually read from the TLS connection.\r | |
2873 | @retval <=0 The read operation was not successful.\r | |
2874 | \r | |
2875 | **/\r | |
2876 | INTN\r | |
2877 | EFIAPI\r | |
2878 | TlsRead (\r | |
2879 | IN VOID *Tls,\r | |
2880 | IN OUT VOID *Buffer,\r | |
2881 | IN UINTN BufferSize\r | |
2882 | )\r | |
2883 | {\r | |
2884 | CALL_CRYPTO_SERVICE (TlsRead, (Tls, Buffer, BufferSize), 0);\r | |
2885 | }\r | |
2886 | \r | |
2887 | /**\r | |
2888 | Attempts to write data to a TLS connection.\r | |
2889 | \r | |
2890 | This function tries to write BufferSize bytes data from the Buffer into the\r | |
2891 | specified TLS connection.\r | |
2892 | \r | |
2893 | @param[in] Tls Pointer to the TLS connection for data writing.\r | |
2894 | @param[in] Buffer Pointer to the data buffer.\r | |
2895 | @param[in] BufferSize The size of Buffer in bytes.\r | |
2896 | \r | |
2897 | @retval >0 The write operation was successful, and return value is the\r | |
2898 | number of bytes actually written to the TLS connection.\r | |
2899 | @retval <=0 The write operation was not successful.\r | |
2900 | \r | |
2901 | **/\r | |
2902 | INTN\r | |
2903 | EFIAPI\r | |
2904 | TlsWrite (\r | |
2905 | IN VOID *Tls,\r | |
2906 | IN VOID *Buffer,\r | |
2907 | IN UINTN BufferSize\r | |
2908 | )\r | |
2909 | {\r | |
2910 | CALL_CRYPTO_SERVICE (TlsWrite, (Tls, Buffer, BufferSize), 0);\r | |
2911 | }\r | |
2912 | \r | |
2913 | /**\r | |
2914 | Set a new TLS/SSL method for a particular TLS object.\r | |
2915 | \r | |
2916 | This function sets a new TLS/SSL method for a particular TLS object.\r | |
2917 | \r | |
2918 | @param[in] Tls Pointer to a TLS object.\r | |
2919 | @param[in] MajorVer Major Version of TLS/SSL Protocol.\r | |
2920 | @param[in] MinorVer Minor Version of TLS/SSL Protocol.\r | |
2921 | \r | |
2922 | @retval EFI_SUCCESS The TLS/SSL method was set successfully.\r | |
2923 | @retval EFI_INVALID_PARAMETER The parameter is invalid.\r | |
2924 | @retval EFI_UNSUPPORTED Unsupported TLS/SSL method.\r | |
2925 | \r | |
2926 | **/\r | |
2927 | EFI_STATUS\r | |
2928 | EFIAPI\r | |
2929 | TlsSetVersion (\r | |
2930 | IN VOID *Tls,\r | |
2931 | IN UINT8 MajorVer,\r | |
2932 | IN UINT8 MinorVer\r | |
2933 | )\r | |
2934 | {\r | |
2935 | CALL_CRYPTO_SERVICE (TlsSetVersion, (Tls, MajorVer, MinorVer), EFI_UNSUPPORTED);\r | |
2936 | }\r | |
2937 | \r | |
2938 | /**\r | |
2939 | Set TLS object to work in client or server mode.\r | |
2940 | \r | |
2941 | This function prepares a TLS object to work in client or server mode.\r | |
2942 | \r | |
2943 | @param[in] Tls Pointer to a TLS object.\r | |
2944 | @param[in] IsServer Work in server mode.\r | |
2945 | \r | |
2946 | @retval EFI_SUCCESS The TLS/SSL work mode was set successfully.\r | |
2947 | @retval EFI_INVALID_PARAMETER The parameter is invalid.\r | |
2948 | @retval EFI_UNSUPPORTED Unsupported TLS/SSL work mode.\r | |
2949 | \r | |
2950 | **/\r | |
2951 | EFI_STATUS\r | |
2952 | EFIAPI\r | |
2953 | TlsSetConnectionEnd (\r | |
2954 | IN VOID *Tls,\r | |
2955 | IN BOOLEAN IsServer\r | |
2956 | )\r | |
2957 | {\r | |
2958 | CALL_CRYPTO_SERVICE (TlsSetConnectionEnd, (Tls, IsServer), EFI_UNSUPPORTED);\r | |
2959 | }\r | |
2960 | \r | |
2961 | /**\r | |
2962 | Set the ciphers list to be used by the TLS object.\r | |
2963 | \r | |
2964 | This function sets the ciphers for use by a specified TLS object.\r | |
2965 | \r | |
2966 | @param[in] Tls Pointer to a TLS object.\r | |
2967 | @param[in] CipherId Array of UINT16 cipher identifiers. Each UINT16\r | |
2968 | cipher identifier comes from the TLS Cipher Suite\r | |
2969 | Registry of the IANA, interpreting Byte1 and Byte2\r | |
2970 | in network (big endian) byte order.\r | |
2971 | @param[in] CipherNum The number of cipher in the list.\r | |
2972 | \r | |
2973 | @retval EFI_SUCCESS The ciphers list was set successfully.\r | |
2974 | @retval EFI_INVALID_PARAMETER The parameter is invalid.\r | |
2975 | @retval EFI_UNSUPPORTED No supported TLS cipher was found in CipherId.\r | |
2976 | @retval EFI_OUT_OF_RESOURCES Memory allocation failed.\r | |
2977 | \r | |
2978 | **/\r | |
2979 | EFI_STATUS\r | |
2980 | EFIAPI\r | |
2981 | TlsSetCipherList (\r | |
2982 | IN VOID *Tls,\r | |
2983 | IN UINT16 *CipherId,\r | |
2984 | IN UINTN CipherNum\r | |
2985 | )\r | |
2986 | {\r | |
2987 | CALL_CRYPTO_SERVICE (TlsSetCipherList, (Tls, CipherId, CipherNum), EFI_UNSUPPORTED);\r | |
2988 | }\r | |
2989 | \r | |
2990 | /**\r | |
2991 | Set the compression method for TLS/SSL operations.\r | |
2992 | \r | |
2993 | This function handles TLS/SSL integrated compression methods.\r | |
2994 | \r | |
2995 | @param[in] CompMethod The compression method ID.\r | |
2996 | \r | |
2997 | @retval EFI_SUCCESS The compression method for the communication was\r | |
2998 | set successfully.\r | |
2999 | @retval EFI_UNSUPPORTED Unsupported compression method.\r | |
3000 | \r | |
3001 | **/\r | |
3002 | EFI_STATUS\r | |
3003 | EFIAPI\r | |
3004 | TlsSetCompressionMethod (\r | |
3005 | IN UINT8 CompMethod\r | |
3006 | )\r | |
3007 | {\r | |
3008 | CALL_CRYPTO_SERVICE (TlsSetCompressionMethod, (CompMethod), EFI_UNSUPPORTED);\r | |
3009 | }\r | |
3010 | \r | |
3011 | /**\r | |
3012 | Set peer certificate verification mode for the TLS connection.\r | |
3013 | \r | |
3014 | This function sets the verification mode flags for the TLS connection.\r | |
3015 | \r | |
3016 | @param[in] Tls Pointer to the TLS object.\r | |
3017 | @param[in] VerifyMode A set of logically or'ed verification mode flags.\r | |
3018 | \r | |
3019 | **/\r | |
3020 | VOID\r | |
3021 | EFIAPI\r | |
3022 | TlsSetVerify (\r | |
3023 | IN VOID *Tls,\r | |
3024 | IN UINT32 VerifyMode\r | |
3025 | )\r | |
3026 | {\r | |
3027 | CALL_VOID_CRYPTO_SERVICE (TlsSetVerify, (Tls, VerifyMode));\r | |
3028 | }\r | |
3029 | \r | |
3030 | /**\r | |
3031 | Set the specified host name to be verified.\r | |
3032 | \r | |
3033 | @param[in] Tls Pointer to the TLS object.\r | |
3034 | @param[in] Flags The setting flags during the validation.\r | |
3035 | @param[in] HostName The specified host name to be verified.\r | |
3036 | \r | |
3037 | @retval EFI_SUCCESS The HostName setting was set successfully.\r | |
3038 | @retval EFI_INVALID_PARAMETER The parameter is invalid.\r | |
3039 | @retval EFI_ABORTED Invalid HostName setting.\r | |
3040 | \r | |
3041 | **/\r | |
3042 | EFI_STATUS\r | |
3043 | EFIAPI\r | |
3044 | TlsSetVerifyHost (\r | |
3045 | IN VOID *Tls,\r | |
3046 | IN UINT32 Flags,\r | |
3047 | IN CHAR8 *HostName\r | |
3048 | )\r | |
3049 | {\r | |
3050 | CALL_CRYPTO_SERVICE (TlsSetVerifyHost, (Tls, Flags, HostName), EFI_UNSUPPORTED);\r | |
3051 | }\r | |
3052 | \r | |
3053 | /**\r | |
3054 | Sets a TLS/SSL session ID to be used during TLS/SSL connect.\r | |
3055 | \r | |
3056 | This function sets a session ID to be used when the TLS/SSL connection is\r | |
3057 | to be established.\r | |
3058 | \r | |
3059 | @param[in] Tls Pointer to the TLS object.\r | |
3060 | @param[in] SessionId Session ID data used for session resumption.\r | |
3061 | @param[in] SessionIdLen Length of Session ID in bytes.\r | |
3062 | \r | |
3063 | @retval EFI_SUCCESS Session ID was set successfully.\r | |
3064 | @retval EFI_INVALID_PARAMETER The parameter is invalid.\r | |
3065 | @retval EFI_UNSUPPORTED No available session for ID setting.\r | |
3066 | \r | |
3067 | **/\r | |
3068 | EFI_STATUS\r | |
3069 | EFIAPI\r | |
3070 | TlsSetSessionId (\r | |
3071 | IN VOID *Tls,\r | |
3072 | IN UINT8 *SessionId,\r | |
3073 | IN UINT16 SessionIdLen\r | |
3074 | )\r | |
3075 | {\r | |
3076 | CALL_CRYPTO_SERVICE (TlsSetSessionId, (Tls, SessionId, SessionIdLen), EFI_UNSUPPORTED);\r | |
3077 | }\r | |
3078 | \r | |
3079 | /**\r | |
3080 | Adds the CA to the cert store when requesting Server or Client authentication.\r | |
3081 | \r | |
3082 | This function adds the CA certificate to the list of CAs when requesting\r | |
3083 | Server or Client authentication for the chosen TLS connection.\r | |
3084 | \r | |
3085 | @param[in] Tls Pointer to the TLS object.\r | |
3086 | @param[in] Data Pointer to the data buffer of a DER-encoded binary\r | |
3087 | X.509 certificate or PEM-encoded X.509 certificate.\r | |
3088 | @param[in] DataSize The size of data buffer in bytes.\r | |
3089 | \r | |
3090 | @retval EFI_SUCCESS The operation succeeded.\r | |
3091 | @retval EFI_INVALID_PARAMETER The parameter is invalid.\r | |
3092 | @retval EFI_OUT_OF_RESOURCES Required resources could not be allocated.\r | |
3093 | @retval EFI_ABORTED Invalid X.509 certificate.\r | |
3094 | \r | |
3095 | **/\r | |
3096 | EFI_STATUS\r | |
3097 | EFIAPI\r | |
3098 | TlsSetCaCertificate (\r | |
3099 | IN VOID *Tls,\r | |
3100 | IN VOID *Data,\r | |
3101 | IN UINTN DataSize\r | |
3102 | )\r | |
3103 | {\r | |
3104 | CALL_CRYPTO_SERVICE (TlsSetCaCertificate, (Tls, Data, DataSize), EFI_UNSUPPORTED);\r | |
3105 | }\r | |
3106 | \r | |
3107 | /**\r | |
3108 | Loads the local public certificate into the specified TLS object.\r | |
3109 | \r | |
3110 | This function loads the X.509 certificate into the specified TLS object\r | |
3111 | for TLS negotiation.\r | |
3112 | \r | |
3113 | @param[in] Tls Pointer to the TLS object.\r | |
3114 | @param[in] Data Pointer to the data buffer of a DER-encoded binary\r | |
3115 | X.509 certificate or PEM-encoded X.509 certificate.\r | |
3116 | @param[in] DataSize The size of data buffer in bytes.\r | |
3117 | \r | |
3118 | @retval EFI_SUCCESS The operation succeeded.\r | |
3119 | @retval EFI_INVALID_PARAMETER The parameter is invalid.\r | |
3120 | @retval EFI_OUT_OF_RESOURCES Required resources could not be allocated.\r | |
3121 | @retval EFI_ABORTED Invalid X.509 certificate.\r | |
3122 | \r | |
3123 | **/\r | |
3124 | EFI_STATUS\r | |
3125 | EFIAPI\r | |
3126 | TlsSetHostPublicCert (\r | |
3127 | IN VOID *Tls,\r | |
3128 | IN VOID *Data,\r | |
3129 | IN UINTN DataSize\r | |
3130 | )\r | |
3131 | {\r | |
3132 | CALL_CRYPTO_SERVICE (TlsSetHostPublicCert, (Tls, Data, DataSize), EFI_UNSUPPORTED);\r | |
3133 | }\r | |
3134 | \r | |
3135 | /**\r | |
3136 | Adds the local private key to the specified TLS object.\r | |
3137 | \r | |
3138 | This function adds the local private key (PEM-encoded RSA or PKCS#8 private\r | |
3139 | key) into the specified TLS object for TLS negotiation.\r | |
3140 | \r | |
3141 | @param[in] Tls Pointer to the TLS object.\r | |
3142 | @param[in] Data Pointer to the data buffer of a PEM-encoded RSA\r | |
3143 | or PKCS#8 private key.\r | |
3144 | @param[in] DataSize The size of data buffer in bytes.\r | |
3145 | \r | |
3146 | @retval EFI_SUCCESS The operation succeeded.\r | |
3147 | @retval EFI_UNSUPPORTED This function is not supported.\r | |
3148 | @retval EFI_ABORTED Invalid private key data.\r | |
3149 | \r | |
3150 | **/\r | |
3151 | EFI_STATUS\r | |
3152 | EFIAPI\r | |
3153 | TlsSetHostPrivateKey (\r | |
3154 | IN VOID *Tls,\r | |
3155 | IN VOID *Data,\r | |
3156 | IN UINTN DataSize\r | |
3157 | )\r | |
3158 | {\r | |
3159 | CALL_CRYPTO_SERVICE (TlsSetHostPrivateKey, (Tls, Data, DataSize), EFI_UNSUPPORTED);\r | |
3160 | }\r | |
3161 | \r | |
3162 | /**\r | |
3163 | Adds the CA-supplied certificate revocation list for certificate validation.\r | |
3164 | \r | |
3165 | This function adds the CA-supplied certificate revocation list data for\r | |
3166 | certificate validity checking.\r | |
3167 | \r | |
3168 | @param[in] Data Pointer to the data buffer of a DER-encoded CRL data.\r | |
3169 | @param[in] DataSize The size of data buffer in bytes.\r | |
3170 | \r | |
3171 | @retval EFI_SUCCESS The operation succeeded.\r | |
3172 | @retval EFI_UNSUPPORTED This function is not supported.\r | |
3173 | @retval EFI_ABORTED Invalid CRL data.\r | |
3174 | \r | |
3175 | **/\r | |
3176 | EFI_STATUS\r | |
3177 | EFIAPI\r | |
3178 | TlsSetCertRevocationList (\r | |
3179 | IN VOID *Data,\r | |
3180 | IN UINTN DataSize\r | |
3181 | )\r | |
3182 | {\r | |
3183 | CALL_CRYPTO_SERVICE (TlsSetCertRevocationList, (Data, DataSize), EFI_UNSUPPORTED);\r | |
3184 | }\r | |
3185 | \r | |
3186 | /**\r | |
3187 | Gets the protocol version used by the specified TLS connection.\r | |
3188 | \r | |
3189 | This function returns the protocol version used by the specified TLS\r | |
3190 | connection.\r | |
3191 | \r | |
3192 | If Tls is NULL, then ASSERT().\r | |
3193 | \r | |
3194 | @param[in] Tls Pointer to the TLS object.\r | |
3195 | \r | |
3196 | @return The protocol version of the specified TLS connection.\r | |
3197 | \r | |
3198 | **/\r | |
3199 | UINT16\r | |
3200 | EFIAPI\r | |
3201 | TlsGetVersion (\r | |
3202 | IN VOID *Tls\r | |
3203 | )\r | |
3204 | {\r | |
3205 | CALL_CRYPTO_SERVICE (TlsGetVersion, (Tls), 0);\r | |
3206 | }\r | |
3207 | \r | |
3208 | /**\r | |
3209 | Gets the connection end of the specified TLS connection.\r | |
3210 | \r | |
3211 | This function returns the connection end (as client or as server) used by\r | |
3212 | the specified TLS connection.\r | |
3213 | \r | |
3214 | If Tls is NULL, then ASSERT().\r | |
3215 | \r | |
3216 | @param[in] Tls Pointer to the TLS object.\r | |
3217 | \r | |
3218 | @return The connection end used by the specified TLS connection.\r | |
3219 | \r | |
3220 | **/\r | |
3221 | UINT8\r | |
3222 | EFIAPI\r | |
3223 | TlsGetConnectionEnd (\r | |
3224 | IN VOID *Tls\r | |
3225 | )\r | |
3226 | {\r | |
3227 | CALL_CRYPTO_SERVICE (TlsGetConnectionEnd, (Tls), 0);\r | |
3228 | }\r | |
3229 | \r | |
3230 | /**\r | |
3231 | Gets the cipher suite used by the specified TLS connection.\r | |
3232 | \r | |
3233 | This function returns current cipher suite used by the specified\r | |
3234 | TLS connection.\r | |
3235 | \r | |
3236 | @param[in] Tls Pointer to the TLS object.\r | |
3237 | @param[in,out] CipherId The cipher suite used by the TLS object.\r | |
3238 | \r | |
3239 | @retval EFI_SUCCESS The cipher suite was returned successfully.\r | |
3240 | @retval EFI_INVALID_PARAMETER The parameter is invalid.\r | |
3241 | @retval EFI_UNSUPPORTED Unsupported cipher suite.\r | |
3242 | \r | |
3243 | **/\r | |
3244 | EFI_STATUS\r | |
3245 | EFIAPI\r | |
3246 | TlsGetCurrentCipher (\r | |
3247 | IN VOID *Tls,\r | |
3248 | IN OUT UINT16 *CipherId\r | |
3249 | )\r | |
3250 | {\r | |
3251 | CALL_CRYPTO_SERVICE (TlsGetCurrentCipher, (Tls, CipherId), EFI_UNSUPPORTED);\r | |
3252 | }\r | |
3253 | \r | |
3254 | /**\r | |
3255 | Gets the compression methods used by the specified TLS connection.\r | |
3256 | \r | |
3257 | This function returns current integrated compression methods used by\r | |
3258 | the specified TLS connection.\r | |
3259 | \r | |
3260 | @param[in] Tls Pointer to the TLS object.\r | |
3261 | @param[in,out] CompressionId The current compression method used by\r | |
3262 | the TLS object.\r | |
3263 | \r | |
3264 | @retval EFI_SUCCESS The compression method was returned successfully.\r | |
3265 | @retval EFI_INVALID_PARAMETER The parameter is invalid.\r | |
3266 | @retval EFI_ABORTED Invalid Compression method.\r | |
3267 | @retval EFI_UNSUPPORTED This function is not supported.\r | |
3268 | \r | |
3269 | **/\r | |
3270 | EFI_STATUS\r | |
3271 | EFIAPI\r | |
3272 | TlsGetCurrentCompressionId (\r | |
3273 | IN VOID *Tls,\r | |
3274 | IN OUT UINT8 *CompressionId\r | |
3275 | )\r | |
3276 | {\r | |
3277 | CALL_CRYPTO_SERVICE (TlsGetCurrentCompressionId, (Tls, CompressionId), EFI_UNSUPPORTED);\r | |
3278 | }\r | |
3279 | \r | |
3280 | /**\r | |
3281 | Gets the verification mode currently set in the TLS connection.\r | |
3282 | \r | |
3283 | This function returns the peer verification mode currently set in the\r | |
3284 | specified TLS connection.\r | |
3285 | \r | |
3286 | If Tls is NULL, then ASSERT().\r | |
3287 | \r | |
3288 | @param[in] Tls Pointer to the TLS object.\r | |
3289 | \r | |
3290 | @return The verification mode set in the specified TLS connection.\r | |
3291 | \r | |
3292 | **/\r | |
3293 | UINT32\r | |
3294 | EFIAPI\r | |
3295 | TlsGetVerify (\r | |
3296 | IN VOID *Tls\r | |
3297 | )\r | |
3298 | {\r | |
3299 | CALL_CRYPTO_SERVICE (TlsGetVerify, (Tls), 0);\r | |
3300 | }\r | |
3301 | \r | |
3302 | /**\r | |
3303 | Gets the session ID used by the specified TLS connection.\r | |
3304 | \r | |
3305 | This function returns the TLS/SSL session ID currently used by the\r | |
3306 | specified TLS connection.\r | |
3307 | \r | |
3308 | @param[in] Tls Pointer to the TLS object.\r | |
3309 | @param[in,out] SessionId Buffer to contain the returned session ID.\r | |
3310 | @param[in,out] SessionIdLen The length of Session ID in bytes.\r | |
3311 | \r | |
3312 | @retval EFI_SUCCESS The Session ID was returned successfully.\r | |
3313 | @retval EFI_INVALID_PARAMETER The parameter is invalid.\r | |
3314 | @retval EFI_UNSUPPORTED Invalid TLS/SSL session.\r | |
3315 | \r | |
3316 | **/\r | |
3317 | EFI_STATUS\r | |
3318 | EFIAPI\r | |
3319 | TlsGetSessionId (\r | |
3320 | IN VOID *Tls,\r | |
3321 | IN OUT UINT8 *SessionId,\r | |
3322 | IN OUT UINT16 *SessionIdLen\r | |
3323 | )\r | |
3324 | {\r | |
3325 | CALL_CRYPTO_SERVICE (TlsGetSessionId, (Tls, SessionId, SessionIdLen), EFI_UNSUPPORTED);\r | |
3326 | }\r | |
3327 | \r | |
3328 | /**\r | |
3329 | Gets the client random data used in the specified TLS connection.\r | |
3330 | \r | |
3331 | This function returns the TLS/SSL client random data currently used in\r | |
3332 | the specified TLS connection.\r | |
3333 | \r | |
3334 | @param[in] Tls Pointer to the TLS object.\r | |
3335 | @param[in,out] ClientRandom Buffer to contain the returned client\r | |
3336 | random data (32 bytes).\r | |
3337 | \r | |
3338 | **/\r | |
3339 | VOID\r | |
3340 | EFIAPI\r | |
3341 | TlsGetClientRandom (\r | |
3342 | IN VOID *Tls,\r | |
3343 | IN OUT UINT8 *ClientRandom\r | |
3344 | )\r | |
3345 | {\r | |
3346 | CALL_VOID_CRYPTO_SERVICE (TlsGetClientRandom, (Tls, ClientRandom));\r | |
3347 | }\r | |
3348 | \r | |
3349 | /**\r | |
3350 | Gets the server random data used in the specified TLS connection.\r | |
3351 | \r | |
3352 | This function returns the TLS/SSL server random data currently used in\r | |
3353 | the specified TLS connection.\r | |
3354 | \r | |
3355 | @param[in] Tls Pointer to the TLS object.\r | |
3356 | @param[in,out] ServerRandom Buffer to contain the returned server\r | |
3357 | random data (32 bytes).\r | |
3358 | \r | |
3359 | **/\r | |
3360 | VOID\r | |
3361 | EFIAPI\r | |
3362 | TlsGetServerRandom (\r | |
3363 | IN VOID *Tls,\r | |
3364 | IN OUT UINT8 *ServerRandom\r | |
3365 | )\r | |
3366 | {\r | |
3367 | CALL_VOID_CRYPTO_SERVICE (TlsGetServerRandom, (Tls, ServerRandom));\r | |
3368 | }\r | |
3369 | \r | |
3370 | /**\r | |
3371 | Gets the master key data used in the specified TLS connection.\r | |
3372 | \r | |
3373 | This function returns the TLS/SSL master key material currently used in\r | |
3374 | the specified TLS connection.\r | |
3375 | \r | |
3376 | @param[in] Tls Pointer to the TLS object.\r | |
3377 | @param[in,out] KeyMaterial Buffer to contain the returned key material.\r | |
3378 | \r | |
3379 | @retval EFI_SUCCESS Key material was returned successfully.\r | |
3380 | @retval EFI_INVALID_PARAMETER The parameter is invalid.\r | |
3381 | @retval EFI_UNSUPPORTED Invalid TLS/SSL session.\r | |
3382 | \r | |
3383 | **/\r | |
3384 | EFI_STATUS\r | |
3385 | EFIAPI\r | |
3386 | TlsGetKeyMaterial (\r | |
3387 | IN VOID *Tls,\r | |
3388 | IN OUT UINT8 *KeyMaterial\r | |
3389 | )\r | |
3390 | {\r | |
3391 | CALL_CRYPTO_SERVICE (TlsGetKeyMaterial, (Tls, KeyMaterial), EFI_UNSUPPORTED);\r | |
3392 | }\r | |
3393 | \r | |
3394 | /**\r | |
3395 | Gets the CA Certificate from the cert store.\r | |
3396 | \r | |
3397 | This function returns the CA certificate for the chosen\r | |
3398 | TLS connection.\r | |
3399 | \r | |
3400 | @param[in] Tls Pointer to the TLS object.\r | |
3401 | @param[out] Data Pointer to the data buffer to receive the CA\r | |
3402 | certificate data sent to the client.\r | |
3403 | @param[in,out] DataSize The size of data buffer in bytes.\r | |
3404 | \r | |
3405 | @retval EFI_SUCCESS The operation succeeded.\r | |
3406 | @retval EFI_UNSUPPORTED This function is not supported.\r | |
3407 | @retval EFI_BUFFER_TOO_SMALL The Data is too small to hold the data.\r | |
3408 | \r | |
3409 | **/\r | |
3410 | EFI_STATUS\r | |
3411 | EFIAPI\r | |
3412 | TlsGetCaCertificate (\r | |
3413 | IN VOID *Tls,\r | |
3414 | OUT VOID *Data,\r | |
3415 | IN OUT UINTN *DataSize\r | |
3416 | )\r | |
3417 | {\r | |
3418 | CALL_CRYPTO_SERVICE (TlsGetCaCertificate, (Tls, Data, DataSize), EFI_UNSUPPORTED);\r | |
3419 | }\r | |
3420 | \r | |
3421 | /**\r | |
3422 | Gets the local public Certificate set in the specified TLS object.\r | |
3423 | \r | |
3424 | This function returns the local public certificate which was currently set\r | |
3425 | in the specified TLS object.\r | |
3426 | \r | |
3427 | @param[in] Tls Pointer to the TLS object.\r | |
3428 | @param[out] Data Pointer to the data buffer to receive the local\r | |
3429 | public certificate.\r | |
3430 | @param[in,out] DataSize The size of data buffer in bytes.\r | |
3431 | \r | |
3432 | @retval EFI_SUCCESS The operation succeeded.\r | |
3433 | @retval EFI_INVALID_PARAMETER The parameter is invalid.\r | |
3434 | @retval EFI_NOT_FOUND The certificate is not found.\r | |
3435 | @retval EFI_BUFFER_TOO_SMALL The Data is too small to hold the data.\r | |
3436 | \r | |
3437 | **/\r | |
3438 | EFI_STATUS\r | |
3439 | EFIAPI\r | |
3440 | TlsGetHostPublicCert (\r | |
3441 | IN VOID *Tls,\r | |
3442 | OUT VOID *Data,\r | |
3443 | IN OUT UINTN *DataSize\r | |
3444 | )\r | |
3445 | {\r | |
3446 | CALL_CRYPTO_SERVICE (TlsGetHostPublicCert, (Tls, Data, DataSize), EFI_UNSUPPORTED);\r | |
3447 | }\r | |
3448 | \r | |
3449 | /**\r | |
3450 | Gets the local private key set in the specified TLS object.\r | |
3451 | \r | |
3452 | This function returns the local private key data which was currently set\r | |
3453 | in the specified TLS object.\r | |
3454 | \r | |
3455 | @param[in] Tls Pointer to the TLS object.\r | |
3456 | @param[out] Data Pointer to the data buffer to receive the local\r | |
3457 | private key data.\r | |
3458 | @param[in,out] DataSize The size of data buffer in bytes.\r | |
3459 | \r | |
3460 | @retval EFI_SUCCESS The operation succeeded.\r | |
3461 | @retval EFI_UNSUPPORTED This function is not supported.\r | |
3462 | @retval EFI_BUFFER_TOO_SMALL The Data is too small to hold the data.\r | |
3463 | \r | |
3464 | **/\r | |
3465 | EFI_STATUS\r | |
3466 | EFIAPI\r | |
3467 | TlsGetHostPrivateKey (\r | |
3468 | IN VOID *Tls,\r | |
3469 | OUT VOID *Data,\r | |
3470 | IN OUT UINTN *DataSize\r | |
3471 | )\r | |
3472 | {\r | |
3473 | CALL_CRYPTO_SERVICE (TlsGetHostPrivateKey, (Tls, Data, DataSize), EFI_UNSUPPORTED);\r | |
3474 | }\r | |
3475 | \r | |
3476 | /**\r | |
3477 | Gets the CA-supplied certificate revocation list data set in the specified\r | |
3478 | TLS object.\r | |
3479 | \r | |
3480 | This function returns the CA-supplied certificate revocation list data which\r | |
3481 | was currently set in the specified TLS object.\r | |
3482 | \r | |
3483 | @param[out] Data Pointer to the data buffer to receive the CRL data.\r | |
3484 | @param[in,out] DataSize The size of data buffer in bytes.\r | |
3485 | \r | |
3486 | @retval EFI_SUCCESS The operation succeeded.\r | |
3487 | @retval EFI_UNSUPPORTED This function is not supported.\r | |
3488 | @retval EFI_BUFFER_TOO_SMALL The Data is too small to hold the data.\r | |
3489 | \r | |
3490 | **/\r | |
3491 | EFI_STATUS\r | |
3492 | EFIAPI\r | |
3493 | TlsGetCertRevocationList (\r | |
3494 | OUT VOID *Data,\r | |
3495 | IN OUT UINTN *DataSize\r | |
3496 | )\r | |
3497 | {\r | |
3498 | CALL_CRYPTO_SERVICE (TlsGetCertRevocationList, (Data, DataSize), EFI_UNSUPPORTED);\r | |
3499 | }\r |