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