#include <tcti/tcti-tabrmd.h>
TSS2_RC Tss2_Tcti_Tabrmd_Init (TSS2_TCTI_CONTEXT *tcti_context, size_t *size, const char *conf);
The conf parameter is a string of key / value pairs describing the desired connection properties for the TCTI. If the caller provides a NULL conf string then defaults that correspond to the defaults for the tpm2-abrmd (8) will be used. This is the same as providing the conf string: "bus_name=com.intel.tss2.Tabrmd,bus_type=system". Keys and values are separated by the '=' character while each key / value pair is separated by the ',' character. The supported keys and values are:
Once initialized, the TCTI context returned exposes the Trusted Computing Group (TCG) defined API for the lowest level communication with the TPM. Using this API the caller can exchange (send / receive) TPM2 command and response buffers with the tpm2-abrmd (8). In nearly all cases however, the caller will initialize a context using this function before passing the context to a higher level API like the System API (SAPI), and then never touch it again.
For a more thorough discussion of the TCTI API see the ``TSS System Level API and TPM Command Transmission Interface Specification'' specification as published by the TCG: https://trustedcomputinggroup.org/tss-system-level-api-tpm-command-transmission-interface-specification/
TSS2_TCTI_RC_NO_CONNECTION is returned when communication with the tpm2-abrmd (8) fails.
TSS2_TCTI_RC_GENERAL_FAILURE is returned for all other errors.
#include <inttypes.h> #include <stdlib.h> #include <stdio.h> #include <tcti/tcti-tabrmd.h> TSS2_RC rc; TSS2_TCTI_CONTEXT *tcti_context; size_t size; rc = tss2_tcti_tabrmd_init (NULL, &size, NULL, if (rc != TSS2_RC_SUCCESS) { fprintf (stderr, "Failed to get allocation size for tabrmd TCTI " " context: 0x%" PRIx32 ", rc); exit (EXIT_FAILURE); } tcti_context = calloc (1, size); if (tcti_context == NULL) { fprintf (stderr, "Allocation for TCTI context failed: %s, strerror (errno)); exit (EXIT_FAILURE); } rc = tss2_tcti_tabrmd_init (tcti_context, &size, NULL); if (rc != TSS2_RC_SUCCESS) { fprintf (stderr, "Failed to initialize tabrmd TCTI context: " "0x%" PRIx32 ", rc); free (tcti_context); exit (EXIT_FAILURE); } exit (EXIT_SUCCESS);