TPMLIB\_ChooseTPMVersion(3) TPMLIB\_ChooseTPMVersion(3)

# [NAME](#NAME)

TPMLIB\_ChooseTPMVersion - Choose the version of the TPM

# [SYNOPSIS](#SYNOPSIS)

**#include &lt;libtpms/tpm\_types.h**&gt;

**#include &lt;libtpms/tpm\_library.h**&gt;

**TPM\_RESULT TPMLIB\_ChooseTPMVersion(TPMLIB\_TPMVersion** *ver);*

```
 typedef enum TPMLIB_TPMVersion {
    TPMLIB_TPM_VERSION_1_2,
    TPMLIB_TPM_VERSION_2,
 } TPMLIB_TPMVersion;
```

# [DESCRIPTION](#DESCRIPTION)

The **TPMLIB\_ChooseTPMVersion()** function is used to choose the version of the TPM, either a TPM 1.2 or TPM 2.

This function must be called before **TPMLIB\_MainInit()** is called and will otherwise return an error. This function may be called again once **TPMLIB\_Terminate()** has been called.

If this function is not called, the last chosen TPM version will be started with **TPMLIB\_MainInit()**. If this function is not called, a TPM 1.2 will be used.

# [ERRORS](#ERRORS)

[**TPM\_SUCCESS**](#TPM_SUCCESS)

The version of the TPM was chosen successfully.

[**TPM\_FAIL**](#TPM_FAIL)

The choice of the TPM was wrong, or **TPMLIB\_MainInit()** has already been called.

For a complete list of TPM error codes please consult the include file **libtpms/tpm\_error.h**

# [SEE ALSO](#SEE_ALSO)

[**TPMLIB\_MainInit**(3)](/man/enterprise-packages/libtpms/TPMLIB_MainInit.3), [**TPMLIB\_Terminate**(3)](/man/enterprise-packages/libtpms/TPMLIB_Terminate.3)

2026-10-01 libtpms

---

Document: TPMLIB_ChooseTPMVersion(3) from libtpms 0.10.2-r3 (Chainguard OS)
Source: https://github.com/stefanberger/libtpms
