tpm2_policysecret.1 14 KB

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