• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // This file was extracted from the TCG Published
2 // Trusted Platform Module Library
3 // Part 3: Commands
4 // Family "2.0"
5 // Level 00 Revision 01.16
6 // October 30, 2014
7 
8 #include "InternalRoutines.h"
9 #include "PolicyAuthValue_fp.h"
10 #include "Policy_spt_fp.h"
11 TPM_RC
TPM2_PolicyAuthValue(PolicyAuthValue_In * in)12 TPM2_PolicyAuthValue(
13    PolicyAuthValue_In    *in            // IN: input parameter list
14    )
15 {
16    SESSION               *session;
17    TPM_CC                 commandCode = TPM_CC_PolicyAuthValue;
18    HASH_STATE             hashState;
19 
20 // Internal Data Update
21 
22    // Get pointer to the session structure
23    session = SessionGet(in->policySession);
24 
25    // Update policy hash
26    // policyDigestnew = hash(policyDigestold || TPM_CC_PolicyAuthValue)
27    //   Start hash
28    CryptStartHash(session->authHashAlg, &hashState);
29 
30    // add old digest
31    CryptUpdateDigest2B(&hashState, &session->u2.policyDigest.b);
32 
33    // add commandCode
34    CryptUpdateDigestInt(&hashState, sizeof(TPM_CC), &commandCode);
35 
36    // complete the hash and get the results
37    CryptCompleteHash2B(&hashState, &session->u2.policyDigest.b);
38 
39    // update isAuthValueNeeded bit in the session context
40    session->attributes.isAuthValueNeeded = SET;
41    session->attributes.isPasswordNeeded = CLEAR;
42 
43    return TPM_RC_SUCCESS;
44 }
45