Tss2_Tcti_Mssim_Init.3.in 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. .\" Process this file with
  2. .\" groff -man -Tascii foo.1
  3. .\"
  4. .TH Tss2_Tcti_Mssim_Init 3 "JUNE 2017" "TPM2 Software Stack"
  5. .SH NAME
  6. Tss2_Tcti_Mssim_Init \- Initialization function for the Microsoft TPM simulator TCTI library.
  7. .SH SYNOPSIS
  8. .B #include <tcti/tcti_mssim.h>
  9. .sp
  10. .BI "TSS2_RC Tss2_Tcti_Mssim_Init (TSS2_TCTI_CONTEXT " "*tctiContext" ", size_t " "*contextSize" ", const char " "*conf" ");"
  11. .sp
  12. The
  13. .BR Tss2_Tcti_Mssim_Init ()
  14. function initializes a TCTI context used to communicate with the Microsoft TPM2
  15. simulator.
  16. .SH DESCRIPTION
  17. .BR Tss2_Tcti_Mssim_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_Mssim_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_Mssim_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 a series of key / value pairs that specify the host
  56. and port used to connect to an instance of the Microsoft TPM2 simulator. The
  57. keys and values are separated by the '=' character, while each key / value
  58. pair is separated by the ',' character.
  59. The only keys supported in the
  60. .I conf
  61. string are
  62. .B host
  63. and
  64. .B port.
  65. The host may be an IPv4 address, an IPv6 address, or a host name. The port
  66. must be a valid uint16_t in string form. If a NULL
  67. .I conf
  68. string is provided by the caller then the default of
  69. "host=localhost,port=2321" is used. If either
  70. .B host
  71. or
  72. .B port
  73. are omitted then their respective default value will be used.
  74. .sp
  75. Once initialized, the TCTI context returned exposes the Trusted Computing
  76. Group (TCG) defined API for the lowest level communication with the TPM.
  77. Using this API the caller can exchange (send / receive) TPM2 command and
  78. response buffers with the Microsoft TPM simulator. In nearly all cases however,
  79. the caller will initialize a context using this function before passing the
  80. context to a higher level API like the System API (SAPI), and then never touch
  81. it again.
  82. .sp
  83. For a more thorough discussion of the TCTI API see the \*(lqTSS System Level
  84. API and TPM Command Transmission Interface Specification\*(rq as published by
  85. the TCG:
  86. \%https://trustedcomputinggroup.org/tss-system-level-api-tpm-command-transmission-interface-specification/
  87. .SH RETURN VALUE
  88. A successful call to
  89. .BR Tss2_Tcti_Mssim_Init ()
  90. will return
  91. .B TSS2_RC_SUCCESS.
  92. An unsuccessful call will produce a response code described in section
  93. .B ERRORS.
  94. .SH ERRORS
  95. .B TSS2_TCTI_RC_BAD_VALUE
  96. is returned if both the
  97. .I tcti_context
  98. and the
  99. .I size
  100. parameters are NULL, or if the
  101. .I config
  102. parameter is NULL.
  103. .SH EXAMPLE
  104. .sp
  105. TCTI initialization fragment:
  106. .sp
  107. .nf
  108. #include <inttypes.h>
  109. #include <stdlib.h>
  110. #include <stdio.h>
  111. #include <tcti/tcti_mssim.h>
  112. TSS2_RC rc;
  113. TSS2_TCTI_CONTEXT *tcti_context;
  114. size_t size;
  115. const char *conf = "host=localhost,port=2321"
  116. rc = Tss2_Tcti_Mssim_Init (NULL, &size, NULL);
  117. if (rc != TSS2_RC_SUCCESS) {
  118. fprintf (stderr, "Failed to get allocation size for mssim TCTI "
  119. " context: 0x%" PRIx32 "\n", rc);
  120. exit (EXIT_FAILURE);
  121. }
  122. tcti_context = calloc (1, size);
  123. if (tcti_context == NULL) {
  124. fprintf (stderr, "Allocation for TCTI context failed: %s\n",
  125. strerror (errno));
  126. exit (EXIT_FAILURE);
  127. }
  128. rc = Tss2_Tcti_Mssim_Init (&tcti_context, &size, conf);
  129. if (rc != TSS2_RC_SUCCESS) {
  130. fprintf (stderr, "Failed to initialize mssim TCTI context: "
  131. "0x%" PRIx32 "\n", rc);
  132. free (tcti_context);
  133. exit (EXIT_FAILURE);
  134. }
  135. .fi