Tss2_Tcti_Cmd_Init.3.in 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. .\" Process this file with
  2. .\" groff -man -Tascii foo.1
  3. .\"
  4. .TH Tss2_Tcti_Cmd_Init 3 "MAY 2020" "TPM2 Software Stack"
  5. .SH NAME
  6. Tss2_Tcti_Cmd_Init \- Initialization function for the Cmd TCTI library.
  7. .SH SYNOPSIS
  8. .B #include <tss2/tss2_tcti_cmd.h>
  9. .sp
  10. .BI "TSS2_RC Tss2_Tcti_Cmd_Init (TSS2_TCTI_CONTEXT " "*tctiContext" ", size_t " "*contextSize" ", const char " "*conf" ");"
  11. .sp
  12. The
  13. .BR Tss2_Tcti_Cmd_Init ()
  14. function initializes a TCTI context used to communicate with a subprocess specified in the conf string.
  15. TCTI send and receives utilize the sub-process's stdio and stdout respectively.
  16. .SH DESCRIPTION
  17. .BR Tss2_Tcti_Cmd_Init ()
  18. attempts to initialize a caller allocated
  19. .I tcti_context
  20. of size
  21. .I size
  22. using caller provided configuration string
  23. .I conf
  24. \&. Since the
  25. .I tcti_context
  26. must be a caller allocated buffer, the caller needs to know the buffer size
  27. required by the TCTI library. The minimum size of this context can be
  28. discovered by providing
  29. .BR NULL
  30. for the
  31. .I tcti_context
  32. and a non-
  33. .BR NULL
  34. .I size
  35. parameter. The initialization function will then populate the
  36. .I size
  37. parameter with the minimum size of the
  38. .I tcti_context
  39. buffer. The caller must then allocate a buffer of this size (or larger) and
  40. call
  41. .B Tss2_Tcti_Cmd_Init ()
  42. again providing the newly allocated
  43. .I tcti_context
  44. and the size of this context in the
  45. .I size
  46. parameter. This pattern is common to all TCTI initialization functions. We
  47. provide an example of this pattern using the
  48. .BR Tss2_Tcti_Cmd_Init ()
  49. function in the section titled
  50. .B EXAMPLE.
  51. .sp
  52. The
  53. .I conf
  54. parameter is a C string used to configure the TCTI context. This
  55. configuration string is the command used for popen(3). The conf string
  56. cannot be NULL for this TCTI.
  57. .sp
  58. Once initialized, the TCTI context returned exposes the Trusted Computing
  59. Group (TCG) defined API for the lowest level communication with the TPM.
  60. Using this API the caller can exchange (send / receive) TPM2 command and
  61. response buffers with a service that can excahnge TPM2 command and response
  62. buffers. In nearly all cases however, the caller will initialize a context
  63. using this function before passing the context to a higher level API like
  64. the System API (SAPI), Enhanced System API (ESAPI) or Feature API (FAPI)
  65. and then never touch it again.
  66. .sp
  67. For a more thorough discussion of the TCTI API see the \*(lqTSS System Level
  68. API and TPM Command Transmission Interface Specification\*(rq as published by
  69. the TCG:
  70. \%https://trustedcomputinggroup.org/tss-system-level-api-tpm-command-transmission-interface-specification/
  71. .SH RETURN VALUE
  72. A successful call to
  73. .BR Tss2_Tcti_Cmd_Init ()
  74. will return
  75. .B TSS2_RC_SUCCESS.
  76. An unsuccessful call will produce a response code described in section
  77. .B ERRORS.
  78. .SH ERRORS
  79. .B TSS2_TCTI_RC_BAD_VALUE
  80. is returned if both the
  81. .I tcti_context
  82. and the
  83. .I size
  84. parameters are NULL, or if the
  85. .I config
  86. parameter is NULL.
  87. .SH EXAMPLE
  88. .sp
  89. TCTI initialization fragment:
  90. .sp
  91. .nf
  92. #include <inttypes.h>
  93. #include <stdlib.h>
  94. #include <stdio.h>
  95. #include <tcti/tcti_mssim.h>
  96. TSS2_RC rc;
  97. TSS2_TCTI_CONTEXT *tcti_context;
  98. size_t size;
  99. const char *conf = "XXX TODO SAMPLE"
  100. rc = Tss2_Tcti_Cmd_Init (NULL, &size, NULL);
  101. if (rc != TSS2_RC_SUCCESS) {
  102. fprintf (stderr, "Failed to get allocation size for mssim TCTI "
  103. " context: 0x%" PRIx32 "\n", rc);
  104. exit (EXIT_FAILURE);
  105. }
  106. tcti_context = calloc (1, size);
  107. if (tcti_context == NULL) {
  108. fprintf (stderr, "Allocation for TCTI context failed: %s\n",
  109. strerror (errno));
  110. exit (EXIT_FAILURE);
  111. }
  112. rc = Tss2_Tcti_Cmd_Init (&tcti_context, &size, conf);
  113. if (rc != TSS2_RC_SUCCESS) {
  114. fprintf (stderr, "Failed to initialize mssim TCTI context: "
  115. "0x%" PRIx32 "\n", rc);
  116. free (tcti_context);
  117. exit (EXIT_FAILURE);
  118. }
  119. .fi