tpm2_rsaencrypt.1 11 KB

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