Merge from vendor branch LIBARCHIVE:
[dragonfly.git] / secure / usr.bin / openssl / man / enc.1
1 .\" Automatically generated by Pod::Man 2.12 (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 .\" If the F register is turned on, we'll generate index entries on stderr for
52 .\" titles (.TH), headers (.SH), subsections (.Sh), items (.Ip), and index
53 .\" entries marked with X<> in POD.  Of course, you'll have to process the
54 .\" output yourself in some meaningful fashion.
55 .if \nF \{\
56 .    de IX
57 .    tm Index:\\$1\t\\n%\t"\\$2"
58 ..
59 .    nr % 0
60 .    rr F
61 .\}
62 .\"
63 .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
64 .\" Fear.  Run.  Save yourself.  No user-serviceable parts.
65 .    \" fudge factors for nroff and troff
66 .if n \{\
67 .    ds #H 0
68 .    ds #V .8m
69 .    ds #F .3m
70 .    ds #[ \f1
71 .    ds #] \fP
72 .\}
73 .if t \{\
74 .    ds #H ((1u-(\\\\n(.fu%2u))*.13m)
75 .    ds #V .6m
76 .    ds #F 0
77 .    ds #[ \&
78 .    ds #] \&
79 .\}
80 .    \" simple accents for nroff and troff
81 .if n \{\
82 .    ds ' \&
83 .    ds ` \&
84 .    ds ^ \&
85 .    ds , \&
86 .    ds ~ ~
87 .    ds /
88 .\}
89 .if t \{\
90 .    ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
91 .    ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
92 .    ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
93 .    ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
94 .    ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
95 .    ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
96 .\}
97 .    \" troff and (daisy-wheel) nroff accents
98 .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
99 .ds 8 \h'\*(#H'\(*b\h'-\*(#H'
100 .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
101 .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
102 .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
103 .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
104 .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
105 .ds ae a\h'-(\w'a'u*4/10)'e
106 .ds Ae A\h'-(\w'A'u*4/10)'E
107 .    \" corrections for vroff
108 .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
109 .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
110 .    \" for low resolution devices (crt and lpr)
111 .if \n(.H>23 .if \n(.V>19 \
112 \{\
113 .    ds : e
114 .    ds 8 ss
115 .    ds o a
116 .    ds d- d\h'-1'\(ga
117 .    ds D- D\h'-1'\(hy
118 .    ds th \o'bp'
119 .    ds Th \o'LP'
120 .    ds ae ae
121 .    ds Ae AE
122 .\}
123 .rm #[ #] #H #V #F C
124 .\" ========================================================================
125 .\"
126 .IX Title "ENC 1"
127 .TH ENC 1 "2007-10-24" "0.9.8g" "OpenSSL"
128 .\" For nroff, turn off justification.  Always turn off hyphenation; it makes
129 .\" way too many mistakes in technical documents.
130 .if n .ad l
131 .nh
132 .SH "NAME"
133 enc \- symmetric cipher routines
134 .SH "SYNOPSIS"
135 .IX Header "SYNOPSIS"
136 \&\fBopenssl enc \-ciphername\fR
137 [\fB\-in filename\fR]
138 [\fB\-out filename\fR]
139 [\fB\-pass arg\fR]
140 [\fB\-e\fR]
141 [\fB\-d\fR]
142 [\fB\-a\fR]
143 [\fB\-A\fR]
144 [\fB\-k password\fR]
145 [\fB\-kfile filename\fR]
146 [\fB\-K key\fR]
147 [\fB\-iv \s-1IV\s0\fR]
148 [\fB\-p\fR]
149 [\fB\-P\fR]
150 [\fB\-bufsize number\fR]
151 [\fB\-nopad\fR]
152 [\fB\-debug\fR]
153 .SH "DESCRIPTION"
154 .IX Header "DESCRIPTION"
155 The symmetric cipher commands allow data to be encrypted or decrypted
156 using various block and stream ciphers using keys based on passwords
157 or explicitly provided. Base64 encoding or decoding can also be performed
158 either by itself or in addition to the encryption or decryption.
159 .SH "OPTIONS"
160 .IX Header "OPTIONS"
161 .IP "\fB\-in filename\fR" 4
162 .IX Item "-in filename"
163 the input filename, standard input by default.
164 .IP "\fB\-out filename\fR" 4
165 .IX Item "-out filename"
166 the output filename, standard output by default.
167 .IP "\fB\-pass arg\fR" 4
168 .IX Item "-pass arg"
169 the password source. For more information about the format of \fBarg\fR
170 see the \fB\s-1PASS\s0 \s-1PHRASE\s0 \s-1ARGUMENTS\s0\fR section in \fIopenssl\fR\|(1).
171 .IP "\fB\-salt\fR" 4
172 .IX Item "-salt"
173 use a salt in the key derivation routines. This option should \fB\s-1ALWAYS\s0\fR
174 be used unless compatibility with previous versions of OpenSSL or SSLeay
175 is required. This option is only present on OpenSSL versions 0.9.5 or
176 above.
177 .IP "\fB\-nosalt\fR" 4
178 .IX Item "-nosalt"
179 don't use a salt in the key derivation routines. This is the default for
180 compatibility with previous versions of OpenSSL and SSLeay.
181 .IP "\fB\-e\fR" 4
182 .IX Item "-e"
183 encrypt the input data: this is the default.
184 .IP "\fB\-d\fR" 4
185 .IX Item "-d"
186 decrypt the input data.
187 .IP "\fB\-a\fR" 4
188 .IX Item "-a"
189 base64 process the data. This means that if encryption is taking place
190 the data is base64 encoded after encryption. If decryption is set then
191 the input data is base64 decoded before being decrypted.
192 .IP "\fB\-A\fR" 4
193 .IX Item "-A"
194 if the \fB\-a\fR option is set then base64 process the data on one line.
195 .IP "\fB\-k password\fR" 4
196 .IX Item "-k password"
197 the password to derive the key from. This is for compatibility with previous
198 versions of OpenSSL. Superseded by the \fB\-pass\fR argument.
199 .IP "\fB\-kfile filename\fR" 4
200 .IX Item "-kfile filename"
201 read the password to derive the key from the first line of \fBfilename\fR.
202 This is for compatibility with previous versions of OpenSSL. Superseded by
203 the \fB\-pass\fR argument.
204 .IP "\fB\-S salt\fR" 4
205 .IX Item "-S salt"
206 the actual salt to use: this must be represented as a string comprised only
207 of hex digits.
208 .IP "\fB\-K key\fR" 4
209 .IX Item "-K key"
210 the actual key to use: this must be represented as a string comprised only
211 of hex digits. If only the key is specified, the \s-1IV\s0 must additionally specified
212 using the \fB\-iv\fR option. When both a key and a password are specified, the
213 key given with the \fB\-K\fR option will be used and the \s-1IV\s0 generated from the
214 password will be taken. It probably does not make much sense to specify
215 both key and password.
216 .IP "\fB\-iv \s-1IV\s0\fR" 4
217 .IX Item "-iv IV"
218 the actual \s-1IV\s0 to use: this must be represented as a string comprised only
219 of hex digits. When only the key is specified using the \fB\-K\fR option, the
220 \&\s-1IV\s0 must explicitly be defined. When a password is being specified using
221 one of the other options, the \s-1IV\s0 is generated from this password.
222 .IP "\fB\-p\fR" 4
223 .IX Item "-p"
224 print out the key and \s-1IV\s0 used.
225 .IP "\fB\-P\fR" 4
226 .IX Item "-P"
227 print out the key and \s-1IV\s0 used then immediately exit: don't do any encryption
228 or decryption.
229 .IP "\fB\-bufsize number\fR" 4
230 .IX Item "-bufsize number"
231 set the buffer size for I/O
232 .IP "\fB\-nopad\fR" 4
233 .IX Item "-nopad"
234 disable standard block padding
235 .IP "\fB\-debug\fR" 4
236 .IX Item "-debug"
237 debug the BIOs used for I/O.
238 .SH "NOTES"
239 .IX Header "NOTES"
240 The program can be called either as \fBopenssl ciphername\fR or
241 \&\fBopenssl enc \-ciphername\fR.
242 .PP
243 A password will be prompted for to derive the key and \s-1IV\s0 if necessary.
244 .PP
245 The \fB\-salt\fR option should \fB\s-1ALWAYS\s0\fR be used if the key is being derived
246 from a password unless you want compatibility with previous versions of
247 OpenSSL and SSLeay.
248 .PP
249 Without the \fB\-salt\fR option it is possible to perform efficient dictionary
250 attacks on the password and to attack stream cipher encrypted data. The reason
251 for this is that without the salt the same password always generates the same
252 encryption key. When the salt is being used the first eight bytes of the
253 encrypted data are reserved for the salt: it is generated at random when
254 encrypting a file and read from the encrypted file when it is decrypted.
255 .PP
256 Some of the ciphers do not have large keys and others have security
257 implications if not used correctly. A beginner is advised to just use
258 a strong block cipher in \s-1CBC\s0 mode such as bf or des3.
259 .PP
260 All the block ciphers normally use PKCS#5 padding also known as standard block
261 padding: this allows a rudimentary integrity or password check to be
262 performed. However since the chance of random data passing the test is
263 better than 1 in 256 it isn't a very good test.
264 .PP
265 If padding is disabled then the input data must be a multiple of the cipher
266 block length.
267 .PP
268 All \s-1RC2\s0 ciphers have the same key and effective key length.
269 .PP
270 Blowfish and \s-1RC5\s0 algorithms use a 128 bit key.
271 .SH "SUPPORTED CIPHERS"
272 .IX Header "SUPPORTED CIPHERS"
273 .Vb 1
274 \& base64             Base 64
275 \&
276 \& bf\-cbc             Blowfish in CBC mode
277 \& bf                 Alias for bf\-cbc
278 \& bf\-cfb             Blowfish in CFB mode
279 \& bf\-ecb             Blowfish in ECB mode
280 \& bf\-ofb             Blowfish in OFB mode
281 \&
282 \& cast\-cbc           CAST in CBC mode
283 \& cast               Alias for cast\-cbc
284 \& cast5\-cbc          CAST5 in CBC mode
285 \& cast5\-cfb          CAST5 in CFB mode
286 \& cast5\-ecb          CAST5 in ECB mode
287 \& cast5\-ofb          CAST5 in OFB mode
288 \&
289 \& des\-cbc            DES in CBC mode
290 \& des                Alias for des\-cbc
291 \& des\-cfb            DES in CBC mode
292 \& des\-ofb            DES in OFB mode
293 \& des\-ecb            DES in ECB mode
294 \&
295 \& des\-ede\-cbc        Two key triple DES EDE in CBC mode
296 \& des\-ede            Two key triple DES EDE in ECB mode
297 \& des\-ede\-cfb        Two key triple DES EDE in CFB mode
298 \& des\-ede\-ofb        Two key triple DES EDE in OFB mode
299 \&
300 \& des\-ede3\-cbc       Three key triple DES EDE in CBC mode
301 \& des\-ede3           Three key triple DES EDE in ECB mode
302 \& des3               Alias for des\-ede3\-cbc
303 \& des\-ede3\-cfb       Three key triple DES EDE CFB mode
304 \& des\-ede3\-ofb       Three key triple DES EDE in OFB mode
305 \&
306 \& desx               DESX algorithm.
307 \&
308 \& idea\-cbc           IDEA algorithm in CBC mode
309 \& idea               same as idea\-cbc
310 \& idea\-cfb           IDEA in CFB mode
311 \& idea\-ecb           IDEA in ECB mode
312 \& idea\-ofb           IDEA in OFB mode
313 \&
314 \& rc2\-cbc            128 bit RC2 in CBC mode
315 \& rc2                Alias for rc2\-cbc
316 \& rc2\-cfb            128 bit RC2 in CFB mode
317 \& rc2\-ecb            128 bit RC2 in ECB mode
318 \& rc2\-ofb            128 bit RC2 in OFB mode
319 \& rc2\-64\-cbc         64 bit RC2 in CBC mode
320 \& rc2\-40\-cbc         40 bit RC2 in CBC mode
321 \&
322 \& rc4                128 bit RC4
323 \& rc4\-64             64 bit RC4
324 \& rc4\-40             40 bit RC4
325 \&
326 \& rc5\-cbc            RC5 cipher in CBC mode
327 \& rc5                Alias for rc5\-cbc
328 \& rc5\-cfb            RC5 cipher in CFB mode
329 \& rc5\-ecb            RC5 cipher in ECB mode
330 \& rc5\-ofb            RC5 cipher in OFB mode
331 \&
332 \& aes\-[128|192|256]\-cbc  128/192/256 bit AES in CBC mode
333 \& aes\-[128|192|256]      Alias for aes\-[128|192|256]\-cbc
334 \& aes\-[128|192|256]\-cfb  128/192/256 bit AES in 128 bit CFB mode
335 \& aes\-[128|192|256]\-cfb1 128/192/256 bit AES in 1 bit CFB mode
336 \& aes\-[128|192|256]\-cfb8 128/192/256 bit AES in 8 bit CFB mode
337 \& aes\-[128|192|256]\-ecb  128/192/256 bit AES in ECB mode
338 \& aes\-[128|192|256]\-ofb  128/192/256 bit AES in OFB mode
339 .Ve
340 .SH "EXAMPLES"
341 .IX Header "EXAMPLES"
342 Just base64 encode a binary file:
343 .PP
344 .Vb 1
345 \& openssl base64 \-in file.bin \-out file.b64
346 .Ve
347 .PP
348 Decode the same file
349 .PP
350 .Vb 1
351 \& openssl base64 \-d \-in file.b64 \-out file.bin
352 .Ve
353 .PP
354 Encrypt a file using triple \s-1DES\s0 in \s-1CBC\s0 mode using a prompted password:
355 .PP
356 .Vb 1
357 \& openssl des3 \-salt \-in file.txt \-out file.des3
358 .Ve
359 .PP
360 Decrypt a file using a supplied password:
361 .PP
362 .Vb 1
363 \& openssl des3 \-d \-salt \-in file.des3 \-out file.txt \-k mypassword
364 .Ve
365 .PP
366 Encrypt a file then base64 encode it (so it can be sent via mail for example)
367 using Blowfish in \s-1CBC\s0 mode:
368 .PP
369 .Vb 1
370 \& openssl bf \-a \-salt \-in file.txt \-out file.bf
371 .Ve
372 .PP
373 Base64 decode a file then decrypt it:
374 .PP
375 .Vb 1
376 \& openssl bf \-d \-salt \-a \-in file.bf \-out file.txt
377 .Ve
378 .PP
379 Decrypt some data using a supplied 40 bit \s-1RC4\s0 key:
380 .PP
381 .Vb 1
382 \& openssl rc4\-40 \-in file.rc4 \-out file.txt \-K 0102030405
383 .Ve
384 .SH "BUGS"
385 .IX Header "BUGS"
386 The \fB\-A\fR option when used with large files doesn't work properly.
387 .PP
388 There should be an option to allow an iteration count to be included.
389 .PP
390 The \fBenc\fR program only supports a fixed number of algorithms with
391 certain parameters. So if, for example, you want to use \s-1RC2\s0 with a
392 76 bit key or \s-1RC4\s0 with an 84 bit key you can't use this program.