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_GetContextSize(size_t maxCommandSize)15 size_t Tss2_Sys_GetContextSize(size_t maxCommandSize)
16 {
17     if (maxCommandSize == 0) {
18         return sizeof(_TSS2_SYS_CONTEXT_BLOB) + TPM2_MAX_COMMAND_SIZE;
19     } else {
20         return sizeof(_TSS2_SYS_CONTEXT_BLOB) +
21                      ((maxCommandSize > sizeof(TPM20_Header_In)) ?
22                        maxCommandSize : sizeof(TPM20_Header_In));
23     }
24 }
25