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