aboutsummaryrefslogtreecommitdiff
path: root/FlushContext.c
blob: 2d1f09b113cbdd3754a26d3321ab2fdee200b763 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
// This file was extracted from the TCG Published
// Trusted Platform Module Library
// Part 3: Commands
// Family "2.0"
// Level 00 Revision 01.16
// October 30, 2014

#include "InternalRoutines.h"
#include "FlushContext_fp.h"
//
//
//     Error Returns                     Meaning
//
//     TPM_RC_HANDLE                     flushHandle does not reference a loaded object or session
//
TPM_RC
TPM2_FlushContext(
   FlushContext_In       *in                  // IN: input parameter list
   )
{
// Internal Data Update

   // Call object or session specific routine to flush
   switch(HandleGetType(in->flushHandle))
   {
   case TPM_HT_TRANSIENT:
       if(!ObjectIsPresent(in->flushHandle))
           return TPM_RC_HANDLE;
       // Flush object
       ObjectFlush(in->flushHandle);
       break;
   case TPM_HT_HMAC_SESSION:
   case TPM_HT_POLICY_SESSION:
       if(   !SessionIsLoaded(in->flushHandle)
          && !SessionIsSaved(in->flushHandle)
         )
           return TPM_RC_HANDLE;

       // If the session to be flushed is the exclusive audit session, then
       // indicate that there is no exclusive audit session any longer.
       if(in->flushHandle == g_exclusiveAuditSession)
           g_exclusiveAuditSession = TPM_RH_UNASSIGNED;

       // Flush session
       SessionFlush(in->flushHandle);
       break;
   default:
       // This command only take object or session handle.              Other handles
       // should be filtered out at handle unmarshal
       pAssert(FALSE);
       break;
   }

   return TPM_RC_SUCCESS;
}