Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[202405][Rebase&&FF] Everything MS Changes #311

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions SecurityPkg/Include/Library/Tpm2CommandLib.h
Original file line number Diff line number Diff line change
Expand Up @@ -1241,4 +1241,24 @@ Tpm2PcrReadForActiveBank (
OUT TPML_DIGEST *HashList
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Investigate Tianocore version of the different options for the PCR banks. If rotten throw away otherwise upstream

);

// MU_CHANGE [BEGIN]

/**
Check if all hash algorithms supported in HashAlgorithmMask are
present in the DigestList.

@param DigestList Digest list
@param HashAlgorithmMask Bitfield of allowed hash algorithms.

@retval TRUE All hash algorithms present.
@retval FALSE Some hash algorithms not present.
**/
BOOLEAN
IsDigestListInSyncWithHashAlgorithmMask (
IN TPML_DIGEST_VALUES *DigestList,
IN UINT32 HashAlgorithmMask
);

// MU_CHANGE [END]

#endif
81 changes: 81 additions & 0 deletions SecurityPkg/Library/Tpm2CommandLib/Tpm2Help.c
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,87 @@ IsHashAlgSupportedInHashAlgorithmMask (
return FALSE;
}

// MU_CHANGE [BEGIN]

/**
Check if DigestList has an entry for HashAlg.

@param DigestList Digest list.
@param HashAlg Hash algorithm id.

@retval TRUE Match found.
@retval FALSE No match found.
**/
BOOLEAN
CheckDigestListForHashAlg (
IN TPML_DIGEST_VALUES *DigestList,
IN TPM_ALG_ID HashAlg
)
{
UINT32 Index;

for (Index = 0; Index < DigestList->count; Index++) {
if (DigestList->digests[Index].hashAlg == HashAlg) {
DEBUG ((DEBUG_INFO, "Hash alg 0x%x found in DigestList.\n", HashAlg));
return TRUE;
}
}

DEBUG ((DEBUG_INFO, "Hash alg 0x%x not found in DigestList.\n", HashAlg));
return FALSE;
}

/**
Check if all hash algorithms supported in HashAlgorithmMask are
present in the DigestList.

@param DigestList Digest list.
@param HashAlgorithmMask Bitfield of allowed hash algorithms.

@retval TRUE All hash algorithms present.
@retval FALSE Some hash algorithms not present.
**/
BOOLEAN
IsDigestListInSyncWithHashAlgorithmMask (
IN TPML_DIGEST_VALUES *DigestList,
IN UINT32 HashAlgorithmMask
)
{
if ((HashAlgorithmMask & HASH_ALG_SHA1) != 0) {
if (!CheckDigestListForHashAlg (DigestList, TPM_ALG_SHA1)) {
return FALSE;
}
}

if ((HashAlgorithmMask & HASH_ALG_SHA256) != 0) {
if (!CheckDigestListForHashAlg (DigestList, TPM_ALG_SHA256)) {
return FALSE;
}
}

if ((HashAlgorithmMask & HASH_ALG_SHA384) != 0) {
if (!CheckDigestListForHashAlg (DigestList, TPM_ALG_SHA384)) {
return FALSE;
}
}

if ((HashAlgorithmMask & HASH_ALG_SHA512) != 0) {
if (!CheckDigestListForHashAlg (DigestList, TPM_ALG_SHA512)) {
return FALSE;
}
}

if ((HashAlgorithmMask & HASH_ALG_SM3_256) != 0) {
if (!CheckDigestListForHashAlg (DigestList, TPM_ALG_SM3_256)) {
return FALSE;
}
}

return TRUE;
}

// MU_CHANGE [END]

/**
Copy TPML_DIGEST_VALUES into a buffer

Expand Down