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