Switch from OpenSSL 0.9.7d to 0.9.7e.
[dragonfly.git] / secure / usr.bin / openssl / man / rsautl.1
1 .rn '' }`
2 ''' $RCSfile$$Revision$$Date$
3 '''
4 ''' $Log$
5 '''
6 .de Sh
7 .br
8 .if t .Sp
9 .ne 5
10 .PP
11 \fB\\$1\fR
12 .PP
13 ..
14 .de Sp
15 .if t .sp .5v
16 .if n .sp
17 ..
18 .de Ip
19 .br
20 .ie \\n(.$>=3 .ne \\$3
21 .el .ne 3
22 .IP "\\$1" \\$2
23 ..
24 .de Vb
25 .ft CW
26 .nf
27 .ne \\$1
28 ..
29 .de Ve
30 .ft R
31
32 .fi
33 ..
34 '''
35 '''
36 '''     Set up \*(-- to give an unbreakable dash;
37 '''     string Tr holds user defined translation string.
38 '''     Bell System Logo is used as a dummy character.
39 '''
40 .tr \(*W-|\(bv\*(Tr
41 .ie n \{\
42 .ds -- \(*W-
43 .ds PI pi
44 .if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
45 .if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch
46 .ds L" ""
47 .ds R" ""
48 '''   \*(M", \*(S", \*(N" and \*(T" are the equivalent of
49 '''   \*(L" and \*(R", except that they are used on ".xx" lines,
50 '''   such as .IP and .SH, which do another additional levels of
51 '''   double-quote interpretation
52 .ds M" """
53 .ds S" """
54 .ds N" """""
55 .ds T" """""
56 .ds L' '
57 .ds R' '
58 .ds M' '
59 .ds S' '
60 .ds N' '
61 .ds T' '
62 'br\}
63 .el\{\
64 .ds -- \(em\|
65 .tr \*(Tr
66 .ds L" ``
67 .ds R" ''
68 .ds M" ``
69 .ds S" ''
70 .ds N" ``
71 .ds T" ''
72 .ds L' `
73 .ds R' '
74 .ds M' `
75 .ds S' '
76 .ds N' `
77 .ds T' '
78 .ds PI \(*p
79 'br\}
80 .\"     If the F register is turned on, we'll generate
81 .\"     index entries out stderr for the following things:
82 .\"             TH      Title 
83 .\"             SH      Header
84 .\"             Sh      Subsection 
85 .\"             Ip      Item
86 .\"             X<>     Xref  (embedded
87 .\"     Of course, you have to process the output yourself
88 .\"     in some meaninful fashion.
89 .if \nF \{
90 .de IX
91 .tm Index:\\$1\t\\n%\t"\\$2"
92 ..
93 .nr % 0
94 .rr F
95 .\}
96 .TH RSAUTL 1 "0.9.7d" "2/Sep/2004" "OpenSSL"
97 .UC
98 .if n .hy 0
99 .if n .na
100 .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
101 .de CQ          \" put $1 in typewriter font
102 .ft CW
103 'if n "\c
104 'if t \\&\\$1\c
105 'if n \\&\\$1\c
106 'if n \&"
107 \\&\\$2 \\$3 \\$4 \\$5 \\$6 \\$7
108 '.ft R
109 ..
110 .\" @(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2
111 .       \" AM - accent mark definitions
112 .bd B 3
113 .       \" fudge factors for nroff and troff
114 .if n \{\
115 .       ds #H 0
116 .       ds #V .8m
117 .       ds #F .3m
118 .       ds #[ \f1
119 .       ds #] \fP
120 .\}
121 .if t \{\
122 .       ds #H ((1u-(\\\\n(.fu%2u))*.13m)
123 .       ds #V .6m
124 .       ds #F 0
125 .       ds #[ \&
126 .       ds #] \&
127 .\}
128 .       \" simple accents for nroff and troff
129 .if n \{\
130 .       ds ' \&
131 .       ds ` \&
132 .       ds ^ \&
133 .       ds , \&
134 .       ds ~ ~
135 .       ds ? ?
136 .       ds ! !
137 .       ds /
138 .       ds q
139 .\}
140 .if t \{\
141 .       ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
142 .       ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
143 .       ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
144 .       ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
145 .       ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
146 .       ds ? \s-2c\h'-\w'c'u*7/10'\u\h'\*(#H'\zi\d\s+2\h'\w'c'u*8/10'
147 .       ds ! \s-2\(or\s+2\h'-\w'\(or'u'\v'-.8m'.\v'.8m'
148 .       ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
149 .       ds q o\h'-\w'o'u*8/10'\s-4\v'.4m'\z\(*i\v'-.4m'\s+4\h'\w'o'u*8/10'
150 .\}
151 .       \" troff and (daisy-wheel) nroff accents
152 .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
153 .ds 8 \h'\*(#H'\(*b\h'-\*(#H'
154 .ds v \\k:\h'-(\\n(.wu*9/10-\*(#H)'\v'-\*(#V'\*(#[\s-4v\s0\v'\*(#V'\h'|\\n:u'\*(#]
155 .ds _ \\k:\h'-(\\n(.wu*9/10-\*(#H+(\*(#F*2/3))'\v'-.4m'\z\(hy\v'.4m'\h'|\\n:u'
156 .ds . \\k:\h'-(\\n(.wu*8/10)'\v'\*(#V*4/10'\z.\v'-\*(#V*4/10'\h'|\\n:u'
157 .ds 3 \*(#[\v'.2m'\s-2\&3\s0\v'-.2m'\*(#]
158 .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
159 .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
160 .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
161 .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
162 .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
163 .ds ae a\h'-(\w'a'u*4/10)'e
164 .ds Ae A\h'-(\w'A'u*4/10)'E
165 .ds oe o\h'-(\w'o'u*4/10)'e
166 .ds Oe O\h'-(\w'O'u*4/10)'E
167 .       \" corrections for vroff
168 .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
169 .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
170 .       \" for low resolution devices (crt and lpr)
171 .if \n(.H>23 .if \n(.V>19 \
172 \{\
173 .       ds : e
174 .       ds 8 ss
175 .       ds v \h'-1'\o'\(aa\(ga'
176 .       ds _ \h'-1'^
177 .       ds . \h'-1'.
178 .       ds 3 3
179 .       ds o a
180 .       ds d- d\h'-1'\(ga
181 .       ds D- D\h'-1'\(hy
182 .       ds th \o'bp'
183 .       ds Th \o'LP'
184 .       ds ae ae
185 .       ds Ae AE
186 .       ds oe oe
187 .       ds Oe OE
188 .\}
189 .rm #[ #] #H #V #F C
190 .SH "NAME"
191 rsautl \- RSA utility
192 .SH "SYNOPSIS"
193 \fBopenssl\fR \fBrsautl\fR
194 [\fB\-in file\fR]
195 [\fB\-out file\fR]
196 [\fB\-inkey file\fR]
197 [\fB\-pubin\fR]
198 [\fB\-certin\fR]
199 [\fB\-sign\fR]
200 [\fB\-verify\fR]
201 [\fB\-encrypt\fR]
202 [\fB\-decrypt\fR]
203 [\fB\-pkcs\fR]
204 [\fB\-ssl\fR]
205 [\fB\-raw\fR]
206 [\fB\-hexdump\fR]
207 [\fB\-asn1parse\fR]
208 .SH "DESCRIPTION"
209 The \fBrsautl\fR command can be used to sign, verify, encrypt and decrypt
210 data using the RSA algorithm.
211 .SH "COMMAND OPTIONS"
212 .Ip "\fB\-in filename\fR" 4
213 This specifies the input filename to read data from or standard input
214 if this option is not specified.
215 .Ip "\fB\-out filename\fR" 4
216 specifies the output filename to write to or standard output by
217 default.
218 .Ip "\fB\-inkey file\fR" 4
219 the input key file, by default it should be an \s-1RSA\s0 private key.
220 .Ip "\fB\-pubin\fR" 4
221 the input file is an \s-1RSA\s0 public key. 
222 .Ip "\fB\-certin\fR" 4
223 the input is a certificate containing an \s-1RSA\s0 public key. 
224 .Ip "\fB\-sign\fR" 4
225 sign the input data and output the signed result. This requires
226 and \s-1RSA\s0 private key.
227 .Ip "\fB\-verify\fR" 4
228 verify the input data and output the recovered data.
229 .Ip "\fB\-encrypt\fR" 4
230 encrypt the input data using an \s-1RSA\s0 public key.
231 .Ip "\fB\-decrypt\fR" 4
232 decrypt the input data using an \s-1RSA\s0 private key.
233 .Ip "\fB\-pkcs, \-oaep, \-ssl, \-raw\fR" 4
234 the padding to use: \s-1PKCS\s0#1 v1.5 (the default), \s-1PKCS\s0#1 \s-1OAEP\s0,
235 special padding used in \s-1SSL\s0 v2 backwards compatible handshakes,
236 or no padding, respectively.
237 For signatures, only \fB\-pkcs\fR and \fB\-raw\fR can be used.
238 .Ip "\fB\-hexdump\fR" 4
239 hex dump the output data.
240 .Ip "\fB\-asn1parse\fR" 4
241 asn1parse the output data, this is useful when combined with the
242 \fB\-verify\fR option.
243 .SH "NOTES"
244 \fBrsautl\fR because it uses the RSA algorithm directly can only be
245 used to sign or verify small pieces of data.
246 .SH "EXAMPLES"
247 Sign some data using a private key:
248 .PP
249 .Vb 1
250 \& openssl rsautl -sign -in file -inkey key.pem -out sig
251 .Ve
252 Recover the signed data
253 .PP
254 .Vb 1
255 \& openssl rsautl -verify -in sig -inkey key.pem
256 .Ve
257 Examine the raw signed data:
258 .PP
259 .Vb 1
260 \& openssl rsautl -verify -in file -inkey key.pem -raw -hexdump
261 .Ve
262 .Vb 8
263 \& 0000 - 00 01 ff ff ff ff ff ff-ff ff ff ff ff ff ff ff   ................
264 \& 0010 - ff ff ff ff ff ff ff ff-ff ff ff ff ff ff ff ff   ................
265 \& 0020 - ff ff ff ff ff ff ff ff-ff ff ff ff ff ff ff ff   ................
266 \& 0030 - ff ff ff ff ff ff ff ff-ff ff ff ff ff ff ff ff   ................
267 \& 0040 - ff ff ff ff ff ff ff ff-ff ff ff ff ff ff ff ff   ................
268 \& 0050 - ff ff ff ff ff ff ff ff-ff ff ff ff ff ff ff ff   ................
269 \& 0060 - ff ff ff ff ff ff ff ff-ff ff ff ff ff ff ff ff   ................
270 \& 0070 - ff ff ff ff 00 68 65 6c-6c 6f 20 77 6f 72 6c 64   .....hello world
271 .Ve
272 The PKCS#1 block formatting is evident from this. If this was done using
273 encrypt and decrypt the block would have been of type 2 (the second byte)
274 and random padding data visible instead of the 0xff bytes.
275 .PP
276 It is possible to analyse the signature of certificates using this
277 utility in conjunction with \fBasn1parse\fR. Consider the self signed
278 example in certs/pca-cert.pem . Running \fBasn1parse\fR as follows yields:
279 .PP
280 .Vb 1
281 \& openssl asn1parse -in pca-cert.pem
282 .Ve
283 .Vb 18
284 \&    0:d=0  hl=4 l= 742 cons: SEQUENCE          
285 \&    4:d=1  hl=4 l= 591 cons:  SEQUENCE          
286 \&    8:d=2  hl=2 l=   3 cons:   cont [ 0 ]        
287 \&   10:d=3  hl=2 l=   1 prim:    INTEGER           :02
288 \&   13:d=2  hl=2 l=   1 prim:   INTEGER           :00
289 \&   16:d=2  hl=2 l=  13 cons:   SEQUENCE          
290 \&   18:d=3  hl=2 l=   9 prim:    OBJECT            :md5WithRSAEncryption
291 \&   29:d=3  hl=2 l=   0 prim:    NULL              
292 \&   31:d=2  hl=2 l=  92 cons:   SEQUENCE          
293 \&   33:d=3  hl=2 l=  11 cons:    SET               
294 \&   35:d=4  hl=2 l=   9 cons:     SEQUENCE          
295 \&   37:d=5  hl=2 l=   3 prim:      OBJECT            :countryName
296 \&   42:d=5  hl=2 l=   2 prim:      PRINTABLESTRING   :AU
297 \&  ....
298 \&  599:d=1  hl=2 l=  13 cons:  SEQUENCE          
299 \&  601:d=2  hl=2 l=   9 prim:   OBJECT            :md5WithRSAEncryption
300 \&  612:d=2  hl=2 l=   0 prim:   NULL              
301 \&  614:d=1  hl=3 l= 129 prim:  BIT STRING        
302 .Ve
303 The final BIT STRING contains the actual signature. It can be extracted with:
304 .PP
305 .Vb 1
306 \& openssl asn1parse -in pca-cert.pem -out sig -noout -strparse 614
307 .Ve
308 The certificate public key can be extracted with:
309  
310  openssl x509 \-in test/testx509.pem \-pubout \-noout >pubkey.pem
311 .PP
312 The signature can be analysed with:
313 .PP
314 .Vb 1
315 \& openssl rsautl -in sig -verify -asn1parse -inkey pubkey.pem -pubin
316 .Ve
317 .Vb 6
318 \&    0:d=0  hl=2 l=  32 cons: SEQUENCE          
319 \&    2:d=1  hl=2 l=  12 cons:  SEQUENCE          
320 \&    4:d=2  hl=2 l=   8 prim:   OBJECT            :md5
321 \&   14:d=2  hl=2 l=   0 prim:   NULL              
322 \&   16:d=1  hl=2 l=  16 prim:  OCTET STRING      
323 \&      0000 - f3 46 9e aa 1a 4a 73 c9-37 ea 93 00 48 25 08 b5   .F...Js.7...H%..
324 .Ve
325 This is the parsed version of an ASN1 DigestInfo structure. It can be seen that
326 the digest used was md5. The actual part of the certificate that was signed can
327 be extracted with:
328 .PP
329 .Vb 1
330 \& openssl asn1parse -in pca-cert.pem -out tbs -noout -strparse 4
331 .Ve
332 and its digest computed with:
333 .PP
334 .Vb 2
335 \& openssl md5 -c tbs
336 \& MD5(tbs)= f3:46:9e:aa:1a:4a:73:c9:37:ea:93:00:48:25:08:b5
337 .Ve
338 which it can be seen agrees with the recovered value above.
339 .SH "SEE ALSO"
340 dgst(1), rsa(1), genrsa(1)
341
342 .rn }` ''
343 .IX Title "RSAUTL 1"
344 .IX Name "rsautl - RSA utility"
345
346 .IX Header "NAME"
347
348 .IX Header "SYNOPSIS"
349
350 .IX Header "DESCRIPTION"
351
352 .IX Header "COMMAND OPTIONS"
353
354 .IX Item "\fB\-in filename\fR"
355
356 .IX Item "\fB\-out filename\fR"
357
358 .IX Item "\fB\-inkey file\fR"
359
360 .IX Item "\fB\-pubin\fR"
361
362 .IX Item "\fB\-certin\fR"
363
364 .IX Item "\fB\-sign\fR"
365
366 .IX Item "\fB\-verify\fR"
367
368 .IX Item "\fB\-encrypt\fR"
369
370 .IX Item "\fB\-decrypt\fR"
371
372 .IX Item "\fB\-pkcs, \-oaep, \-ssl, \-raw\fR"
373
374 .IX Item "\fB\-hexdump\fR"
375
376 .IX Item "\fB\-asn1parse\fR"
377
378 .IX Header "NOTES"
379
380 .IX Header "EXAMPLES"
381
382 .IX Header "SEE ALSO"
383