TianoCore EDK2 master
Loading...
Searching...
No Matches
HashLibBaseCryptoRouterCommon.c
Go to the documentation of this file.
1
9#include <PiPei.h>
10#include <Library/BaseLib.h>
13#include <Library/DebugLib.h>
15#include <Library/HashLib.h>
17
18typedef struct {
19 EFI_GUID Guid;
20 UINT32 Mask;
22
23TPM2_HASH_MASK mTpm2HashMask[] = {
24 { HASH_ALGORITHM_SHA1_GUID, HASH_ALG_SHA1 },
25 { HASH_ALGORITHM_SHA256_GUID, HASH_ALG_SHA256 },
26 { HASH_ALGORITHM_SHA384_GUID, HASH_ALG_SHA384 },
27 { HASH_ALGORITHM_SHA512_GUID, HASH_ALG_SHA512 },
28 { HASH_ALGORITHM_SM3_256_GUID, HASH_ALG_SM3_256 },
29};
30
38UINT32
39EFIAPI
41 IN EFI_GUID *HashGuid
42 )
43{
44 UINTN Index;
45
46 for (Index = 0; Index < sizeof (mTpm2HashMask)/sizeof (mTpm2HashMask[0]); Index++) {
47 if (CompareGuid (HashGuid, &mTpm2HashMask[Index].Guid)) {
48 return mTpm2HashMask[Index].Mask;
49 }
50 }
51
52 return 0;
53}
54
61VOID
62EFIAPI
64 IN OUT TPML_DIGEST_VALUES *DigestList,
66 )
67{
68 CopyMem (
69 &DigestList->digests[DigestList->count],
70 &Digest->digests[0],
71 sizeof (Digest->digests[0])
72 );
73 DigestList->count++;
74}
UINT64 UINTN
VOID *EFIAPI CopyMem(OUT VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
BOOLEAN EFIAPI CompareGuid(IN CONST GUID *Guid1, IN CONST GUID *Guid2)
Definition: MemLibGuid.c:73
UINT32 EFIAPI Tpm2GetHashMaskFromAlgo(IN EFI_GUID *HashGuid)
VOID EFIAPI Tpm2SetHashToDigestList(IN OUT TPML_DIGEST_VALUES *DigestList, IN TPML_DIGEST_VALUES *Digest)
#define IN
Definition: Base.h:279
#define OUT
Definition: Base.h:284
Definition: Base.h:213