---
name: "ESYS_CONTEXT"
section: "3"
platform: "linux"
package: "tpm2-tss"
version: "4.2.0-2"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/ESYS_CONTEXT"
---

# ESYS\_CONTEXT(3)

Esys Context ESYS\_CONTEXT

## NAME

ESYS\_CONTEXT - Esys Context ESYS\_CONTEXT

## SYNOPSIS

### Typedefs

typedef struct ESYS\_CONTEXT **ESYS\_CONTEXT**\

### Functions

TSS2\_RC **Esys\_Initialize** (**ESYS\_CONTEXT** \*\*esys\_context, TSS2\_TCTI\_CONTEXT \*tcti, TSS2\_ABI\_VERSION \*abiVersion)\
 TSS2\_RC **Esys\_GetTcti** (**ESYS\_CONTEXT** \*esys\_context, TSS2\_TCTI\_CONTEXT \*\*tcti)\
 TSS2\_RC **Esys\_GetPollHandles** (**ESYS\_CONTEXT** \*esys\_context, TSS2\_TCTI\_POLL\_HANDLE \*\*handles, size\_t \*count)\
 TSS2\_RC **Esys\_SetTimeout** (**ESYS\_CONTEXT** \*esys\_context, int32\_t timeout)\
 TSS2\_RC **Esys\_GetSysContext** (**ESYS\_CONTEXT** \*esys\_context, TSS2\_SYS\_CONTEXT \*\*sys\_context)\
 TSS2\_RC **Esys\_SetCryptoCallbacks** (**ESYS\_CONTEXT** \*esysContext, **ESYS\_CRYPTO\_CALLBACKS** \*callbacks)\
 void **Esys\_Free** (void \*ptr)\

## Detailed Description

An **ESYS\_CONTEXT** holds tdata for the connection to the TPM as well as the metadata for TPM Resource; such as Transient key, Persistent objects, NV spaces, Sessions or PCRs.

## Typedef Documentation

### typedef struct ESYS\_CONTEXT ESYS\_CONTEXT

Reference to the **ESYS\_CONTEXT** that holds data for the connection to the TPM as well as the metadata for TPM Resource; such as Transient key, Persistent objects, NV spaces, Sessions or PCRs.

## Function Documentation

### TSS2\_RC Esys\_GetPollHandles (ESYS\_CONTEXT \* esys\_context, TSS2\_TCTI\_POLL\_HANDLE \*\* handles, size\_t \* count)

Return the poll handles of the used TCTI.

The connection to the TPM is held using a TCTI. These may optionally provide handles that can be used to poll for incoming data. This is useful when using the asynchronous function of ESAPI in an event-loop model.

**Parameters**

*esys\_context* \[in\] The **ESYS\_CONTEXT**. \
 *handles* \[out\] The poll handles (callee-allocated, use free()) \
 *count* \[out\] The number of poll handles.

**Return values**

*TSS2\_RC\_SUCCESS* on Success. \
 *TSS2\_ESYS\_RC\_BAD\_REFERENCE* if esysContext, handles or count is NULL. \
 *TSS2\_RCs* produced by lower layers of the software stack.

### TSS2\_RC Esys\_GetSysContext (ESYS\_CONTEXT \* esys\_context, TSS2\_SYS\_CONTEXT \*\* sys\_context)

Helper function that returns sys contest from the give esys context.

Function returns sys contest from the give esys context.

**Parameters**

*esys\_context* \[in\] ESYS context. \
 *sys\_context* \[out\] SYS context.

**Return values**

*TSS2\_RC\_SUCCESS* on Success. \
 *TSS2\_ESYS\_RC\_BAD\_REFERENCE* if esys\_context of sys\_context are NULL.

### TSS2\_RC Esys\_GetTcti (ESYS\_CONTEXT \* esys\_context, TSS2\_TCTI\_CONTEXT \*\* tcti)

Return the used TCTI context.

