tpm2_duplicate.1 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873
  1. .\" Automatically generated by Pandoc 1.19.2.4
  2. .\"
  3. .TH "tpm2_duplicate" "1" "" "tpm2\-tools" "General Commands Manual"
  4. .hy
  5. .SH NAME
  6. .PP
  7. tpm2_duplicate(1) \- Duplicates a loaded object so that it may be used
  8. in a different hierarchy.
  9. .SH SYNOPSIS
  10. .PP
  11. \f[B]tpm2_duplicate\f[] [\f[I]OPTIONS\f[]]
  12. .SH DESCRIPTION
  13. .PP
  14. \f[B]tpm2_duplicate\f[](1) \- This tool duplicates a loaded object so
  15. that it may be used in a different hierarchy.
  16. The new parent key for the duplicate may be on the same or different TPM
  17. or TPM_RH_NULL.
  18. .SH OPTIONS
  19. .PP
  20. These options control the key importation process:
  21. .IP \[bu] 2
  22. \f[B]\-G\f[], \f[B]\-\-wrapper\-algorithm\f[]=\f[I]ALGORITHM\f[]:
  23. .RS 2
  24. The symmetric algorithm to be used for the inner wrapper.
  25. Supports:
  26. .IP \[bu] 2
  27. aes \- AES 128 in CFB mode.
  28. .IP \[bu] 2
  29. null \- none
  30. .RE
  31. .IP \[bu] 2
  32. \f[B]\-i\f[], \f[B]\-\-encryptionkey\-in\f[]=\f[I]FILE\f[]:
  33. .RS 2
  34. .PP
  35. Specifies the filename of the symmetric key (128 bit data) to be used
  36. for the inner wrapper.
  37. Valid only when specified symmetric algorithm is not null
  38. .RE
  39. .IP \[bu] 2
  40. \f[B]\-o\f[], \f[B]\-\-encryptionkey\-out\f[]=\f[I]FILE\f[]:
  41. .RS 2
  42. .PP
  43. Specifies the filename to store the symmetric key (128 bit data) that
  44. was used for the inner wrapper.
  45. Valid only when specified symmetric algorithm is not null and
  46. \-\-input\-key\-file is not specified.
  47. The TPM generates the key in this case.
  48. .RE
  49. .IP \[bu] 2
  50. \f[B]\-C\f[], \f[B]\-\-parent\-context\f[]=\f[I]OBJECT\f[]:
  51. .RS 2
  52. .PP
  53. The parent key object.
  54. .RE
  55. .IP \[bu] 2
  56. \f[B]\-U\f[], \f[B]\-\-parent\-public\f[]=\f[I]FILE\f[]:
  57. .RS 2
  58. .PP
  59. Specifies the file path to the public key of the parent object on the
  60. destination TPM.
  61. This should be a \f[C]TPM2B_PUBLIC\f[] formatted file.
  62. .RE
  63. .IP \[bu] 2
  64. \f[B]\-k\f[], \f[B]\-\-private\-key\f[]=\f[I]FILE\f[]:
  65. .RS 2
  66. .PP
  67. Specifies the file path to the external private key be encrypted for the
  68. remote TPM.
  69. This should be a PEM format private key.
  70. .RE
  71. .IP \[bu] 2
  72. \f[B]\-r\f[], \f[B]\-\-private\f[]=\f[I]FILE\f[]:
  73. .RS 2
  74. .PP
  75. Specifies the file path to save the private portion of the duplicated
  76. object.
  77. # Protection Details
  78. .RE
  79. .PP
  80. Objects that can move outside of TPM need to be protected
  81. (confidentiality and integrity).
  82. For instance, transient objects require that TPM protected data (key or
  83. seal material) be stored outside of the TPM.
  84. This is seen in tools like tpm2_create(1), where the \f[B]\-r\f[] option
  85. outputs this protected data.
  86. This blob contains the sensitive portions of the object.
  87. The sensitive portions of the object are protected by the parent object,
  88. using the parent\[aq]s symmetric encryption details to encrypt the
  89. sensitive data and HMAC it.
  90. .PP
  91. In\-depth details can be found in sections 23 of:
  92. .IP \[bu] 2
  93. https://trustedcomputinggroup.org/wp\-content/uploads/TPM\-Rev\-2.0\-Part\-1\-Architecture\-01.38.pdf
  94. .PP
  95. Notably Figure 20, is relevant, even though it\[aq]s specifically
  96. referring to duplication blobs, the process is identical.
  97. .PP
  98. If the output is from tpm2_duplicate(1), the output will be slightly
  99. different, as described fully in section 23.
  100. .IP \[bu] 2
  101. \f[B]\-u\f[], \f[B]\-\-public\f[]=\f[I]FILE\f[]:
  102. .RS 2
  103. .PP
  104. Specifies the file path to save the public portion of the duplicated
  105. object, if an external key is being duplicated.
  106. .RE
  107. .IP \[bu] 2
  108. \f[B]\-s\f[], \f[B]\-\-encrypted\-seed\f[]=\f[I]FILE\f[]:
  109. .RS 2
  110. .PP
  111. The file to save the encrypted seed of the duplicated object.
  112. .RE
  113. .IP \[bu] 2
  114. \f[B]\-p\f[], \f[B]\-\-auth\f[]=\f[I]AUTH\f[]:
  115. .RS 2
  116. .PP
  117. The authorization value for the key, optional.
  118. .RE
  119. .IP \[bu] 2
  120. \f[B]\-c\f[], \f[B]\-\-key\-context\f[]=\f[I]OBJECT\f[]:
  121. .RS 2
  122. .PP
  123. The object to be duplicated.
  124. .RE
  125. .IP \[bu] 2
  126. \f[B]\-\-cphash\f[]=\f[I]FILE\f[]
  127. .RS 2
  128. .PP
  129. File path to record the hash of the command parameters.
  130. This is commonly termed as cpHash.
  131. NOTE: When this option is selected, The tool will not actually execute
  132. the command, it simply returns a cpHash.
  133. .RE
  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 Algorithm Specifiers
  284. .PP
  285. Options that take algorithms support "nice\-names".
  286. .PP
  287. There are two major algorithm specification string classes, simple and
  288. complex.
  289. Only certain algorithms will be accepted by the TPM, based on usage and
  290. conditions.
  291. .SS Simple specifiers
  292. .PP
  293. These are strings with no additional specification data.
  294. When creating objects, non\-specified portions of an object are assumed
  295. to defaults.
  296. You can find the list of known "Simple Specifiers Below".
  297. .SS Asymmetric
  298. .IP \[bu] 2
  299. rsa
  300. .IP \[bu] 2
  301. ecc
  302. .SS Symmetric
  303. .IP \[bu] 2
  304. aes
  305. .IP \[bu] 2
  306. camellia
  307. .SS Hashing Algorithms
  308. .IP \[bu] 2
  309. sha1
  310. .IP \[bu] 2
  311. sha256
  312. .IP \[bu] 2
  313. sha384
  314. .IP \[bu] 2
  315. sha512
  316. .IP \[bu] 2
  317. sm3_256
  318. .IP \[bu] 2
  319. sha3_256
  320. .IP \[bu] 2
  321. sha3_384
  322. .IP \[bu] 2
  323. sha3_512
  324. .SS Keyed Hash
  325. .IP \[bu] 2
  326. hmac
  327. .IP \[bu] 2
  328. xor
  329. .SS Signing Schemes
  330. .IP \[bu] 2
  331. rsassa
  332. .IP \[bu] 2
  333. rsapss
  334. .IP \[bu] 2
  335. ecdsa
  336. .IP \[bu] 2
  337. ecdaa
  338. .IP \[bu] 2
  339. ecschnorr
  340. .SS Asymmetric Encryption Schemes
  341. .IP \[bu] 2
  342. oaep
  343. .IP \[bu] 2
  344. rsaes
  345. .IP \[bu] 2
  346. ecdh
  347. .SS Modes
  348. .IP \[bu] 2
  349. ctr
  350. .IP \[bu] 2
  351. ofb
  352. .IP \[bu] 2
  353. cbc
  354. .IP \[bu] 2
  355. cfb
  356. .IP \[bu] 2
  357. ecb
  358. .SS Misc
  359. .IP \[bu] 2
  360. null
  361. .SS Complex Specifiers
  362. .PP
  363. Objects, when specified for creation by the TPM, have numerous
  364. algorithms to populate in the public data.
  365. Things like type, scheme and asymmetric details, key size, etc.
  366. Below is the general format for specifying this data:
  367. \f[C]<type>:<scheme>:<symmetric\-details>\f[]
  368. .SS Type Specifiers
  369. .PP
  370. This portion of the complex algorithm specifier is required.
  371. The remaining scheme and symmetric details will default based on the
  372. type specified and the type of the object being created.
  373. .IP \[bu] 2
  374. aes \- Default AES: aes128
  375. .IP \[bu] 2
  376. aes128\f[C]<mode>\f[] \- 128 bit AES with optional mode
  377. (\f[I]ctr\f[]|\f[I]ofb\f[]|\f[I]cbc\f[]|\f[I]cfb\f[]|\f[I]ecb\f[]).
  378. If mode is not specified, defaults to \f[I]null\f[].
  379. .IP \[bu] 2
  380. aes192\f[C]<mode>\f[] \- Same as aes128\f[C]<mode>\f[], except for a 192
  381. bit key size.
  382. .IP \[bu] 2
  383. aes256\f[C]<mode>\f[] \- Same as aes128\f[C]<mode>\f[], except for a 256
  384. bit key size.
  385. .IP \[bu] 2
  386. ecc \- Elliptical Curve, defaults to ecc256.
  387. .IP \[bu] 2
  388. ecc192 \- 192 bit ECC
  389. .IP \[bu] 2
  390. ecc224 \- 224 bit ECC
  391. .IP \[bu] 2
  392. ecc256 \- 256 bit ECC
  393. .IP \[bu] 2
  394. ecc384 \- 384 bit ECC
  395. .IP \[bu] 2
  396. ecc521 \- 521 bit ECC
  397. .IP \[bu] 2
  398. rsa \- Default RSA: rsa2048
  399. .IP \[bu] 2
  400. rsa1024 \- RSA with 1024 bit keysize.
  401. .IP \[bu] 2
  402. rsa2048 \- RSA with 2048 bit keysize.
  403. .IP \[bu] 2
  404. rsa4096 \- RSA with 4096 bit keysize.
  405. .SS Scheme Specifiers
  406. .PP
  407. Next, is an optional field, it can be skipped.
  408. .PP
  409. Schemes are usually \f[B]Signing Schemes\f[] or \f[B]Asymmetric
  410. Encryption Schemes\f[].
  411. Most signing schemes take a hash algorithm directly following the
  412. signing scheme.
  413. If the hash algorithm is missing, it defaults to \f[I]sha256\f[].
  414. Some take no arguments, and some take multiple arguments.
  415. .SS Hash Optional Scheme Specifiers
  416. .PP
  417. These scheme specifiers are followed by a dash and a valid hash
  418. algorithm, For example: \f[C]oaep\-sha256\f[].
  419. .IP \[bu] 2
  420. oaep
  421. .IP \[bu] 2
  422. ecdh
  423. .IP \[bu] 2
  424. rsassa
  425. .IP \[bu] 2
  426. rsapss
  427. .IP \[bu] 2
  428. ecdsa
  429. .IP \[bu] 2
  430. ecschnorr
  431. .SS Multiple Option Scheme Specifiers
  432. .PP
  433. This scheme specifier is followed by a count (max size UINT16) then
  434. followed by a dash(\-) and a valid hash algorithm.
  435. * ecdaa For example, ecdaa4\-sha256.
  436. If no count is specified, it defaults to 4.
  437. .SS No Option Scheme Specifiers
  438. .PP
  439. This scheme specifier takes NO arguments.
  440. * rsaes
  441. .SS Symmetric Details Specifiers
  442. .PP
  443. This field is optional, and defaults based on the \f[I]type\f[] of
  444. object being created and it\[aq]s attributes.
  445. Generally, any valid \f[B]Symmetric\f[] specifier from the \f[B]Type
  446. Specifiers\f[] list should work.
  447. If not specified, an asymmetric objects symmetric details defaults to
  448. \f[I]aes128cfb\f[].
  449. .SS Examples
  450. .SS Create an rsa2048 key with an rsaes asymmetric encryption scheme
  451. .PP
  452. \f[C]tpm2_create\ \-C\ parent.ctx\ \-G\ rsa2048:rsaes\ \-u\ key.pub\ \-r\ key.priv\f[]
  453. .SS Create an ecc256 key with an ecdaa signing scheme with a count of 4
  454. and sha384 hash
  455. .PP
  456. \f[C]/tpm2_create\ \-C\ parent.ctx\ \-G\ ecc256:ecdaa4\-sha384\ \-u\ key.pub\ \-r\ key.priv\f[]
  457. cryptographic algorithms \f[I]ALGORITHM\f[].
  458. .SH COMMON OPTIONS
  459. .PP
  460. This collection of options are common to many programs and provide
  461. information that many users may expect.
  462. .IP \[bu] 2
  463. \f[B]\-h\f[], \f[B]\-\-help=[man|no\-man]\f[]: Display the tools
  464. manpage.
  465. By default, it attempts to invoke the manpager for the tool, however, on
  466. failure will output a short tool summary.
  467. This is the same behavior if the "man" option argument is specified,
  468. however if explicit "man" is requested, the tool will provide errors
  469. from man on stderr.
  470. If the "no\-man" option if specified, or the manpager fails, the short
  471. options will be output to stdout.
  472. .RS 2
  473. .PP
  474. To successfully use the manpages feature requires the manpages to be
  475. installed or on \f[I]MANPATH\f[], See man(1) for more details.
  476. .RE
  477. .IP \[bu] 2
  478. \f[B]\-v\f[], \f[B]\-\-version\f[]: Display version information for this
  479. tool, supported tctis and exit.
  480. .IP \[bu] 2
  481. \f[B]\-V\f[], \f[B]\-\-verbose\f[]: Increase the information that the
  482. tool prints to the console during its execution.
  483. When using this option the file and line number are printed.
  484. .IP \[bu] 2
  485. \f[B]\-Q\f[], \f[B]\-\-quiet\f[]: Silence normal tool output to stdout.
  486. .IP \[bu] 2
  487. \f[B]\-Z\f[], \f[B]\-\-enable\-errata\f[]: Enable the application of
  488. errata fixups.
  489. Useful if an errata fixup needs to be applied to commands sent to the
  490. TPM.
  491. Defining the environment TPM2TOOLS_ENABLE_ERRATA is equivalent.
  492. information many users may expect.
  493. .SH TCTI Configuration
  494. .PP
  495. The TCTI or "Transmission Interface" is the communication mechanism with
  496. the TPM.
  497. TCTIs can be changed for communication with TPMs across different
  498. mediums.
  499. .PP
  500. To control the TCTI, the tools respect:
  501. .IP "1." 3
  502. The command line option \f[B]\-T\f[] or \f[B]\-\-tcti\f[]
  503. .IP "2." 3
  504. The environment variable: \f[I]TPM2TOOLS_TCTI\f[].
  505. .PP
  506. \f[B]Note:\f[] The command line option always overrides the environment
  507. variable.
  508. .PP
  509. The current known TCTIs are:
  510. .IP \[bu] 2
  511. tabrmd \- The resource manager, called
  512. tabrmd (https://github.com/tpm2-software/tpm2-abrmd).
  513. Note that tabrmd and abrmd as a tcti name are synonymous.
  514. .IP \[bu] 2
  515. mssim \- Typically used for communicating to the TPM software simulator.
  516. .IP \[bu] 2
  517. device \- Used when talking directly to a TPM device file.
  518. .IP \[bu] 2
  519. none \- Do not initalize a connection with the TPM.
  520. Some tools allow for off\-tpm options and thus support not using a TCTI.
  521. Tools that do not support it will error when attempted to be used
  522. without a TCTI connection.
  523. Does not support \f[I]ANY\f[] options and \f[I]MUST BE\f[] presented as
  524. the exact text of "none".
  525. .PP
  526. The arguments to either the command line option or the environment
  527. variable are in the form:
  528. .PP
  529. \f[C]<tcti\-name>:<tcti\-option\-config>\f[]
  530. .PP
  531. Specifying an empty string for either the \f[C]<tcti\-name>\f[] or
  532. \f[C]<tcti\-option\-config>\f[] results in the default being used for
  533. that portion respectively.
  534. .SS TCTI Defaults
  535. .PP
  536. When a TCTI is not specified, the default TCTI is searched for using
  537. \f[I]dlopen(3)\f[] semantics.
  538. The tools will search for \f[I]tabrmd\f[], \f[I]device\f[] and
  539. \f[I]mssim\f[] TCTIs \f[B]IN THAT ORDER\f[] and \f[B]USE THE FIRST ONE
  540. FOUND\f[].
  541. You can query what TCTI will be chosen as the default by using the
  542. \f[B]\-v\f[] option to print the version information.
  543. The "default\-tcti" key\-value pair will indicate which of the
  544. aforementioned TCTIs is the default.
  545. .SS Custom TCTIs
  546. .PP
  547. Any TCTI that implements the dynamic TCTI interface can be loaded.
  548. The tools internally use \f[I]dlopen(3)\f[], and the raw
  549. \f[I]tcti\-name\f[] value is used for the lookup.
  550. Thus, this could be a path to the shared library, or a library name as
  551. understood by \f[I]dlopen(3)\f[] semantics.
  552. .SH TCTI OPTIONS
  553. .PP
  554. This collection of options are used to configure the various known TCTI
  555. modules available:
  556. .IP \[bu] 2
  557. \f[B]device\f[]: For the device TCTI, the TPM character device file for
  558. use by the device TCTI can be specified.
  559. The default is \f[I]/dev/tpm0\f[].
  560. .RS 2
  561. .PP
  562. Example: \f[B]\-T device:/dev/tpm0\f[] or \f[B]export
  563. \f[I]TPM2TOOLS_TCTI\f[]="device:/dev/tpm0"\f[]
  564. .RE
  565. .IP \[bu] 2
  566. \f[B]mssim\f[]: For the mssim TCTI, the domain name or IP address and
  567. port number used by the simulator can be specified.
  568. The default are 127.0.0.1 and 2321.
  569. .RS 2
  570. .PP
  571. Example: \f[B]\-T mssim:host=localhost,port=2321\f[] or \f[B]export
  572. \f[I]TPM2TOOLS_TCTI\f[]="mssim:host=localhost,port=2321"\f[]
  573. .RE
  574. .IP \[bu] 2
  575. \f[B]abrmd\f[]: For the abrmd TCTI, the configuration string format is a
  576. series of simple key value pairs separated by a \[aq],\[aq] character.
  577. Each key and value string are separated by a \[aq]=\[aq] character.
  578. .RS 2
  579. .IP \[bu] 2
  580. TCTI abrmd supports two keys:
  581. .RS 2
  582. .IP "1." 3
  583. \[aq]bus_name\[aq] : The name of the tabrmd service on the bus (a
  584. string).
  585. .IP "2." 3
  586. \[aq]bus_type\[aq] : The type of the dbus instance (a string) limited to
  587. \[aq]session\[aq] and \[aq]system\[aq].
  588. .RE
  589. .PP
  590. Specify the tabrmd tcti name and a config string of
  591. \f[C]bus_name=com.example.FooBar\f[]:
  592. .PP
  593. \f[C]\\\-\-tcti=tabrmd:bus_name=com.example.FooBar\f[]
  594. .PP
  595. Specify the default (abrmd) tcti and a config string of
  596. \f[C]bus_type=session\f[]:
  597. .PP
  598. \f[C]\\\-\-tcti:bus_type=session\f[]
  599. .PP
  600. \f[B]NOTE\f[]: abrmd and tabrmd are synonymous.
  601. the various known TCTI modules.
  602. .RE
  603. .SH EXAMPLES
  604. .PP
  605. To duplicate a key, one needs the key to duplicate, created with a
  606. policy that
  607. .PD 0
  608. .P
  609. .PD
  610. allows duplication and a new parent:
  611. .IP
  612. .nf
  613. \f[C]
  614. tpm2_startauthsession\ \-S\ session.dat
  615. tpm2_policycommandcode\ \-S\ session.dat\ \-L\ policy.dat\ TPM2_CC_Duplicate
  616. tpm2_flushcontext\ session.dat
  617. tpm2_createprimary\ \-C\ o\ \-g\ sha256\ \-G\ rsa\ \-c\ primary.ctxt
  618. tpm2_create\ \-C\ primary.ctxt\ \-g\ sha256\ \-G\ rsa\ \-r\ key.prv\ \-u\ key.pub\ \\
  619. \-L\ policy.dat\ \-a\ "sensitivedataorigin"
  620. tpm2_loadexternal\ \-C\ o\ \-u\ new_parent.pub\ \-c\ new_parent.ctxt
  621. tpm2_startauthsession\ \\\-\-policy\-session\ \-S\ session.dat
  622. tpm2_policycommandcode\ \-S\ session.dat\ \-L\ policy.dat\ TPM2_CC_Duplicate
  623. tpm2_duplicate\ \-C\ new_parent.ctxt\ \-c\ key.ctxt\ \-G\ null\ \-p\ "session:session.dat"\ \\
  624. \-r\ duprv.bin\ \-s\ seed.dat
  625. tpm2_flushcontext\ session.dat
  626. \f[]
  627. .fi
  628. .PP
  629. As an end\-to\-end example, the following will transfer an RSA key
  630. generated on \f[C]TPM\-A\f[] to \f[C]TPM\-B\f[]
  631. .SS On TPM\-B
  632. .PP
  633. Create a parent object that will be used to wrap/transfer the key.
  634. .IP
  635. .nf
  636. \f[C]
  637. tpm2_createprimary\ \-C\ o\ \-g\ sha256\ \-G\ rsa\ \-c\ primary.ctx
  638. tpm2_create\ \ \-C\ primary.ctx\ \-g\ sha256\ \-G\ rsa\ \\
  639. \-r\ new_parent.prv\ \ \-u\ new_parent.pub\ \\
  640. \-a\ "restricted|sensitivedataorigin|decrypt|userwithauth"
  641. \f[]
  642. .fi
  643. .PP
  644. Copy \f[C]new_parent.pub\f[] to \f[C]TPM\-A\f[].
  645. .SS On TPM\-A
  646. .PP
  647. Create root object and auth policy allows duplication only
  648. .IP
  649. .nf
  650. \f[C]
  651. tpm2_createprimary\ \-C\ o\ \-g\ sha256\ \-G\ rsa\ \-c\ primary.ctx
  652. tpm2_startauthsession\ \-S\ session.dat
  653. tpm2_policycommandcode\ \-S\ session.dat\ \-L\ dpolicy.dat\ TPM2_CC_Duplicate
  654. tpm2_flushcontext\ session.dat
  655. rm\ session.dat
  656. \f[]
  657. .fi
  658. .PP
  659. Generate an RSA keypair on TPM\-A that will be duplicated (note the
  660. passphrase is \[aq]foo\[aq])
  661. .IP
  662. .nf
  663. \f[C]
  664. tpm2_create\ \-C\ primary.ctx\ \-g\ sha256\ \-G\ rsa\ \-p\ foo\ \-r\ key.prv\ \\
  665. \-u\ key.pub\ \ \-L\ dpolicy.dat\ \-a\ "sensitivedataorigin|userwithauth|decrypt|sign"
  666. tpm2_load\ \-C\ primary.ctx\ \-r\ key.prv\ \-u\ key.pub\ \-c\ key.ctx
  667. tpm2_readpublic\ \-c\ key.ctx\ \-o\ dup.pub
  668. \f[]
  669. .fi
  670. .PP
  671. Test sign and encryption locally (so we can compare later that the same
  672. key was transferred).
  673. .IP
  674. .nf
  675. \f[C]
  676. echo\ "meet\ me\ at.."\ >file.txt
  677. tpm2_rsaencrypt\ \-c\ key.ctx\ \ \-o\ data.encrypted\ file.txt
  678. tpm2_sign\ \-c\ key.ctx\ \-g\ sha256\ \-f\ plain\ \-p\ foo\ \-o\ sign.raw\ file.txt
  679. \f[]
  680. .fi
  681. .PP
  682. Compare the signature hash (we will use this later to confirm the key
  683. was transferred to TPM\-B):
  684. .IP
  685. .nf
  686. \f[C]
  687. sha256sum\ sign.raw
  688. a1b4e3fbaa29e6e46d95cff498150b6b8e7d9fd21182622e8f5a3ddde257879e
  689. \f[]
  690. .fi
  691. .PP
  692. Start an auth session and policy command to allow duplication
  693. .IP
  694. .nf
  695. \f[C]
  696. tpm2_startauthsession\ \-\-policy\-session\ \-S\ session.dat
  697. tpm2_policycommandcode\ \-S\ session.dat\ \-L\ dpolicy.dat\ TPM2_CC_Duplicate
  698. \f[]
  699. .fi
  700. .PP
  701. Load the new_parent.pub file transferred from \f[C]TPM\-B\f[]
  702. .IP
  703. .nf
  704. \f[C]
  705. tpm2_loadexternal\ \-C\ o\ \-u\ new_parent.pub\ \-c\ new_parent.ctx
  706. \f[]
  707. .fi
  708. .PP
  709. Start the duplication
  710. .IP
  711. .nf
  712. \f[C]
  713. tpm2_duplicate\ \-C\ new_parent.ctx\ \-c\ key.ctx\ \-G\ null\ \ \\
  714. \-p\ "session:session.dat"\ \-r\ dup.dpriv\ \-s\ dup.seed
  715. \f[]
  716. .fi
  717. .PP
  718. Copy the following files to TPM\-B: * dup.pub * dup.dpriv * dup.seed *
  719. (optionally data.encrypted just to test decryption)
  720. .SS On TPM\-B
  721. .PP
  722. Start an auth,policy session
  723. .IP
  724. .nf
  725. \f[C]
  726. tpm2_startauthsession\ \-\-policy\-session\ \-S\ session.dat
  727. tpm2_policycommandcode\ \-S\ session.dat\ \-L\ dpolicy.dat\ TPM2_CC_Duplicate
  728. \f[]
  729. .fi
  730. .PP
  731. Load the context we used to transfer
  732. .IP
  733. .nf
  734. \f[C]
  735. tpm2_flushcontext\ \-\-transient\-object
  736. tpm2_load\ \-C\ primary.ctx\ \-u\ new_parent.pub\ \-r\ new_parent.prv\ \-c\ new_parent.ctx
  737. \f[]
  738. .fi
  739. .PP
  740. Import the duplicated context against the parent we used
  741. .IP
  742. .nf
  743. \f[C]
  744. tpm2_import\ \-C\ new_parent.ctx\ \-u\ dup.pub\ \-i\ dup.dpriv\ \\
  745. \-r\ dup.prv\ \-s\ dup.seed\ \-L\ dpolicy.dat
  746. \f[]
  747. .fi
  748. .PP
  749. Load the duplicated key context
  750. .IP
  751. .nf
  752. \f[C]
  753. tpm2_flushcontext\ \-\-transient\-object
  754. tpm2_load\ \-C\ new_parent.ctx\ \-u\ dup.pub\ \-r\ dup.prv\ \-c\ dup.ctx
  755. \f[]
  756. .fi
  757. .PP
  758. Test the imported key matches
  759. .IP \[bu] 2
  760. Sign
  761. .IP
  762. .nf
  763. \f[C]
  764. echo\ "meet\ me\ at.."\ >file.txt
  765. tpm2_sign\ \-c\ dup.ctx\ \-g\ sha256\ \-o\ sig.rss\ \-p\ foo\ file.txt
  766. dd\ if=sig.rss\ of=sign.raw\ bs=1\ skip=6\ count=256
  767. \f[]
  768. .fi
  769. .PP
  770. Compare the signature file hash:
  771. .IP
  772. .nf
  773. \f[C]
  774. $\ sha256sum\ sign.raw
  775. a1b4e3fbaa29e6e46d95cff498150b6b8e7d9fd21182622e8f5a3ddde257879e
  776. \f[]
  777. .fi
  778. .IP \[bu] 2
  779. Decryption
  780. .IP
  781. .nf
  782. \f[C]
  783. tpm2_flushcontext\ \-\-transient\-object
  784. tpm2_rsadecrypt\ \-p\ foo\ \-c\ dup.ctx\ \-o\ data.ptext\ data.encrypted
  785. #\ cat\ data.ptext\
  786. meet\ me\ at..
  787. \f[]
  788. .fi
  789. .SS Exporting an OpenSSL RSA key for a remote TPM
  790. .PP
  791. To securely send an OpenSSL generated RSA key to a remote TPM such that
  792. only that remote TPM will be able to load it, and without exposing the
  793. private key to the host operating system on the remote machine:
  794. .IP \[bu] 2
  795. On the destination TPM\-B, create a primary context and read its public
  796. key, then send \f[C]primary.pub\f[] to the source machine:
  797. .IP
  798. .nf
  799. \f[C]
  800. tpm2_createprimary\ \-c\ primary.ctx
  801. tpm2_readpublic\ \-c\ primary.ctx\ \-o\ primary.pub
  802. \f[]
  803. .fi
  804. .IP \[bu] 2
  805. On the source machine create the RSA private key and wrap it for the
  806. destination TPM\[aq]s public key.
  807. Similar to \f[C]tpm2_makecredential\f[], this step should not require a
  808. TPM.
  809. .IP
  810. .nf
  811. \f[C]
  812. openssl\ genrsa\ \-out\ rsa.pem
  813. tpm2_duplicate\ \-U\ primary.pub\ \-G\ rsa\ \-k\ rsa.pem\ \-u\ rsa.pub\ \-r\ rsa.dpriv\ \-s\ rsa.seed
  814. \f[]
  815. .fi
  816. .IP \[bu] 2
  817. Send the \f[C]rsa.pub\f[], \f[C]rsa.dpriv\f[] and \f[C]rsa.seed\f[] to
  818. the destination TPM\-B and import the files, which will decrypt them
  819. using the \f[C]primary.ctx\f[] to produce \f[C]rsa.priv\f[], which can
  820. then be loaded and used as a TPM key:
  821. .IP
  822. .nf
  823. \f[C]
  824. tpm2_import\ \-C\ primary.ctx\ \-G\ rsa\ \-i\ rsa.dpriv\ \-s\ rsa.seed\ \-u\ rsa.pub\ \-r\ rsa.priv
  825. tpm2_load\ \-C\ primary.ctx\ \-c\ rsa.ctx\ \-u\ rsa.pub\ \-r\ rsa.priv
  826. \f[]
  827. .fi
  828. .SH Returns
  829. .PP
  830. Tools can return any of the following codes:
  831. .IP \[bu] 2
  832. 0 \- Success.
  833. .IP \[bu] 2
  834. 1 \- General non\-specific error.
  835. .IP \[bu] 2
  836. 2 \- Options handling error.
  837. .IP \[bu] 2
  838. 3 \- Authentication error.
  839. .IP \[bu] 2
  840. 4 \- TCTI related error.
  841. .IP \[bu] 2
  842. 5 \- Non supported scheme.
  843. Applicable to tpm2_testparams.
  844. .SH BUGS
  845. .PP
  846. Github Issues (https://github.com/tpm2-software/tpm2-tools/issues)
  847. .SH HELP
  848. .PP
  849. See the Mailing List (https://lists.01.org/mailman/listinfo/tpm2)