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