If a tcti context was passed into Esys\_Initialize then this tcti context is return. If NULL was passed in, then NULL will be returned. This function is useful before Esys\_Finalize to retrieve the tcti context and perform a clean Tss2\_Tcti\_Finalize.

**Parameters**

*esys\_context* \[in\] The **ESYS\_CONTEXT**. \
 *tcti* \[out\] The TCTI context used to connect to the TPM (may be NULL).

**Return values**

*TSS2\_RC\_SUCCESS* on Success. \
 *TSS2\_ESYS\_RC\_BAD\_REFERENCE* if esysContext or tcti is NULL.

### TSS2\_RC Esys\_Initialize (ESYS\_CONTEXT \*\* esys\_context, TSS2\_TCTI\_CONTEXT \* tcti, TSS2\_ABI\_VERSION \* abiVersion)

Initialize an **ESYS\_CONTEXT** for further use.

Initialize an **ESYS\_CONTEXT** that holds all the state and metadata information during an interaction with the TPM. If not specified, load a TCTI in this order: Library libtss2-tcti-default.so (link to the preferred TCTI) Library libtss2-tcti-tabrmd.so (tabrmd) Device /dev/tpmrm0 (kernel resident resource manager) Device /dev/tpm0 (hardware TPM) Device /dev/tcm0 (hardware TCM) TCP socket localhost:2321 (TPM simulator)

**Parameters**

*esys\_context* \[out\] The **ESYS\_CONTEXT**. \
 *tcti* \[in\] The TCTI context used to connect to the TPM (may be NULL). \
 *abiVersion* \[in,out\] The abi version to check and the abi version supported by this implementation (may be NULL).

**Return values**

*TSS2\_ESYS\_RC\_SUCCESS* if the function call was a success. \
 *TSS2\_ESYS\_RC\_BAD\_REFERENCE* if esysContext is NULL. \
 *TSS2\_ESYS\_RC\_MEMORY* if the ESAPI cannot allocate enough memory to create the context. \
 *TSS2\_RCs* produced by lower layers of the software stack may be returned to the caller unaltered unless handled internally.

### TSS2\_RC Esys\_SetCryptoCallbacks (ESYS\_CONTEXT \* esysContext, ESYS\_CRYPTO\_CALLBACKS \* callbacks)

Set Crypto Callbacks

This is an advanced functionality that should be used with caution and by those who know exactly what they are doing. This function provides the ability to set and restore to the original state, the cryptographic callbacks that ESAPI uses internally. This is useful for custom builds where runtime configurable cryptography is beneficial over a configure time, --with-crypto=\<ossl\|mbed\> backend.

**Parameters**

*esysContext* The **ESYS\_CONTEXT**. \
 *callbacks* The user define crypto callbacks or NULL for a reset to the ./configure time state.

**Return values**

*TSS2\_ESYS\_RC\_BAD\_REFERENCE* is esysContext is NULL. \
 *TSS2\_TSS2\_ESYS\_RC\_CALLBACK\_NULL* if a required callback pointer is NULL. \
 *USER\_DEFINED* user defined errors if the user callback fails.

**Note**

If ./configure --with-crypto=none, ESAPI functions that need crypto will fail with TSS2\_TSS2\_ESYS\_RC\_CALLBACK\_NULL until the application registers callbacks. Under the same scenario, It will also fail if the application resets the state back to the original state.

### TSS2\_RC Esys\_SetTimeout (ESYS\_CONTEXT \* esys\_context, int32\_t timeout)

Set the timeout of Esys asynchronous functions.

Sets the timeout for the \_finish() functions in the asynchronous versions of the Esys commands.

**Parameters**

*esys\_context* \[in\] The **ESYS\_CONTEXT**. \
 *timeout* \[in\] The timeout in ms or -1 to block indefinately.

**Return values**

*TSS2\_RC\_SUCCESS* on Success. \
 *TSS2\_ESYS\_RC\_BAD\_REFERENCE* if esysContext is NULL.

## Author

Generated automatically by Doxygen for tpm2-tss from the source code.
