9#include "InternalCryptLib.h"
11#include <openssl/objects.h>
12#include <openssl/x509.h>
13#include <openssl/x509v3.h>
14#include <openssl/pkcs7.h>
33 INTN Nid = OBJ_obj2nid (P7->type);
37 case NID_pkcs7_signed:
38 case NID_pkcs7_enveloped:
39 case NID_pkcs7_signedAndEnveloped:
40 case NID_pkcs7_encrypted:
65 if (PKCS7_type_is_data (P7)) {
70 (P7->d.other->type == V_ASN1_OCTET_STRING))
72 return P7->d.other->value.octet_string;
110 UINTN SignedDataSize;
113 ASN1_OCTET_STRING *OctStr;
118 if ((P7Data ==
NULL) || (P7Length > INT_MAX) || (Content ==
NULL) || (ContentSize ==
NULL)) {
127 Status =
WrapPkcs7Data (P7Data, P7Length, &Wrapped, &SignedData, &SignedDataSize);
128 if (!Status || (SignedDataSize > INT_MAX)) {
138 Pkcs7 = d2i_PKCS7 (
NULL, (
const unsigned char **)&Temp, (
int)SignedDataSize);
146 if (!PKCS7_type_is_signed (Pkcs7)) {
153 if (PKCS7_get_detached (Pkcs7)) {
164 if (OctStr ==
NULL) {
168 if ((OctStr->length > 0) && (OctStr->data !=
NULL)) {
169 *ContentSize = OctStr->length;
171 if (*Content ==
NULL) {
176 CopyMem (*Content, OctStr->data, *ContentSize);
189 OPENSSL_free (SignedData);
BOOLEAN WrapPkcs7Data(IN CONST UINT8 *P7Data, IN UINTN P7Length, OUT BOOLEAN *WrapFlag, OUT UINT8 **WrapData, OUT UINTN *WrapDataSize)
VOID *EFIAPI CopyMem(OUT VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
STATIC ASN1_OCTET_STRING * Pkcs7GetOctetString(IN PKCS7 *P7)
BOOLEAN EFIAPI Pkcs7GetAttachedContent(IN CONST UINT8 *P7Data, IN UINTN P7Length, OUT VOID **Content, OUT UINTN *ContentSize)
STATIC BOOLEAN Pkcs7TypeIsOther(IN PKCS7 *P7)
VOID *EFIAPI AllocatePool(IN UINTN AllocationSize)