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

Go to the source code of this file.

Functions

RETURN_STATUS FmpAuthenticatedHandlerRsa2048Sha256 (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)
 

Variables

STATIC CONST UINT8 mRsaE [] = { 0x01, 0x00, 0x01 }
 

Detailed Description

FMP Authentication RSA2048SHA256 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.

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

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

Definition in file FmpAuthenticationLibRsa2048Sha256.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 298 of file FmpAuthenticationLibRsa2048Sha256.c.

◆ FmpAuthenticatedHandlerRsa2048Sha256()

RETURN_STATUS FmpAuthenticatedHandlerRsa2048Sha256 ( 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 63 of file FmpAuthenticationLibRsa2048Sha256.c.

Variable Documentation

◆ mRsaE

STATIC CONST UINT8 mRsaE[] = { 0x01, 0x00, 0x01 }

Public Exponent of RSA Key.

Definition at line 37 of file FmpAuthenticationLibRsa2048Sha256.c.