TPMLIB\_Process(3) TPMLIB\_Process(3)

# [NAME](#NAME)

TPMLIB\_Process - process a TPM command

# [LIBRARY](#LIBRARY)

TPM library (libtpms, -ltpms)

# [SYNOPSIS](#SYNOPSIS)

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

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

**TPM\_RESULT TPMLIB\_Process(unsigned char** \*\**respbuffer,*  
**uint32\_t** \**resp\_size,*  
**uint32\_t** \**respbufsize,*  
**unsigned char** \**command,*  
**uint32\_t** *command\_size);*

# [DESCRIPTION](#DESCRIPTION)

The **TPMLIB\_Process()** function is used to send TPM commands to the TPM and receive the results.

The *command* parameter provides the buffer for the TPM command and the *command\_size* the number of valid TPM command bytes within that buffer.

The *respbuffer* is a pointer to a buffer where the TPM will return its result. If no buffer is given (*respbuffer* is NULL), the TPM will allocate a buffer. The parameter *resp\_size* returns the number of valid TPM response bytes in the buffer. The number of valid bytes in the response is guaranteed to not exceed the maximum I/O buffer size. Use the ***TPMLIB\_GetTPMProperty()*** API and parameter *TPMPROP\_TPM\_BUFFER\_MAX* for getting the maximum size. The user must indicate the size of a provided buffer with the *respbufsize* parameter. If the buffer is not big enough for the response, the TPM will free the provided buffer and allocate one of sufficient size and adapt *respbufsize*. The returned buffer is only subject to size restrictions as explained for **TPM\_Malloc()**.

# [ERRORS](#ERRORS)

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

The function completed successfully.

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

General failure.

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

# [EXAMPLE](#EXAMPLE)

```
 #include <stdio.h>
 #include <libtpms/tpm_types.h>
 #include <libtpms/tpm_library.h>
 #include <libtpms/tpm_error.h>
 static unsigned char TPM_Startup_ST_CLEAR[] = {
     0x00, 0xC1, 0x00, 0x00, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x99,
     0x00, TPM_ST_CLEAR
 };
 int main(void) {
     TPM_RESULT res;
     unsigned char *respbuffer = NULL;
     uint32_t resp_size = 0;
     uint32_t respbufsize = 0;
     unsigned char *command;
     uint32_t command_size;
     [...]
     if (TPMLIB_MainInit() != TPM_SUCCESS) {
          fprintf(stderr, "Could not start the TPM.\n");
          return 1;
     }
     [...]
     /* build TPM command */
     command = TPM_Startup_ST_CLEAR;
     command_size = sizeof(TPM_Startup_ST_CLEAR);
     [...]
     res = TPMLIB_Process(&respbuffer, &resp_size,
                          &respbufsize,
                          command, command_size);
     [...]
     TPMLIB_Terminate();
     return 0;
 }
```

# [SEE ALSO](#SEE_ALSO)

[**TPMLIB\_MainInit**(3)](/man/enterprise-packages/libtpms/TPMLIB_MainInit.3), [**TPMLIB\_Terminate**(3)](/man/enterprise-packages/libtpms/TPMLIB_Terminate.3), [**TPMLIB\_RegisterCallbacks**(3)](/man/enterprise-packages/libtpms/TPMLIB_RegisterCallbacks.3) [**TPMLIB\_GetTPMProperty**(3)](/man/enterprise-packages/libtpms/TPMLIB_GetTPMProperty.3), [**TPMLIB\_Malloc**(3)](/man/enterprise-packages/libtpms/TPMLIB_Malloc.3), [**TPMLIB\_Realloc**(3)](/man/enterprise-packages/libtpms/TPMLIB_Realloc.3)

2026-10-01 libtpms

---

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