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

NAME

6       Tss2_Tcti_Device_init - Initialization function for the device TCTI li‐
7       brary.
8

SYNOPSIS

10       #include <tcti/tcti_device.h>
11
12
13       TSS2_RC Tss2_Tcti_Device_Init (TSS2_TCTI_CONTEXT  *tctiContext,  size_t
14       *size, const char *conf);
15
16       The Tss2_Tcti_Device_Init() function initializes a TCTI context used to
17       communicate with the TPM device driver.
18

DESCRIPTION

20       Tss2_Tcti_Device_Init() attempts to initialize a caller allocated tcti‐
21       Context of size size . Since the tctiContext must be a caller allocated
22       buffer, the caller needs to know the size required by the TCTI library.
23       The  minimum  size  of this context can be discovered by providing NULL
24       for the tctiContext and a non- NULL size parameter. The  initialization
25       function will then populate the size parameter with the minimum size of
26       the tctiContext buffer. The caller must then allocate a buffer of  this
27       size  (or larger) and call Tss2_Tcti_Device_Init () again providing the
28       newly allocated tctiContext 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_Device_Init()
31       function in the section titled EXAMPLE.
32
33       The  conf  parameter is a C string. If this string is NULL then the li‐
34       brary will use a default configuration string for the caller.  Alterna‐
35       tively, the caller may provide a configuration string that must contain
36       the path to the device node exposed by the TPM device driver.
37
38       Once initialized, the TCTI context returned exposes the Trusted Comput‐
39       ing Group (TCG) defined API for the lowest level communication with the
40       TPM.  Using this API the caller can exchange (send / receive) TPM2 com‐
41       mand  and  response  buffers  with the TPM device driver. In nearly all
42       cases however, the caller will initialize a context using this function
43       before  passing  the  context to a higher level API like the System API
44       (SAPI), and then never touch it again.
45
46       TCG TSS 2.0 TPM Command Transmission Interface (TCTI) API Specification
47
48       For a more thorough discussion of the TCTI API see the “TCG TSS 2.0 TPM
49       Command  Transmission  Interface (TCTI) API Specification” as published
50       by                               the                               TCG:
51       https://trustedcomputinggroup.org/wp-content/uploads/TSS_TCTI_Version-1.0_Revision-05_Review_END030918.pdf
52

RETURN VALUE

54       A successful call to Tss2_Tcti_Device_Init() will  return  TSS2_RC_SUC‐
55       CESS.   An  unsuccessful call will produce a response code described in
56       section ERRORS.
57

ERRORS

59       TSS2_TCTI_RC_BAD_VALUE is returned if any parameters contain unexpected
60       values.   TSS2_TCTI_RC_BAD_REFERENCE  is returned if any parameters are
61       NULL when they should not be.  TSS2_TCTI_RC_BAD_CONTEXT is returned  if
62       the size of the provided tctiContext is insufficient.
63

EXAMPLE

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

AUTHOR

99       TPM2 Software Project <https://github.com/tpm2-software/tpm2-tss>
100

SEE ALSO

102       Tss2_Tcti_Device_Init(3),  Tss2_Tcti_Socket_Init(3),  Tss2_TctiLdr_Ini‐
103       tialize(3), Tss2_TctiLdr_Finalize(3),  tcti-device(7),  tcti-socket(7),
104       tcti-tabrmd(7), tpm2-abrmd(8)
105

COLOPHON

107       This page is part of release 4.0.1 of Open Source implementation of the
108       TCG TPM2 Software Stack (TSS2). A description of the project,  informa‐
109       tion  about  reporting bugs, and the latest version of this page can be
110       found at https://github.com/tpm2-software/tpm2-tss/.
111
112
113
114TPM2 Software Stack               MARCH 2018          Tss2_Tcti_Device_Init(3)
Impressum