tpm2_hash.1 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397
  1. .\" Automatically generated by Pandoc 1.19.2.4
  2. .\"
  3. .TH "tpm2_hash" "1" "" "tpm2\-tools" "General Commands Manual"
  4. .hy
  5. .SH NAME
  6. .PP
  7. \f[B]tpm2_hash\f[](1) \- Performs a hash operation with the TPM.
  8. .SH SYNOPSIS
  9. .PP
  10. \f[B]tpm2_hash\f[] [\f[I]OPTIONS\f[]] [\f[I]ARGUMENT\f[] OR
  11. \f[I]STDIN\f[]]
  12. .SH DESCRIPTION
  13. .PP
  14. \f[B]tpm2_hash\f[](1) \- Performs a hash operation on file and returns
  15. the results.
  16. If argument is not specified, then data is read from stdin.
  17. If the results of the hash will be used in a signing operation that uses
  18. a restricted signing key, then the ticket returned by this command can
  19. indicate that the hash is safe to sign.
  20. .PP
  21. Output defaults to \f[I]stdout\f[] and binary format unless otherwise
  22. specified via \f[B]\-o\f[] and \f[B]\-\-hex\f[] options respectively.
  23. .SH OPTIONS
  24. .IP \[bu] 2
  25. \f[B]\-C\f[], \f[B]\-\-hierarchy\f[]=\f[I]OBJECT\f[]:
  26. .RS 2
  27. Hierarchy to use for the ticket.
  28. Defaults to \f[B]o\f[], \f[B]TPM_RH_OWNER\f[], when no value has been
  29. specified.
  30. Supported options are:
  31. .IP \[bu] 2
  32. \f[B]o\f[] for \f[B]TPM_RH_OWNER\f[]
  33. .IP \[bu] 2
  34. \f[B]p\f[] for \f[B]TPM_RH_PLATFORM\f[]
  35. .IP \[bu] 2
  36. \f[B]e\f[] for \f[B]TPM_RH_ENDORSEMENT\f[]
  37. .IP \[bu] 2
  38. \f[B]n\f[] for \f[B]TPM_RH_NULL\f[]
  39. .RE
  40. .IP \[bu] 2
  41. \f[B]\-g\f[], \f[B]\-\-hash\-algorithm\f[]=\f[I]ALGORITHM\f[]:
  42. .RS 2
  43. .PP
  44. The hashing algorithm for the digest operation.
  45. .RE
  46. .IP \[bu] 2
  47. \f[B]\-\-hex\f[]
  48. .RS 2
  49. .PP
  50. Convert the output hmac to hex format without a leading "0x".
  51. .RE
  52. .IP \[bu] 2
  53. \f[B]\-o\f[], \f[B]\-\-output\f[]=\f[I]FILE\f[] or \f[I]STDOUT\f[]:
  54. .RS 2
  55. .PP
  56. Optional file to save the hash result.
  57. Defaults to stdout in hex form.
  58. .RE
  59. .IP \[bu] 2
  60. \f[B]\-t\f[], \f[B]\-\-ticket\f[]=\f[I]TICKET_FILE\f[]
  61. .RS 2
  62. .PP
  63. Optional file record of the ticket result.
  64. Defaults to stdout in hex form.
  65. .RE
  66. .IP \[bu] 2
  67. \f[B]ARGUMENT\f[] or \f[B]STDIN\f[] the command line argument specifies
  68. the \f[I]FILE\f[] to hash.
  69. .SS References
  70. .SH Context Object Format
  71. .PP
  72. The type of a context object, whether it is a handle or file name, is
  73. determined according to the following logic \f[I]in\-order\f[]:
  74. .IP \[bu] 2
  75. If the argument is a file path, then the file is loaded as a restored
  76. TPM transient object.
  77. .IP \[bu] 2
  78. If the argument is a \f[I]prefix\f[] match on one of:
  79. .RS 2
  80. .IP \[bu] 2
  81. owner: the owner hierarchy
  82. .IP \[bu] 2
  83. platform: the platform hierarchy
  84. .IP \[bu] 2
  85. endorsement: the endorsement hierarchy
  86. .IP \[bu] 2
  87. lockout: the lockout control persistent object
  88. .RE
  89. .IP \[bu] 2
  90. If the argument argument can be loaded as a number it will be treat as a
  91. handle, e.g.
  92. 0x81010013 and used directly.\f[I]OBJECT\f[].
  93. .SH Authorization Formatting
  94. .PP
  95. Authorization for use of an object in TPM2.0 can come in 3 different
  96. forms: 1.
  97. Password 2.
  98. HMAC 3.
  99. Sessions
  100. .PP
  101. \f[B]NOTE:\f[] "Authorizations default to the \f[B]EMPTY PASSWORD\f[]
  102. when not specified".
  103. .SS Passwords
  104. .PP
  105. Passwords are interpreted in the following forms below using prefix
  106. identifiers.
  107. .PP
  108. \f[B]Note\f[]: By default passwords are assumed to be in the string form
  109. when they do not have a prefix.
  110. .SS String
  111. .PP
  112. A string password, specified by prefix "str:" or it\[aq]s absence (raw
  113. string without prefix) is not interpreted, and is directly used for
  114. authorization.
  115. .SS Examples
  116. .IP
  117. .nf
  118. \f[C]
  119. foobar
  120. str:foobar
  121. \f[]
  122. .fi
  123. .SS Hex\-string
  124. .PP
  125. A hex\-string password, specified by prefix "hex:" is converted from a
  126. hexidecimal form into a byte array form, thus allowing passwords with
  127. non\-printable and/or terminal un\-friendly characters.
  128. .SS Example
  129. .IP
  130. .nf
  131. \f[C]
  132. hex:0x1122334455667788
  133. \f[]
  134. .fi
  135. .SS File
  136. .PP
  137. A file based password, specified be prefix "file:" should be the path of
  138. a file containing the password to be read by the tool or a "\-" to use
  139. stdin.
  140. Storing passwords in files prevents information leakage, passwords
  141. passed as options can be read from the process list or common shell
  142. history features.
  143. .SS Examples
  144. .IP
  145. .nf
  146. \f[C]
  147. #\ to\ use\ stdin\ and\ be\ prompted
  148. file:\-
  149. #\ to\ use\ a\ file\ from\ a\ path
  150. file:path/to/password/file
  151. #\ to\ echo\ a\ password\ via\ stdin:
  152. echo\ foobar\ |\ tpm2_tool\ \-p\ file:\-
  153. #\ to\ use\ a\ bash\ here\-string\ via\ stdin:
  154. tpm2_tool\ \-p\ file:\-\ <<<\ foobar
  155. \f[]
  156. .fi
  157. .SS Sessions
  158. .PP
  159. When using a policy session to authorize the use of an object, prefix
  160. the option argument with the \f[I]session\f[] keyword.
  161. Then indicate a path to a session file that was created with
  162. tpm2_startauthsession(1).
  163. Optionally, if the session requires an auth value to be sent with the
  164. session handle (eg policy password), then append a + and a string as
  165. described in the \f[B]Passwords\f[] section.
  166. .SS Examples
  167. .PP
  168. To use a session context file called \f[I]session.ctx\f[].
  169. .IP
  170. .nf
  171. \f[C]
  172. session:session.ctx
  173. \f[]
  174. .fi
  175. .PP
  176. To use a session context file called \f[I]session.ctx\f[] \f[B]AND\f[]
  177. send the authvalue mypassword.
  178. .IP
  179. .nf
  180. \f[C]
  181. session:session.ctx+mypassword
  182. \f[]
  183. .fi
  184. .PP
  185. To use a session context file called \f[I]session.ctx\f[] \f[B]AND\f[]
  186. send the \f[I]HEX\f[] authvalue 0x11223344.
  187. .IP
  188. .nf
  189. \f[C]
  190. session:session.ctx+hex:11223344
  191. \f[]
  192. .fi
  193. .SS PCR Authorizations
  194. .PP
  195. You can satisfy a PCR policy using the "pcr:" prefix and the PCR
  196. minilanguage.
  197. The PCR minilanguage is as follows:
  198. \f[C]<pcr\-spec>=<raw\-pcr\-file>\f[]
  199. .PP
  200. The PCR spec is documented in in the section "PCR bank specifiers".
  201. .PP
  202. The \f[C]raw\-pcr\-file\f[] is an \f[B]optional\f[] the output of the
  203. raw PCR contents as returned by \f[I]tpm2_pcrread(1)\f[].
  204. .PP
  205. PCR bank specifiers (common/pcr.md)
  206. .SS Examples
  207. .PP
  208. To satisfy a PCR policy of sha256 on banks 0, 1, 2 and 3 use a specifier
  209. of:
  210. .IP
  211. .nf
  212. \f[C]
  213. pcr:sha256:0,1,2,3
  214. \f[]
  215. .fi
  216. .PP
  217. \f[I]ALGORITHM\f[].
  218. .SH COMMON OPTIONS
  219. .PP
  220. This collection of options are common to many programs and provide
  221. information that many users may expect.
  222. .IP \[bu] 2
  223. \f[B]\-h\f[], \f[B]\-\-help=[man|no\-man]\f[]: Display the tools
  224. manpage.
  225. By default, it attempts to invoke the manpager for the tool, however, on
  226. failure will output a short tool summary.
  227. This is the same behavior if the "man" option argument is specified,
  228. however if explicit "man" is requested, the tool will provide errors
  229. from man on stderr.
  230. If the "no\-man" option if specified, or the manpager fails, the short
  231. options will be output to stdout.
  232. .RS 2
  233. .PP
  234. To successfully use the manpages feature requires the manpages to be
  235. installed or on \f[I]MANPATH\f[], See man(1) for more details.
  236. .RE
  237. .IP \[bu] 2
  238. \f[B]\-v\f[], \f[B]\-\-version\f[]: Display version information for this
  239. tool, supported tctis and exit.
  240. .IP \[bu] 2
  241. \f[B]\-V\f[], \f[B]\-\-verbose\f[]: Increase the information that the
  242. tool prints to the console during its execution.
  243. When using this option the file and line number are printed.
  244. .IP \[bu] 2
  245. \f[B]\-Q\f[], \f[B]\-\-quiet\f[]: Silence normal tool output to stdout.
  246. .IP \[bu] 2
  247. \f[B]\-Z\f[], \f[B]\-\-enable\-errata\f[]: Enable the application of
  248. errata fixups.
  249. Useful if an errata fixup needs to be applied to commands sent to the
  250. TPM.
  251. Defining the environment TPM2TOOLS_ENABLE_ERRATA is equivalent.
  252. information many users may expect.
  253. .SH TCTI Configuration
  254. .PP
  255. The TCTI or "Transmission Interface" is the communication mechanism with
  256. the TPM.
  257. TCTIs can be changed for communication with TPMs across different
  258. mediums.
  259. .PP
  260. To control the TCTI, the tools respect:
  261. .IP "1." 3
  262. The command line option \f[B]\-T\f[] or \f[B]\-\-tcti\f[]
  263. .IP "2." 3
  264. The environment variable: \f[I]TPM2TOOLS_TCTI\f[].
  265. .PP
  266. \f[B]Note:\f[] The command line option always overrides the environment
  267. variable.
  268. .PP
  269. The current known TCTIs are:
  270. .IP \[bu] 2
  271. tabrmd \- The resource manager, called
  272. tabrmd (https://github.com/tpm2-software/tpm2-abrmd).
  273. Note that tabrmd and abrmd as a tcti name are synonymous.
  274. .IP \[bu] 2
  275. mssim \- Typically used for communicating to the TPM software simulator.
  276. .IP \[bu] 2
  277. device \- Used when talking directly to a TPM device file.
  278. .IP \[bu] 2
  279. none \- Do not initalize a connection with the TPM.
  280. Some tools allow for off\-tpm options and thus support not using a TCTI.
  281. Tools that do not support it will error when attempted to be used
  282. without a TCTI connection.
  283. Does not support \f[I]ANY\f[] options and \f[I]MUST BE\f[] presented as
  284. the exact text of "none".
  285. .PP
  286. The arguments to either the command line option or the environment
  287. variable are in the form:
  288. .PP
  289. \f[C]<tcti\-name>:<tcti\-option\-config>\f[]
  290. .PP
  291. Specifying an empty string for either the \f[C]<tcti\-name>\f[] or
  292. \f[C]<tcti\-option\-config>\f[] results in the default being used for
  293. that portion respectively.
  294. .SS TCTI Defaults
  295. .PP
  296. When a TCTI is not specified, the default TCTI is searched for using
  297. \f[I]dlopen(3)\f[] semantics.
  298. The tools will search for \f[I]tabrmd\f[], \f[I]device\f[] and
  299. \f[I]mssim\f[] TCTIs \f[B]IN THAT ORDER\f[] and \f[B]USE THE FIRST ONE
  300. FOUND\f[].
  301. You can query what TCTI will be chosen as the default by using the
  302. \f[B]\-v\f[] option to print the version information.
  303. The "default\-tcti" key\-value pair will indicate which of the
  304. aforementioned TCTIs is the default.
  305. .SS Custom TCTIs
  306. .PP
  307. Any TCTI that implements the dynamic TCTI interface can be loaded.
  308. The tools internally use \f[I]dlopen(3)\f[], and the raw
  309. \f[I]tcti\-name\f[] value is used for the lookup.
  310. Thus, this could be a path to the shared library, or a library name as
  311. understood by \f[I]dlopen(3)\f[] semantics.
  312. .SH TCTI OPTIONS
  313. .PP
  314. This collection of options are used to configure the various known TCTI
  315. modules available:
  316. .IP \[bu] 2
  317. \f[B]device\f[]: For the device TCTI, the TPM character device file for
  318. use by the device TCTI can be specified.
  319. The default is \f[I]/dev/tpm0\f[].
  320. .RS 2
  321. .PP
  322. Example: \f[B]\-T device:/dev/tpm0\f[] or \f[B]export
  323. \f[I]TPM2TOOLS_TCTI\f[]="device:/dev/tpm0"\f[]
  324. .RE
  325. .IP \[bu] 2
  326. \f[B]mssim\f[]: For the mssim TCTI, the domain name or IP address and
  327. port number used by the simulator can be specified.
  328. The default are 127.0.0.1 and 2321.
  329. .RS 2
  330. .PP
  331. Example: \f[B]\-T mssim:host=localhost,port=2321\f[] or \f[B]export
  332. \f[I]TPM2TOOLS_TCTI\f[]="mssim:host=localhost,port=2321"\f[]
  333. .RE
  334. .IP \[bu] 2
  335. \f[B]abrmd\f[]: For the abrmd TCTI, the configuration string format is a
  336. series of simple key value pairs separated by a \[aq],\[aq] character.
  337. Each key and value string are separated by a \[aq]=\[aq] character.
  338. .RS 2
  339. .IP \[bu] 2
  340. TCTI abrmd supports two keys:
  341. .RS 2
  342. .IP "1." 3
  343. \[aq]bus_name\[aq] : The name of the tabrmd service on the bus (a
  344. string).
  345. .IP "2." 3
  346. \[aq]bus_type\[aq] : The type of the dbus instance (a string) limited to
  347. \[aq]session\[aq] and \[aq]system\[aq].
  348. .RE
  349. .PP
  350. Specify the tabrmd tcti name and a config string of
  351. \f[C]bus_name=com.example.FooBar\f[]:
  352. .PP
  353. \f[C]\\\-\-tcti=tabrmd:bus_name=com.example.FooBar\f[]
  354. .PP
  355. Specify the default (abrmd) tcti and a config string of
  356. \f[C]bus_type=session\f[]:
  357. .PP
  358. \f[C]\\\-\-tcti:bus_type=session\f[]
  359. .PP
  360. \f[B]NOTE\f[]: abrmd and tabrmd are synonymous.
  361. the various known TCTI modules.
  362. .RE
  363. .SH EXAMPLES
  364. .SS Hash a file with sha1 hash algorithm and save the hash and ticket to
  365. a file
  366. .IP
  367. .nf
  368. \f[C]
  369. tpm2_hash\ \-C\ e\ \-g\ sha1\ \-o\ hash.bin\ \-t\ ticket.bin\ data.txt
  370. \f[]
  371. .fi
  372. .SH Returns
  373. .PP
  374. Tools can return any of the following codes:
  375. .IP \[bu] 2
  376. 0 \- Success.
  377. .IP \[bu] 2
  378. 1 \- General non\-specific error.
  379. .IP \[bu] 2
  380. 2 \- Options handling error.
  381. .IP \[bu] 2
  382. 3 \- Authentication error.
  383. .IP \[bu] 2
  384. 4 \- TCTI related error.
  385. .IP \[bu] 2
  386. 5 \- Non supported scheme.
  387. Applicable to tpm2_testparams.
  388. .SH BUGS
  389. .PP
  390. Github Issues (https://github.com/tpm2-software/tpm2-tools/issues)
  391. .SH HELP
  392. .PP
  393. See the Mailing List (https://lists.01.org/mailman/listinfo/tpm2)