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