openssl-rsautl.1ossl 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387
  1. .\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.42)
  2. .\"
  3. .\" Standard preamble:
  4. .\" ========================================================================
  5. .de Sp \" Vertical space (when we can't use .PP)
  6. .if t .sp .5v
  7. .if n .sp
  8. ..
  9. .de Vb \" Begin verbatim text
  10. .ft CW
  11. .nf
  12. .ne \\$1
  13. ..
  14. .de Ve \" End verbatim text
  15. .ft R
  16. .fi
  17. ..
  18. .\" Set up some character translations and predefined strings. \*(-- will
  19. .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
  20. .\" double quote, and \*(R" will give a right double quote. \*(C+ will
  21. .\" give a nicer C++. Capital omega is used to do unbreakable dashes and
  22. .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff,
  23. .\" nothing in troff, for use with C<>.
  24. .tr \(*W-
  25. .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
  26. .ie n \{\
  27. . ds -- \(*W-
  28. . ds PI pi
  29. . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
  30. . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch
  31. . ds L" ""
  32. . ds R" ""
  33. . ds C` ""
  34. . ds C' ""
  35. 'br\}
  36. .el\{\
  37. . ds -- \|\(em\|
  38. . ds PI \(*p
  39. . ds L" ``
  40. . ds R" ''
  41. . ds C`
  42. . ds C'
  43. 'br\}
  44. .\"
  45. .\" Escape single quotes in literal strings from groff's Unicode transform.
  46. .ie \n(.g .ds Aq \(aq
  47. .el .ds Aq '
  48. .\"
  49. .\" If the F register is >0, we'll generate index entries on stderr for
  50. .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
  51. .\" entries marked with X<> in POD. Of course, you'll have to process the
  52. .\" output yourself in some meaningful fashion.
  53. .\"
  54. .\" Avoid warning from groff about undefined register 'F'.
  55. .de IX
  56. ..
  57. .nr rF 0
  58. .if \n(.g .if rF .nr rF 1
  59. .if (\n(rF:(\n(.g==0)) \{\
  60. . if \nF \{\
  61. . de IX
  62. . tm Index:\\$1\t\\n%\t"\\$2"
  63. ..
  64. . if !\nF==2 \{\
  65. . nr % 0
  66. . nr F 2
  67. . \}
  68. . \}
  69. .\}
  70. .rr rF
  71. .\"
  72. .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
  73. .\" Fear. Run. Save yourself. No user-serviceable parts.
  74. . \" fudge factors for nroff and troff
  75. .if n \{\
  76. . ds #H 0
  77. . ds #V .8m
  78. . ds #F .3m
  79. . ds #[ \f1
  80. . ds #] \fP
  81. .\}
  82. .if t \{\
  83. . ds #H ((1u-(\\\\n(.fu%2u))*.13m)
  84. . ds #V .6m
  85. . ds #F 0
  86. . ds #[ \&
  87. . ds #] \&
  88. .\}
  89. . \" simple accents for nroff and troff
  90. .if n \{\
  91. . ds ' \&
  92. . ds ` \&
  93. . ds ^ \&
  94. . ds , \&
  95. . ds ~ ~
  96. . ds /
  97. .\}
  98. .if t \{\
  99. . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
  100. . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
  101. . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
  102. . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
  103. . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
  104. . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
  105. .\}
  106. . \" troff and (daisy-wheel) nroff accents
  107. .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
  108. .ds 8 \h'\*(#H'\(*b\h'-\*(#H'
  109. .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
  110. .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
  111. .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
  112. .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
  113. .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
  114. .ds ae a\h'-(\w'a'u*4/10)'e
  115. .ds Ae A\h'-(\w'A'u*4/10)'E
  116. . \" corrections for vroff
  117. .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
  118. .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
  119. . \" for low resolution devices (crt and lpr)
  120. .if \n(.H>23 .if \n(.V>19 \
  121. \{\
  122. . ds : e
  123. . ds 8 ss
  124. . ds o a
  125. . ds d- d\h'-1'\(ga
  126. . ds D- D\h'-1'\(hy
  127. . ds th \o'bp'
  128. . ds Th \o'LP'
  129. . ds ae ae
  130. . ds Ae AE
  131. .\}
  132. .rm #[ #] #H #V #F C
  133. .\" ========================================================================
  134. .\"
  135. .IX Title "OPENSSL-RSAUTL 1ossl"
  136. .TH OPENSSL-RSAUTL 1ossl "2025-06-29" "3.3.2" "OpenSSL"
  137. .\" For nroff, turn off justification. Always turn off hyphenation; it makes
  138. .\" way too many mistakes in technical documents.
  139. .if n .ad l
  140. .nh
  141. .SH "NAME"
  142. openssl\-rsautl \- RSA command
  143. .SH "SYNOPSIS"
  144. .IX Header "SYNOPSIS"
  145. \&\fBopenssl\fR \fBrsautl\fR
  146. [\fB\-help\fR]
  147. [\fB\-in\fR \fIfile\fR]
  148. [\fB\-passin\fR \fIarg\fR]
  149. [\fB\-rev\fR]
  150. [\fB\-out\fR \fIfile\fR]
  151. [\fB\-inkey\fR \fIfilename\fR|\fIuri\fR]
  152. [\fB\-keyform\fR \fB\s-1DER\s0\fR|\fB\s-1PEM\s0\fR|\fBP12\fR|\fB\s-1ENGINE\s0\fR]
  153. [\fB\-pubin\fR]
  154. [\fB\-certin\fR]
  155. [\fB\-sign\fR]
  156. [\fB\-verify\fR]
  157. [\fB\-encrypt\fR]
  158. [\fB\-decrypt\fR]
  159. [\fB\-pkcs\fR]
  160. [\fB\-x931\fR]
  161. [\fB\-oaep\fR]
  162. [\fB\-raw\fR]
  163. [\fB\-hexdump\fR]
  164. [\fB\-asn1parse\fR]
  165. [\fB\-engine\fR \fIid\fR]
  166. [\fB\-rand\fR \fIfiles\fR]
  167. [\fB\-writerand\fR \fIfile\fR]
  168. [\fB\-provider\fR \fIname\fR]
  169. [\fB\-provider\-path\fR \fIpath\fR]
  170. [\fB\-propquery\fR \fIpropq\fR]
  171. .SH "DESCRIPTION"
  172. .IX Header "DESCRIPTION"
  173. This command has been deprecated.
  174. The \fBopenssl\-pkeyutl\fR\|(1) command should be used instead.
  175. .PP
  176. This command can be used to sign, verify, encrypt and decrypt
  177. data using the \s-1RSA\s0 algorithm.
  178. .SH "OPTIONS"
  179. .IX Header "OPTIONS"
  180. .IP "\fB\-help\fR" 4
  181. .IX Item "-help"
  182. Print out a usage message.
  183. .IP "\fB\-in\fR \fIfilename\fR" 4
  184. .IX Item "-in filename"
  185. This specifies the input filename to read data from or standard input
  186. if this option is not specified.
  187. .IP "\fB\-passin\fR \fIarg\fR" 4
  188. .IX Item "-passin arg"
  189. The passphrase used in the output file.
  190. See see \fBopenssl\-passphrase\-options\fR\|(1).
  191. .IP "\fB\-rev\fR" 4
  192. .IX Item "-rev"
  193. Reverse the order of the input.
  194. .IP "\fB\-out\fR \fIfilename\fR" 4
  195. .IX Item "-out filename"
  196. Specifies the output filename to write to or standard output by
  197. default.
  198. .IP "\fB\-inkey\fR \fIfilename\fR|\fIuri\fR" 4
  199. .IX Item "-inkey filename|uri"
  200. The input key, by default it should be an \s-1RSA\s0 private key.
  201. .IP "\fB\-keyform\fR \fB\s-1DER\s0\fR|\fB\s-1PEM\s0\fR|\fBP12\fR|\fB\s-1ENGINE\s0\fR" 4
  202. .IX Item "-keyform DER|PEM|P12|ENGINE"
  203. The key format; unspecified by default.
  204. See \fBopenssl\-format\-options\fR\|(1) for details.
  205. .IP "\fB\-pubin\fR" 4
  206. .IX Item "-pubin"
  207. By default a private key is read from the key input.
  208. With this option a public key is read instead.
  209. If the input contains no public key but a private key, its public part is used.
  210. .IP "\fB\-certin\fR" 4
  211. .IX Item "-certin"
  212. The input is a certificate containing an \s-1RSA\s0 public key.
  213. .IP "\fB\-sign\fR" 4
  214. .IX Item "-sign"
  215. Sign the input data and output the signed result. This requires
  216. an \s-1RSA\s0 private key.
  217. .IP "\fB\-verify\fR" 4
  218. .IX Item "-verify"
  219. Verify the input data and output the recovered data.
  220. .IP "\fB\-encrypt\fR" 4
  221. .IX Item "-encrypt"
  222. Encrypt the input data using an \s-1RSA\s0 public key.
  223. .IP "\fB\-decrypt\fR" 4
  224. .IX Item "-decrypt"
  225. Decrypt the input data using an \s-1RSA\s0 private key.
  226. .IP "\fB\-pkcs\fR, \fB\-oaep\fR, \fB\-x931\fR, \fB\-raw\fR" 4
  227. .IX Item "-pkcs, -oaep, -x931, -raw"
  228. The padding to use: PKCS#1 v1.5 (the default), PKCS#1 \s-1OAEP,
  229. ANSI X9.31,\s0 or no padding, respectively.
  230. For signatures, only \fB\-pkcs\fR and \fB\-raw\fR can be used.
  231. .Sp
  232. Note: because of protection against Bleichenbacher attacks, decryption
  233. using PKCS#1 v1.5 mode will not return errors in case padding check failed.
  234. Use \fB\-raw\fR and inspect the returned value manually to check if the
  235. padding is correct.
  236. .IP "\fB\-hexdump\fR" 4
  237. .IX Item "-hexdump"
  238. Hex dump the output data.
  239. .IP "\fB\-asn1parse\fR" 4
  240. .IX Item "-asn1parse"
  241. Parse the \s-1ASN.1\s0 output data, this is useful when combined with the
  242. \&\fB\-verify\fR option.
  243. .IP "\fB\-engine\fR \fIid\fR" 4
  244. .IX Item "-engine id"
  245. See \*(L"Engine Options\*(R" in \fBopenssl\fR\|(1).
  246. This option is deprecated.
  247. .IP "\fB\-rand\fR \fIfiles\fR, \fB\-writerand\fR \fIfile\fR" 4
  248. .IX Item "-rand files, -writerand file"
  249. See \*(L"Random State Options\*(R" in \fBopenssl\fR\|(1) for details.
  250. .IP "\fB\-provider\fR \fIname\fR" 4
  251. .IX Item "-provider name"
  252. .PD 0
  253. .IP "\fB\-provider\-path\fR \fIpath\fR" 4
  254. .IX Item "-provider-path path"
  255. .IP "\fB\-propquery\fR \fIpropq\fR" 4
  256. .IX Item "-propquery propq"
  257. .PD
  258. See \*(L"Provider Options\*(R" in \fBopenssl\fR\|(1), \fBprovider\fR\|(7), and \fBproperty\fR\|(7).
  259. .SH "NOTES"
  260. .IX Header "NOTES"
  261. Since this command uses the \s-1RSA\s0 algorithm directly, it can only be
  262. used to sign or verify small pieces of data.
  263. .SH "EXAMPLES"
  264. .IX Header "EXAMPLES"
  265. Examples equivalent to these can be found in the documentation for the
  266. non-deprecated \fBopenssl\-pkeyutl\fR\|(1) command.
  267. .PP
  268. Sign some data using a private key:
  269. .PP
  270. .Vb 1
  271. \& openssl rsautl \-sign \-in file \-inkey key.pem \-out sig
  272. .Ve
  273. .PP
  274. Recover the signed data
  275. .PP
  276. .Vb 1
  277. \& openssl rsautl \-verify \-in sig \-inkey key.pem
  278. .Ve
  279. .PP
  280. Examine the raw signed data:
  281. .PP
  282. .Vb 1
  283. \& openssl rsautl \-verify \-in sig \-inkey key.pem \-raw \-hexdump
  284. \&
  285. \& 0000 \- 00 01 ff ff ff ff ff ff\-ff ff ff ff ff ff ff ff ................
  286. \& 0010 \- ff ff ff ff ff ff ff ff\-ff ff ff ff ff ff ff ff ................
  287. \& 0020 \- ff ff ff ff ff ff ff ff\-ff ff ff ff ff ff ff ff ................
  288. \& 0030 \- ff ff ff ff ff ff ff ff\-ff ff ff ff ff ff ff ff ................
  289. \& 0040 \- ff ff ff ff ff ff ff ff\-ff ff ff ff ff ff ff ff ................
  290. \& 0050 \- ff ff ff ff ff ff ff ff\-ff ff ff ff ff ff ff ff ................
  291. \& 0060 \- ff ff ff ff ff ff ff ff\-ff ff ff ff ff ff ff ff ................
  292. \& 0070 \- ff ff ff ff 00 68 65 6c\-6c 6f 20 77 6f 72 6c 64 .....hello world
  293. .Ve
  294. .PP
  295. The PKCS#1 block formatting is evident from this. If this was done using
  296. encrypt and decrypt the block would have been of type 2 (the second byte)
  297. and random padding data visible instead of the 0xff bytes.
  298. .PP
  299. It is possible to analyse the signature of certificates using this
  300. command in conjunction with \fBopenssl\-asn1parse\fR\|(1). Consider the self signed
  301. example in \fIcerts/pca\-cert.pem\fR. Running \fBopenssl\-asn1parse\fR\|(1) as follows
  302. yields:
  303. .PP
  304. .Vb 1
  305. \& openssl asn1parse \-in pca\-cert.pem
  306. \&
  307. \& 0:d=0 hl=4 l= 742 cons: SEQUENCE
  308. \& 4:d=1 hl=4 l= 591 cons: SEQUENCE
  309. \& 8:d=2 hl=2 l= 3 cons: cont [ 0 ]
  310. \& 10:d=3 hl=2 l= 1 prim: INTEGER :02
  311. \& 13:d=2 hl=2 l= 1 prim: INTEGER :00
  312. \& 16:d=2 hl=2 l= 13 cons: SEQUENCE
  313. \& 18:d=3 hl=2 l= 9 prim: OBJECT :md5WithRSAEncryption
  314. \& 29:d=3 hl=2 l= 0 prim: NULL
  315. \& 31:d=2 hl=2 l= 92 cons: SEQUENCE
  316. \& 33:d=3 hl=2 l= 11 cons: SET
  317. \& 35:d=4 hl=2 l= 9 cons: SEQUENCE
  318. \& 37:d=5 hl=2 l= 3 prim: OBJECT :countryName
  319. \& 42:d=5 hl=2 l= 2 prim: PRINTABLESTRING :AU
  320. \& ....
  321. \& 599:d=1 hl=2 l= 13 cons: SEQUENCE
  322. \& 601:d=2 hl=2 l= 9 prim: OBJECT :md5WithRSAEncryption
  323. \& 612:d=2 hl=2 l= 0 prim: NULL
  324. \& 614:d=1 hl=3 l= 129 prim: BIT STRING
  325. .Ve
  326. .PP
  327. The final \s-1BIT STRING\s0 contains the actual signature. It can be extracted with:
  328. .PP
  329. .Vb 1
  330. \& openssl asn1parse \-in pca\-cert.pem \-out sig \-noout \-strparse 614
  331. .Ve
  332. .PP
  333. The certificate public key can be extracted with:
  334. .PP
  335. .Vb 1
  336. \& openssl x509 \-in test/testx509.pem \-pubkey \-noout >pubkey.pem
  337. .Ve
  338. .PP
  339. The signature can be analysed with:
  340. .PP
  341. .Vb 1
  342. \& openssl rsautl \-in sig \-verify \-asn1parse \-inkey pubkey.pem \-pubin
  343. \&
  344. \& 0:d=0 hl=2 l= 32 cons: SEQUENCE
  345. \& 2:d=1 hl=2 l= 12 cons: SEQUENCE
  346. \& 4:d=2 hl=2 l= 8 prim: OBJECT :md5
  347. \& 14:d=2 hl=2 l= 0 prim: NULL
  348. \& 16:d=1 hl=2 l= 16 prim: OCTET STRING
  349. \& 0000 \- f3 46 9e aa 1a 4a 73 c9\-37 ea 93 00 48 25 08 b5 .F...Js.7...H%..
  350. .Ve
  351. .PP
  352. This is the parsed version of an \s-1ASN1\s0 DigestInfo structure. It can be seen that
  353. the digest used was md5. The actual part of the certificate that was signed can
  354. be extracted with:
  355. .PP
  356. .Vb 1
  357. \& openssl asn1parse \-in pca\-cert.pem \-out tbs \-noout \-strparse 4
  358. .Ve
  359. .PP
  360. and its digest computed with:
  361. .PP
  362. .Vb 2
  363. \& openssl md5 \-c tbs
  364. \& MD5(tbs)= f3:46:9e:aa:1a:4a:73:c9:37:ea:93:00:48:25:08:b5
  365. .Ve
  366. .PP
  367. which it can be seen agrees with the recovered value above.
  368. .SH "SEE ALSO"
  369. .IX Header "SEE ALSO"
  370. \&\fBopenssl\fR\|(1),
  371. \&\fBopenssl\-pkeyutl\fR\|(1),
  372. \&\fBopenssl\-dgst\fR\|(1),
  373. \&\fBopenssl\-rsa\fR\|(1),
  374. \&\fBopenssl\-genrsa\fR\|(1)
  375. .SH "HISTORY"
  376. .IX Header "HISTORY"
  377. This command was deprecated in OpenSSL 3.0.
  378. .PP
  379. The \fB\-engine\fR option was deprecated in OpenSSL 3.0.
  380. .SH "COPYRIGHT"
  381. .IX Header "COPYRIGHT"
  382. Copyright 2000\-2023 The OpenSSL Project Authors. All Rights Reserved.
  383. .PP
  384. Licensed under the Apache License 2.0 (the \*(L"License\*(R"). You may not use
  385. this file except in compliance with the License. You can obtain a copy
  386. in the file \s-1LICENSE\s0 in the source distribution or at
  387. <https://www.openssl.org/source/license.html>.