tpm2_readpublic.1 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307
  1. .\" Automatically generated by Pandoc 1.19.2.4
  2. .\"
  3. .TH "tpm2_readpublic" "1" "" "tpm2\-tools" "General Commands Manual"
  4. .hy
  5. .SH NAME
  6. .PP
  7. \f[B]tpm2_readpublic\f[](1) \- Read the public area of a loaded object.
  8. .SH SYNOPSIS
  9. .PP
  10. \f[B]tpm2_readpublic\f[] [\f[I]OPTIONS\f[]]
  11. .SH DESCRIPTION
  12. .PP
  13. \f[B]tpm2_readpublic\f[](1) \- Reads the public area of a loaded object.
  14. .SH OPTIONS
  15. .IP \[bu] 2
  16. \f[B]\-c\f[], \f[B]\-\-object\-context\f[]=\f[I]OBJECT\f[]:
  17. .RS 2
  18. .PP
  19. Context object for the object to read.
  20. .RE
  21. .IP \[bu] 2
  22. \f[B]\-n\f[], \f[B]\-\-name\f[]=\f[I]FILE\f[]:
  23. .RS 2
  24. .PP
  25. An optional file to save the name structure of the object.
  26. .RE
  27. .IP \[bu] 2
  28. \f[B]\-f\f[], \f[B]\-\-format\f[]:
  29. .RS 2
  30. .PP
  31. Format selection for the public key output file.
  32. \[aq]tss\[aq] (the default) will output a binary blob according to the
  33. TPM 2.0 Specification.
  34. \[aq]pem\[aq] will output an OpenSSL compatible PEM encoded public key.
  35. \[aq]der\[aq] will output an OpenSSL compatible DER encoded public key.
  36. \[aq]tpmt\[aq] will output a binary blob of the TPMT_PUBLIC struct
  37. referenced by TPM 2.0 specs.
  38. .PP
  39. Public key format.
  40. .RE
  41. .IP \[bu] 2
  42. \f[B]\-o\f[], \f[B]\-\-output\f[]=\f[I]FILE\f[]:
  43. .RS 2
  44. .PP
  45. The output file path, recording the public portion of the object.
  46. .RE
  47. .IP \[bu] 2
  48. \f[B]\-t\f[], \f[B]\-\-serialized\-handle\f[]=\f[I]HANDLE\f[]:
  49. .RS 2
  50. .PP
  51. If the object to be read is a persistent object specified by a raw
  52. handle, optionally save the serialized handle for use later.
  53. This routine does NOT verify the name of the object being read.
  54. Callers should ensure that the contents of name match the expected
  55. objects name.
  56. .RE
  57. .IP \[bu] 2
  58. \f[B]\-q\f[], \f[B]\-\-qualified\-name\f[]=\f[I]FILE\f[]:
  59. .RS 2
  60. .PP
  61. Saves the qualified name of the object to \f[I]FILE\f[].
  62. The qualified name of the object is the name algorithm hash of the
  63. parents qualified and the objects name.
  64. Thus the qualified name of the object serves as proof of the objects
  65. parents.
  66. .RE
  67. .SS References
  68. .SH Context Object Format
  69. .PP
  70. The type of a context object, whether it is a handle or file name, is
  71. determined according to the following logic \f[I]in\-order\f[]:
  72. .IP \[bu] 2
  73. If the argument is a file path, then the file is loaded as a restored
  74. TPM transient object.
  75. .IP \[bu] 2
  76. If the argument is a \f[I]prefix\f[] match on one of:
  77. .RS 2
  78. .IP \[bu] 2
  79. owner: the owner hierarchy
  80. .IP \[bu] 2
  81. platform: the platform hierarchy
  82. .IP \[bu] 2
  83. endorsement: the endorsement hierarchy
  84. .IP \[bu] 2
  85. lockout: the lockout control persistent object
  86. .RE
  87. .IP \[bu] 2
  88. If the argument argument can be loaded as a number it will be treat as a
  89. handle, e.g.
  90. 0x81010013 and used directly.\f[I]OBJECT\f[].
  91. .SH COMMON OPTIONS
  92. .PP
  93. This collection of options are common to many programs and provide
  94. information that many users may expect.
  95. .IP \[bu] 2
  96. \f[B]\-h\f[], \f[B]\-\-help=[man|no\-man]\f[]: Display the tools
  97. manpage.
  98. By default, it attempts to invoke the manpager for the tool, however, on
  99. failure will output a short tool summary.
  100. This is the same behavior if the "man" option argument is specified,
  101. however if explicit "man" is requested, the tool will provide errors
  102. from man on stderr.
  103. If the "no\-man" option if specified, or the manpager fails, the short
  104. options will be output to stdout.
  105. .RS 2
  106. .PP
  107. To successfully use the manpages feature requires the manpages to be
  108. installed or on \f[I]MANPATH\f[], See man(1) for more details.
  109. .RE
  110. .IP \[bu] 2
  111. \f[B]\-v\f[], \f[B]\-\-version\f[]: Display version information for this
  112. tool, supported tctis and exit.
  113. .IP \[bu] 2
  114. \f[B]\-V\f[], \f[B]\-\-verbose\f[]: Increase the information that the
  115. tool prints to the console during its execution.
  116. When using this option the file and line number are printed.
  117. .IP \[bu] 2
  118. \f[B]\-Q\f[], \f[B]\-\-quiet\f[]: Silence normal tool output to stdout.
  119. .IP \[bu] 2
  120. \f[B]\-Z\f[], \f[B]\-\-enable\-errata\f[]: Enable the application of
  121. errata fixups.
  122. Useful if an errata fixup needs to be applied to commands sent to the
  123. TPM.
  124. Defining the environment TPM2TOOLS_ENABLE_ERRATA is equivalent.
  125. information many users may expect.
  126. .SH TCTI Configuration
  127. .PP
  128. The TCTI or "Transmission Interface" is the communication mechanism with
  129. the TPM.
  130. TCTIs can be changed for communication with TPMs across different
  131. mediums.
  132. .PP
  133. To control the TCTI, the tools respect:
  134. .IP "1." 3
  135. The command line option \f[B]\-T\f[] or \f[B]\-\-tcti\f[]
  136. .IP "2." 3
  137. The environment variable: \f[I]TPM2TOOLS_TCTI\f[].
  138. .PP
  139. \f[B]Note:\f[] The command line option always overrides the environment
  140. variable.
  141. .PP
  142. The current known TCTIs are:
  143. .IP \[bu] 2
  144. tabrmd \- The resource manager, called
  145. tabrmd (https://github.com/tpm2-software/tpm2-abrmd).
  146. Note that tabrmd and abrmd as a tcti name are synonymous.
  147. .IP \[bu] 2
  148. mssim \- Typically used for communicating to the TPM software simulator.
  149. .IP \[bu] 2
  150. device \- Used when talking directly to a TPM device file.
  151. .IP \[bu] 2
  152. none \- Do not initalize a connection with the TPM.
  153. Some tools allow for off\-tpm options and thus support not using a TCTI.
  154. Tools that do not support it will error when attempted to be used
  155. without a TCTI connection.
  156. Does not support \f[I]ANY\f[] options and \f[I]MUST BE\f[] presented as
  157. the exact text of "none".
  158. .PP
  159. The arguments to either the command line option or the environment
  160. variable are in the form:
  161. .PP
  162. \f[C]<tcti\-name>:<tcti\-option\-config>\f[]
  163. .PP
  164. Specifying an empty string for either the \f[C]<tcti\-name>\f[] or
  165. \f[C]<tcti\-option\-config>\f[] results in the default being used for
  166. that portion respectively.
  167. .SS TCTI Defaults
  168. .PP
  169. When a TCTI is not specified, the default TCTI is searched for using
  170. \f[I]dlopen(3)\f[] semantics.
  171. The tools will search for \f[I]tabrmd\f[], \f[I]device\f[] and
  172. \f[I]mssim\f[] TCTIs \f[B]IN THAT ORDER\f[] and \f[B]USE THE FIRST ONE
  173. FOUND\f[].
  174. You can query what TCTI will be chosen as the default by using the
  175. \f[B]\-v\f[] option to print the version information.
  176. The "default\-tcti" key\-value pair will indicate which of the
  177. aforementioned TCTIs is the default.
  178. .SS Custom TCTIs
  179. .PP
  180. Any TCTI that implements the dynamic TCTI interface can be loaded.
  181. The tools internally use \f[I]dlopen(3)\f[], and the raw
  182. \f[I]tcti\-name\f[] value is used for the lookup.
  183. Thus, this could be a path to the shared library, or a library name as
  184. understood by \f[I]dlopen(3)\f[] semantics.
  185. .SH TCTI OPTIONS
  186. .PP
  187. This collection of options are used to configure the various known TCTI
  188. modules available:
  189. .IP \[bu] 2
  190. \f[B]device\f[]: For the device TCTI, the TPM character device file for
  191. use by the device TCTI can be specified.
  192. The default is \f[I]/dev/tpm0\f[].
  193. .RS 2
  194. .PP
  195. Example: \f[B]\-T device:/dev/tpm0\f[] or \f[B]export
  196. \f[I]TPM2TOOLS_TCTI\f[]="device:/dev/tpm0"\f[]
  197. .RE
  198. .IP \[bu] 2
  199. \f[B]mssim\f[]: For the mssim TCTI, the domain name or IP address and
  200. port number used by the simulator can be specified.
  201. The default are 127.0.0.1 and 2321.
  202. .RS 2
  203. .PP
  204. Example: \f[B]\-T mssim:host=localhost,port=2321\f[] or \f[B]export
  205. \f[I]TPM2TOOLS_TCTI\f[]="mssim:host=localhost,port=2321"\f[]
  206. .RE
  207. .IP \[bu] 2
  208. \f[B]abrmd\f[]: For the abrmd TCTI, the configuration string format is a
  209. series of simple key value pairs separated by a \[aq],\[aq] character.
  210. Each key and value string are separated by a \[aq]=\[aq] character.
  211. .RS 2
  212. .IP \[bu] 2
  213. TCTI abrmd supports two keys:
  214. .RS 2
  215. .IP "1." 3
  216. \[aq]bus_name\[aq] : The name of the tabrmd service on the bus (a
  217. string).
  218. .IP "2." 3
  219. \[aq]bus_type\[aq] : The type of the dbus instance (a string) limited to
  220. \[aq]session\[aq] and \[aq]system\[aq].
  221. .RE
  222. .PP
  223. Specify the tabrmd tcti name and a config string of
  224. \f[C]bus_name=com.example.FooBar\f[]:
  225. .PP
  226. \f[C]\\\-\-tcti=tabrmd:bus_name=com.example.FooBar\f[]
  227. .PP
  228. Specify the default (abrmd) tcti and a config string of
  229. \f[C]bus_type=session\f[]:
  230. .PP
  231. \f[C]\\\-\-tcti:bus_type=session\f[]
  232. .PP
  233. \f[B]NOTE\f[]: abrmd and tabrmd are synonymous.
  234. the various known TCTI modules.
  235. # EXAMPLES
  236. .RE
  237. .SS Create a primary object and read the public structure in an openssl
  238. compliant format
  239. .IP
  240. .nf
  241. \f[C]
  242. tpm2_createprimary\ \-c\ primary.ctx
  243. tpm2_readpublic\ \-c\ primary.ctx\ \-o\ output.dat\ \-f\ pem
  244. \f[]
  245. .fi
  246. .SS Serialize an existing persistent object handle to disk for later use
  247. .PP
  248. This work\-flow is primarily intended for existing persistent TPM
  249. objects.
  250. This work\-flow does not verify that the name of the serialized object
  251. matches the expected, and thus the serialized handle could be pointing
  252. to an attacker controlled object if no verification is done.
  253. If you are creating an object from scratch, save the serialized handle
  254. when making the object persistent.
  255. .PP
  256. We assume that an object has already been persisted, for example via:
  257. .IP
  258. .nf
  259. \f[C]
  260. #\ We\ assume\ that\ an\ object\ has\ already\ been\ persisted,\ for\ example
  261. tpm2_createprimary\ \-c\ primary.ctx
  262. #\ context\ files\ have\ all\ the\ information\ for\ the\ TPM\ to\ verify\ the\ object
  263. tpm2_evictcontrol\ \-c\ primary.ctx
  264. persistent\-handle:\ 0x81000001
  265. action:\ persisted
  266. \f[]
  267. .fi
  268. .PP
  269. Next use the persistent handle to get a serialized handle:
  270. .IP
  271. .nf
  272. \f[C]
  273. #\ The\ persistent\ handle\ output\ could\ be\ at\ an\ attacker\ controlled\ object,
  274. #\ best\ practice\ is\ to\ use\ the\ option\ "\-o:\ for\ tpm2_evictcontrol\ to\ get\ a
  275. #\ serialized\ handle\ instead.
  276. tpm2_readpublic\ \-c\ 0x81000001\ \-o\ output.dat\ \-f\ pem\ \-t\ primary.handle
  277. #\ use\ this\ verified\ handle\ in\ an\ encrypted\ session\ with\ the\ tpm
  278. tpm2_startauthsession\ \-\-policy\-session\ \-S\ session.ctx\ \-c\ primary.handle
  279. \f[]
  280. .fi
  281. .PP
  282. For new objects, its best to use all serialized handles.
  283. .SH Returns
  284. .PP
  285. Tools can return any of the following codes:
  286. .IP \[bu] 2
  287. 0 \- Success.
  288. .IP \[bu] 2
  289. 1 \- General non\-specific error.
  290. .IP \[bu] 2
  291. 2 \- Options handling error.
  292. .IP \[bu] 2
  293. 3 \- Authentication error.
  294. .IP \[bu] 2
  295. 4 \- TCTI related error.
  296. .IP \[bu] 2
  297. 5 \- Non supported scheme.
  298. Applicable to tpm2_testparams.
  299. .SH BUGS
  300. .PP
  301. Github Issues (https://github.com/tpm2-software/tpm2-tools/issues)
  302. .SH HELP
  303. .PP
  304. See the Mailing List (https://lists.01.org/mailman/listinfo/tpm2)