tpm2: Add missing check for disallowed SHA1 HMAC creation

CryptSelectMac is called (only) from TPM2_HMAC and TPM2_Mac_Start and needs
to check whether the creation of an HMAC with SHA1 is not allowed per the
profile attribute no-sha1-hmac-creation and/or no-sha1-hmac.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
This commit is contained in:
Stefan Berger 2026-03-19 15:45:05 -04:00
parent 77104fbfbd
commit b9eee494b7

View File

@ -1961,6 +1961,12 @@ CryptSelectMac(TPMT_PUBLIC* publicArea, TPMI_ALG_MAC_SCHEME* inMac)
}
if(!CryptMacIsValidForKey(publicArea->type, *inMac, FALSE))
return TPM_RCS_SCHEME;
if(macAlg == TPM_ALG_SHA1 && // libtpms added begin
RuntimeProfileRequiresAttributeFlags(&g_RuntimeProfile,
RUNTIME_ATTRIBUTE_NO_SHA1_HMAC_CREATION))
return TPM_RC_HASH; // libtpms added end
return TPM_RC_SUCCESS;
}