]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - secure/usr.bin/openssl/man/enc.1
MFC: r325328
[FreeBSD/FreeBSD.git] / secure / usr.bin / openssl / man / enc.1
1 .\" Automatically generated by Pod::Man 4.07 (Pod::Simple 3.35)
2 .\"
3 .\" Standard preamble:
4 .\" ========================================================================
5 .de Sp \" Vertical space (when we can't use .PP)
6 .if t .sp .5v
7 .if n .sp
8 ..
9 .de Vb \" Begin verbatim text
10 .ft CW
11 .nf
12 .ne \\$1
13 ..
14 .de Ve \" End verbatim text
15 .ft R
16 .fi
17 ..
18 .\" Set up some character translations and predefined strings.  \*(-- will
19 .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
20 .\" double quote, and \*(R" will give a right double quote.  \*(C+ will
21 .\" give a nicer C++.  Capital omega is used to do unbreakable dashes and
22 .\" therefore won't be available.  \*(C` and \*(C' expand to `' in nroff,
23 .\" nothing in troff, for use with C<>.
24 .tr \(*W-
25 .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
26 .ie n \{\
27 .    ds -- \(*W-
28 .    ds PI pi
29 .    if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
30 .    if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\"  diablo 12 pitch
31 .    ds L" ""
32 .    ds R" ""
33 .    ds C` ""
34 .    ds C' ""
35 'br\}
36 .el\{\
37 .    ds -- \|\(em\|
38 .    ds PI \(*p
39 .    ds L" ``
40 .    ds R" ''
41 .    ds C`
42 .    ds C'
43 'br\}
44 .\"
45 .\" Escape single quotes in literal strings from groff's Unicode transform.
46 .ie \n(.g .ds Aq \(aq
47 .el       .ds Aq '
48 .\"
49 .\" If the F register is >0, we'll generate index entries on stderr for
50 .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
51 .\" entries marked with X<> in POD.  Of course, you'll have to process the
52 .\" output yourself in some meaningful fashion.
53 .\"
54 .\" Avoid warning from groff about undefined register 'F'.
55 .de IX
56 ..
57 .if !\nF .nr F 0
58 .if \nF>0 \{\
59 .    de IX
60 .    tm Index:\\$1\t\\n%\t"\\$2"
61 ..
62 .    if !\nF==2 \{\
63 .        nr % 0
64 .        nr F 2
65 .    \}
66 .\}
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 "2017-11-02" "1.0.2m" "OpenSSL"
133 .\" For nroff, turn off justification.  Always turn off hyphenation; it makes
134 .\" way too many mistakes in technical documents.
135 .if n .ad l
136 .nh
137 .SH "NAME"
138 openssl\-enc,
139 enc \- symmetric cipher routines
140 .SH "SYNOPSIS"
141 .IX Header "SYNOPSIS"
142 \&\fBopenssl enc \-ciphername\fR
143 [\fB\-in filename\fR]
144 [\fB\-out filename\fR]
145 [\fB\-pass arg\fR]
146 [\fB\-e\fR]
147 [\fB\-d\fR]
148 [\fB\-a/\-base64\fR]
149 [\fB\-A\fR]
150 [\fB\-k password\fR]
151 [\fB\-kfile filename\fR]
152 [\fB\-K key\fR]
153 [\fB\-iv \s-1IV\s0\fR]
154 [\fB\-S salt\fR]
155 [\fB\-salt\fR]
156 [\fB\-nosalt\fR]
157 [\fB\-z\fR]
158 [\fB\-md\fR]
159 [\fB\-p\fR]
160 [\fB\-P\fR]
161 [\fB\-bufsize number\fR]
162 [\fB\-nopad\fR]
163 [\fB\-debug\fR]
164 [\fB\-none\fR]
165 [\fB\-engine id\fR]
166 .SH "DESCRIPTION"
167 .IX Header "DESCRIPTION"
168 The symmetric cipher commands allow data to be encrypted or decrypted
169 using various block and stream ciphers using keys based on passwords
170 or explicitly provided. Base64 encoding or decoding can also be performed
171 either by itself or in addition to the encryption or decryption.
172 .SH "OPTIONS"
173 .IX Header "OPTIONS"
174 .IP "\fB\-in filename\fR" 4
175 .IX Item "-in filename"
176 the input filename, standard input by default.
177 .IP "\fB\-out filename\fR" 4
178 .IX Item "-out filename"
179 the output filename, standard output by default.
180 .IP "\fB\-pass arg\fR" 4
181 .IX Item "-pass arg"
182 the password source. For more information about the format of \fBarg\fR
183 see the \fB\s-1PASS PHRASE ARGUMENTS\s0\fR section in \fIopenssl\fR\|(1).
184 .IP "\fB\-salt\fR" 4
185 .IX Item "-salt"
186 use a salt in the key derivation routines. This is the default.
187 .IP "\fB\-nosalt\fR" 4
188 .IX Item "-nosalt"
189 don't use a salt in the key derivation routines. This option \fB\s-1SHOULD NOT\s0\fR be
190 used except for test purposes or compatibility with ancient versions of OpenSSL
191 and SSLeay.
192 .IP "\fB\-e\fR" 4
193 .IX Item "-e"
194 encrypt the input data: this is the default.
195 .IP "\fB\-d\fR" 4
196 .IX Item "-d"
197 decrypt the input data.
198 .IP "\fB\-a\fR" 4
199 .IX Item "-a"
200 base64 process the data. This means that if encryption is taking place
201 the data is base64 encoded after encryption. If decryption is set then
202 the input data is base64 decoded before being decrypted.
203 .IP "\fB\-base64\fR" 4
204 .IX Item "-base64"
205 same as \fB\-a\fR
206 .IP "\fB\-A\fR" 4
207 .IX Item "-A"
208 if the \fB\-a\fR option is set then base64 process the data on one line.
209 .IP "\fB\-k password\fR" 4
210 .IX Item "-k password"
211 the password to derive the key from. This is for compatibility with previous
212 versions of OpenSSL. Superseded by the \fB\-pass\fR argument.
213 .IP "\fB\-kfile filename\fR" 4
214 .IX Item "-kfile filename"
215 read the password to derive the key from the first line of \fBfilename\fR.
216 This is for compatibility with previous versions of OpenSSL. Superseded by
217 the \fB\-pass\fR argument.
218 .IP "\fB\-nosalt\fR" 4
219 .IX Item "-nosalt"
220 do not use a salt
221 .IP "\fB\-salt\fR" 4
222 .IX Item "-salt"
223 use salt (randomly generated or provide with \fB\-S\fR option) when
224 encrypting (this is the default).
225 .IP "\fB\-S salt\fR" 4
226 .IX Item "-S salt"
227 the actual salt to use: this must be represented as a string of hex digits.
228 .IP "\fB\-K key\fR" 4
229 .IX Item "-K key"
230 the actual key to use: this must be represented as a string comprised only
231 of hex digits. If only the key is specified, the \s-1IV\s0 must additionally specified
232 using the \fB\-iv\fR option. When both a key and a password are specified, the
233 key given with the \fB\-K\fR option will be used and the \s-1IV\s0 generated from the
234 password will be taken. It probably does not make much sense to specify
235 both key and password.
236 .IP "\fB\-iv \s-1IV\s0\fR" 4
237 .IX Item "-iv IV"
238 the actual \s-1IV\s0 to use: this must be represented as a string comprised only
239 of hex digits. When only the key is specified using the \fB\-K\fR option, the
240 \&\s-1IV\s0 must explicitly be defined. When a password is being specified using
241 one of the other options, the \s-1IV\s0 is generated from this password.
242 .IP "\fB\-p\fR" 4
243 .IX Item "-p"
244 print out the key and \s-1IV\s0 used.
245 .IP "\fB\-P\fR" 4
246 .IX Item "-P"
247 print out the key and \s-1IV\s0 used then immediately exit: don't do any encryption
248 or decryption.
249 .IP "\fB\-bufsize number\fR" 4
250 .IX Item "-bufsize number"
251 set the buffer size for I/O
252 .IP "\fB\-nopad\fR" 4
253 .IX Item "-nopad"
254 disable standard block padding
255 .IP "\fB\-debug\fR" 4
256 .IX Item "-debug"
257 debug the BIOs used for I/O.
258 .IP "\fB\-z\fR" 4
259 .IX Item "-z"
260 Compress or decompress clear text using zlib before encryption or after
261 decryption. This option exists only if OpenSSL with compiled with zlib
262 or zlib-dynamic option.
263 .IP "\fB\-none\fR" 4
264 .IX Item "-none"
265 Use \s-1NULL\s0 cipher (no encryption or decryption of input).
266 .SH "NOTES"
267 .IX Header "NOTES"
268 The program can be called either as \fBopenssl ciphername\fR or
269 \&\fBopenssl enc \-ciphername\fR. But the first form doesn't work with
270 engine-provided ciphers, because this form is processed before the
271 configuration file is read and any ENGINEs loaded.
272 .PP
273 Engines which provide entirely new encryption algorithms (such as ccgost
274 engine which provides gost89 algorithm) should be configured in the
275 configuration file. Engines, specified in the command line using \-engine
276 options can only be used for hadrware-assisted implementations of
277 ciphers, which are supported by OpenSSL core or other engine, specified
278 in the configuration file.
279 .PP
280 When enc command lists supported ciphers, ciphers provided by engines,
281 specified in the configuration files are listed too.
282 .PP
283 A password will be prompted for to derive the key and \s-1IV\s0 if necessary.
284 .PP
285 The \fB\-salt\fR option should \fB\s-1ALWAYS\s0\fR be used if the key is being derived
286 from a password unless you want compatibility with previous versions of
287 OpenSSL and SSLeay.
288 .PP
289 Without the \fB\-salt\fR option it is possible to perform efficient dictionary
290 attacks on the password and to attack stream cipher encrypted data. The reason
291 for this is that without the salt the same password always generates the same
292 encryption key. When the salt is being used the first eight bytes of the
293 encrypted data are reserved for the salt: it is generated at random when
294 encrypting a file and read from the encrypted file when it is decrypted.
295 .PP
296 Some of the ciphers do not have large keys and others have security
297 implications if not used correctly. A beginner is advised to just use
298 a strong block cipher in \s-1CBC\s0 mode such as bf or des3.
299 .PP
300 All the block ciphers normally use PKCS#5 padding also known as standard block
301 padding: this allows a rudimentary integrity or password check to be
302 performed. However since the chance of random data passing the test is
303 better than 1 in 256 it isn't a very good test.
304 .PP
305 If padding is disabled then the input data must be a multiple of the cipher
306 block length.
307 .PP
308 All \s-1RC2\s0 ciphers have the same key and effective key length.
309 .PP
310 Blowfish and \s-1RC5\s0 algorithms use a 128 bit key.
311 .SH "SUPPORTED CIPHERS"
312 .IX Header "SUPPORTED CIPHERS"
313 Note that some of these ciphers can be disabled at compile time
314 and some are available only if an appropriate engine is configured
315 in the configuration file. The output of the \fBenc\fR command run with
316 unsupported options (for example \fBopenssl enc \-help\fR) includes a
317 list of ciphers, supported by your versesion of OpenSSL, including
318 ones provided by configured engines.
319 .PP
320 The \fBenc\fR program does not support authenticated encryption modes
321 like \s-1CCM\s0 and \s-1GCM.\s0 The utility does not store or retrieve the
322 authentication tag.
323 .PP
324 .Vb 1
325 \& base64             Base 64
326 \&
327 \& bf\-cbc             Blowfish in CBC mode
328 \& bf                 Alias for bf\-cbc
329 \& bf\-cfb             Blowfish in CFB mode
330 \& bf\-ecb             Blowfish in ECB mode
331 \& bf\-ofb             Blowfish in OFB mode
332 \&
333 \& cast\-cbc           CAST in CBC mode
334 \& cast               Alias for cast\-cbc
335 \& cast5\-cbc          CAST5 in CBC mode
336 \& cast5\-cfb          CAST5 in CFB mode
337 \& cast5\-ecb          CAST5 in ECB mode
338 \& cast5\-ofb          CAST5 in OFB mode
339 \&
340 \& des\-cbc            DES in CBC mode
341 \& des                Alias for des\-cbc
342 \& des\-cfb            DES in CBC mode
343 \& des\-ofb            DES in OFB mode
344 \& des\-ecb            DES in ECB mode
345 \&
346 \& des\-ede\-cbc        Two key triple DES EDE in CBC mode
347 \& des\-ede            Two key triple DES EDE in ECB mode
348 \& des\-ede\-cfb        Two key triple DES EDE in CFB mode
349 \& des\-ede\-ofb        Two key triple DES EDE in OFB mode
350 \&
351 \& des\-ede3\-cbc       Three key triple DES EDE in CBC mode
352 \& des\-ede3           Three key triple DES EDE in ECB mode
353 \& des3               Alias for des\-ede3\-cbc
354 \& des\-ede3\-cfb       Three key triple DES EDE CFB mode
355 \& des\-ede3\-ofb       Three key triple DES EDE in OFB mode
356 \&
357 \& desx               DESX algorithm.
358 \&
359 \& gost89             GOST 28147\-89 in CFB mode (provided by ccgost engine)
360 \& gost89\-cnt        \`GOST 28147\-89 in CNT mode (provided by ccgost engine) 
361 \&
362 \& idea\-cbc           IDEA algorithm in CBC mode
363 \& idea               same as idea\-cbc
364 \& idea\-cfb           IDEA in CFB mode
365 \& idea\-ecb           IDEA in ECB mode
366 \& idea\-ofb           IDEA in OFB mode
367 \&
368 \& rc2\-cbc            128 bit RC2 in CBC mode
369 \& rc2                Alias for rc2\-cbc
370 \& rc2\-cfb            128 bit RC2 in CFB mode
371 \& rc2\-ecb            128 bit RC2 in ECB mode
372 \& rc2\-ofb            128 bit RC2 in OFB mode
373 \& rc2\-64\-cbc         64 bit RC2 in CBC mode
374 \& rc2\-40\-cbc         40 bit RC2 in CBC mode
375 \&
376 \& rc4                128 bit RC4
377 \& rc4\-64             64 bit RC4
378 \& rc4\-40             40 bit RC4
379 \&
380 \& rc5\-cbc            RC5 cipher in CBC mode
381 \& rc5                Alias for rc5\-cbc
382 \& rc5\-cfb            RC5 cipher in CFB mode
383 \& rc5\-ecb            RC5 cipher in ECB mode
384 \& rc5\-ofb            RC5 cipher in OFB mode
385 \&
386 \& aes\-[128|192|256]\-cbc  128/192/256 bit AES in CBC mode
387 \& aes\-[128|192|256]      Alias for aes\-[128|192|256]\-cbc
388 \& aes\-[128|192|256]\-cfb  128/192/256 bit AES in 128 bit CFB mode
389 \& aes\-[128|192|256]\-cfb1 128/192/256 bit AES in 1 bit CFB mode
390 \& aes\-[128|192|256]\-cfb8 128/192/256 bit AES in 8 bit CFB mode
391 \& aes\-[128|192|256]\-ecb  128/192/256 bit AES in ECB mode
392 \& aes\-[128|192|256]\-ofb  128/192/256 bit AES in OFB mode
393 .Ve
394 .SH "EXAMPLES"
395 .IX Header "EXAMPLES"
396 Just base64 encode a binary file:
397 .PP
398 .Vb 1
399 \& openssl base64 \-in file.bin \-out file.b64
400 .Ve
401 .PP
402 Decode the same file
403 .PP
404 .Vb 1
405 \& openssl base64 \-d \-in file.b64 \-out file.bin
406 .Ve
407 .PP
408 Encrypt a file using triple \s-1DES\s0 in \s-1CBC\s0 mode using a prompted password:
409 .PP
410 .Vb 1
411 \& openssl des3 \-salt \-in file.txt \-out file.des3
412 .Ve
413 .PP
414 Decrypt a file using a supplied password:
415 .PP
416 .Vb 1
417 \& openssl des3 \-d \-salt \-in file.des3 \-out file.txt \-k mypassword
418 .Ve
419 .PP
420 Encrypt a file then base64 encode it (so it can be sent via mail for example)
421 using Blowfish in \s-1CBC\s0 mode:
422 .PP
423 .Vb 1
424 \& openssl bf \-a \-salt \-in file.txt \-out file.bf
425 .Ve
426 .PP
427 Base64 decode a file then decrypt it:
428 .PP
429 .Vb 1
430 \& openssl bf \-d \-salt \-a \-in file.bf \-out file.txt
431 .Ve
432 .PP
433 Decrypt some data using a supplied 40 bit \s-1RC4\s0 key:
434 .PP
435 .Vb 1
436 \& openssl rc4\-40 \-in file.rc4 \-out file.txt \-K 0102030405
437 .Ve
438 .SH "BUGS"
439 .IX Header "BUGS"
440 The \fB\-A\fR option when used with large files doesn't work properly.
441 .PP
442 There should be an option to allow an iteration count to be included.
443 .PP
444 The \fBenc\fR program only supports a fixed number of algorithms with
445 certain parameters. So if, for example, you want to use \s-1RC2\s0 with a
446 76 bit key or \s-1RC4\s0 with an 84 bit key you can't use this program.