• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* SPDX-License-Identifier: BSD-2-Clause */
2 /***********************************************************************;
3  * Copyright (c) 2015 - 2017, Intel Corporation
4  * All rights reserved.
5  ***********************************************************************/
6 
7 #ifdef HAVE_CONFIG_H
8 #include <config.h>
9 #endif
10 
11 #include "tss2_tpm2_types.h"
12 #include "tss2_mu.h"
13 #include "sysapi_util.h"
14 
Tss2_Sys_FlushContext_Prepare(TSS2_SYS_CONTEXT * sysContext,TPMI_DH_CONTEXT flushHandle)15 TSS2_RC Tss2_Sys_FlushContext_Prepare(
16     TSS2_SYS_CONTEXT *sysContext,
17     TPMI_DH_CONTEXT flushHandle)
18 {
19     _TSS2_SYS_CONTEXT_BLOB *ctx = syscontext_cast(sysContext);
20     TSS2_RC rval;
21 
22     if (!ctx)
23         return TSS2_SYS_RC_BAD_REFERENCE;
24 
25     rval = CommonPreparePrologue(ctx, TPM2_CC_FlushContext);
26     if (rval)
27         return rval;
28     rval = Tss2_MU_UINT32_Marshal(flushHandle, ctx->cmdBuffer,
29                                   ctx->maxCmdSize,
30                                   &ctx->nextData);
31     if (rval)
32         return rval;
33 
34     ctx->decryptAllowed = 0;
35     ctx->encryptAllowed = 0;
36     ctx->authAllowed = 0;
37 
38     return CommonPrepareEpilogue(ctx);
39 }
40 
Tss2_Sys_FlushContext_Complete(TSS2_SYS_CONTEXT * sysContext)41 TSS2_RC Tss2_Sys_FlushContext_Complete (
42     TSS2_SYS_CONTEXT *sysContext)
43 {
44     _TSS2_SYS_CONTEXT_BLOB *ctx = syscontext_cast(sysContext);
45 
46     if (!ctx)
47         return TSS2_SYS_RC_BAD_REFERENCE;
48 
49     return CommonComplete(ctx);
50 }
51 
Tss2_Sys_FlushContext(TSS2_SYS_CONTEXT * sysContext,TPMI_DH_CONTEXT flushHandle)52 TSS2_RC Tss2_Sys_FlushContext(
53     TSS2_SYS_CONTEXT *sysContext,
54     TPMI_DH_CONTEXT flushHandle)
55 {
56     _TSS2_SYS_CONTEXT_BLOB *ctx = syscontext_cast(sysContext);
57     TSS2_RC rval;
58 
59     rval = Tss2_Sys_FlushContext_Prepare(sysContext, flushHandle);
60     if (rval)
61         return rval;
62 
63     rval = CommonOneCall(ctx, 0, 0);
64     if (rval)
65         return rval;
66 
67     return Tss2_Sys_FlushContext_Complete(sysContext);
68 }
69