Switch from OpenSSL 0.9.7d to 0.9.7e.
[dragonfly.git] / secure / usr.bin / openssl / man / enc.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 ENC 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 enc \- symmetric cipher routines
192 .SH "SYNOPSIS"
193 \fBopenssl enc \-ciphername\fR
194 [\fB\-in filename\fR]
195 [\fB\-out filename\fR]
196 [\fB\-pass arg\fR]
197 [\fB\-e\fR]
198 [\fB\-d\fR]
199 [\fB\-a\fR]
200 [\fB\-A\fR]
201 [\fB\-k password\fR]
202 [\fB\-kfile filename\fR]
203 [\fB\-K key\fR]
204 [\fB\-iv IV\fR]
205 [\fB\-p\fR]
206 [\fB\-P\fR]
207 [\fB\-bufsize number\fR]
208 [\fB\-nopad\fR]
209 [\fB\-debug\fR]
210 .SH "DESCRIPTION"
211 The symmetric cipher commands allow data to be encrypted or decrypted
212 using various block and stream ciphers using keys based on passwords
213 or explicitly provided. Base64 encoding or decoding can also be performed
214 either by itself or in addition to the encryption or decryption.
215 .SH "OPTIONS"
216 .Ip "\fB\-in filename\fR" 4
217 the input filename, standard input by default.
218 .Ip "\fB\-out filename\fR" 4
219 the output filename, standard output by default.
220 .Ip "\fB\-pass arg\fR" 4
221 the password source. For more information about the format of \fBarg\fR
222 see the \fB\s-1PASS\s0 \s-1PHRASE\s0 \s-1ARGUMENTS\s0\fR section in openssl(1).
223 .Ip "\fB\-salt\fR" 4
224 use a salt in the key derivation routines. This option should \fB\s-1ALWAYS\s0\fR
225 be used unless compatibility with previous versions of OpenSSL or SSLeay
226 is required. This option is only present on OpenSSL versions 0.9.5 or
227 above.
228 .Ip "\fB\-nosalt\fR" 4
229 don't use a salt in the key derivation routines. This is the default for
230 compatibility with previous versions of OpenSSL and SSLeay.
231 .Ip "\fB\-e\fR" 4
232 encrypt the input data: this is the default.
233 .Ip "\fB\-d\fR" 4
234 decrypt the input data.
235 .Ip "\fB\-a\fR" 4
236 base64 process the data. This means that if encryption is taking place
237 the data is base64 encoded after encryption. If decryption is set then
238 the input data is base64 decoded before being decrypted.
239 .Ip "\fB\-A\fR" 4
240 if the \fB\-a\fR option is set then base64 process the data on one line.
241 .Ip "\fB\-k password\fR" 4
242 the password to derive the key from. This is for compatibility with previous
243 versions of OpenSSL. Superseded by the \fB\-pass\fR argument.
244 .Ip "\fB\-kfile filename\fR" 4
245 read the password to derive the key from the first line of \fBfilename\fR.
246 This is for computability with previous versions of OpenSSL. Superseded by
247 the \fB\-pass\fR argument.
248 .Ip "\fB\-S salt\fR" 4
249 the actual salt to use: this must be represented as a string comprised only
250 of hex digits.
251 .Ip "\fB\-K key\fR" 4
252 the actual key to use: this must be represented as a string comprised only
253 of hex digits. If only the key is specified, the \s-1IV\s0 must additionally specified
254 using the \fB\-iv\fR option. When both a key and a password are specified, the
255 key given with the \fB\-K\fR option will be used and the \s-1IV\s0 generated from the
256 password will be taken. It probably does not make much sense to specify
257 both key and password.
258 .Ip "\fB\-iv \s-1IV\s0\fR" 4
259 the actual \s-1IV\s0 to use: this must be represented as a string comprised only
260 of hex digits. When only the key is specified using the \fB\-K\fR option, the
261 \s-1IV\s0 must explicitly be defined. When a password is being specified using
262 one of the other options, the \s-1IV\s0 is generated from this password.
263 .Ip "\fB\-p\fR" 4
264 print out the key and \s-1IV\s0 used.
265 .Ip "\fB\-P\fR" 4
266 print out the key and \s-1IV\s0 used then immediately exit: don't do any encryption
267 or decryption.
268 .Ip "\fB\-bufsize number\fR" 4
269 set the buffer size for I/O
270 .Ip "\fB\-nopad\fR" 4
271 disable standard block padding
272 .Ip "\fB\-debug\fR" 4
273 debug the BIOs used for I/O.
274 .SH "NOTES"
275 The program can be called either as \fBopenssl ciphername\fR or
276 \fBopenssl enc \-ciphername\fR.
277 .PP
278 A password will be prompted for to derive the key and IV if necessary.
279 .PP
280 The \fB\-salt\fR option should \fBALWAYS\fR be used if the key is being derived
281 from a password unless you want compatibility with previous versions of
282 OpenSSL and SSLeay.
283 .PP
284 Without the \fB\-salt\fR option it is possible to perform efficient dictionary
285 attacks on the password and to attack stream cipher encrypted data. The reason
286 for this is that without the salt the same password always generates the same
287 encryption key. When the salt is being used the first eight bytes of the
288 encrypted data are reserved for the salt: it is generated at random when
289 encrypting a file and read from the encrypted file when it is decrypted.
290 .PP
291 Some of the ciphers do not have large keys and others have security
292 implications if not used correctly. A beginner is advised to just use
293 a strong block cipher in CBC mode such as bf or des3.
294 .PP
295 All the block ciphers normally use PKCS#5 padding also known as standard block
296 padding: this allows a rudimentary integrity or password check to be
297 performed. However since the chance of random data passing the test is
298 better than 1 in 256 it isn't a very good test.
299 .PP
300 If padding is disabled then the input data must be a multiple of the cipher
301 block length.
302 .PP
303 All RC2 ciphers have the same key and effective key length.
304 .PP
305 Blowfish and RC5 algorithms use a 128 bit key.
306 .SH "SUPPORTED CIPHERS"
307 .PP
308 .Vb 1
309 \& base64             Base 64
310 .Ve
311 .Vb 5
312 \& bf-cbc             Blowfish in CBC mode
313 \& bf                 Alias for bf-cbc
314 \& bf-cfb             Blowfish in CFB mode
315 \& bf-ecb             Blowfish in ECB mode
316 \& bf-ofb             Blowfish in OFB mode
317 .Ve
318 .Vb 6
319 \& cast-cbc           CAST in CBC mode
320 \& cast               Alias for cast-cbc
321 \& cast5-cbc          CAST5 in CBC mode
322 \& cast5-cfb          CAST5 in CFB mode
323 \& cast5-ecb          CAST5 in ECB mode
324 \& cast5-ofb          CAST5 in OFB mode
325 .Ve
326 .Vb 5
327 \& des-cbc            DES in CBC mode
328 \& des                Alias for des-cbc
329 \& des-cfb            DES in CBC mode
330 \& des-ofb            DES in OFB mode
331 \& des-ecb            DES in ECB mode
332 .Ve
333 .Vb 4
334 \& des-ede-cbc        Two key triple DES EDE in CBC mode
335 \& des-ede            Alias for des-ede
336 \& des-ede-cfb        Two key triple DES EDE in CFB mode
337 \& des-ede-ofb        Two key triple DES EDE in OFB mode
338 .Ve
339 .Vb 5
340 \& des-ede3-cbc       Three key triple DES EDE in CBC mode
341 \& des-ede3           Alias for des-ede3-cbc
342 \& des3               Alias for des-ede3-cbc
343 \& des-ede3-cfb       Three key triple DES EDE CFB mode
344 \& des-ede3-ofb       Three key triple DES EDE in OFB mode
345 .Ve
346 .Vb 1
347 \& desx               DESX algorithm.
348 .Ve
349 .Vb 5
350 \& idea-cbc           IDEA algorithm in CBC mode
351 \& idea               same as idea-cbc
352 \& idea-cfb           IDEA in CFB mode
353 \& idea-ecb           IDEA in ECB mode
354 \& idea-ofb           IDEA in OFB mode
355 .Ve
356 .Vb 7
357 \& rc2-cbc            128 bit RC2 in CBC mode
358 \& rc2                Alias for rc2-cbc
359 \& rc2-cfb            128 bit RC2 in CBC mode
360 \& rc2-ecb            128 bit RC2 in CBC mode
361 \& rc2-ofb            128 bit RC2 in CBC mode
362 \& rc2-64-cbc         64 bit RC2 in CBC mode
363 \& rc2-40-cbc         40 bit RC2 in CBC mode
364 .Ve
365 .Vb 3
366 \& rc4                128 bit RC4
367 \& rc4-64             64 bit RC4
368 \& rc4-40             40 bit RC4
369 .Ve
370 .Vb 5
371 \& rc5-cbc            RC5 cipher in CBC mode
372 \& rc5                Alias for rc5-cbc
373 \& rc5-cfb            RC5 cipher in CBC mode
374 \& rc5-ecb            RC5 cipher in CBC mode
375 \& rc5-ofb            RC5 cipher in CBC mode
376 .Ve
377 .SH "EXAMPLES"
378 Just base64 encode a binary file:
379 .PP
380 .Vb 1
381 \& openssl base64 -in file.bin -out file.b64
382 .Ve
383 Decode the same file
384 .PP
385 .Vb 1
386 \& openssl base64 -d -in file.b64 -out file.bin 
387 .Ve
388 Encrypt a file using triple DES in CBC mode using a prompted password:
389 .PP
390 .Vb 1
391 \& openssl des3 -salt -in file.txt -out file.des3 
392 .Ve
393 Decrypt a file using a supplied password:
394 .PP
395 .Vb 1
396 \& openssl des3 -d -salt -in file.des3 -out file.txt -k mypassword
397 .Ve
398 Encrypt a file then base64 encode it (so it can be sent via mail for example)
399 using Blowfish in CBC mode:
400 .PP
401 .Vb 1
402 \& openssl bf -a -salt -in file.txt -out file.bf
403 .Ve
404 Base64 decode a file then decrypt it:
405 .PP
406 .Vb 1
407 \& openssl bf -d -salt -a -in file.bf -out file.txt
408 .Ve
409 Decrypt some data using a supplied 40 bit RC4 key:
410 .PP
411 .Vb 1
412 \& openssl rc4-40 -in file.rc4 -out file.txt -K 0102030405
413 .Ve
414 .SH "BUGS"
415 The \fB\-A\fR option when used with large files doesn't work properly.
416 .PP
417 There should be an option to allow an iteration count to be included.
418 .PP
419 The \fBenc\fR program only supports a fixed number of algorithms with
420 certain parameters. So if, for example, you want to use RC2 with a
421 76 bit key or RC4 with an 84 bit key you can't use this program.
422
423 .rn }` ''
424 .IX Title "ENC 1"
425 .IX Name "enc - symmetric cipher routines"
426
427 .IX Header "NAME"
428
429 .IX Header "SYNOPSIS"
430
431 .IX Header "DESCRIPTION"
432
433 .IX Header "OPTIONS"
434
435 .IX Item "\fB\-in filename\fR"
436
437 .IX Item "\fB\-out filename\fR"
438
439 .IX Item "\fB\-pass arg\fR"
440
441 .IX Item "\fB\-salt\fR"
442
443 .IX Item "\fB\-nosalt\fR"
444
445 .IX Item "\fB\-e\fR"
446
447 .IX Item "\fB\-d\fR"
448
449 .IX Item "\fB\-a\fR"
450
451 .IX Item "\fB\-A\fR"
452
453 .IX Item "\fB\-k password\fR"
454
455 .IX Item "\fB\-kfile filename\fR"
456
457 .IX Item "\fB\-S salt\fR"
458
459 .IX Item "\fB\-K key\fR"
460
461 .IX Item "\fB\-iv \s-1IV\s0\fR"
462
463 .IX Item "\fB\-p\fR"
464
465 .IX Item "\fB\-P\fR"
466
467 .IX Item "\fB\-bufsize number\fR"
468
469 .IX Item "\fB\-nopad\fR"
470
471 .IX Item "\fB\-debug\fR"
472
473 .IX Header "NOTES"
474
475 .IX Header "SUPPORTED CIPHERS"
476
477 .IX Header "EXAMPLES"
478
479 .IX Header "BUGS"
480