mirror of
https://git.proxmox.com/git/mirror_edk2
synced 2025-10-06 10:12:47 +00:00

This reverts commit542d04e2a4
. The reason is that said commit indirectly depends on commit49c1e683c4
("MdePkg/Protocol/Hash: introduce GUID for SM3", 2019-07-03), and the latter commit is going to be reverted, due to its review process not having followed established edk2 norms. Cc: Chao Zhang <chao.b.zhang@intel.com> Cc: Imran Desai <imran.desai@intel.com> Cc: Jian Wang <jian.j.wang@intel.com> Cc: Jiewen Yao <jiewen.yao@intel.com> Cc: Leif Lindholm <leif.lindholm@linaro.org> Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=1781 Signed-off-by: Laszlo Ersek <lersek@redhat.com> Reviewed-by: Leif Lindholm <leif.lindholm@linaro.org> Reviewed-by: Philippe Mathieu-Daude <philmd@redhat.com>
72 lines
1.6 KiB
C
72 lines
1.6 KiB
C
/** @file
|
|
This is BaseCrypto router support function.
|
|
|
|
Copyright (c) 2013 - 2016, Intel Corporation. All rights reserved. <BR>
|
|
SPDX-License-Identifier: BSD-2-Clause-Patent
|
|
|
|
**/
|
|
|
|
#include <PiPei.h>
|
|
#include <Library/BaseLib.h>
|
|
#include <Library/BaseMemoryLib.h>
|
|
#include <Library/Tpm2CommandLib.h>
|
|
#include <Library/DebugLib.h>
|
|
#include <Library/MemoryAllocationLib.h>
|
|
#include <Library/HashLib.h>
|
|
#include <Protocol/Tcg2Protocol.h>
|
|
|
|
typedef struct {
|
|
EFI_GUID Guid;
|
|
UINT32 Mask;
|
|
} TPM2_HASH_MASK;
|
|
|
|
TPM2_HASH_MASK mTpm2HashMask[] = {
|
|
{HASH_ALGORITHM_SHA1_GUID, HASH_ALG_SHA1},
|
|
{HASH_ALGORITHM_SHA256_GUID, HASH_ALG_SHA256},
|
|
{HASH_ALGORITHM_SHA384_GUID, HASH_ALG_SHA384},
|
|
{HASH_ALGORITHM_SHA512_GUID, HASH_ALG_SHA512},
|
|
};
|
|
|
|
/**
|
|
The function get hash mask info from algorithm.
|
|
|
|
@param HashGuid Hash Guid
|
|
|
|
@return HashMask
|
|
**/
|
|
UINT32
|
|
EFIAPI
|
|
Tpm2GetHashMaskFromAlgo (
|
|
IN EFI_GUID *HashGuid
|
|
)
|
|
{
|
|
UINTN Index;
|
|
for (Index = 0; Index < sizeof(mTpm2HashMask)/sizeof(mTpm2HashMask[0]); Index++) {
|
|
if (CompareGuid (HashGuid, &mTpm2HashMask[Index].Guid)) {
|
|
return mTpm2HashMask[Index].Mask;
|
|
}
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
/**
|
|
The function set digest to digest list.
|
|
|
|
@param DigestList digest list
|
|
@param Digest digest data
|
|
**/
|
|
VOID
|
|
EFIAPI
|
|
Tpm2SetHashToDigestList (
|
|
IN OUT TPML_DIGEST_VALUES *DigestList,
|
|
IN TPML_DIGEST_VALUES *Digest
|
|
)
|
|
{
|
|
CopyMem (
|
|
&DigestList->digests[DigestList->count],
|
|
&Digest->digests[0],
|
|
sizeof(Digest->digests[0])
|
|
);
|
|
DigestList->count ++;
|
|
}
|