SecurityPkg: Add TCG PFP 1.06 support.
Add new api Tpm2ExtendNvIndex. It is uesd in HashCompleteAndExtend when PcrIndex > MAX_PCR_INDEX. Cc: Jiewen Yao <jiewen.yao@intel.com> Cc: Rahul Kumar <rahul1.kumar@intel.com> Signed-off-by: Wenxing Hou <wenxing.hou@intel.com> Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
This commit is contained in:
committed by
mergify[bot]
parent
d8e4c4b000
commit
c3f615a1bd
@@ -3,7 +3,7 @@
|
||||
hash handler registered, such as SHA1, SHA256.
|
||||
Platform can use PcdTpm2HashMask to mask some hash engines.
|
||||
|
||||
Copyright (c) 2013 - 2021, Intel Corporation. All rights reserved. <BR>
|
||||
Copyright (c) 2013 - 2024, Intel Corporation. All rights reserved. <BR>
|
||||
SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
|
||||
**/
|
||||
@@ -16,6 +16,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
#include <Library/MemoryAllocationLib.h>
|
||||
#include <Library/PcdLib.h>
|
||||
#include <Library/HashLib.h>
|
||||
#include <Protocol/Tcg2Protocol.h>
|
||||
|
||||
#include "HashLibBaseCryptoRouterCommon.h"
|
||||
|
||||
@@ -128,6 +129,49 @@ HashUpdate (
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
/**
|
||||
Extend to TPM NvIndex.
|
||||
|
||||
@param[in] NvIndex The NV Index of the area to extend.
|
||||
@param[in] DataSize The data size to extend.
|
||||
@param[in] Data The data to extend.
|
||||
|
||||
@retval EFI_SUCCESS Operation completed successfully.
|
||||
@retval EFI_DEVICE_ERROR The command was unsuccessful.
|
||||
@retval EFI_NOT_FOUND The command was returned successfully, but NvIndex is not found.
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
Tpm2ExtendNvIndex (
|
||||
TPMI_RH_NV_INDEX NvIndex,
|
||||
UINT16 DataSize,
|
||||
BYTE *Data
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
TPMI_RH_NV_AUTH AuthHandle;
|
||||
TPM2B_MAX_BUFFER NvExtendData;
|
||||
|
||||
AuthHandle = TPM_RH_PLATFORM;
|
||||
ZeroMem (&NvExtendData, sizeof (NvExtendData));
|
||||
CopyMem (NvExtendData.buffer, Data, DataSize);
|
||||
NvExtendData.size = DataSize;
|
||||
Status = Tpm2NvExtend (
|
||||
AuthHandle,
|
||||
NvIndex,
|
||||
NULL,
|
||||
&NvExtendData
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
DEBUG (
|
||||
(DEBUG_ERROR, "Extend TPM NV index failed, Index: 0x%x Status: %d\n",
|
||||
NvIndex, Status)
|
||||
);
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
/**
|
||||
Hash sequence complete and extend to PCR.
|
||||
|
||||
@@ -149,11 +193,16 @@ HashCompleteAndExtend (
|
||||
OUT TPML_DIGEST_VALUES *DigestList
|
||||
)
|
||||
{
|
||||
TPML_DIGEST_VALUES Digest;
|
||||
HASH_HANDLE *HashCtx;
|
||||
UINTN Index;
|
||||
EFI_STATUS Status;
|
||||
UINT32 HashMask;
|
||||
TPML_DIGEST_VALUES Digest;
|
||||
HASH_HANDLE *HashCtx;
|
||||
UINTN Index;
|
||||
EFI_STATUS Status;
|
||||
UINT32 HashMask;
|
||||
TPML_DIGEST_VALUES TcgPcrEvent2Digest;
|
||||
EFI_TCG2_EVENT_ALGORITHM_BITMAP TpmHashAlgorithmBitmap;
|
||||
UINT32 ActivePcrBanks;
|
||||
UINT32 *BufferPtr;
|
||||
UINT32 DigestListBinSize;
|
||||
|
||||
if (mHashInterfaceCount == 0) {
|
||||
return EFI_UNSUPPORTED;
|
||||
@@ -175,10 +224,29 @@ HashCompleteAndExtend (
|
||||
|
||||
FreePool (HashCtx);
|
||||
|
||||
Status = Tpm2PcrExtend (
|
||||
PcrIndex,
|
||||
DigestList
|
||||
);
|
||||
if (PcrIndex <= MAX_PCR_INDEX) {
|
||||
Status = Tpm2PcrExtend (
|
||||
PcrIndex,
|
||||
DigestList
|
||||
);
|
||||
} else {
|
||||
Status = Tpm2GetCapabilitySupportedAndActivePcrs (&TpmHashAlgorithmBitmap, &ActivePcrBanks);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
ActivePcrBanks = ActivePcrBanks & mSupportedHashMaskCurrent;
|
||||
ZeroMem (&TcgPcrEvent2Digest, sizeof (TcgPcrEvent2Digest));
|
||||
BufferPtr = CopyDigestListToBuffer (&TcgPcrEvent2Digest, DigestList, ActivePcrBanks);
|
||||
DigestListBinSize = (UINT32)((UINT8 *)BufferPtr - (UINT8 *)&TcgPcrEvent2Digest);
|
||||
|
||||
//
|
||||
// Extend to TPM NvIndex
|
||||
//
|
||||
Status = Tpm2ExtendNvIndex (
|
||||
PcrIndex,
|
||||
(UINT16)DigestListBinSize,
|
||||
(BYTE *)&TcgPcrEvent2Digest
|
||||
);
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user