Update per latest manual pages after running 'man-update'.
[dragonfly.git] / secure / usr.bin / openssl / man / rsautl.1
1 .\" Automatically generated by Pod::Man version 1.15
2 .\" Wed Feb 19 16:49:36 2003
3 .\"
4 .\" Standard preamble:
5 .\" ======================================================================
6 .de Sh \" Subsection heading
7 .br
8 .if t .Sp
9 .ne 5
10 .PP
11 \fB\\$1\fR
12 .PP
13 ..
14 .de Sp \" Vertical space (when we can't use .PP)
15 .if t .sp .5v
16 .if n .sp
17 ..
18 .de Ip \" List item
19 .br
20 .ie \\n(.$>=3 .ne \\$3
21 .el .ne 3
22 .IP "\\$1" \\$2
23 ..
24 .de Vb \" Begin verbatim text
25 .ft CW
26 .nf
27 .ne \\$1
28 ..
29 .de Ve \" End verbatim text
30 .ft R
31
32 .fi
33 ..
34 .\" Set up some character translations and predefined strings.  \*(-- will
35 .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
36 .\" double quote, and \*(R" will give a right double quote.  | will give a
37 .\" real vertical bar.  \*(C+ will give a nicer C++.  Capital omega is used
38 .\" to do unbreakable dashes and therefore won't be available.  \*(C` and
39 .\" \*(C' expand to `' in nroff, nothing in troff, for use with C<>
40 .tr \(*W-|\(bv\*(Tr
41 .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
42 .ie n \{\
43 .    ds -- \(*W-
44 .    ds PI pi
45 .    if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
46 .    if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\"  diablo 12 pitch
47 .    ds L" ""
48 .    ds R" ""
49 .    ds C` ""
50 .    ds C' ""
51 'br\}
52 .el\{\
53 .    ds -- \|\(em\|
54 .    ds PI \(*p
55 .    ds L" ``
56 .    ds R" ''
57 'br\}
58 .\"
59 .\" If the F register is turned on, we'll generate index entries on stderr
60 .\" for titles (.TH), headers (.SH), subsections (.Sh), items (.Ip), and
61 .\" index entries marked with X<> in POD.  Of course, you'll have to process
62 .\" the output yourself in some meaningful fashion.
63 .if \nF \{\
64 .    de IX
65 .    tm Index:\\$1\t\\n%\t"\\$2"
66 ..
67 .    nr % 0
68 .    rr F
69 .\}
70 .\"
71 .\" For nroff, turn off justification.  Always turn off hyphenation; it
72 .\" makes way too many mistakes in technical documents.
73 .hy 0
74 .if n .na
75 .\"
76 .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
77 .\" Fear.  Run.  Save yourself.  No user-serviceable parts.
78 .bd B 3
79 .    \" fudge factors for nroff and troff
80 .if n \{\
81 .    ds #H 0
82 .    ds #V .8m
83 .    ds #F .3m
84 .    ds #[ \f1
85 .    ds #] \fP
86 .\}
87 .if t \{\
88 .    ds #H ((1u-(\\\\n(.fu%2u))*.13m)
89 .    ds #V .6m
90 .    ds #F 0
91 .    ds #[ \&
92 .    ds #] \&
93 .\}
94 .    \" simple accents for nroff and troff
95 .if n \{\
96 .    ds ' \&
97 .    ds ` \&
98 .    ds ^ \&
99 .    ds , \&
100 .    ds ~ ~
101 .    ds /
102 .\}
103 .if t \{\
104 .    ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
105 .    ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
106 .    ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
107 .    ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
108 .    ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
109 .    ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
110 .\}
111 .    \" troff and (daisy-wheel) nroff accents
112 .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
113 .ds 8 \h'\*(#H'\(*b\h'-\*(#H'
114 .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
115 .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
116 .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
117 .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
118 .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
119 .ds ae a\h'-(\w'a'u*4/10)'e
120 .ds Ae A\h'-(\w'A'u*4/10)'E
121 .    \" corrections for vroff
122 .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
123 .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
124 .    \" for low resolution devices (crt and lpr)
125 .if \n(.H>23 .if \n(.V>19 \
126 \{\
127 .    ds : e
128 .    ds 8 ss
129 .    ds o a
130 .    ds d- d\h'-1'\(ga
131 .    ds D- D\h'-1'\(hy
132 .    ds th \o'bp'
133 .    ds Th \o'LP'
134 .    ds ae ae
135 .    ds Ae AE
136 .\}
137 .rm #[ #] #H #V #F C
138 .\" ======================================================================
139 .\"
140 .IX Title "RSAUTL 1"
141 .TH RSAUTL 1 "0.9.7a" "2003-02-19" "OpenSSL"
142 .UC
143 .SH "NAME"
144 rsautl \- \s-1RSA\s0 utility
145 .SH "SYNOPSIS"
146 .IX Header "SYNOPSIS"
147 \&\fBopenssl\fR \fBrsautl\fR
148 [\fB\-in file\fR]
149 [\fB\-out file\fR]
150 [\fB\-inkey file\fR]
151 [\fB\-pubin\fR]
152 [\fB\-certin\fR]
153 [\fB\-sign\fR]
154 [\fB\-verify\fR]
155 [\fB\-encrypt\fR]
156 [\fB\-decrypt\fR]
157 [\fB\-pkcs\fR]
158 [\fB\-ssl\fR]
159 [\fB\-raw\fR]
160 [\fB\-hexdump\fR]
161 [\fB\-asn1parse\fR]
162 .SH "DESCRIPTION"
163 .IX Header "DESCRIPTION"
164 The \fBrsautl\fR command can be used to sign, verify, encrypt and decrypt
165 data using the \s-1RSA\s0 algorithm.
166 .SH "COMMAND OPTIONS"
167 .IX Header "COMMAND OPTIONS"
168 .Ip "\fB\-in filename\fR" 4
169 .IX Item "-in filename"
170 This specifies the input filename to read data from or standard input
171 if this option is not specified.
172 .Ip "\fB\-out filename\fR" 4
173 .IX Item "-out filename"
174 specifies the output filename to write to or standard output by
175 default.
176 .Ip "\fB\-inkey file\fR" 4
177 .IX Item "-inkey file"
178 the input key file, by default it should be an \s-1RSA\s0 private key.
179 .Ip "\fB\-pubin\fR" 4
180 .IX Item "-pubin"
181 the input file is an \s-1RSA\s0 public key. 
182 .Ip "\fB\-certin\fR" 4
183 .IX Item "-certin"
184 the input is a certificate containing an \s-1RSA\s0 public key. 
185 .Ip "\fB\-sign\fR" 4
186 .IX Item "-sign"
187 sign the input data and output the signed result. This requires
188 and \s-1RSA\s0 private key.
189 .Ip "\fB\-verify\fR" 4
190 .IX Item "-verify"
191 verify the input data and output the recovered data.
192 .Ip "\fB\-encrypt\fR" 4
193 .IX Item "-encrypt"
194 encrypt the input data using an \s-1RSA\s0 public key.
195 .Ip "\fB\-decrypt\fR" 4
196 .IX Item "-decrypt"
197 decrypt the input data using an \s-1RSA\s0 private key.
198 .Ip "\fB\-pkcs, \-oaep, \-ssl, \-raw\fR" 4
199 .IX Item "-pkcs, -oaep, -ssl, -raw"
200 the padding to use: PKCS#1 v1.5 (the default), PKCS#1 \s-1OAEP\s0,
201 special padding used in \s-1SSL\s0 v2 backwards compatible handshakes,
202 or no padding, respectively.
203 For signatures, only \fB\-pkcs\fR and \fB\-raw\fR can be used.
204 .Ip "\fB\-hexdump\fR" 4
205 .IX Item "-hexdump"
206 hex dump the output data.
207 .Ip "\fB\-asn1parse\fR" 4
208 .IX Item "-asn1parse"
209 asn1parse the output data, this is useful when combined with the
210 \&\fB\-verify\fR option.
211 .SH "NOTES"
212 .IX Header "NOTES"
213 \&\fBrsautl\fR because it uses the \s-1RSA\s0 algorithm directly can only be
214 used to sign or verify small pieces of data.
215 .SH "EXAMPLES"
216 .IX Header "EXAMPLES"
217 Sign some data using a private key:
218 .PP
219 .Vb 1
220 \& openssl rsautl -sign -in file -inkey key.pem -out sig
221 .Ve
222 Recover the signed data
223 .PP
224 .Vb 1
225 \& openssl rsautl -verify -in sig -inkey key.pem
226 .Ve
227 Examine the raw signed data:
228 .PP
229 .Vb 1
230 \& openssl rsautl -verify -in file -inkey key.pem -raw -hexdump
231 .Ve
232 .Vb 8
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 The PKCS#1 block formatting is evident from this. If this was done using
243 encrypt and decrypt the block would have been of type 2 (the second byte)
244 and random padding data visible instead of the 0xff bytes.
245 .PP
246 It is possible to analyse the signature of certificates using this
247 utility in conjunction with \fBasn1parse\fR. Consider the self signed
248 example in certs/pca-cert.pem . Running \fBasn1parse\fR as follows yields:
249 .PP
250 .Vb 1
251 \& openssl asn1parse -in pca-cert.pem
252 .Ve
253 .Vb 18
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 The final \s-1BIT\s0 \s-1STRING\s0 contains the actual signature. It can be extracted with:
274 .PP
275 .Vb 1
276 \& openssl asn1parse -in pca-cert.pem -out sig -noout -strparse 614
277 .Ve
278 The certificate public key can be extracted with:
279 .PP
280 .Vb 1
281 \& openssl x509 -in test/testx509.pem -pubout -noout >pubkey.pem
282 .Ve
283 The signature can be analysed with:
284 .PP
285 .Vb 1
286 \& openssl rsautl -in sig -verify -asn1parse -inkey pubkey.pem -pubin
287 .Ve
288 .Vb 6
289 \&    0:d=0  hl=2 l=  32 cons: SEQUENCE          
290 \&    2:d=1  hl=2 l=  12 cons:  SEQUENCE          
291 \&    4:d=2  hl=2 l=   8 prim:   OBJECT            :md5
292 \&   14:d=2  hl=2 l=   0 prim:   NULL              
293 \&   16:d=1  hl=2 l=  16 prim:  OCTET STRING      
294 \&      0000 - f3 46 9e aa 1a 4a 73 c9-37 ea 93 00 48 25 08 b5   .F...Js.7...H%..
295 .Ve
296 This is the parsed version of an \s-1ASN1\s0 DigestInfo structure. It can be seen that
297 the digest used was md5. The actual part of the certificate that was signed can
298 be extracted with:
299 .PP
300 .Vb 1
301 \& openssl asn1parse -in pca-cert.pem -out tbs -noout -strparse 4
302 .Ve
303 and its digest computed with:
304 .PP
305 .Vb 2
306 \& openssl md5 -c tbs
307 \& MD5(tbs)= f3:46:9e:aa:1a:4a:73:c9:37:ea:93:00:48:25:08:b5
308 .Ve
309 which it can be seen agrees with the recovered value above.
310 .SH "SEE ALSO"
311 .IX Header "SEE ALSO"
312 dgst(1), rsa(1), genrsa(1)