mirror of https://github.com/acidanthera/audk.git
1.Measure ACPI table data comes from flash event type EV_POST_CODE ACPI DATA to PCR[0]
2.Re-measure ACPI table after fix up with event type EV_EFI_HANDOFF_TABLES to PCR[1] Signed-off-by : Chao Zhang<chao.b.zhang@intel.com> Reviewed-by : Dong Guo<guo.dong@intel.com> Reviewed-by : Yao Jiewen<jiewen.yao@intel.com> git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@13964 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
parent
2096185d2a
commit
a332cfd308
|
@ -0,0 +1,45 @@
|
|||
/** @file
|
||||
This library is used by other modules to measure data to TPM.
|
||||
|
||||
Copyright (c) 2012, Intel Corporation. All rights reserved. <BR>
|
||||
This program and the accompanying materials
|
||||
are licensed and made available under the terms and conditions of the BSD License
|
||||
which accompanies this distribution. The full text of the license may be found at
|
||||
http://opensource.org/licenses/bsd-license.php
|
||||
|
||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
|
||||
**/
|
||||
|
||||
#ifndef _TPM_MEASUREMENT_LIB_H_
|
||||
#define _TPM_MEASUREMENT_LIB_H_
|
||||
|
||||
/**
|
||||
Tpm measure and log data, and extend the measurement result into a specific PCR.
|
||||
|
||||
@param[in] PcrIndex PCR Index.
|
||||
@param[in] EventType Event type.
|
||||
@param[in] EventLog Measurement event log.
|
||||
@param[in] LogLen Event log length in bytes.
|
||||
@param[in] HashData The start of the data buffer to be hashed, extended.
|
||||
@param[in] HashDataLen The length, in bytes, of the buffer referenced by HashData
|
||||
|
||||
@retval EFI_SUCCESS Operation completed successfully.
|
||||
@retval EFI_UNSUPPORTED TPM device not available.
|
||||
@retval EFI_OUT_OF_RESOURCES Out of memory.
|
||||
@retval EFI_DEVICE_ERROR The operation was unsuccessful.
|
||||
**/
|
||||
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
TpmMeasureAndLogData (
|
||||
IN UINT32 PcrIndex,
|
||||
IN UINT32 EventType,
|
||||
IN VOID *EventLog,
|
||||
IN UINT32 LogLen,
|
||||
IN VOID *HashData,
|
||||
IN UINT64 HashDataLen
|
||||
);
|
||||
|
||||
#endif
|
|
@ -0,0 +1,139 @@
|
|||
/** @file
|
||||
This library is used by other modules to measure data to TPM.
|
||||
|
||||
Copyright (c) 2012, Intel Corporation. All rights reserved. <BR>
|
||||
This program and the accompanying materials
|
||||
are licensed and made available under the terms and conditions of the BSD License
|
||||
which accompanies this distribution. The full text of the license may be found at
|
||||
http://opensource.org/licenses/bsd-license.php
|
||||
|
||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
|
||||
**/
|
||||
|
||||
#include <PiDxe.h>
|
||||
|
||||
#include <Protocol/TcgService.h>
|
||||
|
||||
#include <Library/BaseMemoryLib.h>
|
||||
#include <Library/MemoryAllocationLib.h>
|
||||
#include <Library/UefiBootServicesTableLib.h>
|
||||
#include <Library/DebugLib.h>
|
||||
#include <Library/TpmMeasurementLib.h>
|
||||
|
||||
#include <Guid/Acpi.h>
|
||||
#include <IndustryStandard/Acpi.h>
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Tpm12 measure and log data, and extend the measurement result into a specific PCR.
|
||||
|
||||
@param[in] PcrIndex PCR Index.
|
||||
@param[in] EventType Event type.
|
||||
@param[in] EventLog Measurement event log.
|
||||
@param[in] LogLen Event log length in bytes.
|
||||
@param[in] HashData The start of the data buffer to be hashed, extended.
|
||||
@param[in] HashDataLen The length, in bytes, of the buffer referenced by HashData
|
||||
|
||||
@retval EFI_SUCCESS Operation completed successfully.
|
||||
@retval EFI_UNSUPPORTED TPM device not available.
|
||||
@retval EFI_OUT_OF_RESOURCES Out of memory.
|
||||
@retval EFI_DEVICE_ERROR The operation was unsuccessful.
|
||||
**/
|
||||
|
||||
EFI_STATUS
|
||||
Tpm12MeasureAndLogData (
|
||||
IN UINT32 PcrIndex,
|
||||
IN UINT32 EventType,
|
||||
IN VOID *EventLog,
|
||||
IN UINT32 LogLen,
|
||||
IN VOID *HashData,
|
||||
IN UINT64 HashDataLen
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
EFI_TCG_PROTOCOL *TcgProtocol;
|
||||
TCG_PCR_EVENT *TcgEvent;
|
||||
EFI_PHYSICAL_ADDRESS EventLogLastEntry;
|
||||
UINT32 EventNumber;
|
||||
|
||||
TcgEvent = NULL;
|
||||
|
||||
//
|
||||
// Tpm active/deactive state is checked in HashLogExtendEvent
|
||||
//
|
||||
Status = gBS->LocateProtocol (&gEfiTcgProtocolGuid, NULL, (VOID **) &TcgProtocol);
|
||||
if (EFI_ERROR(Status)){
|
||||
return Status;
|
||||
}
|
||||
|
||||
TcgEvent = (TCG_PCR_EVENT *)AllocateZeroPool (sizeof (TCG_PCR_EVENT_HDR) + LogLen);
|
||||
if(TcgEvent == NULL) {
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
TcgEvent->PCRIndex = PcrIndex;
|
||||
TcgEvent->EventType = EventType;
|
||||
TcgEvent->EventSize = LogLen;
|
||||
CopyMem (&TcgEvent->Event[0], EventLog, LogLen);
|
||||
EventNumber = 1;
|
||||
Status = TcgProtocol->HashLogExtendEvent (
|
||||
TcgProtocol,
|
||||
(EFI_PHYSICAL_ADDRESS)(UINTN)HashData,
|
||||
HashDataLen,
|
||||
TPM_ALG_SHA,
|
||||
TcgEvent,
|
||||
&EventNumber,
|
||||
&EventLogLastEntry
|
||||
);
|
||||
|
||||
FreePool (TcgEvent);
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
/**
|
||||
Tpm measure and log data, and extend the measurement result into a specific PCR.
|
||||
|
||||
@param[in] PcrIndex PCR Index.
|
||||
@param[in] EventType Event type.
|
||||
@param[in] EventLog Measurement event log.
|
||||
@param[in] LogLen Event log length in bytes.
|
||||
@param[in] HashData The start of the data buffer to be hashed, extended.
|
||||
@param[in] HashDataLen The length, in bytes, of the buffer referenced by HashData
|
||||
|
||||
@retval EFI_SUCCESS Operation completed successfully.
|
||||
@retval EFI_UNSUPPORTED TPM device not available.
|
||||
@retval EFI_OUT_OF_RESOURCES Out of memory.
|
||||
@retval EFI_DEVICE_ERROR The operation was unsuccessful.
|
||||
**/
|
||||
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
TpmMeasureAndLogData (
|
||||
IN UINT32 PcrIndex,
|
||||
IN UINT32 EventType,
|
||||
IN VOID *EventLog,
|
||||
IN UINT32 LogLen,
|
||||
IN VOID *HashData,
|
||||
IN UINT64 HashDataLen
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
|
||||
//
|
||||
// Try to measure using Tpm1.2 protocol
|
||||
//
|
||||
Status = Tpm12MeasureAndLogData(
|
||||
PcrIndex,
|
||||
EventType,
|
||||
EventLog,
|
||||
LogLen,
|
||||
HashData,
|
||||
HashDataLen
|
||||
);
|
||||
|
||||
return Status;
|
||||
}
|
|
@ -0,0 +1,43 @@
|
|||
## @file
|
||||
# This library is used by other modules to measure data to TPM 1.2.
|
||||
#
|
||||
# Copyright (c) 2012, Intel Corporation. All rights reserved.<BR>
|
||||
# This program and the accompanying materials
|
||||
# are licensed and made available under the terms and conditions of the BSD License
|
||||
# which accompanies this distribution. The full text of the license may be found at
|
||||
# http://opensource.org/licenses/bsd-license.php
|
||||
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
#
|
||||
##
|
||||
|
||||
[Defines]
|
||||
INF_VERSION = 0x00010005
|
||||
BASE_NAME = DxeTpmMeasurementLib
|
||||
FILE_GUID = 30930D10-AF5B-4abf-80E6-EB4FFC0AE9D1
|
||||
MODULE_TYPE = UEFI_DRIVER
|
||||
VERSION_STRING = 1.0
|
||||
LIBRARY_CLASS = TpmMeasurementLib|DXE_DRIVER DXE_RUNTIME_DRIVER DXE_SAL_DRIVER DXE_SMM_DRIVER UEFI_APPLICATION UEFI_DRIVER
|
||||
|
||||
#
|
||||
# The following information is for reference only and not required by the build tools.
|
||||
#
|
||||
# VALID_ARCHITECTURES = IA32 X64 IPF
|
||||
#
|
||||
|
||||
[Sources]
|
||||
DxeTpmMeasurementLib.c
|
||||
|
||||
[Packages]
|
||||
MdePkg/MdePkg.dec
|
||||
SecurityPkg/SecurityPkg.dec
|
||||
|
||||
[LibraryClasses]
|
||||
BaseLib
|
||||
BaseMemoryLib
|
||||
DebugLib
|
||||
MemoryAllocationLib
|
||||
UefiBootServicesTableLib
|
||||
|
||||
[Protocols]
|
||||
gEfiTcgProtocolGuid
|
|
@ -50,6 +50,7 @@
|
|||
TpmCommLib|SecurityPkg/Library/TpmCommLib/TpmCommLib.inf
|
||||
PlatformSecureLib|SecurityPkg/Library/PlatformSecureLibNull/PlatformSecureLibNull.inf
|
||||
TcgPhysicalPresenceLib|SecurityPkg/Library/DxeTcgPhysicalPresenceLib/DxeTcgPhysicalPresenceLib.inf
|
||||
TpmMeasurementLib|SecurityPkg/Library/DxeTpmMeasurementLib/DxeTpmMeasurementLib.inf
|
||||
|
||||
[LibraryClasses.common.PEIM]
|
||||
PeimEntryPoint|MdePkg/Library/PeimEntryPoint/PeimEntryPoint.inf
|
||||
|
|
|
@ -309,6 +309,20 @@ PublishAcpiTable (
|
|||
);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
|
||||
|
||||
//
|
||||
// Measure to PCR[0] with event EV_POST_CODE ACPI DATA
|
||||
//
|
||||
TpmMeasureAndLogData(
|
||||
0,
|
||||
EV_POST_CODE,
|
||||
EV_POSTCODE_INFO_ACPI_DATA,
|
||||
ACPI_DATA_LEN,
|
||||
Table,
|
||||
TableSize
|
||||
);
|
||||
|
||||
|
||||
ASSERT (Table->OemTableId == SIGNATURE_64 ('T', 'c', 'g', 'T', 'a', 'b', 'l', 'e'));
|
||||
mTcgNvs = AssignOpRegion (Table, SIGNATURE_32 ('T', 'N', 'V', 'S'), (UINT16) sizeof (TCG_NVS));
|
||||
ASSERT (mTcgNvs != NULL);
|
||||
|
|
|
@ -17,8 +17,11 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
|||
|
||||
#include <PiDxe.h>
|
||||
#include <IndustryStandard/Acpi.h>
|
||||
#include <IndustryStandard/UefiTcgPlatform.h>
|
||||
|
||||
#include <Guid/PhysicalPresenceData.h>
|
||||
#include <Guid/MemoryOverwriteControl.h>
|
||||
|
||||
#include <Protocol/SmmSwDispatch2.h>
|
||||
#include <Protocol/AcpiTable.h>
|
||||
#include <Protocol/SmmVariable.h>
|
||||
|
@ -30,6 +33,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
|||
#include <Library/UefiDriverEntryPoint.h>
|
||||
#include <Library/UefiBootServicesTableLib.h>
|
||||
#include <Library/DxeServicesLib.h>
|
||||
#include <Library/TpmMeasurementLib.h>
|
||||
|
||||
#pragma pack(1)
|
||||
typedef struct {
|
||||
|
|
|
@ -44,6 +44,7 @@
|
|||
UefiBootServicesTableLib
|
||||
DebugLib
|
||||
DxeServicesLib
|
||||
TpmMeasurementLib
|
||||
|
||||
[Guids]
|
||||
gEfiPhysicalPresenceGuid
|
||||
|
|
Loading…
Reference in New Issue