rev180: Use IsCpHashUnionOccupied to convert non-trivial case

Use IsCpHashUnionOccupied to convert a non-trivial case.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
This commit is contained in:
Stefan Berger 2023-12-27 12:01:08 -05:00 committed by Stefan Berger
parent 4f1c4f5886
commit d902ce42f8

View File

@ -1496,14 +1496,12 @@ TPM2_PolicyTemplate(PolicyTemplate_In* in // IN: input parameter list
// Get pointer to the session structure
session = SessionGet(in->policySession);
// If the template is set, make sure that it is the same as the input value
if(session->attributes.isTemplateHashDefined)
{
if(!MemoryEqual2B(&in->templateHash.b, &session->u1.cpHash.b))
return TPM_RCS_VALUE + RC_PolicyTemplate_templateHash;
}
// error if cpHash contains something that is not a template
else if(session->u1.templateHash.t.size != 0)
// error if the templateHash in session context is not empty and is not the
// same as the input or is not a template
if((IsCpHashUnionOccupied(session->attributes))
&& (!session->attributes.isTemplateHashDefined
|| !MemoryEqual2B(&in->templateHash.b, &session->u1.templateHash.b)))
return TPM_RC_CPHASH;
// A valid templateHash must have the same size as session hash digest