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_SetCommandCodeAuditStatus_Prepare(TSS2_SYS_CONTEXT * sysContext,TPMI_RH_PROVISION auth,TPMI_ALG_HASH auditAlg,const TPML_CC * setList,const TPML_CC * clearList)15 TSS2_RC Tss2_Sys_SetCommandCodeAuditStatus_Prepare(
16 TSS2_SYS_CONTEXT *sysContext,
17 TPMI_RH_PROVISION auth,
18 TPMI_ALG_HASH auditAlg,
19 const TPML_CC *setList,
20 const TPML_CC *clearList)
21 {
22 _TSS2_SYS_CONTEXT_BLOB *ctx = syscontext_cast(sysContext);
23 TSS2_RC rval;
24
25 if (!ctx || !setList || !clearList)
26 return TSS2_SYS_RC_BAD_REFERENCE;
27
28 if (IsAlgorithmWeak(auditAlg, 0))
29 return TSS2_SYS_RC_BAD_VALUE;
30
31 rval = CommonPreparePrologue(ctx, TPM2_CC_SetCommandCodeAuditStatus);
32 if (rval)
33 return rval;
34
35 rval = Tss2_MU_UINT32_Marshal(auth, ctx->cmdBuffer,
36 ctx->maxCmdSize,
37 &ctx->nextData);
38 if (rval)
39 return rval;
40
41 rval = Tss2_MU_UINT16_Marshal(auditAlg, ctx->cmdBuffer,
42 ctx->maxCmdSize,
43 &ctx->nextData);
44 if (rval)
45 return rval;
46
47 rval = Tss2_MU_TPML_CC_Marshal(setList, ctx->cmdBuffer,
48 ctx->maxCmdSize,
49 &ctx->nextData);
50 if (rval)
51 return rval;
52
53 rval = Tss2_MU_TPML_CC_Marshal(clearList, ctx->cmdBuffer,
54 ctx->maxCmdSize,
55 &ctx->nextData);
56 if (rval)
57 return rval;
58
59 ctx->decryptAllowed = 0;
60 ctx->encryptAllowed = 0;
61 ctx->authAllowed = 1;
62
63 return CommonPrepareEpilogue(ctx);
64 }
65
Tss2_Sys_SetCommandCodeAuditStatus_Complete(TSS2_SYS_CONTEXT * sysContext)66 TSS2_RC Tss2_Sys_SetCommandCodeAuditStatus_Complete (
67 TSS2_SYS_CONTEXT *sysContext)
68 {
69 _TSS2_SYS_CONTEXT_BLOB *ctx = syscontext_cast(sysContext);
70
71 if (!ctx)
72 return TSS2_SYS_RC_BAD_REFERENCE;
73
74 return CommonComplete(ctx);
75 }
76
Tss2_Sys_SetCommandCodeAuditStatus(TSS2_SYS_CONTEXT * sysContext,TPMI_RH_PROVISION auth,TSS2L_SYS_AUTH_COMMAND const * cmdAuthsArray,TPMI_ALG_HASH auditAlg,const TPML_CC * setList,const TPML_CC * clearList,TSS2L_SYS_AUTH_RESPONSE * rspAuthsArray)77 TSS2_RC Tss2_Sys_SetCommandCodeAuditStatus(
78 TSS2_SYS_CONTEXT *sysContext,
79 TPMI_RH_PROVISION auth,
80 TSS2L_SYS_AUTH_COMMAND const *cmdAuthsArray,
81 TPMI_ALG_HASH auditAlg,
82 const TPML_CC *setList,
83 const TPML_CC *clearList,
84 TSS2L_SYS_AUTH_RESPONSE *rspAuthsArray)
85 {
86 _TSS2_SYS_CONTEXT_BLOB *ctx = syscontext_cast(sysContext);
87 TSS2_RC rval;
88
89 if (!setList || !clearList)
90 return TSS2_SYS_RC_BAD_REFERENCE;
91
92 rval = Tss2_Sys_SetCommandCodeAuditStatus_Prepare(sysContext, auth, auditAlg,
93 setList, clearList);
94 if (rval)
95 return rval;
96
97 rval = CommonOneCall(ctx, cmdAuthsArray, rspAuthsArray);
98 if (rval)
99 return rval;
100
101 return Tss2_Sys_SetCommandCodeAuditStatus_Complete(sysContext);
102 }
103