/** @file\r
- Ihis library is BaseCrypto router. It will redirect hash request to each individual\r
+ This library is BaseCrypto router. It will redirect hash request to each individual\r
hash handler registerd, such as SHA1, SHA256.\r
Platform can use PcdTpm2HashMask to mask some hash engines.\r
\r
-Copyright (c) 2013, Intel Corporation. All rights reserved. <BR>\r
+Copyright (c) 2013 - 2016, Intel Corporation. All rights reserved. <BR>\r
This program and the accompanying materials\r
are licensed and made available under the terms and conditions of the BSD License\r
which accompanies this distribution. The full text of the license may be found at\r
HASH_INTERFACE_HOB *HashInterfaceHob;\r
HASH_HANDLE *HashCtx;\r
UINTN Index;\r
+ UINT32 HashMask;\r
\r
HashInterfaceHob = InternalGetHashInterface ();\r
if (HashInterfaceHob == NULL) {\r
ASSERT (HashCtx != NULL);\r
\r
for (Index = 0; Index < HashInterfaceHob->HashInterfaceCount; Index++) {\r
- HashInterfaceHob->HashInterface[Index].HashInit (&HashCtx[Index]);\r
+ HashMask = Tpm2GetHashMaskFromAlgo (&HashInterfaceHob->HashInterface[Index].HashGuid);\r
+ if ((HashMask & PcdGet32 (PcdTpm2HashMask)) != 0) {\r
+ HashInterfaceHob->HashInterface[Index].HashInit (&HashCtx[Index]);\r
+ }\r
}\r
\r
*HashHandle = (HASH_HANDLE)HashCtx;\r
HASH_INTERFACE_HOB *HashInterfaceHob;\r
HASH_HANDLE *HashCtx;\r
UINTN Index;\r
+ UINT32 HashMask;\r
\r
HashInterfaceHob = InternalGetHashInterface ();\r
if (HashInterfaceHob == NULL) {\r
HashCtx = (HASH_HANDLE *)HashHandle;\r
\r
for (Index = 0; Index < HashInterfaceHob->HashInterfaceCount; Index++) {\r
- HashInterfaceHob->HashInterface[Index].HashUpdate (HashCtx[Index], DataToHash, DataToHashLen);\r
+ HashMask = Tpm2GetHashMaskFromAlgo (&HashInterfaceHob->HashInterface[Index].HashGuid);\r
+ if ((HashMask & PcdGet32 (PcdTpm2HashMask)) != 0) {\r
+ HashInterfaceHob->HashInterface[Index].HashUpdate (HashCtx[Index], DataToHash, DataToHashLen);\r
+ }\r
}\r
\r
return EFI_SUCCESS;\r
HASH_HANDLE *HashCtx;\r
UINTN Index;\r
EFI_STATUS Status;\r
+ UINT32 HashMask;\r
\r
HashInterfaceHob = InternalGetHashInterface ();\r
if (HashInterfaceHob == NULL) {\r
ZeroMem (DigestList, sizeof(*DigestList));\r
\r
for (Index = 0; Index < HashInterfaceHob->HashInterfaceCount; Index++) {\r
- HashInterfaceHob->HashInterface[Index].HashUpdate (HashCtx[Index], DataToHash, DataToHashLen);\r
- HashInterfaceHob->HashInterface[Index].HashFinal (HashCtx[Index], &Digest);\r
- Tpm2SetHashToDigestList (DigestList, &Digest);\r
+ HashMask = Tpm2GetHashMaskFromAlgo (&HashInterfaceHob->HashInterface[Index].HashGuid);\r
+ if ((HashMask & PcdGet32 (PcdTpm2HashMask)) != 0) {\r
+ HashInterfaceHob->HashInterface[Index].HashUpdate (HashCtx[Index], DataToHash, DataToHashLen);\r
+ HashInterfaceHob->HashInterface[Index].HashFinal (HashCtx[Index], &Digest);\r
+ Tpm2SetHashToDigestList (DigestList, &Digest);\r
+ }\r
}\r
\r
FreePool (HashCtx);\r
HASH_INTERFACE_HOB *HashInterfaceHob;\r
HASH_INTERFACE_HOB LocalHashInterfaceHob;\r
UINT32 HashMask;\r
+ UINT32 BiosSupportedHashMask;\r
+ EFI_STATUS Status;\r
\r
//\r
// Check allow\r
if (HashInterfaceHob->HashInterfaceCount >= HASH_COUNT) {\r
return EFI_OUT_OF_RESOURCES;\r
}\r
+ BiosSupportedHashMask = PcdGet32 (PcdTcg2HashAlgorithmBitmap);\r
+ Status = PcdSet32S (PcdTcg2HashAlgorithmBitmap, BiosSupportedHashMask | HashMask);\r
+ ASSERT_EFI_ERROR (Status);\r
\r
//\r
// Check duplication\r
//\r
// In PEI phase, there will be shadow driver dispatched again.\r
//\r
- DEBUG ((EFI_D_ERROR, "RegisterHashInterfaceLib - Override\n"));\r
+ DEBUG ((EFI_D_INFO, "RegisterHashInterfaceLib - Override\n"));\r
CopyMem (&HashInterfaceHob->HashInterface[Index], HashInterface, sizeof(*HashInterface));\r
return EFI_SUCCESS;\r
}\r