Debian Codegraph @

upstream/debian-unstable/man1/openssl-rsautl.1ssl

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