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