OpenCore  1.0.4
OpenCore Bootloader
Loading...
Searching...
No Matches
Measurement.c File Reference
#include <PiDxe.h>
#include <Guid/ImageAuthentication.h>
#include <IndustryStandard/UefiTcgPlatform.h>
#include <Library/UefiBootServicesTableLib.h>
#include <Library/UefiRuntimeServicesTableLib.h>
#include <Library/MemoryAllocationLib.h>
#include <Library/BaseMemoryLib.h>
#include <Library/DebugLib.h>
#include <Library/BaseLib.h>
#include <Library/TpmMeasurementLib.h>
#include "PrivilegePolymorphic.h"

Go to the source code of this file.

Data Structures

struct  VARIABLE_TYPE
 

Functions

BOOLEAN IsSecureBootPolicyVariable (IN CHAR16 *VariableName, IN EFI_GUID *VendorGuid)
 
EFI_STATUS EFIAPI MeasureVariable (IN CHAR16 *VarName, IN EFI_GUID *VendorGuid, IN VOID *VarData, IN UINTN VarSize)
 
EFI_STATUS InternalGetVariable (IN CONST CHAR16 *Name, IN CONST EFI_GUID *Guid, OUT VOID **Value, OUT UINTN *Size)
 
VOID EFIAPI SecureBootHook (IN CHAR16 *VariableName, IN EFI_GUID *VendorGuid)
 
VOID EFIAPI RecordSecureBootPolicyVarData (VOID)
 

Variables

VARIABLE_TYPE mVariableType []
 
UINT8 * mSecureBootVarData = NULL
 
UINTN mSecureBootVarDataSize = 0
 

Detailed Description

Measure TCG required variable.

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

Definition in file Measurement.c.

Function Documentation

◆ InternalGetVariable()

EFI_STATUS InternalGetVariable ( IN CONST CHAR16 * Name,
IN CONST EFI_GUID * Guid,
OUT VOID ** Value,
OUT UINTN * Size )

Returns the status whether get the variable success. The function retrieves variable through the UEFI Runtime Service GetVariable(). The returned buffer is allocated using AllocatePool(). The caller is responsible for freeing this buffer with FreePool().

This API is only invoked in boot time. It may NOT be invoked at runtime.

Parameters
[in]NameThe pointer to a Null-terminated Unicode string.
[in]GuidThe pointer to an EFI_GUID structure
[out]ValueThe buffer point saved the variable info.
[out]SizeThe buffer size of the variable.
Returns
EFI_OUT_OF_RESOURCES Allocate buffer failed.
EFI_SUCCESS Find the specified variable.
Others Errors Return errors from call to gRT->GetVariable.

Definition at line 160 of file Measurement.c.

◆ IsSecureBootPolicyVariable()

BOOLEAN IsSecureBootPolicyVariable ( IN CHAR16 * VariableName,
IN EFI_GUID * VendorGuid )

This function will return if this variable is SecureBootPolicy Variable.

Parameters
[in]VariableNameA Null-terminated string that is the name of the vendor's variable.
[in]VendorGuidA unique identifier for the vendor.
Return values
TRUEThis is SecureBootPolicy Variable
FALSEThis is not SecureBootPolicy Variable

Definition at line 54 of file Measurement.c.

◆ MeasureVariable()

EFI_STATUS EFIAPI MeasureVariable ( IN CHAR16 * VarName,
IN EFI_GUID * VendorGuid,
IN VOID * VarData,
IN UINTN VarSize )

Measure and log an EFI variable, and extend the measurement result into a specific PCR.

Parameters
[in]VarNameA Null-terminated string that is the name of the vendor's variable.
[in]VendorGuidA unique identifier for the vendor.
[in]VarDataThe content of the variable data.
[in]VarSizeThe size of the variable data.
Return values
EFI_SUCCESSOperation completed successfully.
EFI_OUT_OF_RESOURCESOut of memory.
EFI_DEVICE_ERRORThe operation was unsuccessful.

Definition at line 87 of file Measurement.c.

◆ RecordSecureBootPolicyVarData()

VOID EFIAPI RecordSecureBootPolicyVarData ( VOID )

Some Secure Boot Policy Variable may update following other variable changes(SecureBoot follows PK change, etc). Record their initial State when variable write service is ready.

Definition at line 321 of file Measurement.c.

◆ SecureBootHook()

VOID EFIAPI SecureBootHook ( IN CHAR16 * VariableName,
IN EFI_GUID * VendorGuid )

SecureBoot Hook for SetVariable.

Parameters
[in]VariableNameName of Variable to be found.
[in]VendorGuidVariable vendor GUID.

Definition at line 218 of file Measurement.c.

Variable Documentation

◆ mSecureBootVarData

UINT8* mSecureBootVarData = NULL

Definition at line 41 of file Measurement.c.

◆ mSecureBootVarDataSize

UINTN mSecureBootVarDataSize = 0

Definition at line 42 of file Measurement.c.

◆ mVariableType

VARIABLE_TYPE mVariableType[]
Initial value:
= {
{ EFI_SECURE_BOOT_MODE_NAME, &gEfiGlobalVariableGuid },
{ EFI_PLATFORM_KEY_NAME, &gEfiGlobalVariableGuid },
{ EFI_KEY_EXCHANGE_KEY_NAME, &gEfiGlobalVariableGuid },
{ EFI_IMAGE_SECURITY_DATABASE, &gEfiImageSecurityDatabaseGuid },
{ EFI_IMAGE_SECURITY_DATABASE1, &gEfiImageSecurityDatabaseGuid },
{ EFI_IMAGE_SECURITY_DATABASE2, &gEfiImageSecurityDatabaseGuid },
}
EFI_GUID gEfiGlobalVariableGuid

Definition at line 28 of file Measurement.c.