esys_int.h
/* SPDX-License-Identifier: BSD-2-Clause */
/*******************************************************************************
* Copyright 2017, Fraunhofer SIT sponsored by Infineon Technologies AG
* All rights reserved.
*******************************************************************************/
#ifndef ESYS_INT_H
#define ESYS_INT_H
#include <stdint.h>
#include "esys_crypto.h"
#include "esys_types.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef struct RSRC_NODE_T {
ESYS_TR esys_handle;
TPM2B_AUTH auth;
IESYS_RESOURCE rsrc;
size_t reference_count;
struct RSRC_NODE_T * next;
} RSRC_NODE_T;
typedef struct {
ESYS_TR tpmKey;
ESYS_TR bind;
TPM2_SE sessionType;
TPMI_ALG_HASH authHash;
TPM2B_NONCE *nonceCaller;
TPM2B_NONCE nonceCallerData;
TPMT_SYM_DEF *symmetric;
TPMT_SYM_DEF symmetricData;
} StartAuthSession_IN;
typedef struct {
TPM2B_SENSITIVE_CREATE *inSensitive;
TPM2B_SENSITIVE_CREATE inSensitiveData;
} CreatePrimary_IN;
typedef struct {
TPM2B_SENSITIVE_CREATE *inSensitive;
TPM2B_SENSITIVE_CREATE inSensitiveData;
} Create_IN;
typedef struct {
ESYS_TR saveHandle;
} ContextSave_IN;
typedef struct {
TPMS_CONTEXT *context;
TPMS_CONTEXT contextData;
} ContextLoad_IN;
typedef struct {
TPM2B_PUBLIC *inPublic;
TPM2B_PUBLIC inPublicData;
} Load_IN;
typedef struct {
TPM2B_PUBLIC *inPublic;
TPM2B_PUBLIC inPublicData;
} LoadExternal_IN;
typedef struct {
TPM2B_SENSITIVE_CREATE *inSensitive;
TPM2B_SENSITIVE_CREATE inSensitiveData;
TPM2B_TEMPLATE *inPublic;
TPM2B_TEMPLATE inPublicData;
} CreateLoaded_IN;
typedef struct {
ESYS_TR objectHandle;
TPMI_DH_PERSISTENT persistentHandle;
} EvictControl_IN;
typedef struct {
TPM2B_AUTH authData;
} HMAC_Start_IN;
typedef HMAC_Start_IN MAC_Start_IN;
typedef struct {
ESYS_TR authHandle;
TPM2B_AUTH newAuth;
} HierarchyChangeAuth_IN;
typedef struct {
ESYS_TR sequenceHandle;
} SequenceComplete_IN;
typedef struct {
ESYS_TR policySession;
} Policy_IN;
typedef struct {
ESYS_TR nvIndex;
TPM2B_AUTH authData;
TPM2B_NV_PUBLIC *publicInfo;
TPM2B_NV_PUBLIC publicInfoData;
} NV_IN;
typedef struct {
ESYS_TR flushHandle;
} FlushContext_IN;
typedef struct {
ESYS_TR pcrHandle;
TPM2B_AUTH authData;
} PCR_IN;
typedef union {
StartAuthSession_IN StartAuthSession;
CreatePrimary_IN CreatePrimary;
Create_IN Create;
ContextSave_IN ContextSave;
ContextLoad_IN ContextLoad;
Load_IN Load;
LoadExternal_IN LoadExternal;
CreateLoaded_IN CreateLoaded;
EvictControl_IN EvictControl;
HMAC_Start_IN HMAC_Start;
MAC_Start_IN MAC_Start;
HierarchyChangeAuth_IN HierarchyChangeAuth;
SequenceComplete_IN SequenceComplete;
Policy_IN Policy;
NV_IN NV;
FlushContext_IN FlushContext;
PCR_IN PCR;
} IESYS_CMD_IN_PARAM;
enum _ESYS_STATE {
_ESYS_STATE_INIT = 0,
_ESYS_STATE_SENT,
_ESYS_STATE_RESUBMISSION,
_ESYS_STATE_INTERNALERROR
};
struct ESYS_CONTEXT {
enum _ESYS_STATE state;
TSS2_SYS_CONTEXT *sys;
ESYS_TR esys_handle_cnt;
RSRC_NODE_T *rsrc_list;
int32_t timeout;
ESYS_TR session_type[3];
RSRC_NODE_T *session_tab[3];
int encryptNonceIdx;
TPM2B_NONCE *encryptNonce;
int authsCount;
int submissionCount;
TPM2B_DATA salt;
IESYS_CMD_IN_PARAM in;
ESYS_TR esys_handle;
TSS2_TCTI_CONTEXT *tcti_app_param;
void *dlhandle;
IESYS_SESSION *enc_session;
ESYS_TR sav_session1;
ESYS_TR sav_session2;
ESYS_TR sav_session3;
ESYS_CRYPTO_CALLBACKS crypto_backend;
};
#define _ESYS_MAX_SUBMISSIONS 5
#define _ESYS_ASSERT_NON_NULL(x) \
if (x == NULL) { \
LOG_ERROR(str(x) " == NULL."); \
return TSS2_ESYS_RC_BAD_REFERENCE; \
}
#ifdef __cplusplus
}
#endif
#endif /* ESYS_INT_H */
ESYS_TR
uint32_t ESYS_TR
Definition tss2_esys.h:16
RSRC_NODE_T::reference_count
size_t reference_count
Definition esys_int.h:27
ESYS_CONTEXT::enc_session
IESYS_SESSION * enc_session
Definition esys_int.h:191
ESYS_CONTEXT::timeout
int32_t timeout
Definition esys_int.h:168
ESYS_CONTEXT::encryptNonceIdx
int encryptNonceIdx
Definition esys_int.h:174
ESYS_CONTEXT::in
IESYS_CMD_IN_PARAM in
Definition esys_int.h:182
ESYS_CONTEXT::tcti_app_param
TSS2_TCTI_CONTEXT * tcti_app_param
Definition esys_int.h:186
RSRC_NODE_T::rsrc
IESYS_RESOURCE rsrc
Definition esys_int.h:26
ESYS_CONTEXT::state
enum _ESYS_STATE state
Definition esys_int.h:163
ESYS_CONTEXT::dlhandle
void * dlhandle
Definition esys_int.h:189
ESYS_CONTEXT::sys
TSS2_SYS_CONTEXT * sys
Definition esys_int.h:164
ESYS_CONTEXT::session_tab
RSRC_NODE_T * session_tab[3]
Definition esys_int.h:172
RSRC_NODE_T::next
struct RSRC_NODE_T * next
Definition esys_int.h:28
RSRC_NODE_T::esys_handle
ESYS_TR esys_handle
Definition esys_int.h:23
ESYS_CONTEXT::esys_handle_cnt
ESYS_TR esys_handle_cnt
Definition esys_int.h:166
RSRC_NODE_T::auth
TPM2B_AUTH auth
Definition esys_int.h:25
ESYS_CONTEXT::session_type
ESYS_TR session_type[3]
Definition esys_int.h:170
ESYS_CONTEXT::rsrc_list
RSRC_NODE_T * rsrc_list
Definition esys_int.h:167
ESYS_CONTEXT::crypto_backend
ESYS_CRYPTO_CALLBACKS crypto_backend
Definition esys_int.h:199
ESYS_CONTEXT::encryptNonce
TPM2B_NONCE * encryptNonce
Definition esys_int.h:175
ESYS_CONTEXT::sav_session1
ESYS_TR sav_session1
Definition esys_int.h:193
ESYS_CONTEXT::submissionCount
int submissionCount
Definition esys_int.h:179
ESYS_CONTEXT::authsCount
int authsCount
Definition esys_int.h:177
ESYS_CONTEXT::salt
TPM2B_DATA salt
Definition esys_int.h:181
ESYS_CONTEXT
Definition esys_int.h:162
IESYS_RESOURCE
Definition esys_types.h:86
IESYS_SESSION
Definition esys_types.h:51
RSRC_NODE_T
Definition esys_int.h:22
ESYS_CRYPTO_CALLBACKS
Definition tss2_esys.h:416