]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - secure/usr.bin/openssl/man/rsautl.1
Merge OpenSSL 1.0.2s.
[FreeBSD/FreeBSD.git] / secure / usr.bin / openssl / man / rsautl.1
1 .\" Automatically generated by Pod::Man 4.10 (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 .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 "RSAUTL 1"
136 .TH RSAUTL 1 "2019-05-28" "1.0.2s" "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,
143 rsautl \- RSA utility
144 .SH "SYNOPSIS"
145 .IX Header "SYNOPSIS"
146 \&\fBopenssl\fR \fBrsautl\fR
147 [\fB\-in file\fR]
148 [\fB\-out file\fR]
149 [\fB\-inkey file\fR]
150 [\fB\-pubin\fR]
151 [\fB\-certin\fR]
152 [\fB\-sign\fR]
153 [\fB\-verify\fR]
154 [\fB\-encrypt\fR]
155 [\fB\-decrypt\fR]
156 [\fB\-pkcs\fR]
157 [\fB\-ssl\fR]
158 [\fB\-raw\fR]
159 [\fB\-hexdump\fR]
160 [\fB\-asn1parse\fR]
161 .SH "DESCRIPTION"
162 .IX Header "DESCRIPTION"
163 The \fBrsautl\fR command can be used to sign, verify, encrypt and decrypt
164 data using the \s-1RSA\s0 algorithm.
165 .SH "COMMAND OPTIONS"
166 .IX Header "COMMAND OPTIONS"
167 .IP "\fB\-in filename\fR" 4
168 .IX Item "-in filename"
169 This specifies the input filename to read data from or standard input
170 if this option is not specified.
171 .IP "\fB\-out filename\fR" 4
172 .IX Item "-out filename"
173 specifies the output filename to write to or standard output by
174 default.
175 .IP "\fB\-inkey file\fR" 4
176 .IX Item "-inkey file"
177 the input key file, by default it should be an \s-1RSA\s0 private key.
178 .IP "\fB\-pubin\fR" 4
179 .IX Item "-pubin"
180 the input file is an \s-1RSA\s0 public key.
181 .IP "\fB\-certin\fR" 4
182 .IX Item "-certin"
183 the input is a certificate containing an \s-1RSA\s0 public key.
184 .IP "\fB\-sign\fR" 4
185 .IX Item "-sign"
186 sign the input data and output the signed result. This requires
187 and \s-1RSA\s0 private key.
188 .IP "\fB\-verify\fR" 4
189 .IX Item "-verify"
190 verify the input data and output the recovered data.
191 .IP "\fB\-encrypt\fR" 4
192 .IX Item "-encrypt"
193 encrypt the input data using an \s-1RSA\s0 public key.
194 .IP "\fB\-decrypt\fR" 4
195 .IX Item "-decrypt"
196 decrypt the input data using an \s-1RSA\s0 private key.
197 .IP "\fB\-pkcs, \-oaep, \-ssl, \-raw\fR" 4
198 .IX Item "-pkcs, -oaep, -ssl, -raw"
199 the padding to use: PKCS#1 v1.5 (the default), PKCS#1 \s-1OAEP,\s0
200 special padding used in \s-1SSL\s0 v2 backwards compatible handshakes,
201 or no padding, respectively.
202 For signatures, only \fB\-pkcs\fR and \fB\-raw\fR can be used.
203 .IP "\fB\-hexdump\fR" 4
204 .IX Item "-hexdump"
205 hex dump the output data.
206 .IP "\fB\-asn1parse\fR" 4
207 .IX Item "-asn1parse"
208 asn1parse the output data, this is useful when combined with the
209 \&\fB\-verify\fR option.
210 .SH "NOTES"
211 .IX Header "NOTES"
212 \&\fBrsautl\fR because it uses the \s-1RSA\s0 algorithm directly can only be
213 used to sign or verify small pieces of data.
214 .SH "EXAMPLES"
215 .IX Header "EXAMPLES"
216 Sign some data using a private key:
217 .PP
218 .Vb 1
219 \& openssl rsautl \-sign \-in file \-inkey key.pem \-out sig
220 .Ve
221 .PP
222 Recover the signed data
223 .PP
224 .Vb 1
225 \& openssl rsautl \-verify \-in sig \-inkey key.pem
226 .Ve
227 .PP
228 Examine the raw signed data:
229 .PP
230 .Vb 1
231 \& openssl rsautl \-verify \-in sig \-inkey key.pem \-raw \-hexdump
232 \&
233 \& 0000 \- 00 01 ff ff ff ff ff ff\-ff ff ff ff ff ff ff ff   ................
234 \& 0010 \- ff ff ff ff ff ff ff ff\-ff ff ff ff ff ff ff ff   ................
235 \& 0020 \- ff ff ff ff ff ff ff ff\-ff ff ff ff ff ff ff ff   ................
236 \& 0030 \- ff ff ff ff ff ff ff ff\-ff ff ff ff ff ff ff ff   ................
237 \& 0040 \- ff ff ff ff ff ff ff ff\-ff ff ff ff ff ff ff ff   ................
238 \& 0050 \- ff ff ff ff ff ff ff ff\-ff ff ff ff ff ff ff ff   ................
239 \& 0060 \- ff ff ff ff ff ff ff ff\-ff ff ff ff ff ff ff ff   ................
240 \& 0070 \- ff ff ff ff 00 68 65 6c\-6c 6f 20 77 6f 72 6c 64   .....hello world
241 .Ve
242 .PP
243 The PKCS#1 block formatting is evident from this. If this was done using
244 encrypt and decrypt the block would have been of type 2 (the second byte)
245 and random padding data visible instead of the 0xff bytes.
246 .PP
247 It is possible to analyse the signature of certificates using this
248 utility in conjunction with \fBasn1parse\fR. Consider the self signed
249 example in certs/pca\-cert.pem . Running \fBasn1parse\fR as follows yields:
250 .PP
251 .Vb 1
252 \& openssl asn1parse \-in pca\-cert.pem
253 \&
254 \&    0:d=0  hl=4 l= 742 cons: SEQUENCE          
255 \&    4:d=1  hl=4 l= 591 cons:  SEQUENCE          
256 \&    8:d=2  hl=2 l=   3 cons:   cont [ 0 ]        
257 \&   10:d=3  hl=2 l=   1 prim:    INTEGER           :02
258 \&   13:d=2  hl=2 l=   1 prim:   INTEGER           :00
259 \&   16:d=2  hl=2 l=  13 cons:   SEQUENCE          
260 \&   18:d=3  hl=2 l=   9 prim:    OBJECT            :md5WithRSAEncryption
261 \&   29:d=3  hl=2 l=   0 prim:    NULL              
262 \&   31:d=2  hl=2 l=  92 cons:   SEQUENCE          
263 \&   33:d=3  hl=2 l=  11 cons:    SET               
264 \&   35:d=4  hl=2 l=   9 cons:     SEQUENCE          
265 \&   37:d=5  hl=2 l=   3 prim:      OBJECT            :countryName
266 \&   42:d=5  hl=2 l=   2 prim:      PRINTABLESTRING   :AU
267 \&  ....
268 \&  599:d=1  hl=2 l=  13 cons:  SEQUENCE          
269 \&  601:d=2  hl=2 l=   9 prim:   OBJECT            :md5WithRSAEncryption
270 \&  612:d=2  hl=2 l=   0 prim:   NULL              
271 \&  614:d=1  hl=3 l= 129 prim:  BIT STRING
272 .Ve
273 .PP
274 The final \s-1BIT STRING\s0 contains the actual signature. It can be extracted with:
275 .PP
276 .Vb 1
277 \& openssl asn1parse \-in pca\-cert.pem \-out sig \-noout \-strparse 614
278 .Ve
279 .PP
280 The certificate public key can be extracted with:
281 .PP
282 .Vb 1
283 \& openssl x509 \-in test/testx509.pem \-pubkey \-noout >pubkey.pem
284 .Ve
285 .PP
286 The signature can be analysed with:
287 .PP
288 .Vb 1
289 \& openssl rsautl \-in sig \-verify \-asn1parse \-inkey pubkey.pem \-pubin
290 \&
291 \&    0:d=0  hl=2 l=  32 cons: SEQUENCE          
292 \&    2:d=1  hl=2 l=  12 cons:  SEQUENCE          
293 \&    4:d=2  hl=2 l=   8 prim:   OBJECT            :md5
294 \&   14:d=2  hl=2 l=   0 prim:   NULL              
295 \&   16:d=1  hl=2 l=  16 prim:  OCTET STRING      
296 \&      0000 \- f3 46 9e aa 1a 4a 73 c9\-37 ea 93 00 48 25 08 b5   .F...Js.7...H%..
297 .Ve
298 .PP
299 This is the parsed version of an \s-1ASN1\s0 DigestInfo structure. It can be seen that
300 the digest used was md5. The actual part of the certificate that was signed can
301 be extracted with:
302 .PP
303 .Vb 1
304 \& openssl asn1parse \-in pca\-cert.pem \-out tbs \-noout \-strparse 4
305 .Ve
306 .PP
307 and its digest computed with:
308 .PP
309 .Vb 2
310 \& openssl md5 \-c tbs
311 \& MD5(tbs)= f3:46:9e:aa:1a:4a:73:c9:37:ea:93:00:48:25:08:b5
312 .Ve
313 .PP
314 which it can be seen agrees with the recovered value above.
315 .SH "SEE ALSO"
316 .IX Header "SEE ALSO"
317 \&\fBdgst\fR\|(1), \fBrsa\fR\|(1), \fBgenrsa\fR\|(1)