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