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