tpm2_getrandom.1 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262
  1. .\" Automatically generated by Pandoc 1.19.2.4
  2. .\"
  3. .TH "tpm2_getrandom" "1" "" "tpm2\-tools" "General Commands Manual"
  4. .hy
  5. .SH NAME
  6. .PP
  7. \f[B]tpm2_getrandom\f[](1) \- Retrieves random bytes from the TPM.
  8. .SH SYNOPSIS
  9. .PP
  10. \f[B]tpm2_getrandom\f[] [\f[I]OPTIONS\f[]] [\f[I]ARGUMENT\f[]]
  11. .SH DESCRIPTION
  12. .PP
  13. \f[B]tpm2_getrandom\f[](1) \- Returns the next \f[I]SIZE\f[] octets from
  14. the random number generator.
  15. The \f[I]SIZE\f[] parameter is expected as the only argument to the
  16. tool.
  17. .PP
  18. Note that the TPM specification recommends that TPM\[aq]s fix the number
  19. of available entry to the maximum size of a hash algorithm output in
  20. bytes.
  21. .PP
  22. Most TPMs do this, and thus the tool verifies that input size is bounded
  23. by property \f[B]TPM2_PT_MAX_DIGEST\f[] and issues an error if it is too
  24. large.
  25. .PP
  26. Output defaults to \f[I]stdout\f[] and binary format unless otherwise
  27. specified with \f[B]\-o\f[] and \f[B]\-\-hex\f[] options respectively.
  28. .SH OPTIONS
  29. .IP \[bu] 2
  30. \f[B]\-o\f[], \f[B]\-\-output\f[]=\f[I]FILE\f[]
  31. .RS 2
  32. .PP
  33. Specifies the filename to output the raw bytes to.
  34. Defaults to stdout as a hex string.
  35. .RE
  36. .IP \[bu] 2
  37. \f[B]\-\-hex\f[]
  38. .RS 2
  39. .PP
  40. Convert the output data to hex format without a leading "0x".
  41. .RE
  42. .IP \[bu] 2
  43. \f[B]\-f\f[], \f[B]\-\-force\f[]
  44. .RS 2
  45. Override checking that the:
  46. .IP \[bu] 2
  47. Requested size is within the hash size limit of the TPM.
  48. .IP \[bu] 2
  49. Number of retrieved random bytes matches requested amount.
  50. .RE
  51. .IP \[bu] 2
  52. \f[B]\-S\f[], \f[B]\-\-session\f[]=\f[I]FILE\f[]:
  53. .RS 2
  54. .PP
  55. The session created using \f[B]tpm2_startauthsession\f[].
  56. Multiple of these can be specified.
  57. For example, you can have one session for auditing and another for
  58. encryption of the parameters.
  59. .RE
  60. .IP \[bu] 2
  61. \f[B]\-\-cphash\f[]=\f[I]FILE\f[]:
  62. .RS 2
  63. .PP
  64. File path to record the hash of the command parameters.
  65. This is commonly termed as cpHash.
  66. NOTE: When this option is selected, in absence of rphash option, The
  67. tool will not actually execute the command, it simply returns a cpHash.
  68. .RE
  69. .IP \[bu] 2
  70. \f[B]\-\-rphash\f[]=\f[I]FILE\f[]:
  71. .RS 2
  72. .PP
  73. File path to record the hash of the response parameters.
  74. This is commonly termed as rpHash.
  75. .RE
  76. .IP \[bu] 2
  77. \f[B]ARGUMENT\f[] the command line argument specifies the size of the
  78. output.
  79. .SS References
  80. .SH COMMON OPTIONS
  81. .PP
  82. This collection of options are common to many programs and provide
  83. information that many users may expect.
  84. .IP \[bu] 2
  85. \f[B]\-h\f[], \f[B]\-\-help=[man|no\-man]\f[]: Display the tools
  86. manpage.
  87. By default, it attempts to invoke the manpager for the tool, however, on
  88. failure will output a short tool summary.
  89. This is the same behavior if the "man" option argument is specified,
  90. however if explicit "man" is requested, the tool will provide errors
  91. from man on stderr.
  92. If the "no\-man" option if specified, or the manpager fails, the short
  93. options will be output to stdout.
  94. .RS 2
  95. .PP
  96. To successfully use the manpages feature requires the manpages to be
  97. installed or on \f[I]MANPATH\f[], See man(1) for more details.
  98. .RE
  99. .IP \[bu] 2
  100. \f[B]\-v\f[], \f[B]\-\-version\f[]: Display version information for this
  101. tool, supported tctis and exit.
  102. .IP \[bu] 2
  103. \f[B]\-V\f[], \f[B]\-\-verbose\f[]: Increase the information that the
  104. tool prints to the console during its execution.
  105. When using this option the file and line number are printed.
  106. .IP \[bu] 2
  107. \f[B]\-Q\f[], \f[B]\-\-quiet\f[]: Silence normal tool output to stdout.
  108. .IP \[bu] 2
  109. \f[B]\-Z\f[], \f[B]\-\-enable\-errata\f[]: Enable the application of
  110. errata fixups.
  111. Useful if an errata fixup needs to be applied to commands sent to the
  112. TPM.
  113. Defining the environment TPM2TOOLS_ENABLE_ERRATA is equivalent.
  114. information many users may expect.
  115. .SH TCTI Configuration
  116. .PP
  117. The TCTI or "Transmission Interface" is the communication mechanism with
  118. the TPM.
  119. TCTIs can be changed for communication with TPMs across different
  120. mediums.
  121. .PP
  122. To control the TCTI, the tools respect:
  123. .IP "1." 3
  124. The command line option \f[B]\-T\f[] or \f[B]\-\-tcti\f[]
  125. .IP "2." 3
  126. The environment variable: \f[I]TPM2TOOLS_TCTI\f[].
  127. .PP
  128. \f[B]Note:\f[] The command line option always overrides the environment
  129. variable.
  130. .PP
  131. The current known TCTIs are:
  132. .IP \[bu] 2
  133. tabrmd \- The resource manager, called
  134. tabrmd (https://github.com/tpm2-software/tpm2-abrmd).
  135. Note that tabrmd and abrmd as a tcti name are synonymous.
  136. .IP \[bu] 2
  137. mssim \- Typically used for communicating to the TPM software simulator.
  138. .IP \[bu] 2
  139. device \- Used when talking directly to a TPM device file.
  140. .IP \[bu] 2
  141. none \- Do not initalize a connection with the TPM.
  142. Some tools allow for off\-tpm options and thus support not using a TCTI.
  143. Tools that do not support it will error when attempted to be used
  144. without a TCTI connection.
  145. Does not support \f[I]ANY\f[] options and \f[I]MUST BE\f[] presented as
  146. the exact text of "none".
  147. .PP
  148. The arguments to either the command line option or the environment
  149. variable are in the form:
  150. .PP
  151. \f[C]<tcti\-name>:<tcti\-option\-config>\f[]
  152. .PP
  153. Specifying an empty string for either the \f[C]<tcti\-name>\f[] or
  154. \f[C]<tcti\-option\-config>\f[] results in the default being used for
  155. that portion respectively.
  156. .SS TCTI Defaults
  157. .PP
  158. When a TCTI is not specified, the default TCTI is searched for using
  159. \f[I]dlopen(3)\f[] semantics.
  160. The tools will search for \f[I]tabrmd\f[], \f[I]device\f[] and
  161. \f[I]mssim\f[] TCTIs \f[B]IN THAT ORDER\f[] and \f[B]USE THE FIRST ONE
  162. FOUND\f[].
  163. You can query what TCTI will be chosen as the default by using the
  164. \f[B]\-v\f[] option to print the version information.
  165. The "default\-tcti" key\-value pair will indicate which of the
  166. aforementioned TCTIs is the default.
  167. .SS Custom TCTIs
  168. .PP
  169. Any TCTI that implements the dynamic TCTI interface can be loaded.
  170. The tools internally use \f[I]dlopen(3)\f[], and the raw
  171. \f[I]tcti\-name\f[] value is used for the lookup.
  172. Thus, this could be a path to the shared library, or a library name as
  173. understood by \f[I]dlopen(3)\f[] semantics.
  174. .SH TCTI OPTIONS
  175. .PP
  176. This collection of options are used to configure the various known TCTI
  177. modules available:
  178. .IP \[bu] 2
  179. \f[B]device\f[]: For the device TCTI, the TPM character device file for
  180. use by the device TCTI can be specified.
  181. The default is \f[I]/dev/tpm0\f[].
  182. .RS 2
  183. .PP
  184. Example: \f[B]\-T device:/dev/tpm0\f[] or \f[B]export
  185. \f[I]TPM2TOOLS_TCTI\f[]="device:/dev/tpm0"\f[]
  186. .RE
  187. .IP \[bu] 2
  188. \f[B]mssim\f[]: For the mssim TCTI, the domain name or IP address and
  189. port number used by the simulator can be specified.
  190. The default are 127.0.0.1 and 2321.
  191. .RS 2
  192. .PP
  193. Example: \f[B]\-T mssim:host=localhost,port=2321\f[] or \f[B]export
  194. \f[I]TPM2TOOLS_TCTI\f[]="mssim:host=localhost,port=2321"\f[]
  195. .RE
  196. .IP \[bu] 2
  197. \f[B]abrmd\f[]: For the abrmd TCTI, the configuration string format is a
  198. series of simple key value pairs separated by a \[aq],\[aq] character.
  199. Each key and value string are separated by a \[aq]=\[aq] character.
  200. .RS 2
  201. .IP \[bu] 2
  202. TCTI abrmd supports two keys:
  203. .RS 2
  204. .IP "1." 3
  205. \[aq]bus_name\[aq] : The name of the tabrmd service on the bus (a
  206. string).
  207. .IP "2." 3
  208. \[aq]bus_type\[aq] : The type of the dbus instance (a string) limited to
  209. \[aq]session\[aq] and \[aq]system\[aq].
  210. .RE
  211. .PP
  212. Specify the tabrmd tcti name and a config string of
  213. \f[C]bus_name=com.example.FooBar\f[]:
  214. .PP
  215. \f[C]\\\-\-tcti=tabrmd:bus_name=com.example.FooBar\f[]
  216. .PP
  217. Specify the default (abrmd) tcti and a config string of
  218. \f[C]bus_type=session\f[]:
  219. .PP
  220. \f[C]\\\-\-tcti:bus_type=session\f[]
  221. .PP
  222. \f[B]NOTE\f[]: abrmd and tabrmd are synonymous.
  223. the various known TCTI modules.
  224. .RE
  225. .SH EXAMPLES
  226. .SS Generate a random 20 bytes and output the binary data to a file
  227. .IP
  228. .nf
  229. \f[C]
  230. tpm2_getrandom\ \-o\ random.out\ 20
  231. \f[]
  232. .fi
  233. .SS Generate a random 8 bytes and output the hex formatted data to
  234. stdout
  235. .IP
  236. .nf
  237. \f[C]
  238. tpm2_getrandom\ 8
  239. \f[]
  240. .fi
  241. .SH Returns
  242. .PP
  243. Tools can return any of the following codes:
  244. .IP \[bu] 2
  245. 0 \- Success.
  246. .IP \[bu] 2
  247. 1 \- General non\-specific error.
  248. .IP \[bu] 2
  249. 2 \- Options handling error.
  250. .IP \[bu] 2
  251. 3 \- Authentication error.
  252. .IP \[bu] 2
  253. 4 \- TCTI related error.
  254. .IP \[bu] 2
  255. 5 \- Non supported scheme.
  256. Applicable to tpm2_testparams.
  257. .SH BUGS
  258. .PP
  259. Github Issues (https://github.com/tpm2-software/tpm2-tools/issues)
  260. .SH HELP
  261. .PP
  262. See the Mailing List (https://lists.01.org/mailman/listinfo/tpm2)