TianoCore EDK2 master
Loading...
Searching...
No Matches
FmpAuthenticationLibPkcs7.c File Reference

Go to the source code of this file.

Functions

RETURN_STATUS FmpAuthenticatedHandlerPkcs7 (IN EFI_FIRMWARE_IMAGE_AUTHENTICATION *Image, IN UINTN ImageSize, IN CONST UINT8 *PublicKeyData, IN UINTN PublicKeyDataLength)
 
RETURN_STATUS EFIAPI AuthenticateFmpImage (IN EFI_FIRMWARE_IMAGE_AUTHENTICATION *Image, IN UINTN ImageSize, IN CONST UINT8 *PublicKeyData, IN UINTN PublicKeyDataLength)
 

Detailed Description

FMP Authentication PKCS7 handler. Provide generic FMP authentication functions for DXE/PEI post memory phase.

Caution: This module requires additional review when modified. This module will have external input - capsule image. This external input must be validated carefully to avoid security issue like buffer overflow, integer overflow.

FmpAuthenticatedHandlerPkcs7(), AuthenticateFmpImage() will receive untrusted input and do basic validation.

Copyright (c) 2016 - 2017, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent

Definition in file FmpAuthenticationLibPkcs7.c.

Function Documentation

◆ AuthenticateFmpImage()

RETURN_STATUS EFIAPI AuthenticateFmpImage ( IN EFI_FIRMWARE_IMAGE_AUTHENTICATION Image,
IN UINTN  ImageSize,
IN CONST UINT8 *  PublicKeyData,
IN UINTN  PublicKeyDataLength 
)

The function is used to do the authentication for FMP capsule based upon EFI_FIRMWARE_IMAGE_AUTHENTICATION.

The FMP capsule image should start with EFI_FIRMWARE_IMAGE_AUTHENTICATION, followed by the payload.

If the return status is RETURN_SUCCESS, the caller may continue the rest FMP update process. If the return status is NOT RETURN_SUCCESS, the caller should stop the FMP update process and convert the return status to LastAttemptStatus to indicate that FMP update fails. The LastAttemptStatus can be got from ESRT table or via EFI_FIRMWARE_MANAGEMENT_PROTOCOL.GetImageInfo().

Caution: This function may receive untrusted input.

Parameters
[in]ImagePoints to an FMP authentication image, started from EFI_FIRMWARE_IMAGE_AUTHENTICATION.
[in]ImageSizeSize of the authentication image in bytes.
[in]PublicKeyDataThe public key data used to validate the signature.
[in]PublicKeyDataLengthThe length of the public key data.
Return values
RETURN_SUCCESSAuthentication pass. The LastAttemptStatus should be LAST_ATTEMPT_STATUS_SUCCESS.
RETURN_SECURITY_VIOLATIONAuthentication fail. The LastAttemptStatus should be LAST_ATTEMPT_STATUS_ERROR_AUTH_ERROR.
RETURN_INVALID_PARAMETERThe image is in an invalid format. The LastAttemptStatus should be LAST_ATTEMPT_STATUS_ERROR_INVALID_FORMAT.
RETURN_UNSUPPORTEDNo Authentication handler associated with CertType. The LastAttemptStatus should be LAST_ATTEMPT_STATUS_ERROR_INVALID_FORMAT.
RETURN_UNSUPPORTEDImage or ImageSize is invalid. The LastAttemptStatus should be LAST_ATTEMPT_STATUS_ERROR_INVALID_FORMAT.
RETURN_OUT_OF_RESOURCESNo Authentication handler associated with CertType. The LastAttemptStatus should be LAST_ATTEMPT_STATUS_ERROR_INSUFFICIENT_RESOURCES.

Definition at line 157 of file FmpAuthenticationLibPkcs7.c.

◆ FmpAuthenticatedHandlerPkcs7()

RETURN_STATUS FmpAuthenticatedHandlerPkcs7 ( IN EFI_FIRMWARE_IMAGE_AUTHENTICATION Image,
IN UINTN  ImageSize,
IN CONST UINT8 *  PublicKeyData,
IN UINTN  PublicKeyDataLength 
)

The handler is used to do the authentication for FMP capsule based upon EFI_FIRMWARE_IMAGE_AUTHENTICATION.

Caution: This function may receive untrusted input.

This function assumes the caller AuthenticateFmpImage() already did basic validation for EFI_FIRMWARE_IMAGE_AUTHENTICATION.

Parameters
[in]ImagePoints to an FMP authentication image, started from EFI_FIRMWARE_IMAGE_AUTHENTICATION.
[in]ImageSizeSize of the authentication image in bytes.
[in]PublicKeyDataThe public key data used to validate the signature.
[in]PublicKeyDataLengthThe length of the public key data.
Return values
RETURN_SUCCESSAuthentication pass. The LastAttemptStatus should be LAST_ATTEMPT_STATUS_SUCCESS.
RETURN_SECURITY_VIOLATIONAuthentication fail. The LastAttemptStatus should be LAST_ATTEMPT_STATUS_ERROR_AUTH_ERROR.
RETURN_INVALID_PARAMETERThe image is in an invalid format. The LastAttemptStatus should be LAST_ATTEMPT_STATUS_ERROR_INVALID_FORMAT.
RETURN_OUT_OF_RESOURCESNo Authentication handler associated with CertType. The LastAttemptStatus should be LAST_ATTEMPT_STATUS_ERROR_INSUFFICIENT_RESOURCES.

Definition at line 58 of file FmpAuthenticationLibPkcs7.c.