]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - secure/usr.bin/openssl/man/rsautl.1
MFC: r340703
[FreeBSD/FreeBSD.git] / secure / usr.bin / openssl / man / rsautl.1
1 .\" Automatically generated by Pod::Man 4.09 (Pod::Simple 3.35)
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 .if !\nF .nr F 0
58 .if \nF>0 \{\
59 .    de IX
60 .    tm Index:\\$1\t\\n%\t"\\$2"
61 ..
62 .    if !\nF==2 \{\
63 .        nr % 0
64 .        nr F 2
65 .    \}
66 .\}
67 .\"
68 .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
69 .\" Fear.  Run.  Save yourself.  No user-serviceable parts.
70 .    \" fudge factors for nroff and troff
71 .if n \{\
72 .    ds #H 0
73 .    ds #V .8m
74 .    ds #F .3m
75 .    ds #[ \f1
76 .    ds #] \fP
77 .\}
78 .if t \{\
79 .    ds #H ((1u-(\\\\n(.fu%2u))*.13m)
80 .    ds #V .6m
81 .    ds #F 0
82 .    ds #[ \&
83 .    ds #] \&
84 .\}
85 .    \" simple accents for nroff and troff
86 .if n \{\
87 .    ds ' \&
88 .    ds ` \&
89 .    ds ^ \&
90 .    ds , \&
91 .    ds ~ ~
92 .    ds /
93 .\}
94 .if t \{\
95 .    ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
96 .    ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
97 .    ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
98 .    ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
99 .    ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
100 .    ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
101 .\}
102 .    \" troff and (daisy-wheel) nroff accents
103 .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
104 .ds 8 \h'\*(#H'\(*b\h'-\*(#H'
105 .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
106 .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
107 .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
108 .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
109 .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
110 .ds ae a\h'-(\w'a'u*4/10)'e
111 .ds Ae A\h'-(\w'A'u*4/10)'E
112 .    \" corrections for vroff
113 .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
114 .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
115 .    \" for low resolution devices (crt and lpr)
116 .if \n(.H>23 .if \n(.V>19 \
117 \{\
118 .    ds : e
119 .    ds 8 ss
120 .    ds o a
121 .    ds d- d\h'-1'\(ga
122 .    ds D- D\h'-1'\(hy
123 .    ds th \o'bp'
124 .    ds Th \o'LP'
125 .    ds ae ae
126 .    ds Ae AE
127 .\}
128 .rm #[ #] #H #V #F C
129 .\" ========================================================================
130 .\"
131 .IX Title "RSAUTL 1"
132 .TH RSAUTL 1 "2018-11-20" "1.1.1a" "OpenSSL"
133 .\" For nroff, turn off justification.  Always turn off hyphenation; it makes
134 .\" way too many mistakes in technical documents.
135 .if n .ad l
136 .nh
137 .SH "NAME"
138 openssl\-rsautl, rsautl \- RSA utility
139 .SH "SYNOPSIS"
140 .IX Header "SYNOPSIS"
141 \&\fBopenssl\fR \fBrsautl\fR
142 [\fB\-help\fR]
143 [\fB\-in file\fR]
144 [\fB\-out file\fR]
145 [\fB\-inkey file\fR]
146 [\fB\-keyform PEM|DER|ENGINE\fR]
147 [\fB\-pubin\fR]
148 [\fB\-certin\fR]
149 [\fB\-sign\fR]
150 [\fB\-verify\fR]
151 [\fB\-encrypt\fR]
152 [\fB\-decrypt\fR]
153 [\fB\-rand file...\fR]
154 [\fB\-writerand file\fR]
155 [\fB\-pkcs\fR]
156 [\fB\-ssl\fR]
157 [\fB\-raw\fR]
158 [\fB\-hexdump\fR]
159 [\fB\-asn1parse\fR]
160 .SH "DESCRIPTION"
161 .IX Header "DESCRIPTION"
162 The \fBrsautl\fR command can be used to sign, verify, encrypt and decrypt
163 data using the \s-1RSA\s0 algorithm.
164 .SH "OPTIONS"
165 .IX Header "OPTIONS"
166 .IP "\fB\-help\fR" 4
167 .IX Item "-help"
168 Print out a usage message.
169 .IP "\fB\-in filename\fR" 4
170 .IX Item "-in filename"
171 This specifies the input filename to read data from or standard input
172 if this option is not specified.
173 .IP "\fB\-out filename\fR" 4
174 .IX Item "-out filename"
175 Specifies the output filename to write to or standard output by
176 default.
177 .IP "\fB\-inkey file\fR" 4
178 .IX Item "-inkey file"
179 The input key file, by default it should be an \s-1RSA\s0 private key.
180 .IP "\fB\-keyform PEM|DER|ENGINE\fR" 4
181 .IX Item "-keyform PEM|DER|ENGINE"
182 The key format \s-1PEM, DER\s0 or \s-1ENGINE.\s0
183 .IP "\fB\-pubin\fR" 4
184 .IX Item "-pubin"
185 The input file is an \s-1RSA\s0 public key.
186 .IP "\fB\-certin\fR" 4
187 .IX Item "-certin"
188 The input is a certificate containing an \s-1RSA\s0 public key.
189 .IP "\fB\-sign\fR" 4
190 .IX Item "-sign"
191 Sign the input data and output the signed result. This requires
192 an \s-1RSA\s0 private key.
193 .IP "\fB\-verify\fR" 4
194 .IX Item "-verify"
195 Verify the input data and output the recovered data.
196 .IP "\fB\-encrypt\fR" 4
197 .IX Item "-encrypt"
198 Encrypt the input data using an \s-1RSA\s0 public key.
199 .IP "\fB\-decrypt\fR" 4
200 .IX Item "-decrypt"
201 Decrypt the input data using an \s-1RSA\s0 private key.
202 .IP "\fB\-rand file...\fR" 4
203 .IX Item "-rand file..."
204 A file or files containing random data used to seed the random number
205 generator.
206 Multiple files can be specified separated by an OS-dependent character.
207 The separator is \fB;\fR for MS-Windows, \fB,\fR for OpenVMS, and \fB:\fR for
208 all others.
209 .IP "[\fB\-writerand file\fR]" 4
210 .IX Item "[-writerand file]"
211 Writes random data to the specified \fIfile\fR upon exit.
212 This can be used with a subsequent \fB\-rand\fR flag.
213 .IP "\fB\-pkcs, \-oaep, \-ssl, \-raw\fR" 4
214 .IX Item "-pkcs, -oaep, -ssl, -raw"
215 The padding to use: PKCS#1 v1.5 (the default), PKCS#1 \s-1OAEP,\s0
216 special padding used in \s-1SSL\s0 v2 backwards compatible handshakes,
217 or no padding, respectively.
218 For signatures, only \fB\-pkcs\fR and \fB\-raw\fR can be used.
219 .IP "\fB\-hexdump\fR" 4
220 .IX Item "-hexdump"
221 Hex dump the output data.
222 .IP "\fB\-asn1parse\fR" 4
223 .IX Item "-asn1parse"
224 Parse the \s-1ASN.1\s0 output data, this is useful when combined with the
225 \&\fB\-verify\fR option.
226 .SH "NOTES"
227 .IX Header "NOTES"
228 \&\fBrsautl\fR because it uses the \s-1RSA\s0 algorithm directly can only be
229 used to sign or verify small pieces of data.
230 .SH "EXAMPLES"
231 .IX Header "EXAMPLES"
232 Sign some data using a private key:
233 .PP
234 .Vb 1
235 \& openssl rsautl \-sign \-in file \-inkey key.pem \-out sig
236 .Ve
237 .PP
238 Recover the signed data
239 .PP
240 .Vb 1
241 \& openssl rsautl \-verify \-in sig \-inkey key.pem
242 .Ve
243 .PP
244 Examine the raw signed data:
245 .PP
246 .Vb 1
247 \& openssl rsautl \-verify \-in sig \-inkey key.pem \-raw \-hexdump
248 \&
249 \& 0000 \- 00 01 ff ff ff ff ff ff\-ff ff ff ff ff ff ff ff   ................
250 \& 0010 \- ff ff ff ff ff ff ff ff\-ff ff ff ff ff ff ff ff   ................
251 \& 0020 \- ff ff ff ff ff ff ff ff\-ff ff ff ff ff ff ff ff   ................
252 \& 0030 \- ff ff ff ff ff ff ff ff\-ff ff ff ff ff ff ff ff   ................
253 \& 0040 \- ff ff ff ff ff ff ff ff\-ff ff ff ff ff ff ff ff   ................
254 \& 0050 \- ff ff ff ff ff ff ff ff\-ff ff ff ff ff ff ff ff   ................
255 \& 0060 \- ff ff ff ff ff ff ff ff\-ff ff ff ff ff ff ff ff   ................
256 \& 0070 \- ff ff ff ff 00 68 65 6c\-6c 6f 20 77 6f 72 6c 64   .....hello world
257 .Ve
258 .PP
259 The PKCS#1 block formatting is evident from this. If this was done using
260 encrypt and decrypt the block would have been of type 2 (the second byte)
261 and random padding data visible instead of the 0xff bytes.
262 .PP
263 It is possible to analyse the signature of certificates using this
264 utility in conjunction with \fBasn1parse\fR. Consider the self signed
265 example in certs/pca\-cert.pem . Running \fBasn1parse\fR as follows yields:
266 .PP
267 .Vb 1
268 \& openssl asn1parse \-in pca\-cert.pem
269 \&
270 \&    0:d=0  hl=4 l= 742 cons: SEQUENCE
271 \&    4:d=1  hl=4 l= 591 cons:  SEQUENCE
272 \&    8:d=2  hl=2 l=   3 cons:   cont [ 0 ]
273 \&   10:d=3  hl=2 l=   1 prim:    INTEGER           :02
274 \&   13:d=2  hl=2 l=   1 prim:   INTEGER           :00
275 \&   16:d=2  hl=2 l=  13 cons:   SEQUENCE
276 \&   18:d=3  hl=2 l=   9 prim:    OBJECT            :md5WithRSAEncryption
277 \&   29:d=3  hl=2 l=   0 prim:    NULL
278 \&   31:d=2  hl=2 l=  92 cons:   SEQUENCE
279 \&   33:d=3  hl=2 l=  11 cons:    SET
280 \&   35:d=4  hl=2 l=   9 cons:     SEQUENCE
281 \&   37:d=5  hl=2 l=   3 prim:      OBJECT            :countryName
282 \&   42:d=5  hl=2 l=   2 prim:      PRINTABLESTRING   :AU
283 \&  ....
284 \&  599:d=1  hl=2 l=  13 cons:  SEQUENCE
285 \&  601:d=2  hl=2 l=   9 prim:   OBJECT            :md5WithRSAEncryption
286 \&  612:d=2  hl=2 l=   0 prim:   NULL
287 \&  614:d=1  hl=3 l= 129 prim:  BIT STRING
288 .Ve
289 .PP
290 The final \s-1BIT STRING\s0 contains the actual signature. It can be extracted with:
291 .PP
292 .Vb 1
293 \& openssl asn1parse \-in pca\-cert.pem \-out sig \-noout \-strparse 614
294 .Ve
295 .PP
296 The certificate public key can be extracted with:
297 .PP
298 .Vb 1
299 \& openssl x509 \-in test/testx509.pem \-pubkey \-noout >pubkey.pem
300 .Ve
301 .PP
302 The signature can be analysed with:
303 .PP
304 .Vb 1
305 \& openssl rsautl \-in sig \-verify \-asn1parse \-inkey pubkey.pem \-pubin
306 \&
307 \&    0:d=0  hl=2 l=  32 cons: SEQUENCE
308 \&    2:d=1  hl=2 l=  12 cons:  SEQUENCE
309 \&    4:d=2  hl=2 l=   8 prim:   OBJECT            :md5
310 \&   14:d=2  hl=2 l=   0 prim:   NULL
311 \&   16:d=1  hl=2 l=  16 prim:  OCTET STRING
312 \&      0000 \- f3 46 9e aa 1a 4a 73 c9\-37 ea 93 00 48 25 08 b5   .F...Js.7...H%..
313 .Ve
314 .PP
315 This is the parsed version of an \s-1ASN1\s0 DigestInfo structure. It can be seen that
316 the digest used was md5. The actual part of the certificate that was signed can
317 be extracted with:
318 .PP
319 .Vb 1
320 \& openssl asn1parse \-in pca\-cert.pem \-out tbs \-noout \-strparse 4
321 .Ve
322 .PP
323 and its digest computed with:
324 .PP
325 .Vb 2
326 \& openssl md5 \-c tbs
327 \& MD5(tbs)= f3:46:9e:aa:1a:4a:73:c9:37:ea:93:00:48:25:08:b5
328 .Ve
329 .PP
330 which it can be seen agrees with the recovered value above.
331 .SH "SEE ALSO"
332 .IX Header "SEE ALSO"
333 \&\fIdgst\fR\|(1), \fIrsa\fR\|(1), \fIgenrsa\fR\|(1)
334 .SH "COPYRIGHT"
335 .IX Header "COPYRIGHT"
336 Copyright 2000\-2017 The OpenSSL Project Authors. All Rights Reserved.
337 .PP
338 Licensed under the OpenSSL license (the \*(L"License\*(R").  You may not use
339 this file except in compliance with the License.  You can obtain a copy
340 in the file \s-1LICENSE\s0 in the source distribution or at
341 <https://www.openssl.org/source/license.html>.