tpm2_nvwrite.1 11 KB

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