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 "PolicyPassword_fp.h"
10#include "Policy_spt_fp.h"
11TPM_RC
12TPM2_PolicyPassword(
13   PolicyPassword_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 digest
37   CryptCompleteHash2B(&hashState, &session->u2.policyDigest.b);
38
39   // Update isPasswordNeeded bit
40   session->attributes.isPasswordNeeded = SET;
41   session->attributes.isAuthValueNeeded = CLEAR;
42
43   return TPM_RC_SUCCESS;
44}
45