• 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_EvictControl_Prepare(TSS2_SYS_CONTEXT * sysContext,TPMI_RH_PROVISION auth,TPMI_DH_OBJECT objectHandle,TPMI_DH_PERSISTENT persistentHandle)15 TSS2_RC Tss2_Sys_EvictControl_Prepare(
16     TSS2_SYS_CONTEXT *sysContext,
17     TPMI_RH_PROVISION auth,
18     TPMI_DH_OBJECT objectHandle,
19     TPMI_DH_PERSISTENT persistentHandle)
20 {
21     _TSS2_SYS_CONTEXT_BLOB *ctx = syscontext_cast(sysContext);
22     TSS2_RC rval;
23 
24     if (!ctx)
25         return TSS2_SYS_RC_BAD_REFERENCE;
26 
27     rval = CommonPreparePrologue(ctx, TPM2_CC_EvictControl);
28     if (rval)
29         return rval;
30 
31     rval = Tss2_MU_UINT32_Marshal(auth, ctx->cmdBuffer,
32                                   ctx->maxCmdSize,
33                                   &ctx->nextData);
34     if (rval)
35         return rval;
36 
37     rval = Tss2_MU_UINT32_Marshal(objectHandle, ctx->cmdBuffer,
38                                   ctx->maxCmdSize,
39                                   &ctx->nextData);
40     if (rval)
41         return rval;
42 
43     rval = Tss2_MU_UINT32_Marshal(persistentHandle, ctx->cmdBuffer,
44                                   ctx->maxCmdSize,
45                                   &ctx->nextData);
46     if (rval)
47         return rval;
48 
49     ctx->decryptAllowed = 0;
50     ctx->encryptAllowed = 0;
51     ctx->authAllowed = 1;
52 
53     return CommonPrepareEpilogue(ctx);
54 }
55 
Tss2_Sys_EvictControl_Complete(TSS2_SYS_CONTEXT * sysContext)56 TSS2_RC Tss2_Sys_EvictControl_Complete (
57     TSS2_SYS_CONTEXT *sysContext)
58 {
59     _TSS2_SYS_CONTEXT_BLOB *ctx = syscontext_cast(sysContext);
60 
61     if (!ctx)
62         return TSS2_SYS_RC_BAD_REFERENCE;
63 
64     return CommonComplete(ctx);
65 }
66 
Tss2_Sys_EvictControl(TSS2_SYS_CONTEXT * sysContext,TPMI_RH_PROVISION auth,TPMI_DH_OBJECT objectHandle,TSS2L_SYS_AUTH_COMMAND const * cmdAuthsArray,TPMI_DH_PERSISTENT persistentHandle,TSS2L_SYS_AUTH_RESPONSE * rspAuthsArray)67 TSS2_RC Tss2_Sys_EvictControl(
68     TSS2_SYS_CONTEXT *sysContext,
69     TPMI_RH_PROVISION auth,
70     TPMI_DH_OBJECT objectHandle,
71     TSS2L_SYS_AUTH_COMMAND const *cmdAuthsArray,
72     TPMI_DH_PERSISTENT persistentHandle,
73     TSS2L_SYS_AUTH_RESPONSE *rspAuthsArray)
74 {
75     _TSS2_SYS_CONTEXT_BLOB *ctx = syscontext_cast(sysContext);
76     TSS2_RC rval;
77 
78     rval = Tss2_Sys_EvictControl_Prepare(sysContext, auth, objectHandle,
79                                          persistentHandle);
80     if (rval)
81         return rval;
82 
83     rval = CommonOneCall(ctx, cmdAuthsArray, rspAuthsArray);
84     if (rval)
85         return rval;
86 
87     return Tss2_Sys_EvictControl_Complete(sysContext);
88 }
89