• 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 "FlushContext_fp.h"
10 //
11 //
12 //     Error Returns                     Meaning
13 //
14 //     TPM_RC_HANDLE                     flushHandle does not reference a loaded object or session
15 //
16 TPM_RC
TPM2_FlushContext(FlushContext_In * in)17 TPM2_FlushContext(
18    FlushContext_In       *in                  // IN: input parameter list
19    )
20 {
21 // Internal Data Update
22 
23    // Call object or session specific routine to flush
24    switch(HandleGetType(in->flushHandle))
25    {
26    case TPM_HT_TRANSIENT:
27        if(!ObjectIsPresent(in->flushHandle))
28            return TPM_RC_HANDLE;
29        // Flush object
30        ObjectFlush(in->flushHandle);
31        break;
32    case TPM_HT_HMAC_SESSION:
33    case TPM_HT_POLICY_SESSION:
34        if(   !SessionIsLoaded(in->flushHandle)
35           && !SessionIsSaved(in->flushHandle)
36          )
37            return TPM_RC_HANDLE;
38 
39        // If the session to be flushed is the exclusive audit session, then
40        // indicate that there is no exclusive audit session any longer.
41        if(in->flushHandle == g_exclusiveAuditSession)
42            g_exclusiveAuditSession = TPM_RH_UNASSIGNED;
43 
44        // Flush session
45        SessionFlush(in->flushHandle);
46        break;
47    default:
48        // This command only take object or session handle.              Other handles
49        // should be filtered out at handle unmarshal
50        pAssert(FALSE);
51        break;
52    }
53 
54    return TPM_RC_SUCCESS;
55 }
56