]> git.proxmox.com Git - mirror_edk2.git/blob - CryptoPkg/Library/BaseCryptLib/InternalCryptLib.h
026793f66453776ec75593bc239c10fb963486ee
[mirror_edk2.git] / CryptoPkg / Library / BaseCryptLib / InternalCryptLib.h
1 /** @file
2 Internal include file for BaseCryptLib.
3
4 Copyright (c) 2010 - 2017, Intel Corporation. All rights reserved.<BR>
5 This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
9
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
12
13 **/
14
15 #ifndef __INTERNAL_CRYPT_LIB_H__
16 #define __INTERNAL_CRYPT_LIB_H__
17
18 #undef _WIN32
19 #undef _WIN64
20
21 #include <Library/BaseLib.h>
22 #include <Library/BaseMemoryLib.h>
23 #include <Library/MemoryAllocationLib.h>
24 #include <Library/DebugLib.h>
25 #include <Library/BaseCryptLib.h>
26
27 #include "CrtLibSupport.h"
28
29 #include <openssl/opensslv.h>
30
31 #if OPENSSL_VERSION_NUMBER < 0x10100000L
32 #define OBJ_get0_data(o) ((o)->data)
33 #define OBJ_length(o) ((o)->length)
34 #endif
35
36 /**
37 Check input P7Data is a wrapped ContentInfo structure or not. If not construct
38 a new structure to wrap P7Data.
39
40 Caution: This function may receive untrusted input.
41 UEFI Authenticated Variable is external input, so this function will do basic
42 check for PKCS#7 data structure.
43
44 @param[in] P7Data Pointer to the PKCS#7 message to verify.
45 @param[in] P7Length Length of the PKCS#7 message in bytes.
46 @param[out] WrapFlag If TRUE P7Data is a ContentInfo structure, otherwise
47 return FALSE.
48 @param[out] WrapData If return status of this function is TRUE:
49 1) when WrapFlag is TRUE, pointer to P7Data.
50 2) when WrapFlag is FALSE, pointer to a new ContentInfo
51 structure. It's caller's responsibility to free this
52 buffer.
53 @param[out] WrapDataSize Length of ContentInfo structure in bytes.
54
55 @retval TRUE The operation is finished successfully.
56 @retval FALSE The operation is failed due to lack of resources.
57
58 **/
59 BOOLEAN
60 WrapPkcs7Data (
61 IN CONST UINT8 *P7Data,
62 IN UINTN P7Length,
63 OUT BOOLEAN *WrapFlag,
64 OUT UINT8 **WrapData,
65 OUT UINTN *WrapDataSize
66 );
67
68 #endif