tpm2_hmac.1 15 KB

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