tpm2_policypcr.1 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472
  1. .\" Automatically generated by Pandoc 1.19.2.4
  2. .\"
  3. .TH "tpm2_policypcr" "1" "" "tpm2\-tools" "General Commands Manual"
  4. .hy
  5. .SH NAME
  6. .PP
  7. \f[B]tpm2_policypcr\f[](1) \- Create a policy that includes specific PCR
  8. values.
  9. .SH SYNOPSIS
  10. .PP
  11. \f[B]tpm2_policypcr\f[] [\f[I]OPTIONS\f[]]
  12. .SH DESCRIPTION
  13. .PP
  14. \f[B]tpm2_policypcr\f[](1) \- Generates a PCR policy event with the TPM.
  15. A PCR policy event creates a policy bound to specific PCR values and is
  16. useful within larger policies constructed using policyor and
  17. policyauthorize events.
  18. See \f[B]tpm2_policyor(1)\f[] and \f[B]tpm2_policyauthorize(1)\f[]
  19. respectively for their usages.
  20. The PCR data factored into the policy can be specified in one of 3 ways:
  21. 1.
  22. A file containing a concatenated list of PCR values as in the output
  23. from \f[B]tpm2_pcrread\f[].
  24. 2.
  25. Requiring the PCR values be read off the TPM by not specifying a PCR
  26. file input.
  27. 3.
  28. The digest of all the PCR values directly specified as an
  29. \f[B]argument\f[].
  30. .SH OPTIONS
  31. .IP \[bu] 2
  32. \f[B]\-L\f[], \f[B]\-\-policy\f[]=\f[I]FILE\f[]:
  33. .RS 2
  34. .PP
  35. File to save the policy digest.
  36. .RE
  37. .IP \[bu] 2
  38. \f[B]\-f\f[], \f[B]\-\-pcr\f[]=\f[I]FILE\f[]:
  39. .RS 2
  40. .PP
  41. Optional Path or Name of the file containing expected PCR values for the
  42. specified index.
  43. Default is to read the current PCRs per the set list.
  44. .RE
  45. .IP \[bu] 2
  46. \f[B]\-l\f[], \f[B]\-\-pcr\-list\f[]=\f[I]PCR\f[]:
  47. .RS 2
  48. .PP
  49. The list of PCR banks and selected PCRs\[aq] ids for each bank.
  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 policy session file generated via the \f[B]\-S\f[] option to
  56. \f[B]tpm2_startauthsession\f[](1).
  57. .RE
  58. .IP \[bu] 2
  59. \f[B]ARGUMENT\f[]: The calculated digest of all PCR values specified as
  60. a hex byte stream.
  61. Eg:
  62. \f[C]openssl\ dgst\ \-sha256\ \-binary\ pcr.bin\ |\ xxd\ \-p\ \-c\ 32\f[]
  63. .SS References
  64. .SH Context Object Format
  65. .PP
  66. The type of a context object, whether it is a handle or file name, is
  67. determined according to the following logic \f[I]in\-order\f[]:
  68. .IP \[bu] 2
  69. If the argument is a file path, then the file is loaded as a restored
  70. TPM transient object.
  71. .IP \[bu] 2
  72. If the argument is a \f[I]prefix\f[] match on one of:
  73. .RS 2
  74. .IP \[bu] 2
  75. owner: the owner hierarchy
  76. .IP \[bu] 2
  77. platform: the platform hierarchy
  78. .IP \[bu] 2
  79. endorsement: the endorsement hierarchy
  80. .IP \[bu] 2
  81. lockout: the lockout control persistent object
  82. .RE
  83. .IP \[bu] 2
  84. If the argument argument can be loaded as a number it will be treat as a
  85. handle, e.g.
  86. 0x81010013 and used directly.\f[I]OBJECT\f[].
  87. .SH Authorization Formatting
  88. .PP
  89. Authorization for use of an object in TPM2.0 can come in 3 different
  90. forms: 1.
  91. Password 2.
  92. HMAC 3.
  93. Sessions
  94. .PP
  95. \f[B]NOTE:\f[] "Authorizations default to the \f[B]EMPTY PASSWORD\f[]
  96. when not specified".
  97. .SS Passwords
  98. .PP
  99. Passwords are interpreted in the following forms below using prefix
  100. identifiers.
  101. .PP
  102. \f[B]Note\f[]: By default passwords are assumed to be in the string form
  103. when they do not have a prefix.
  104. .SS String
  105. .PP
  106. A string password, specified by prefix "str:" or it\[aq]s absence (raw
  107. string without prefix) is not interpreted, and is directly used for
  108. authorization.
  109. .SS Examples
  110. .IP
  111. .nf
  112. \f[C]
  113. foobar
  114. str:foobar
  115. \f[]
  116. .fi
  117. .SS Hex\-string
  118. .PP
  119. A hex\-string password, specified by prefix "hex:" is converted from a
  120. hexidecimal form into a byte array form, thus allowing passwords with
  121. non\-printable and/or terminal un\-friendly characters.
  122. .SS Example
  123. .IP
  124. .nf
  125. \f[C]
  126. hex:0x1122334455667788
  127. \f[]
  128. .fi
  129. .SS File
  130. .PP
  131. A file based password, specified be prefix "file:" should be the path of
  132. a file containing the password to be read by the tool or a "\-" to use
  133. stdin.
  134. Storing passwords in files prevents information leakage, passwords
  135. passed as options can be read from the process list or common shell
  136. history features.
  137. .SS Examples
  138. .IP
  139. .nf
  140. \f[C]
  141. #\ to\ use\ stdin\ and\ be\ prompted
  142. file:\-
  143. #\ to\ use\ a\ file\ from\ a\ path
  144. file:path/to/password/file
  145. #\ to\ echo\ a\ password\ via\ stdin:
  146. echo\ foobar\ |\ tpm2_tool\ \-p\ file:\-
  147. #\ to\ use\ a\ bash\ here\-string\ via\ stdin:
  148. tpm2_tool\ \-p\ file:\-\ <<<\ foobar
  149. \f[]
  150. .fi
  151. .SS Sessions
  152. .PP
  153. When using a policy session to authorize the use of an object, prefix
  154. the option argument with the \f[I]session\f[] keyword.
  155. Then indicate a path to a session file that was created with
  156. tpm2_startauthsession(1).
  157. Optionally, if the session requires an auth value to be sent with the
  158. session handle (eg policy password), then append a + and a string as
  159. described in the \f[B]Passwords\f[] section.
  160. .SS Examples
  161. .PP
  162. To use a session context file called \f[I]session.ctx\f[].
  163. .IP
  164. .nf
  165. \f[C]
  166. session:session.ctx
  167. \f[]
  168. .fi
  169. .PP
  170. To use a session context file called \f[I]session.ctx\f[] \f[B]AND\f[]
  171. send the authvalue mypassword.
  172. .IP
  173. .nf
  174. \f[C]
  175. session:session.ctx+mypassword
  176. \f[]
  177. .fi
  178. .PP
  179. To use a session context file called \f[I]session.ctx\f[] \f[B]AND\f[]
  180. send the \f[I]HEX\f[] authvalue 0x11223344.
  181. .IP
  182. .nf
  183. \f[C]
  184. session:session.ctx+hex:11223344
  185. \f[]
  186. .fi
  187. .SS PCR Authorizations
  188. .PP
  189. You can satisfy a PCR policy using the "pcr:" prefix and the PCR
  190. minilanguage.
  191. The PCR minilanguage is as follows:
  192. \f[C]<pcr\-spec>=<raw\-pcr\-file>\f[]
  193. .PP
  194. The PCR spec is documented in in the section "PCR bank specifiers".
  195. .PP
  196. The \f[C]raw\-pcr\-file\f[] is an \f[B]optional\f[] the output of the
  197. raw PCR contents as returned by \f[I]tpm2_pcrread(1)\f[].
  198. .PP
  199. PCR bank specifiers (common/pcr.md)
  200. .SS Examples
  201. .PP
  202. To satisfy a PCR policy of sha256 on banks 0, 1, 2 and 3 use a specifier
  203. of:
  204. .IP
  205. .nf
  206. \f[C]
  207. pcr:sha256:0,1,2,3
  208. \f[]
  209. .fi
  210. .PP
  211. specifying \f[I]AUTH\f[].
  212. .SH PCR Bank Specifiers
  213. .PP
  214. PCR Bank Selection lists follow the below specification:
  215. .IP
  216. .nf
  217. \f[C]
  218. <BANK>:<PCR>[,<PCR>]\ or\ <BANK>:all
  219. \f[]
  220. .fi
  221. .PP
  222. multiple banks may be separated by \[aq]+\[aq].
  223. .PP
  224. For example:
  225. .IP
  226. .nf
  227. \f[C]
  228. sha1:3,4+sha256:all
  229. \f[]
  230. .fi
  231. .PP
  232. will select PCRs 3 and 4 from the SHA1 bank and PCRs 0 to 23 from the
  233. SHA256 bank.
  234. .SS Note
  235. .PP
  236. PCR Selections allow for up to 5 hash to pcr selection mappings.
  237. This is a limitation in design in the single call to the tpm to get the
  238. pcr values.
  239. \f[I]PCR\f[].
  240. .SH COMMON OPTIONS
  241. .PP
  242. This collection of options are common to many programs and provide
  243. information that many users may expect.
  244. .IP \[bu] 2
  245. \f[B]\-h\f[], \f[B]\-\-help=[man|no\-man]\f[]: Display the tools
  246. manpage.
  247. By default, it attempts to invoke the manpager for the tool, however, on
  248. failure will output a short tool summary.
  249. This is the same behavior if the "man" option argument is specified,
  250. however if explicit "man" is requested, the tool will provide errors
  251. from man on stderr.
  252. If the "no\-man" option if specified, or the manpager fails, the short
  253. options will be output to stdout.
  254. .RS 2
  255. .PP
  256. To successfully use the manpages feature requires the manpages to be
  257. installed or on \f[I]MANPATH\f[], See man(1) for more details.
  258. .RE
  259. .IP \[bu] 2
  260. \f[B]\-v\f[], \f[B]\-\-version\f[]: Display version information for this
  261. tool, supported tctis and exit.
  262. .IP \[bu] 2
  263. \f[B]\-V\f[], \f[B]\-\-verbose\f[]: Increase the information that the
  264. tool prints to the console during its execution.
  265. When using this option the file and line number are printed.
  266. .IP \[bu] 2
  267. \f[B]\-Q\f[], \f[B]\-\-quiet\f[]: Silence normal tool output to stdout.
  268. .IP \[bu] 2
  269. \f[B]\-Z\f[], \f[B]\-\-enable\-errata\f[]: Enable the application of
  270. errata fixups.
  271. Useful if an errata fixup needs to be applied to commands sent to the
  272. TPM.
  273. Defining the environment TPM2TOOLS_ENABLE_ERRATA is equivalent.
  274. information many users may expect.
  275. .SH TCTI Configuration
  276. .PP
  277. The TCTI or "Transmission Interface" is the communication mechanism with
  278. the TPM.
  279. TCTIs can be changed for communication with TPMs across different
  280. mediums.
  281. .PP
  282. To control the TCTI, the tools respect:
  283. .IP "1." 3
  284. The command line option \f[B]\-T\f[] or \f[B]\-\-tcti\f[]
  285. .IP "2." 3
  286. The environment variable: \f[I]TPM2TOOLS_TCTI\f[].
  287. .PP
  288. \f[B]Note:\f[] The command line option always overrides the environment
  289. variable.
  290. .PP
  291. The current known TCTIs are:
  292. .IP \[bu] 2
  293. tabrmd \- The resource manager, called
  294. tabrmd (https://github.com/tpm2-software/tpm2-abrmd).
  295. Note that tabrmd and abrmd as a tcti name are synonymous.
  296. .IP \[bu] 2
  297. mssim \- Typically used for communicating to the TPM software simulator.
  298. .IP \[bu] 2
  299. device \- Used when talking directly to a TPM device file.
  300. .IP \[bu] 2
  301. none \- Do not initalize a connection with the TPM.
  302. Some tools allow for off\-tpm options and thus support not using a TCTI.
  303. Tools that do not support it will error when attempted to be used
  304. without a TCTI connection.
  305. Does not support \f[I]ANY\f[] options and \f[I]MUST BE\f[] presented as
  306. the exact text of "none".
  307. .PP
  308. The arguments to either the command line option or the environment
  309. variable are in the form:
  310. .PP
  311. \f[C]<tcti\-name>:<tcti\-option\-config>\f[]
  312. .PP
  313. Specifying an empty string for either the \f[C]<tcti\-name>\f[] or
  314. \f[C]<tcti\-option\-config>\f[] results in the default being used for
  315. that portion respectively.
  316. .SS TCTI Defaults
  317. .PP
  318. When a TCTI is not specified, the default TCTI is searched for using
  319. \f[I]dlopen(3)\f[] semantics.
  320. The tools will search for \f[I]tabrmd\f[], \f[I]device\f[] and
  321. \f[I]mssim\f[] TCTIs \f[B]IN THAT ORDER\f[] and \f[B]USE THE FIRST ONE
  322. FOUND\f[].
  323. You can query what TCTI will be chosen as the default by using the
  324. \f[B]\-v\f[] option to print the version information.
  325. The "default\-tcti" key\-value pair will indicate which of the
  326. aforementioned TCTIs is the default.
  327. .SS Custom TCTIs
  328. .PP
  329. Any TCTI that implements the dynamic TCTI interface can be loaded.
  330. The tools internally use \f[I]dlopen(3)\f[], and the raw
  331. \f[I]tcti\-name\f[] value is used for the lookup.
  332. Thus, this could be a path to the shared library, or a library name as
  333. understood by \f[I]dlopen(3)\f[] semantics.
  334. .SH TCTI OPTIONS
  335. .PP
  336. This collection of options are used to configure the various known TCTI
  337. modules available:
  338. .IP \[bu] 2
  339. \f[B]device\f[]: For the device TCTI, the TPM character device file for
  340. use by the device TCTI can be specified.
  341. The default is \f[I]/dev/tpm0\f[].
  342. .RS 2
  343. .PP
  344. Example: \f[B]\-T device:/dev/tpm0\f[] or \f[B]export
  345. \f[I]TPM2TOOLS_TCTI\f[]="device:/dev/tpm0"\f[]
  346. .RE
  347. .IP \[bu] 2
  348. \f[B]mssim\f[]: For the mssim TCTI, the domain name or IP address and
  349. port number used by the simulator can be specified.
  350. The default are 127.0.0.1 and 2321.
  351. .RS 2
  352. .PP
  353. Example: \f[B]\-T mssim:host=localhost,port=2321\f[] or \f[B]export
  354. \f[I]TPM2TOOLS_TCTI\f[]="mssim:host=localhost,port=2321"\f[]
  355. .RE
  356. .IP \[bu] 2
  357. \f[B]abrmd\f[]: For the abrmd TCTI, the configuration string format is a
  358. series of simple key value pairs separated by a \[aq],\[aq] character.
  359. Each key and value string are separated by a \[aq]=\[aq] character.
  360. .RS 2
  361. .IP \[bu] 2
  362. TCTI abrmd supports two keys:
  363. .RS 2
  364. .IP "1." 3
  365. \[aq]bus_name\[aq] : The name of the tabrmd service on the bus (a
  366. string).
  367. .IP "2." 3
  368. \[aq]bus_type\[aq] : The type of the dbus instance (a string) limited to
  369. \[aq]session\[aq] and \[aq]system\[aq].
  370. .RE
  371. .PP
  372. Specify the tabrmd tcti name and a config string of
  373. \f[C]bus_name=com.example.FooBar\f[]:
  374. .PP
  375. \f[C]\\\-\-tcti=tabrmd:bus_name=com.example.FooBar\f[]
  376. .PP
  377. Specify the default (abrmd) tcti and a config string of
  378. \f[C]bus_type=session\f[]:
  379. .PP
  380. \f[C]\\\-\-tcti:bus_type=session\f[]
  381. .PP
  382. \f[B]NOTE\f[]: abrmd and tabrmd are synonymous.
  383. the various known TCTI modules.
  384. .RE
  385. .SH EXAMPLES
  386. .PP
  387. Starts a \f[I]trial\f[] session, builds a PCR policy and uses that
  388. policy in the creation of an object.
  389. Then, it uses a \f[I]policy\f[] session to unseal some data stored in
  390. the object.
  391. .SS Step 1: create a policy
  392. .IP
  393. .nf
  394. \f[C]
  395. tpm2_createprimary\ \-C\ e\ \-g\ sha256\ \-G\ ecc\ \-c\ primary.ctx
  396. tpm2_pcrread\ \-o\ pcr.dat\ "sha1:0,1,2,3"
  397. tpm2_startauthsession\ \-S\ session.dat
  398. tpm2_policypcr\ \-S\ session.dat\ \-l\ "sha1:0,1,2,3"\ \-f\ pcr.dat\ \-L\ policy.dat
  399. tpm2_flushcontext\ session.dat
  400. \f[]
  401. .fi
  402. .SH Step 2: create an object using that policy
  403. .IP
  404. .nf
  405. \f[C]
  406. tpm2_create\ \-Q\ \-u\ key.pub\ \-r\ key.priv\ \-C\ primary.ctx\ \-L\ policy.dat\ \\
  407. \-i\-\ <<<\ "12345678"
  408. tpm2_load\ \-C\ primary.ctx\ \-u\ key.pub\ \-r\ key.priv\ \-n\ unseal.key.name\ \\
  409. \-c\ unseal.key.ctx
  410. \f[]
  411. .fi
  412. .SS Step 3: Satisfy the policy
  413. .IP
  414. .nf
  415. \f[C]
  416. tpm2_startauthsession\ \-\-policy\-session\ \-S\ session.dat
  417. tpm2_policypcr\ \-S\ session.dat\ \-l\ "sha1:0,1,2,3"\ \-f\ pcr.dat\ \-L\ policy.dat
  418. \f[]
  419. .fi
  420. .SS Step 4: Use the policy
  421. .IP
  422. .nf
  423. \f[C]
  424. tpm2_unseal\ \-psession:session.dat\ \-c\ unseal.key.ctx
  425. 12345678
  426. tpm2_flushcontext\ session.dat
  427. \f[]
  428. .fi
  429. .SH Returns
  430. .PP
  431. Tools can return any of the following codes:
  432. .IP \[bu] 2
  433. 0 \- Success.
  434. .IP \[bu] 2
  435. 1 \- General non\-specific error.
  436. .IP \[bu] 2
  437. 2 \- Options handling error.
  438. .IP \[bu] 2
  439. 3 \- Authentication error.
  440. .IP \[bu] 2
  441. 4 \- TCTI related error.
  442. .IP \[bu] 2
  443. 5 \- Non supported scheme.
  444. Applicable to tpm2_testparams.
  445. .SH Limitations
  446. .PP
  447. It expects a session to be already established via
  448. \f[B]tpm2_startauthsession\f[](1) and requires one of the following:
  449. .IP \[bu] 2
  450. direct device access
  451. .IP \[bu] 2
  452. extended session support with \f[B]tpm2\-abrmd\f[].
  453. .PP
  454. Without it, most resource managers \f[B]will not\f[] save session state
  455. between command invocations.
  456. .SH BUGS
  457. .PP
  458. Github Issues (https://github.com/tpm2-software/tpm2-tools/issues)
  459. .SH HELP
  460. .PP
  461. See the Mailing List (https://lists.01.org/mailman/listinfo/tpm2)