| // This file was extracted from the TCG Published |
| // Trusted Platform Module Library |
| // Level 00 Revision 01.16 |
| #include "InternalRoutines.h" |
| #include "PCR_SetAuthPolicy_fp.h" |
| // TPM_RC_SIZE size of authPolicy is not the size of a digest produced by policyDigest |
| // TPM_RC_VALUE PCR referenced by pcrNum is not a member of a PCR policy group |
| PCR_SetAuthPolicy_In *in // IN: input parameter list |
| // The command needs NV update. Check if NV is available. |
| // A TPM_RC_NV_UNAVAILABLE or TPM_RC_NV_RATE error may be returned at |
| result = NvIsAvailable(); |
| if(result != TPM_RC_SUCCESS) return result; |
| // Check the authPolicy consistent with hash algorithm |
| if(in->authPolicy.t.size != CryptGetHashDigestSize(in->hashAlg)) |
| return TPM_RC_SIZE + RC_PCR_SetAuthPolicy_authPolicy; |
| // If PCR does not belong to a policy group, return TPM_RC_VALUE |
| if(!PCRBelongsPolicyGroup(in->pcrNum, &groupIndex)) |
| return TPM_RC_VALUE + RC_PCR_SetAuthPolicy_pcrNum; |
| gp.pcrPolicies.hashAlg[groupIndex] = in->hashAlg; |
| gp.pcrPolicies.policy[groupIndex] = in->authPolicy; |
| NvWriteReserved(NV_PCR_POLICIES, &gp.pcrPolicies); |