TianoCore EDK2 master
Loading...
Searching...
No Matches
FvReportPei.c File Reference
#include "FvReportPei.h"

Go to the source code of this file.

Functions

STATIC CONST HASH_ALG_INFOFindHashAlgInfo (IN UINT16 HashAlgId)
 
STATIC VOID InstallPreHashFvPpi (IN VOID *FvBuffer, IN UINTN FvLength, IN UINT16 HashAlgoId, IN UINT16 HashSize, IN UINT8 *HashValue)
 
STATIC EFI_STATUS VerifyHashedFv (IN FV_HASH_INFO *HashInfo, IN HASHED_FV_INFO *FvInfo, IN UINTN FvNumber, IN EFI_BOOT_MODE BootMode)
 
STATIC VOID ReportHashedFv (IN HASHED_FV_INFO *FvInfo)
 
STATIC FV_HASH_INFOGetHashInfo (IN EDKII_PEI_FIRMWARE_VOLUME_INFO_STORED_HASH_FV_PPI *StoredHashFvPpi, IN EFI_BOOT_MODE BootMode)
 
STATIC EFI_STATUS CheckStoredHashFv (IN CONST EFI_PEI_SERVICES **PeiServices, IN EFI_BOOT_MODE BootMode)
 
EFI_STATUS EFIAPI FvReportEntryPoint (IN EFI_PEI_FILE_HANDLE FileHandle, IN CONST EFI_PEI_SERVICES **PeiServices)
 

Variables

STATIC CONST HASH_ALG_INFO mHashAlgInfo []
 

Detailed Description

This driver verifies and reports OBB FVs.

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

Definition in file FvReportPei.c.

Function Documentation

◆ CheckStoredHashFv()

STATIC EFI_STATUS CheckStoredHashFv ( IN CONST EFI_PEI_SERVICES **  PeiServices,
IN EFI_BOOT_MODE  BootMode 
)

Verify and report pre-hashed FVs.

Doing this must be at post-memory to make sure there's enough memory to hold all FVs to be verified. This is necessary for mitigating TOCTOU issue.

This function will never return if the verification is failed.

Parameters
[in]PeiServicesGeneral purpose services available to every PEIM.
[in]BootModeCurrent boot mode.
Return values
EFI_SUCCESSThe function completed successfully.

Definition at line 360 of file FvReportPei.c.

◆ FindHashAlgInfo()

STATIC CONST HASH_ALG_INFO * FindHashAlgInfo ( IN UINT16  HashAlgId)

Find hash algorithm information from mHashAlgInfo according to given ID.

Parameters
[in]HashAlgIdHash algorithm type id.
Return values
Pointerto HASH_ALG_INFO if given hash algorithm is supported.
NULLif given algorithm is not supported.

Definition at line 28 of file FvReportPei.c.

◆ FvReportEntryPoint()

EFI_STATUS EFIAPI FvReportEntryPoint ( IN EFI_PEI_FILE_HANDLE  FileHandle,
IN CONST EFI_PEI_SERVICES **  PeiServices 
)

Main entry for FvReport PEIM.

Parameters
[in]FileHandleHandle of the file being invoked.
[in]PeiServicesPointer to PEI Services table.
Return values
EFI_SUCCESSIf all FVs reported by StoredHashFvPpi are verified.

Definition at line 444 of file FvReportPei.c.

◆ GetHashInfo()

STATIC FV_HASH_INFO * GetHashInfo ( IN EDKII_PEI_FIRMWARE_VOLUME_INFO_STORED_HASH_FV_PPI StoredHashFvPpi,
IN EFI_BOOT_MODE  BootMode 
)

Verify and report pre-hashed FVs.

Doing this must be at post-memory to make sure there's enough memory to hold all FVs to be verified. This is necessary for mitigating TOCTOU issue.

This function will never return if the verification is failed.

Parameters
[in]StoredHashFvPpiPointer to PPI containing hash information.
[in]BootModeCurrent boot mode.
Return values
Pointerto structure containing valid hash information for current boot mode.
NULLif there's no hash associated with current boot mode.

Definition at line 329 of file FvReportPei.c.

◆ InstallPreHashFvPpi()

