Sync usage with man page.
[netbsd-mini2440.git] / crypto / external / bsd / openssl / lib / libcrypto / man / openssl_rsautl.1
blob1f574ac6096dde49434ab6681383e91b0bae013e
1 .\"     $NetBSD: libcrypto.pl,v 1.3 2007/11/27 22:16:03 christos Exp $
2 .\"
3 .\" Automatically generated by Pod::Man 2.16 (Pod::Simple 3.05)
4 .\"
5 .\" Standard preamble:
6 .\" ========================================================================
7 .de Sh \" Subsection heading
8 .br
9 .if t .Sp
10 .ne 5
11 .PP
12 \fB\\$1\fR
13 .PP
15 .de Sp \" Vertical space (when we can't use .PP)
16 .if t .sp .5v
17 .if n .sp
19 .de Vb \" Begin verbatim text
20 .ft CW
21 .nf
22 .ne \\$1
24 .de Ve \" End verbatim text
25 .ft R
26 .fi
28 .\" Set up some character translations and predefined strings.  \*(-- will
29 .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
30 .\" double quote, and \*(R" will give a right double quote.  \*(C+ will
31 .\" give a nicer C++.  Capital omega is used to do unbreakable dashes and
32 .\" therefore won't be available.  \*(C` and \*(C' expand to `' in nroff,
33 .\" nothing in troff, for use with C<>.
34 .tr \(*W-
35 .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
36 .ie n \{\
37 .    ds -- \(*W-
38 .    ds PI pi
39 .    if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
40 .    if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\"  diablo 12 pitch
41 .    ds L" ""
42 .    ds R" ""
43 .    ds C` ""
44 .    ds C' ""
45 'br\}
46 .el\{\
47 .    ds -- \|\(em\|
48 .    ds PI \(*p
49 .    ds L" ``
50 .    ds R" ''
51 'br\}
52 .\"
53 .\" Escape single quotes in literal strings from groff's Unicode transform.
54 .ie \n(.g .ds Aq \(aq
55 .el       .ds Aq '
56 .\"
57 .\" If the F register is turned on, we'll generate index entries on stderr for
58 .\" titles (.TH), headers (.SH), subsections (.Sh), items (.Ip), and index
59 .\" entries marked with X<> in POD.  Of course, you'll have to process the
60 .\" output yourself in some meaningful fashion.
61 .ie \nF \{\
62 .    de IX
63 .    tm Index:\\$1\t\\n%\t"\\$2"
65 .    nr % 0
66 .    rr F
67 .\}
68 .el \{\
69 .    de IX
71 .\}
72 .\"
73 .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
74 .\" Fear.  Run.  Save yourself.  No user-serviceable parts.
75 .    \" fudge factors for nroff and troff
76 .if n \{\
77 .    ds #H 0
78 .    ds #V .8m
79 .    ds #F .3m
80 .    ds #[ \f1
81 .    ds #] \fP
82 .\}
83 .if t \{\
84 .    ds #H ((1u-(\\\\n(.fu%2u))*.13m)
85 .    ds #V .6m
86 .    ds #F 0
87 .    ds #[ \&
88 .    ds #] \&
89 .\}
90 .    \" simple accents for nroff and troff
91 .if n \{\
92 .    ds ' \&
93 .    ds ` \&
94 .    ds ^ \&
95 .    ds , \&
96 .    ds ~ ~
97 .    ds /
98 .\}
99 .if t \{\
100 .    ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
101 .    ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
102 .    ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
103 .    ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
104 .    ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
105 .    ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
107 .    \" troff and (daisy-wheel) nroff accents
108 .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
109 .ds 8 \h'\*(#H'\(*b\h'-\*(#H'
110 .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
111 .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
112 .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
113 .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
114 .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
115 .ds ae a\h'-(\w'a'u*4/10)'e
116 .ds Ae A\h'-(\w'A'u*4/10)'E
117 .    \" corrections for vroff
118 .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
119 .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
120 .    \" for low resolution devices (crt and lpr)
121 .if \n(.H>23 .if \n(.V>19 \
123 .    ds : e
124 .    ds 8 ss
125 .    ds o a
126 .    ds d- d\h'-1'\(ga
127 .    ds D- D\h'-1'\(hy
128 .    ds th \o'bp'
129 .    ds Th \o'LP'
130 .    ds ae ae
131 .    ds Ae AE
133 .rm #[ #] #H #V #F C
134 .\" ========================================================================
136 .IX Title "RSAUTL 1"
137 .TH RSAUTL 1 "2007-09-17" "1.1.0-dev" "OpenSSL"
138 .\" For nroff, turn off justification.  Always turn off hyphenation; it makes
139 .\" way too many mistakes in technical documents.
140 .if n .ad l
142 .SH "NAME"
143 rsautl \- RSA utility
144 .SH "LIBRARY"
145 libcrypto, -lcrypto
146 .SH "SYNOPSIS"
147 .IX Header "SYNOPSIS"
148 \&\fBopenssl\fR \fBrsautl\fR
149 [\fB\-in file\fR]
150 [\fB\-out file\fR]
151 [\fB\-inkey file\fR]
152 [\fB\-pubin\fR]
153 [\fB\-certin\fR]
154 [\fB\-sign\fR]
155 [\fB\-verify\fR]
156 [\fB\-encrypt\fR]
157 [\fB\-decrypt\fR]
158 [\fB\-pkcs\fR]
159 [\fB\-ssl\fR]
160 [\fB\-raw\fR]
161 [\fB\-hexdump\fR]
162 [\fB\-asn1parse\fR]
163 .SH "DESCRIPTION"
164 .IX Header "DESCRIPTION"
165 The \fBrsautl\fR command can be used to sign, verify, encrypt and decrypt
166 data using the \s-1RSA\s0 algorithm.
167 .SH "COMMAND OPTIONS"
168 .IX Header "COMMAND OPTIONS"
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\-pubin\fR" 4
181 .IX Item "-pubin"
182 the input file is an \s-1RSA\s0 public key.
183 .IP "\fB\-certin\fR" 4
184 .IX Item "-certin"
185 the input is a certificate containing an \s-1RSA\s0 public key.
186 .IP "\fB\-sign\fR" 4
187 .IX Item "-sign"
188 sign the input data and output the signed result. This requires
189 and \s-1RSA\s0 private key.
190 .IP "\fB\-verify\fR" 4
191 .IX Item "-verify"
192 verify the input data and output the recovered data.
193 .IP "\fB\-encrypt\fR" 4
194 .IX Item "-encrypt"
195 encrypt the input data using an \s-1RSA\s0 public key.
196 .IP "\fB\-decrypt\fR" 4
197 .IX Item "-decrypt"
198 decrypt the input data using an \s-1RSA\s0 private key.
199 .IP "\fB\-pkcs, \-oaep, \-ssl, \-raw\fR" 4
200 .IX Item "-pkcs, -oaep, -ssl, -raw"
201 the padding to use: PKCS#1 v1.5 (the default), PKCS#1 \s-1OAEP\s0,
202 special padding used in \s-1SSL\s0 v2 backwards compatible handshakes,
203 or no padding, respectively.
204 For signatures, only \fB\-pkcs\fR and \fB\-raw\fR can be used.
205 .IP "\fB\-hexdump\fR" 4
206 .IX Item "-hexdump"
207 hex dump the output data.
208 .IP "\fB\-asn1parse\fR" 4
209 .IX Item "-asn1parse"
210 asn1parse the output data, this is useful when combined with the
211 \&\fB\-verify\fR option.
212 .SH "NOTES"
213 .IX Header "NOTES"
214 \&\fBrsautl\fR because it uses the \s-1RSA\s0 algorithm directly can only be
215 used to sign or verify small pieces of data.
216 .SH "EXAMPLES"
217 .IX Header "EXAMPLES"
218 Sign some data using a private key:
220 .Vb 1
221 \& openssl rsautl \-sign \-in file \-inkey key.pem \-out sig
224 Recover the signed data
226 .Vb 1
227 \& openssl rsautl \-verify \-in sig \-inkey key.pem
230 Examine the raw signed data:
232 .Vb 1
233 \& openssl rsautl \-verify \-in file \-inkey key.pem \-raw \-hexdump
235 \& 0000 \- 00 01 ff ff ff ff ff ff\-ff ff ff ff ff ff ff ff   ................
236 \& 0010 \- ff ff ff ff ff ff ff ff\-ff ff ff ff ff ff ff ff   ................
237 \& 0020 \- ff ff ff ff ff ff ff ff\-ff ff ff ff ff ff ff ff   ................
238 \& 0030 \- ff ff ff ff ff ff ff ff\-ff ff ff ff ff ff ff ff   ................
239 \& 0040 \- ff ff ff ff ff ff ff ff\-ff ff ff ff ff ff ff ff   ................
240 \& 0050 \- ff ff ff ff ff ff ff ff\-ff ff ff ff ff ff ff ff   ................
241 \& 0060 \- ff ff ff ff ff ff ff ff\-ff ff ff ff ff ff ff ff   ................
242 \& 0070 \- ff ff ff ff 00 68 65 6c\-6c 6f 20 77 6f 72 6c 64   .....hello world
245 The PKCS#1 block formatting is evident from this. If this was done using
246 encrypt and decrypt the block would have been of type 2 (the second byte)
247 and random padding data visible instead of the 0xff bytes.
249 It is possible to analyse the signature of certificates using this
250 utility in conjunction with \fBasn1parse\fR. Consider the self signed
251 example in certs/pca\-cert.pem . Running \fBasn1parse\fR as follows yields:
253 .Vb 1
254 \& openssl asn1parse \-in pca\-cert.pem
256 \&    0:d=0  hl=4 l= 742 cons: SEQUENCE          
257 \&    4:d=1  hl=4 l= 591 cons:  SEQUENCE          
258 \&    8:d=2  hl=2 l=   3 cons:   cont [ 0 ]        
259 \&   10:d=3  hl=2 l=   1 prim:    INTEGER           :02
260 \&   13:d=2  hl=2 l=   1 prim:   INTEGER           :00
261 \&   16:d=2  hl=2 l=  13 cons:   SEQUENCE          
262 \&   18:d=3  hl=2 l=   9 prim:    OBJECT            :md5WithRSAEncryption
263 \&   29:d=3  hl=2 l=   0 prim:    NULL              
264 \&   31:d=2  hl=2 l=  92 cons:   SEQUENCE          
265 \&   33:d=3  hl=2 l=  11 cons:    SET               
266 \&   35:d=4  hl=2 l=   9 cons:     SEQUENCE          
267 \&   37:d=5  hl=2 l=   3 prim:      OBJECT            :countryName
268 \&   42:d=5  hl=2 l=   2 prim:      PRINTABLESTRING   :AU
269 \&  ....
270 \&  599:d=1  hl=2 l=  13 cons:  SEQUENCE          
271 \&  601:d=2  hl=2 l=   9 prim:   OBJECT            :md5WithRSAEncryption
272 \&  612:d=2  hl=2 l=   0 prim:   NULL              
273 \&  614:d=1  hl=3 l= 129 prim:  BIT STRING
276 The final \s-1BIT\s0 \s-1STRING\s0 contains the actual signature. It can be extracted with:
278 .Vb 1
279 \& openssl asn1parse \-in pca\-cert.pem \-out sig \-noout \-strparse 614
282 The certificate public key can be extracted with:
284 .Vb 1
285 \& openssl x509 \-in test/testx509.pem \-pubkey \-noout >pubkey.pem
288 The signature can be analysed with:
290 .Vb 1
291 \& openssl rsautl \-in sig \-verify \-asn1parse \-inkey pubkey.pem \-pubin
293 \&    0:d=0  hl=2 l=  32 cons: SEQUENCE          
294 \&    2:d=1  hl=2 l=  12 cons:  SEQUENCE          
295 \&    4:d=2  hl=2 l=   8 prim:   OBJECT            :md5
296 \&   14:d=2  hl=2 l=   0 prim:   NULL              
297 \&   16:d=1  hl=2 l=  16 prim:  OCTET STRING      
298 \&      0000 \- f3 46 9e aa 1a 4a 73 c9\-37 ea 93 00 48 25 08 b5   .F...Js.7...H%..
301 This is the parsed version of an \s-1ASN1\s0 DigestInfo structure. It can be seen that
302 the digest used was md5. The actual part of the certificate that was signed can
303 be extracted with:
305 .Vb 1
306 \& openssl asn1parse \-in pca\-cert.pem \-out tbs \-noout \-strparse 4
309 and its digest computed with:
311 .Vb 2
312 \& openssl md5 \-c tbs
313 \& MD5(tbs)= f3:46:9e:aa:1a:4a:73:c9:37:ea:93:00:48:25:08:b5
316 which it can be seen agrees with the recovered value above.
317 .SH "SEE ALSO"
318 .IX Header "SEE ALSO"
319 \&\fIopenssl_dgst\fR\|(1), \fIopenssl_rsa\fR\|(1), \fIopenssl_genrsa\fR\|(1)