tpm2_nvread.1 11 KB

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