tpm2_nvdefine.1 14 KB

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