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_EventSequenceComplete_Prepare(TSS2_SYS_CONTEXT * sysContext,TPMI_DH_PCR pcrHandle,TPMI_DH_OBJECT sequenceHandle,const TPM2B_MAX_BUFFER * buffer)15 TSS2_RC Tss2_Sys_EventSequenceComplete_Prepare(
16 TSS2_SYS_CONTEXT *sysContext,
17 TPMI_DH_PCR pcrHandle,
18 TPMI_DH_OBJECT sequenceHandle,
19 const TPM2B_MAX_BUFFER *buffer)
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_EventSequenceComplete);
28 if (rval)
29 return rval;
30
31 rval = Tss2_MU_UINT32_Marshal(pcrHandle, ctx->cmdBuffer,
32 ctx->maxCmdSize,
33 &ctx->nextData);
34 if (rval)
35 return rval;
36
37 rval = Tss2_MU_UINT32_Marshal(sequenceHandle, ctx->cmdBuffer,
38 ctx->maxCmdSize,
39 &ctx->nextData);
40 if (rval)
41 return rval;
42
43 if (!buffer) {
44 rval = Tss2_MU_UINT16_Marshal(0, ctx->cmdBuffer,
45 ctx->maxCmdSize,
46 &ctx->nextData);
47
48 } else {
49
50 rval = Tss2_MU_TPM2B_MAX_BUFFER_Marshal(buffer, ctx->cmdBuffer,
51 ctx->maxCmdSize,
52 &ctx->nextData);
53 }
54
55 if (rval)
56 return rval;
57
58 ctx->decryptAllowed = 1;
59 ctx->encryptAllowed = 0;
60 ctx->authAllowed = 1;
61
62 return CommonPrepareEpilogue(ctx);
63 }
64
Tss2_Sys_EventSequenceComplete_Complete(TSS2_SYS_CONTEXT * sysContext,TPML_DIGEST_VALUES * results)65 TSS2_RC Tss2_Sys_EventSequenceComplete_Complete(
66 TSS2_SYS_CONTEXT *sysContext,
67 TPML_DIGEST_VALUES *results)
68 {
69 _TSS2_SYS_CONTEXT_BLOB *ctx = syscontext_cast(sysContext);
70 TSS2_RC rval;
71
72 if (!ctx)
73 return TSS2_SYS_RC_BAD_REFERENCE;
74
75 rval = CommonComplete(ctx);
76 if (rval)
77 return rval;
78
79 return Tss2_MU_TPML_DIGEST_VALUES_Unmarshal(ctx->cmdBuffer,
80 ctx->maxCmdSize,
81 &ctx->nextData, results);
82 }
83
Tss2_Sys_EventSequenceComplete(TSS2_SYS_CONTEXT * sysContext,TPMI_DH_PCR pcrHandle,TPMI_DH_OBJECT sequenceHandle,TSS2L_SYS_AUTH_COMMAND const * cmdAuthsArray,const TPM2B_MAX_BUFFER * buffer,TPML_DIGEST_VALUES * results,TSS2L_SYS_AUTH_RESPONSE * rspAuthsArray)84 TSS2_RC Tss2_Sys_EventSequenceComplete(
85 TSS2_SYS_CONTEXT *sysContext,
86 TPMI_DH_PCR pcrHandle,
87 TPMI_DH_OBJECT sequenceHandle,
88 TSS2L_SYS_AUTH_COMMAND const *cmdAuthsArray,
89 const TPM2B_MAX_BUFFER *buffer,
90 TPML_DIGEST_VALUES *results,
91 TSS2L_SYS_AUTH_RESPONSE *rspAuthsArray)
92 {
93 _TSS2_SYS_CONTEXT_BLOB *ctx = syscontext_cast(sysContext);
94 TSS2_RC rval;
95
96 rval = Tss2_Sys_EventSequenceComplete_Prepare(sysContext, pcrHandle,
97 sequenceHandle, buffer);
98 if (rval)
99 return rval;
100
101 rval = CommonOneCall(ctx, cmdAuthsArray, rspAuthsArray);
102 if (rval)
103 return rval;
104
105 return Tss2_Sys_EventSequenceComplete_Complete(sysContext, results);
106 }
107