tpm2_policynv.1 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314
  1. .\" Automatically generated by Pandoc 1.19.2.4
  2. .\"
  3. .TH "tpm2_policynv" "1" "" "tpm2\-tools" "General Commands Manual"
  4. .hy
  5. .SH NAME
  6. .PP
  7. \f[B]tpm2_policynv\f[](1) \- Evaluates policy authorization by comparing
  8. a specified value against the contents in the specified NV Index.
  9. .SH SYNOPSIS
  10. .PP
  11. \f[B]tpm2_policynv\f[] [\f[I]OPTIONS\f[]] [\f[I]ARGUMENT\f[]]
  12. [\f[I]ARGUMENT\f[]]
  13. .SH DESCRIPTION
  14. .PP
  15. \f[B]tpm2_policynv\f[](1) \- This command evaluates policy authorization
  16. by comparing the contents written to an NV index against the one
  17. specified in the tool options.
  18. The tool takes two arguments \- (1) The NV index specified as raw handle
  19. or an offset value to the nv handle range "TPM2_HR_NV_INDEX" and (2)
  20. Comparison operator for magnitude comparison and or bit test operations.
  21. In the specification the NV index holding the data is called operandA
  22. and the data that the user specifies to compare is called operandB.
  23. The comparison operator can be specified as follows: * "eq" if operandA
  24. = operandB * "neq" if operandA != operandB * "sgt" if signed operandA >
  25. signed operandB * "ugt" if unsigned operandA > unsigned operandB * "slt"
  26. if signed operandA < signed operandB * "ult" if unsigned operandA <
  27. unsigned operandB * "sge" if signed operandA >= signed operandB * "uge"
  28. if unsigned operandA >= unsigned operandB * "sle" if signed operandA <=
  29. unsigned operandB * "ule" if unsigned operandA <= unsigned operandB *
  30. "bs" if all bits set in operandA are set in operandB * "bc" if all bits
  31. set in operandA are clear in operandB
  32. .SH OPTIONS
  33. .IP \[bu] 2
  34. \f[B]\-C\f[], \f[B]\-\-hierarchy\f[]=\f[I]OBJECT\f[]:
  35. .RS 2
  36. Specifies the hierarchy used to authorize.
  37. Supported options are:
  38. .IP \[bu] 2
  39. \f[B]o\f[] for \f[B]TPM_RH_OWNER\f[]
  40. .IP \[bu] 2
  41. \f[B]p\f[] for \f[B]TPM_RH_PLATFORM\f[]
  42. .IP \[bu] 2
  43. \f[B]\f[C]<num>\f[]\f[] where a hierarchy handle or nv\-index may be
  44. used.
  45. .PP
  46. When \f[B]\-C\f[] isn\[aq]t explicitly passed the index handle will be
  47. used to authorize against the index.
  48. The index auth value is set via the \f[B]\-p\f[] option to
  49. \f[B]tpm2_nvdefine\f[](1).
  50. .RE
  51. .IP \[bu] 2
  52. \f[B]\-P\f[], \f[B]\-\-auth\f[]=\f[I]AUTH\f[]:
  53. .RS 2
  54. .PP
  55. Specifies the authorization value for the hierarchy.
  56. .RE
  57. .IP \[bu] 2
  58. \f[B]\-L\f[], \f[B]\-\-policy\f[]=\f[I]FILE\f[]:
  59. .RS 2
  60. .PP
  61. File to save the policy digest.
  62. .RE
  63. .IP \[bu] 2
  64. \f[B]\-S\f[], \f[B]\-\-session\f[]=\f[I]FILE\f[]:
  65. .RS 2
  66. .PP
  67. The policy session file generated via the \f[B]\-S\f[] option to
  68. \f[B]tpm2_startauthsession\f[] or saved off of a previous tool run.
  69. .RE
  70. .IP \[bu] 2
  71. \f[B]\-\-offset\f[]=\f[I]NATURAL_NUMBER\f[]:
  72. .RS 2
  73. .PP
  74. The offset within the NV index to start comparing at.
  75. The size of the data starting at offset and ending at size of NV index
  76. shall not exceed the size of the operand specified in the options.
  77. .RE
  78. .IP \[bu] 2
  79. \f[B]\-\-cphash\f[]=\f[I]FILE\f[]
  80. .RS 2
  81. .PP
  82. File path to record the hash of the command parameters.
  83. This is commonly termed as cpHash.
  84. NOTE: When this option is selected, The tool will not actually execute
  85. the command, it simply returns a cpHash.
  86. .RE
  87. .IP \[bu] 2
  88. \f[B]\-i\f[], \f[B]\-\-input\f[]=\f[I]FILE\f[]:
  89. .RS 2
  90. .PP
  91. Specifies the input file with data to compare to NV Index contents.
  92. In the standard specification, this is termed as operand or operandB
  93. more specifically .
  94. It can be specified as a file input or stdin if option value is a "\-".
  95. .RE
  96. .SS References
  97. .SH COMMON OPTIONS
  98. .PP
  99. This collection of options are common to many programs and provide
  100. information that many users may expect.
  101. .IP \[bu] 2
  102. \f[B]\-h\f[], \f[B]\-\-help=[man|no\-man]\f[]: Display the tools
  103. manpage.
  104. By default, it attempts to invoke the manpager for the tool, however, on
  105. failure will output a short tool summary.
  106. This is the same behavior if the "man" option argument is specified,
  107. however if explicit "man" is requested, the tool will provide errors
  108. from man on stderr.
  109. If the "no\-man" option if specified, or the manpager fails, the short
  110. options will be output to stdout.
  111. .RS 2
  112. .PP
  113. To successfully use the manpages feature requires the manpages to be
  114. installed or on \f[I]MANPATH\f[], See man(1) for more details.
  115. .RE
  116. .IP \[bu] 2
  117. \f[B]\-v\f[], \f[B]\-\-version\f[]: Display version information for this
  118. tool, supported tctis and exit.
  119. .IP \[bu] 2
  120. \f[B]\-V\f[], \f[B]\-\-verbose\f[]: Increase the information that the
  121. tool prints to the console during its execution.
  122. When using this option the file and line number are printed.
  123. .IP \[bu] 2
  124. \f[B]\-Q\f[], \f[B]\-\-quiet\f[]: Silence normal tool output to stdout.
  125. .IP \[bu] 2
  126. \f[B]\-Z\f[], \f[B]\-\-enable\-errata\f[]: Enable the application of
  127. errata fixups.
  128. Useful if an errata fixup needs to be applied to commands sent to the
  129. TPM.
  130. Defining the environment TPM2TOOLS_ENABLE_ERRATA is equivalent.
  131. information many users may expect.
  132. .SH TCTI Configuration
  133. .PP
  134. The TCTI or "Transmission Interface" is the communication mechanism with
  135. the TPM.
  136. TCTIs can be changed for communication with TPMs across different
  137. mediums.
  138. .PP
  139. To control the TCTI, the tools respect:
  140. .IP "1." 3
  141. The command line option \f[B]\-T\f[] or \f[B]\-\-tcti\f[]
  142. .IP "2." 3
  143. The environment variable: \f[I]TPM2TOOLS_TCTI\f[].
  144. .PP
  145. \f[B]Note:\f[] The command line option always overrides the environment
  146. variable.
  147. .PP
  148. The current known TCTIs are:
  149. .IP \[bu] 2
  150. tabrmd \- The resource manager, called
  151. tabrmd (https://github.com/tpm2-software/tpm2-abrmd).
  152. Note that tabrmd and abrmd as a tcti name are synonymous.
  153. .IP \[bu] 2
  154. mssim \- Typically used for communicating to the TPM software simulator.
  155. .IP \[bu] 2
  156. device \- Used when talking directly to a TPM device file.
  157. .IP \[bu] 2
  158. none \- Do not initalize a connection with the TPM.
  159. Some tools allow for off\-tpm options and thus support not using a TCTI.
  160. Tools that do not support it will error when attempted to be used
  161. without a TCTI connection.
  162. Does not support \f[I]ANY\f[] options and \f[I]MUST BE\f[] presented as
  163. the exact text of "none".
  164. .PP
  165. The arguments to either the command line option or the environment
  166. variable are in the form:
  167. .PP
  168. \f[C]<tcti\-name>:<tcti\-option\-config>\f[]
  169. .PP
  170. Specifying an empty string for either the \f[C]<tcti\-name>\f[] or
  171. \f[C]<tcti\-option\-config>\f[] results in the default being used for
  172. that portion respectively.
  173. .SS TCTI Defaults
  174. .PP
  175. When a TCTI is not specified, the default TCTI is searched for using
  176. \f[I]dlopen(3)\f[] semantics.
  177. The tools will search for \f[I]tabrmd\f[], \f[I]device\f[] and
  178. \f[I]mssim\f[] TCTIs \f[B]IN THAT ORDER\f[] and \f[B]USE THE FIRST ONE
  179. FOUND\f[].
  180. You can query what TCTI will be chosen as the default by using the
  181. \f[B]\-v\f[] option to print the version information.
  182. The "default\-tcti" key\-value pair will indicate which of the
  183. aforementioned TCTIs is the default.
  184. .SS Custom TCTIs
  185. .PP
  186. Any TCTI that implements the dynamic TCTI interface can be loaded.
  187. The tools internally use \f[I]dlopen(3)\f[], and the raw
  188. \f[I]tcti\-name\f[] value is used for the lookup.
  189. Thus, this could be a path to the shared library, or a library name as
  190. understood by \f[I]dlopen(3)\f[] semantics.
  191. .SH TCTI OPTIONS
  192. .PP
  193. This collection of options are used to configure the various known TCTI
  194. modules available:
  195. .IP \[bu] 2
  196. \f[B]device\f[]: For the device TCTI, the TPM character device file for
  197. use by the device TCTI can be specified.
  198. The default is \f[I]/dev/tpm0\f[].
  199. .RS 2
  200. .PP
  201. Example: \f[B]\-T device:/dev/tpm0\f[] or \f[B]export
  202. \f[I]TPM2TOOLS_TCTI\f[]="device:/dev/tpm0"\f[]
  203. .RE
  204. .IP \[bu] 2
  205. \f[B]mssim\f[]: For the mssim TCTI, the domain name or IP address and
  206. port number used by the simulator can be specified.
  207. The default are 127.0.0.1 and 2321.
  208. .RS 2
  209. .PP
  210. Example: \f[B]\-T mssim:host=localhost,port=2321\f[] or \f[B]export
  211. \f[I]TPM2TOOLS_TCTI\f[]="mssim:host=localhost,port=2321"\f[]
  212. .RE
  213. .IP \[bu] 2
  214. \f[B]abrmd\f[]: For the abrmd TCTI, the configuration string format is a
  215. series of simple key value pairs separated by a \[aq],\[aq] character.
  216. Each key and value string are separated by a \[aq]=\[aq] character.
  217. .RS 2
  218. .IP \[bu] 2
  219. TCTI abrmd supports two keys:
  220. .RS 2
  221. .IP "1." 3
  222. \[aq]bus_name\[aq] : The name of the tabrmd service on the bus (a
  223. string).
  224. .IP "2." 3
  225. \[aq]bus_type\[aq] : The type of the dbus instance (a string) limited to
  226. \[aq]session\[aq] and \[aq]system\[aq].
  227. .RE
  228. .PP
  229. Specify the tabrmd tcti name and a config string of
  230. \f[C]bus_name=com.example.FooBar\f[]:
  231. .PP
  232. \f[C]\\\-\-tcti=tabrmd:bus_name=com.example.FooBar\f[]
  233. .PP
  234. Specify the default (abrmd) tcti and a config string of
  235. \f[C]bus_type=session\f[]:
  236. .PP
  237. \f[C]\\\-\-tcti:bus_type=session\f[]
  238. .PP
  239. \f[B]NOTE\f[]: abrmd and tabrmd are synonymous.
  240. the various known TCTI modules.
  241. .RE
  242. .SH EXAMPLES
  243. .PP
  244. Test if NV index content value is equal to an input number.
  245. To do this we first create an NV index of size 1 byte and write a value.
  246. Eg.
  247. 0xAA.
  248. Next we attempt to create a policy that becomes valid if the equality
  249. comparison operation of the NV index content against the one specified
  250. in the tool options.
  251. .SS Define the test NV Index and write the value 0xAA to it
  252. .IP
  253. .nf
  254. \f[C]
  255. nv_test_index=0x01500001
  256. tpm2_nvdefine\ \-C\ o\ \-p\ nvpass\ $nv_test_index\ \-a\ "authread|authwrite"\ \-s\ 1
  257. echo\ "aa"\ |\ xxd\ \-r\ \-p\ |\ tpm2_nvwrite\ \-P\ nvpass\ \-i\-\ $nv_test_index
  258. \f[]
  259. .fi
  260. .SS Attempt defining policynv with wrong comparison value specified in
  261. options.
  262. .IP
  263. .nf
  264. \f[C]
  265. tpm2_startauthsession\ \-S\ session.ctx\ \-\-policy\-session
  266. ###\ This\ should\ fail
  267. echo\ 0xBB\ |\ tpm2_policynv\ \-S\ session.ctx\ \-L\ policy.nv\ \-i\-\ 0x1500001\ eq\ \-P\ nvpass
  268. tpm2_flushcontext\ session.ctx
  269. \f[]
  270. .fi
  271. .SS Attempt defining policynv with right comparison value specified in
  272. options.
  273. .IP
  274. .nf
  275. \f[C]
  276. tpm2_startauthsession\ \-S\ session.ctx\ \-\-policy\-session
  277. ###\ This\ should\ pass
  278. echo\ 0xAA\ |\ tpm2_policynv\ \-S\ session.ctx\ \-L\ policy.nv\ \-i\-\ 0x1500001\ eq\ \-P\ nvpass
  279. tpm2_flushcontext\ session.ctx
  280. \f[]
  281. .fi
  282. .SH Returns
  283. .PP
  284. Tools can return any of the following codes:
  285. .IP \[bu] 2
  286. 0 \- Success.
  287. .IP \[bu] 2
  288. 1 \- General non\-specific error.
  289. .IP \[bu] 2
  290. 2 \- Options handling error.
  291. .IP \[bu] 2
  292. 3 \- Authentication error.
  293. .IP \[bu] 2
  294. 4 \- TCTI related error.
  295. .IP \[bu] 2
  296. 5 \- Non supported scheme.
  297. Applicable to tpm2_testparams.
  298. .SH Limitations
  299. .PP
  300. It expects a session to be already established via
  301. \f[B]tpm2_startauthsession\f[](1) and requires one of the following:
  302. .IP \[bu] 2
  303. direct device access
  304. .IP \[bu] 2
  305. extended session support with \f[B]tpm2\-abrmd\f[].
  306. .PP
  307. Without it, most resource managers \f[B]will not\f[] save session state
  308. between command invocations.
  309. .SH BUGS
  310. .PP
  311. Github Issues (https://github.com/tpm2-software/tpm2-tools/issues)
  312. .SH HELP
  313. .PP
  314. See the Mailing List (https://lists.01.org/mailman/listinfo/tpm2)