Switch from OpenSSL 0.9.7d to 0.9.7e.
[dragonfly.git] / secure / usr.bin / openssl / man / enc.1
CommitLineData
e3cdf75b
JR
1.rn '' }`
2''' $RCSfile$$Revision$$Date$
3'''
4''' $Log$
5'''
6.de Sh
984263bc
MD
7.br
8.if t .Sp
9.ne 5
10.PP
11\fB\\$1\fR
12.PP
13..
e3cdf75b 14.de Sp
984263bc
MD
15.if t .sp .5v
16.if n .sp
17..
e3cdf75b 18.de Ip
984263bc
MD
19.br
20.ie \\n(.$>=3 .ne \\$3
21.el .ne 3
22.IP "\\$1" \\$2
23..
e3cdf75b 24.de Vb
984263bc
MD
25.ft CW
26.nf
27.ne \\$1
28..
e3cdf75b 29.de Ve
984263bc
MD
30.ft R
31
32.fi
33..
e3cdf75b
JR
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'''
984263bc 40.tr \(*W-|\(bv\*(Tr
984263bc 41.ie n \{\
e3cdf75b
JR
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' '
984263bc
MD
62'br\}
63.el\{\
e3cdf75b
JR
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
984263bc 79'br\}
e3cdf75b
JR
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"
984263bc 92..
e3cdf75b
JR
93.nr % 0
94.rr F
984263bc 95.\}
e3cdf75b
JR
96.TH ENC 1 "0.9.7d" "2/Sep/2004" "OpenSSL"
97.UC
98.if n .hy 0
984263bc 99.if n .na
e3cdf75b
JR
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
984263bc 112.bd B 3
e3cdf75b 113. \" fudge factors for nroff and troff
984263bc 114.if n \{\
e3cdf75b
JR
115. ds #H 0
116. ds #V .8m
117. ds #F .3m
118. ds #[ \f1
119. ds #] \fP
984263bc
MD
120.\}
121.if t \{\
e3cdf75b
JR
122. ds #H ((1u-(\\\\n(.fu%2u))*.13m)
123. ds #V .6m
124. ds #F 0
125. ds #[ \&
126. ds #] \&
984263bc 127.\}
e3cdf75b 128. \" simple accents for nroff and troff
984263bc 129.if n \{\
e3cdf75b
JR
130. ds ' \&
131. ds ` \&
132. ds ^ \&
133. ds , \&
134. ds ~ ~
135. ds ? ?
136. ds ! !
137. ds /
138. ds q
984263bc
MD
139.\}
140.if t \{\
e3cdf75b
JR
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'
984263bc 150.\}
e3cdf75b 151. \" troff and (daisy-wheel) nroff accents
984263bc
MD
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'
e3cdf75b
JR
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'\*(#]
984263bc
MD
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
e3cdf75b
JR
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
984263bc
MD
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'
e3cdf75b 170. \" for low resolution devices (crt and lpr)
984263bc
MD
171.if \n(.H>23 .if \n(.V>19 \
172\{\
e3cdf75b
JR
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
984263bc
MD
188.\}
189.rm #[ #] #H #V #F C
984263bc
MD
190.SH "NAME"
191enc \- symmetric cipher routines
192.SH "SYNOPSIS"
e3cdf75b 193\fBopenssl enc \-ciphername\fR
984263bc
MD
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]
e3cdf75b 204[\fB\-iv IV\fR]
984263bc
MD
205[\fB\-p\fR]
206[\fB\-P\fR]
207[\fB\-bufsize number\fR]
208[\fB\-nopad\fR]
209[\fB\-debug\fR]
210.SH "DESCRIPTION"
984263bc
MD
211The symmetric cipher commands allow data to be encrypted or decrypted
212using various block and stream ciphers using keys based on passwords
213or explicitly provided. Base64 encoding or decoding can also be performed
214either by itself or in addition to the encryption or decryption.
215.SH "OPTIONS"
984263bc 216.Ip "\fB\-in filename\fR" 4
984263bc
MD
217the input filename, standard input by default.
218.Ip "\fB\-out filename\fR" 4
984263bc
MD
219the output filename, standard output by default.
220.Ip "\fB\-pass arg\fR" 4
984263bc
MD
221the password source. For more information about the format of \fBarg\fR
222see the \fB\s-1PASS\s0 \s-1PHRASE\s0 \s-1ARGUMENTS\s0\fR section in openssl(1).
223.Ip "\fB\-salt\fR" 4
984263bc
MD
224use a salt in the key derivation routines. This option should \fB\s-1ALWAYS\s0\fR
225be used unless compatibility with previous versions of OpenSSL or SSLeay
226is required. This option is only present on OpenSSL versions 0.9.5 or
227above.
228.Ip "\fB\-nosalt\fR" 4
984263bc
MD
229don't use a salt in the key derivation routines. This is the default for
230compatibility with previous versions of OpenSSL and SSLeay.
231.Ip "\fB\-e\fR" 4
984263bc
MD
232encrypt the input data: this is the default.
233.Ip "\fB\-d\fR" 4
984263bc
MD
234decrypt the input data.
235.Ip "\fB\-a\fR" 4
984263bc
MD
236base64 process the data. This means that if encryption is taking place
237the data is base64 encoded after encryption. If decryption is set then
238the input data is base64 decoded before being decrypted.
239.Ip "\fB\-A\fR" 4
984263bc
MD
240if the \fB\-a\fR option is set then base64 process the data on one line.
241.Ip "\fB\-k password\fR" 4
984263bc
MD
242the password to derive the key from. This is for compatibility with previous
243versions of OpenSSL. Superseded by the \fB\-pass\fR argument.
244.Ip "\fB\-kfile filename\fR" 4
984263bc
MD
245read the password to derive the key from the first line of \fBfilename\fR.
246This is for computability with previous versions of OpenSSL. Superseded by
247the \fB\-pass\fR argument.
248.Ip "\fB\-S salt\fR" 4
984263bc
MD
249the actual salt to use: this must be represented as a string comprised only
250of hex digits.
251.Ip "\fB\-K key\fR" 4
984263bc
MD
252the actual key to use: this must be represented as a string comprised only
253of hex digits. If only the key is specified, the \s-1IV\s0 must additionally specified
254using the \fB\-iv\fR option. When both a key and a password are specified, the
255key given with the \fB\-K\fR option will be used and the \s-1IV\s0 generated from the
256password will be taken. It probably does not make much sense to specify
257both key and password.
258.Ip "\fB\-iv \s-1IV\s0\fR" 4
984263bc
MD
259the actual \s-1IV\s0 to use: this must be represented as a string comprised only
260of hex digits. When only the key is specified using the \fB\-K\fR option, the
e3cdf75b 261\s-1IV\s0 must explicitly be defined. When a password is being specified using
984263bc
MD
262one of the other options, the \s-1IV\s0 is generated from this password.
263.Ip "\fB\-p\fR" 4
984263bc
MD
264print out the key and \s-1IV\s0 used.
265.Ip "\fB\-P\fR" 4
984263bc
MD
266print out the key and \s-1IV\s0 used then immediately exit: don't do any encryption
267or decryption.
268.Ip "\fB\-bufsize number\fR" 4
984263bc
MD
269set the buffer size for I/O
270.Ip "\fB\-nopad\fR" 4
984263bc
MD
271disable standard block padding
272.Ip "\fB\-debug\fR" 4
984263bc
MD
273debug the BIOs used for I/O.
274.SH "NOTES"
984263bc 275The program can be called either as \fBopenssl ciphername\fR or
e3cdf75b 276\fBopenssl enc \-ciphername\fR.
984263bc 277.PP
e3cdf75b 278A password will be prompted for to derive the key and IV if necessary.
984263bc 279.PP
e3cdf75b 280The \fB\-salt\fR option should \fBALWAYS\fR be used if the key is being derived
984263bc
MD
281from a password unless you want compatibility with previous versions of
282OpenSSL and SSLeay.
283.PP
284Without the \fB\-salt\fR option it is possible to perform efficient dictionary
285attacks on the password and to attack stream cipher encrypted data. The reason
286for this is that without the salt the same password always generates the same
287encryption key. When the salt is being used the first eight bytes of the
288encrypted data are reserved for the salt: it is generated at random when
289encrypting a file and read from the encrypted file when it is decrypted.
290.PP
291Some of the ciphers do not have large keys and others have security
292implications if not used correctly. A beginner is advised to just use
e3cdf75b 293a strong block cipher in CBC mode such as bf or des3.
984263bc
MD
294.PP
295All the block ciphers normally use PKCS#5 padding also known as standard block
296padding: this allows a rudimentary integrity or password check to be
297performed. However since the chance of random data passing the test is
298better than 1 in 256 it isn't a very good test.
299.PP
300If padding is disabled then the input data must be a multiple of the cipher
301block length.
302.PP
e3cdf75b 303All RC2 ciphers have the same key and effective key length.
984263bc 304.PP
e3cdf75b 305Blowfish and RC5 algorithms use a 128 bit key.
984263bc 306.SH "SUPPORTED CIPHERS"
e3cdf75b 307.PP
984263bc
MD
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"
984263bc
MD
378Just base64 encode a binary file:
379.PP
380.Vb 1
381\& openssl base64 -in file.bin -out file.b64
382.Ve
383Decode the same file
384.PP
385.Vb 1
e3cdf75b 386\& openssl base64 -d -in file.b64 -out file.bin
984263bc 387.Ve
e3cdf75b 388Encrypt a file using triple DES in CBC mode using a prompted password:
984263bc
MD
389.PP
390.Vb 1
e3cdf75b 391\& openssl des3 -salt -in file.txt -out file.des3
984263bc
MD
392.Ve
393Decrypt 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
398Encrypt a file then base64 encode it (so it can be sent via mail for example)
e3cdf75b 399using Blowfish in CBC mode:
984263bc
MD
400.PP
401.Vb 1
402\& openssl bf -a -salt -in file.txt -out file.bf
403.Ve
404Base64 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
e3cdf75b 409Decrypt some data using a supplied 40 bit RC4 key:
984263bc
MD
410.PP
411.Vb 1
412\& openssl rc4-40 -in file.rc4 -out file.txt -K 0102030405
413.Ve
414.SH "BUGS"
984263bc
MD
415The \fB\-A\fR option when used with large files doesn't work properly.
416.PP
417There should be an option to allow an iteration count to be included.
418.PP
419The \fBenc\fR program only supports a fixed number of algorithms with
e3cdf75b
JR
420certain parameters. So if, for example, you want to use RC2 with a
42176 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