71 DEBUG ((DEBUG_INFO,
"FmpAuthenticatedHandlerPkcs7 - Image: 0x%08x - 0x%08x\n", (
UINTN)Image, (
UINTN)ImageSize));
74 P7Data = Image->AuthInfo.CertData;
77 TempBuffer =
AllocatePool (ImageSize - Image->AuthInfo.Hdr.dwLength);
78 if (TempBuffer ==
NULL) {
79 DEBUG ((DEBUG_ERROR,
"FmpAuthenticatedHandlerPkcs7: TempBuffer == NULL\n"));
86 (UINT8 *)Image +
sizeof (Image->MonotonicCount) + Image->AuthInfo.Hdr.dwLength,
87 ImageSize - sizeof (Image->MonotonicCount) - Image->AuthInfo.Hdr.dwLength
90 (UINT8 *)TempBuffer + ImageSize -
sizeof (Image->MonotonicCount) - Image->AuthInfo.Hdr.dwLength,
91 &Image->MonotonicCount,
92 sizeof (Image->MonotonicCount)
100 ImageSize - Image->AuthInfo.Hdr.dwLength
107 DEBUG ((DEBUG_ERROR,
"FmpAuthenticatedHandlerPkcs7: Pkcs7Verify() failed\n"));
112 DEBUG ((DEBUG_INFO,
"FmpAuthenticatedHandlerPkcs7: PASS verification\n"));
167 if ((Image ==
NULL) || (ImageSize == 0)) {
172 DEBUG ((DEBUG_ERROR,
"AuthenticateFmpImage - ImageSize too small\n"));
177 DEBUG ((DEBUG_ERROR,
"AuthenticateFmpImage - dwLength too small\n"));
181 if ((
UINTN)Image->AuthInfo.Hdr.dwLength > MAX_UINTN - sizeof (UINT64)) {
182 DEBUG ((DEBUG_ERROR,
"AuthenticateFmpImage - dwLength too big\n"));
186 if (ImageSize <=
sizeof (Image->MonotonicCount) + Image->AuthInfo.Hdr.dwLength) {
187 DEBUG ((DEBUG_ERROR,
"AuthenticateFmpImage - ImageSize too small\n"));
191 if (Image->AuthInfo.Hdr.wRevision != 0x0200) {
192 DEBUG ((DEBUG_ERROR,
"AuthenticateFmpImage - wRevision: 0x%02x, expect - 0x%02x\n", (
UINTN)Image->AuthInfo.Hdr.wRevision, (
UINTN)0x0200));
196 if (Image->AuthInfo.Hdr.wCertificateType != WIN_CERT_TYPE_EFI_GUID) {
197 DEBUG ((DEBUG_ERROR,
"AuthenticateFmpImage - wCertificateType: 0x%02x, expect - 0x%02x\n", (
UINTN)Image->AuthInfo.Hdr.wCertificateType, (
UINTN)WIN_CERT_TYPE_EFI_GUID));
201 CertType = &Image->AuthInfo.CertType;
202 DEBUG ((DEBUG_INFO,
"AuthenticateFmpImage - CertType: %g\n", CertType));
BOOLEAN EFIAPI Pkcs7Verify(IN CONST UINT8 *P7Data, IN UINTN P7Length, IN CONST UINT8 *TrustedCert, IN UINTN CertLength, IN CONST UINT8 *InData, IN UINTN DataLength)
VOID *EFIAPI CopyMem(OUT VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
BOOLEAN EFIAPI CompareGuid(IN CONST GUID *Guid1, IN CONST GUID *Guid2)
VOID EFIAPI FreePool(IN VOID *Buffer)
RETURN_STATUS EFIAPI AuthenticateFmpImage(IN EFI_FIRMWARE_IMAGE_AUTHENTICATION *Image, IN UINTN ImageSize, IN CONST UINT8 *PublicKeyData, IN UINTN PublicKeyDataLength)
RETURN_STATUS FmpAuthenticatedHandlerPkcs7(IN EFI_FIRMWARE_IMAGE_AUTHENTICATION *Image, IN UINTN ImageSize, IN CONST UINT8 *PublicKeyData, IN UINTN PublicKeyDataLength)
#define RETURN_UNSUPPORTED
#define RETURN_OUT_OF_RESOURCES
#define RETURN_SECURITY_VIOLATION
#define OFFSET_OF(TYPE, Field)
#define RETURN_INVALID_PARAMETER
#define DEBUG(Expression)
VOID *EFIAPI AllocatePool(IN UINTN AllocationSize)