[go: nahoru, domu]

blob: d08bcfa4a185f08fb545711d5f9856734efea6f4 [file] [log] [blame]
Philip Triccafe671682017-06-04 19:14:31 -07001.\" Process this file with
2.\" groff -man -Tascii foo.1
3.\"
Philip Tricca5a235282018-02-27 14:59:49 -08004.TH Tss2_Tcti_Device_Init 3 "MARCH 2018" Intel "TPM2 Software Stack"
Philip Triccafe671682017-06-04 19:14:31 -07005.SH NAME
Philip Tricca5a235282018-02-27 14:59:49 -08006Tss2_Tcti_Device_init \- Initialization function for the device TCTI library.
Philip Triccafe671682017-06-04 19:14:31 -07007.SH SYNOPSIS
8.B #include <tcti/tcti_device.h>
9.sp
Philip Triccafe671682017-06-04 19:14:31 -070010.sp
Philip Tricca5a235282018-02-27 14:59:49 -080011.BI "TSS2_RC Tss2_Tcti_Device_Init (TSS2_TCTI_CONTEXT " "*tctiContext" ", size_t " "*size" ", const char " "*conf" ");"
Philip Triccafe671682017-06-04 19:14:31 -070012.sp
13The
Philip Tricca5a235282018-02-27 14:59:49 -080014.BR Tss2_Tcti_Device_Init ()
Philip Triccafe671682017-06-04 19:14:31 -070015function initializes a TCTI context used to communicate with the TPM device
16driver.
17.SH DESCRIPTION
Philip Tricca5a235282018-02-27 14:59:49 -080018.BR Tss2_Tcti_Device_Init ()
Philip Triccafe671682017-06-04 19:14:31 -070019attempts to initialize a caller allocated
Philip Tricca5a235282018-02-27 14:59:49 -080020.I tctiContext
Philip Triccafe671682017-06-04 19:14:31 -070021of size
22.I size
23\&. Since the
Philip Tricca5a235282018-02-27 14:59:49 -080024.I tctiContext
Philip Triccafe671682017-06-04 19:14:31 -070025must be a caller allocated buffer, the caller needs to know the size required
26by the TCTI library. The minimum size of this context can be discovered by
27providing
28.BR NULL
29for the
Philip Tricca5a235282018-02-27 14:59:49 -080030.I tctiContext
Philip Triccafe671682017-06-04 19:14:31 -070031and a non-
32.BR NULL
33.I size
34parameter. The initialization function will then populate the
35.I size
36parameter with the minimum size of the
Philip Tricca5a235282018-02-27 14:59:49 -080037.I tctiContext
Philip Triccafe671682017-06-04 19:14:31 -070038buffer. The caller must then allocate a buffer of this size (or larger) and
39call
Philip Tricca5a235282018-02-27 14:59:49 -080040.B Tss2_Tcti_Device_Init ()
Philip Triccafe671682017-06-04 19:14:31 -070041again providing the newly allocated
Philip Tricca5a235282018-02-27 14:59:49 -080042.I tctiContext
Philip Triccafe671682017-06-04 19:14:31 -070043and the size of this context in the
44.I size
dantpm1edd1112018-04-06 15:26:05 -070045parameter. This pattern is common to all TCTI initialization functions. We
Philip Triccafe671682017-06-04 19:14:31 -070046provide an example of this pattern using the
Philip Tricca5a235282018-02-27 14:59:49 -080047.BR Tss2_Tcti_Device_Init ()
Philip Triccafe671682017-06-04 19:14:31 -070048function in the section titled
49.B EXAMPLE.
50.sp
51The
Philip Tricca5a235282018-02-27 14:59:49 -080052.I conf
53parameter is a C string. If this string is
54.BR NULL
55then the library will use a default configuration string for the caller.
56Alternatively, the caller may provide a configuration string that must
57contain the path to the device node exposed by the TPM device driver.
Philip Triccafe671682017-06-04 19:14:31 -070058.sp
Philip Triccafe671682017-06-04 19:14:31 -070059Once initialized, the TCTI context returned exposes the Trusted Computing
60Group (TCG) defined API for the lowest level communication with the TPM.
61Using this API the caller can exchange (send / receive) TPM2 command and
dantpm1edd1112018-04-06 15:26:05 -070062response buffers with the TPM device driver. In nearly all cases however, the
63caller will initialize a context using this function before passing the
Philip Triccafe671682017-06-04 19:14:31 -070064context to a higher level API like the System API (SAPI), and then never touch
65it again.
66.sp
Philip Tricca5a235282018-02-27 14:59:49 -080067TCG TSS 2.0 TPM Command
68Transmission Interface (TCTI) API
69Specification
70
71For a more thorough discussion of the TCTI API see the \*(lqTCG TSS 2.0 TPM Command
72Transmission Interface (TCTI) API Specification\*(rq as published by
Philip Triccafe671682017-06-04 19:14:31 -070073the TCG:
Philip Tricca5a235282018-02-27 14:59:49 -080074\%https://trustedcomputinggroup.org/wp-content/uploads/TSS_TCTI_Version-1.0_Revision-05_Review_END030918.pdf
Philip Triccafe671682017-06-04 19:14:31 -070075.SH RETURN VALUE
76A successful call to
Philip Tricca5a235282018-02-27 14:59:49 -080077.BR Tss2_Tcti_Device_Init ()
Philip Triccafe671682017-06-04 19:14:31 -070078will return
79.B TSS2_RC_SUCCESS.
80An unsuccessful call will produce a response code described in section
81.B ERRORS.
82.SH ERRORS
83.B TSS2_TCTI_RC_BAD_VALUE
Philip Tricca5a235282018-02-27 14:59:49 -080084is returned if any parameters contain unexpected values.
85.B TSS2_TCTI_RC_BAD_REFERENCE
86is returned if any parameters are NULL when they should not be.
87.B TSS2_TCTI_RC_BAD_CONTEXT
88is returned if the size of the provided
89.i tctiContext
90is insufficient.
Philip Triccafe671682017-06-04 19:14:31 -070091.SH EXAMPLE
Philip Triccafe671682017-06-04 19:14:31 -070092TCTI initialization fragment:
93.sp
94.nf
95#include <inttypes.h>
96#include <stdlib.h>
97#include <stdio.h>
98#include <tcti/tcti_device.h>
99
100TSS2_RC rc;
101TSS2_TCTI_CONTEXT *tcti_context;
102size_t size;
Philip Tricca5a235282018-02-27 14:59:49 -0800103char *conf = "/dev/tpm0",
Philip Triccafe671682017-06-04 19:14:31 -0700104
Philip Tricca5a235282018-02-27 14:59:49 -0800105rc = Tss2_Tcti_Device_Init (NULL, &size, NULL);
Philip Triccafe671682017-06-04 19:14:31 -0700106if (rc != TSS2_RC_SUCCESS) {
Doug Goldstein71b24732017-08-02 18:00:41 -0500107 fprintf (stderr, "Failed to get allocation size for device TCTI "
Philip Triccafe671682017-06-04 19:14:31 -0700108 " context: 0x%" PRIx32 "\n", rc);
109 exit (EXIT_FAILURE);
110}
111tcti_context = calloc (1, size);
112if (tcti_context == NULL) {
113 fprintf (stderr, "Allocation for TCTI context failed: %s\n",
114 strerror (errno));
115 exit (EXIT_FAILURE);
116}
Philip Tricca5a235282018-02-27 14:59:49 -0800117rc = Tss2_Tcti_Device_Init (&tcti_context, &size, &conf);
Philip Triccafe671682017-06-04 19:14:31 -0700118if (rc != TSS2_RC_SUCCESS) {
Doug Goldstein71b24732017-08-02 18:00:41 -0500119 fprintf (stderr, "Failed to initialize device TCTI context: "
Philip Triccafe671682017-06-04 19:14:31 -0700120 "0x%" PRIx32 "\n", rc);
121 free (tcti_context);
122 exit (EXIT_FAILURE);
123}
124exit (EXIT_SUCCESS);
125.fi