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