9#include "InternalCryptLib.h"
10#include <mbedtls/pkcs7.h>
47 mbedtls_pkcs7_data *MbedtlsContent;
49 mbedtls_pkcs7_init (&Pkcs7);
54 if ((P7Data ==
NULL) || (P7Length > INT_MAX) || (Content ==
NULL) || (ContentSize ==
NULL)) {
61 Status =
WrapPkcs7Data (P7Data, P7Length, &Wrapped, &SignedData, &SignedDataSize);
62 if (!Status || (SignedDataSize > INT_MAX)) {
68 Ret = mbedtls_pkcs7_parse_der (&Pkcs7, SignedData, (INT32)SignedDataSize);
73 if (Ret != MBEDTLS_PKCS7_SIGNED_DATA) {
80 MbedtlsContent = &(Pkcs7.signed_data.content);
82 if (MbedtlsContent ==
NULL) {
92 if ((MbedtlsContent->data.len > 0) && (MbedtlsContent->data.p !=
NULL)) {
93 *ContentSize = MbedtlsContent->data.len;
95 if (*Content ==
NULL) {
100 CopyMem (*Content, MbedtlsContent->data.p, *ContentSize);
110 mbedtls_pkcs7_free (&Pkcs7);
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)
VOID *EFIAPI AllocateZeroPool(IN UINTN AllocationSize)
BOOLEAN EFIAPI Pkcs7GetAttachedContent(IN CONST UINT8 *P7Data, IN UINTN P7Length, OUT VOID **Content, OUT UINTN *ContentSize)