STATIC VOID InstallPreHashFvPpi ( IN VOID *  FvBuffer,
IN UINTN  FvLength,
IN UINT16  HashAlgoId,
IN UINT16  HashSize,
IN UINT8 *  HashValue 
)

Install a EDKII_PEI_FIRMWARE_VOLUME_INFO_PREHASHED_FV_PPI instance so that TCG driver may use to extend PCRs.

Parameters
[in]FvBufferBuffer containing the whole FV.
[in]FvLengthLength of the FV.
[in]HashAlgoIdHash algorithm type id.
[in]HashSizeHash size.
[in]HashValueHash value buffer.

Definition at line 55 of file FvReportPei.c.

◆ ReportHashedFv()

STATIC VOID ReportHashedFv ( IN HASHED_FV_INFO FvInfo)

Report FV to PEI and/or DXE core for dispatch.

Parameters
[in]FvInfoInformation of a FV.

Definition at line 280 of file FvReportPei.c.

◆ VerifyHashedFv()

STATIC EFI_STATUS VerifyHashedFv ( IN FV_HASH_INFO HashInfo,
IN HASHED_FV_INFO FvInfo,
IN UINTN  FvNumber,
IN EFI_BOOT_MODE  BootMode 
)

Calculate and verify hash value for given FV.

Parameters
[in]HashInfoHash information of the FV.
[in]FvInfoInformation of FV used for verification.
[in]FvNumberLength of the FV.
[in]BootModeLength of the FV.
Return values
EFI_SUCCESSThe given FV is integrate.
EFI_VOLUME_CORRUPTEDThe given FV is corrupted (hash mismatch).
EFI_UNSUPPORTEDThe hash algorithm is not supported.

Definition at line 110 of file FvReportPei.c.

Variable Documentation

◆ mHashAlgInfo

STATIC CONST HASH_ALG_INFO mHashAlgInfo[]
Initial value:
= {
}
BOOLEAN EFIAPI Sha512HashAll(IN CONST VOID *Data, IN UINTN DataSize, OUT UINT8 *HashValue)
Definition: CryptSha512.c:427
BOOLEAN EFIAPI Sha512Final(IN OUT VOID *Sha512Context, OUT UINT8 *HashValue)
Definition: CryptSha512.c:389
BOOLEAN EFIAPI Sha512Init(OUT VOID *Sha512Context)
Definition: CryptSha512.c:270
#define SHA512_DIGEST_SIZE
Definition: BaseCryptLib.h:54
BOOLEAN EFIAPI Sha256Init(OUT VOID *Sha256Context)
Definition: CryptSha256.c:44
BOOLEAN EFIAPI Sha384HashAll(IN CONST VOID *Data, IN UINTN DataSize, OUT UINT8 *HashValue)
Definition: CryptSha512.c:201
BOOLEAN EFIAPI Sha256Final(IN OUT VOID *Sha256Context, OUT UINT8 *HashValue)
Definition: CryptSha256.c:161
#define SHA256_DIGEST_SIZE
Definition: BaseCryptLib.h:44
BOOLEAN EFIAPI Sha384Update(IN OUT VOID *Sha384Context, IN CONST VOID *Data, IN UINTN DataSize)
Definition: CryptSha512.c:115
BOOLEAN EFIAPI Sha256HashAll(IN CONST VOID *Data, IN UINTN DataSize, OUT UINT8 *HashValue)
Definition: CryptSha256.c:199
BOOLEAN EFIAPI Sha256Update(IN OUT VOID *Sha256Context, IN CONST VOID *Data, IN UINTN DataSize)
Definition: CryptSha256.c:113
BOOLEAN EFIAPI Sha384Final(IN OUT VOID *Sha384Context, OUT UINT8 *HashValue)
Definition: CryptSha512.c:163
BOOLEAN EFIAPI Sha384Init(OUT VOID *Sha384Context)
Definition: CryptSha512.c:44
BOOLEAN EFIAPI Sha512Update(IN OUT VOID *Sha512Context, IN CONST VOID *Data, IN UINTN DataSize)
Definition: CryptSha512.c:341
#define SHA384_DIGEST_SIZE
Definition: BaseCryptLib.h:49

Definition at line 11 of file FvReportPei.c.