1 /* SPDX-License-Identifier: BSD-2-Clause */ 2 /***********************************************************************; 3 * Copyright (c) 2015 - 2018, 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_GetCpBuffer(TSS2_SYS_CONTEXT * sysContext,size_t * cpBufferUsedSize,const uint8_t ** cpBuffer)15TSS2_RC Tss2_Sys_GetCpBuffer( 16 TSS2_SYS_CONTEXT *sysContext, 17 size_t *cpBufferUsedSize, 18 const uint8_t **cpBuffer) 19 { 20 _TSS2_SYS_CONTEXT_BLOB *ctx = syscontext_cast(sysContext); 21 22 if (!ctx || !cpBufferUsedSize || !cpBuffer) 23 return TSS2_SYS_RC_BAD_REFERENCE; 24 25 if (ctx->previousStage != CMD_STAGE_PREPARE) 26 return TSS2_SYS_RC_BAD_SEQUENCE; 27 28 *cpBuffer = ctx->cpBuffer; 29 *cpBufferUsedSize = ctx->cpBufferUsedSize; 30 31 return TSS2_RC_SUCCESS; 32 } 33