1Tss2_Tcti_Cmd_Init(3)      Library Functions Manual      Tss2_Tcti_Cmd_Init(3)
2
3
4

NAME

6       Tss2_Tcti_Cmd_Init - Initialization function for the Cmd TCTI library.
7

SYNOPSIS

9       #include <tss2/tss2_tcti_cmd.h>
10
11       TSS2_RC   Tss2_Tcti_Cmd_Init  (TSS2_TCTI_CONTEXT  *tctiContext,  size_t
12       *contextSize, const char *conf);
13
14       The Tss2_Tcti_Cmd_Init() function initializes a TCTI  context  used  to
15       communicate  with a subprocess specified in the conf string.  TCTI send
16       and receives utilize the sub-process's stdio and stdout respectively.
17

DESCRIPTION

19       Tss2_Tcti_Cmd_Init()  attempts  to  initialize   a   caller   allocated
20       tcti_context  of  size  size using caller provided configuration string
21       conf . Since the tcti_context must be a caller  allocated  buffer,  the
22       caller  needs to know the buffer size required by the TCTI library. The
23       minimum size of this context can be discovered by  providing  NULL  for
24       the  tcti_context  and  a  non- NULL size parameter. The initialization
25       function will then populate the size parameter with the minimum size of
26       the tcti_context buffer. The caller must then allocate a buffer of this
27       size (or larger) and call Tss2_Tcti_Cmd_Init  ()  again  providing  the
28       newly  allocated  tcti_context and the size of this context in the size
29       parameter. This pattern is common to all TCTI initialization functions.
30       We  provide  an  example of this pattern using the Tss2_Tcti_Cmd_Init()
31       function in the section titled EXAMPLE.
32
33       The conf parameter is a C string used to configure  the  TCTI  context.
34       This  configuration  string  is the command used for popen(3). The conf
35       string cannot be NULL for this TCTI.
36
37       Once initialized, the TCTI context returned exposes the Trusted Comput‐
38       ing Group (TCG) defined API for the lowest level communication with the
39       TPM.  Using this API the caller can exchange (send / receive) TPM2 com‐
40       mand and response buffers with a service that can excahnge TPM2 command
41       and response buffers. In nearly all cases however, the caller will ini‐
42       tialize  a  context using this function before passing the context to a
43       higher level API like  the  System  API  (SAPI),  Enhanced  System  API
44       (ESAPI) or Feature API (FAPI) and then never touch it again.
45
46       For  a  more  thorough  discussion  of the TCTI API see the “TSS System
47       Level API and TPM Command Transmission Interface Specification” as pub‐
48       lished                   by                   the                  TCG:
49       https://trustedcomputinggroup.org/tss-system-level-api-tpm-command-transmission-interface-specification/
50

RETURN VALUE

52       A  successful call to Tss2_Tcti_Cmd_Init() will return TSS2_RC_SUCCESS.
53       An unsuccessful call will produce a response code described in  section
54       ERRORS.
55

ERRORS

57       TSS2_TCTI_RC_BAD_VALUE  is  returned  if  both the tcti_context and the
58       size parameters are NULL, or if the config parameter is NULL.
59

EXAMPLE

61       TCTI initialization fragment:
62
63       #include <inttypes.h>
64       #include <stdlib.h>
65       #include <stdio.h>
66       #include <tcti/tcti_mssim.h>
67
68       TSS2_RC rc;
69       TSS2_TCTI_CONTEXT *tcti_context;
70       size_t size;
71       const char *conf = "XXX TODO SAMPLE"
72
73       rc = Tss2_Tcti_Cmd_Init (NULL, &size, NULL);
74       if (rc != TSS2_RC_SUCCESS) {
75           fprintf (stderr, "Failed to get allocation size for mssim TCTI "
76                    " context: 0x%" PRIx32 "0, rc);
77           exit (EXIT_FAILURE);
78       }
79       tcti_context = calloc (1, size);
80       if (tcti_context == NULL) {
81           fprintf (stderr, "Allocation for TCTI context failed: %s0,
82                    strerror (errno));
83           exit (EXIT_FAILURE);
84       }
85       rc = Tss2_Tcti_Cmd_Init (&tcti_context, &size, conf);
86       if (rc != TSS2_RC_SUCCESS) {
87           fprintf (stderr, "Failed to initialize mssim TCTI context: "
88                    "0x%" PRIx32 "0, rc);
89           free (tcti_context);
90           exit (EXIT_FAILURE);
91       }
92

AUTHOR

94       Philip Tricca <philip.b.tricca@intel.com>
95

SEE ALSO

97       Tss2_Tcti_Device_Init(3),  Tss2_Tcti_Socket_Init(3),  Tss2_TctiLdr_Ini‐
98       tialize(3),  Tss2_TctiLdr_Finalize(3),  tcti-device(7), tcti-socket(7),
99       tcti-tabrmd(7), tpm2-abrmd(8)
100

COLOPHON

102       This page is part of release 3.0.3 of Open Source implementation of the
103       TCG  TPM2 Software Stack (TSS2). A description of the project, informa‐
104       tion about reporting bugs, and the latest version of this page  can  be
105       found at https://github.com/tpm2-software/tpm2-tss/.
106
107
108
109TPM2 Software Stack                MAY 2020              Tss2_Tcti_Cmd_Init(3)
Impressum