1OPENSSL-ENC(1ossl) OpenSSL OPENSSL-ENC(1ossl)
2
3
4
6 openssl-enc - symmetric cipher routines
7
9 openssl enc|cipher [-cipher] [-help] [-list] [-ciphers] [-in filename]
10 [-out filename] [-pass arg] [-e] [-d] [-a] [-base64] [-A] [-k password]
11 [-kfile filename] [-K key] [-iv IV] [-S salt] [-salt] [-nosalt] [-z]
12 [-md digest] [-iter count] [-pbkdf2] [-p] [-P] [-bufsize number]
13 [-nopad] [-v] [-debug] [-none] [-engine id] [-rand files] [-writerand
14 file] [-provider name] [-provider-path path] [-propquery propq]
15
16 openssl cipher [...]
17
19 The symmetric cipher commands allow data to be encrypted or decrypted
20 using various block and stream ciphers using keys based on passwords or
21 explicitly provided. Base64 encoding or decoding can also be performed
22 either by itself or in addition to the encryption or decryption.
23
25 -cipher
26 The cipher to use.
27
28 -help
29 Print out a usage message.
30
31 -list
32 List all supported ciphers.
33
34 -ciphers
35 Alias of -list to display all supported ciphers.
36
37 -in filename
38 The input filename, standard input by default.
39
40 -out filename
41 The output filename, standard output by default.
42
43 -pass arg
44 The password source. For more information about the format of arg
45 see openssl-passphrase-options(1).
46
47 -e Encrypt the input data: this is the default.
48
49 -d Decrypt the input data.
50
51 -a Base64 process the data. This means that if encryption is taking
52 place the data is base64 encoded after encryption. If decryption is
53 set then the input data is base64 decoded before being decrypted.
54
55 -base64
56 Same as -a
57
58 -A If the -a option is set then base64 process the data on one line.
59
60 -k password
61 The password to derive the key from. This is for compatibility with
62 previous versions of OpenSSL. Superseded by the -pass argument.
63
64 -kfile filename
65 Read the password to derive the key from the first line of
66 filename. This is for compatibility with previous versions of
67 OpenSSL. Superseded by the -pass argument.
68
69 -md digest
70 Use the specified digest to create the key from the passphrase.
71 The default algorithm is sha-256.
72
73 -iter count
74 Use a given number of iterations on the password in deriving the
75 encryption key. High values increase the time required to brute-
76 force the resulting file. This option enables the use of PBKDF2
77 algorithm to derive the key.
78
79 -pbkdf2
80 Use PBKDF2 algorithm with default iteration count unless otherwise
81 specified.
82
83 -nosalt
84 Don't use a salt in the key derivation routines. This option SHOULD
85 NOT be used except for test purposes or compatibility with ancient
86 versions of OpenSSL.
87
88 -salt
89 Use salt (randomly generated or provide with -S option) when
90 encrypting, this is the default.
91
92 -S salt
93 The actual salt to use: this must be represented as a string of hex
94 digits. If this option is used while encrypting, the same exact
95 value will be needed again during decryption.
96
97 -K key
98 The actual key to use: this must be represented as a string
99 comprised only of hex digits. If only the key is specified, the IV
100 must additionally specified using the -iv option. When both a key
101 and a password are specified, the key given with the -K option will
102 be used and the IV generated from the password will be taken. It
103 does not make much sense to specify both key and password.
104
105 -iv IV
106 The actual IV to use: this must be represented as a string
107 comprised only of hex digits. When only the key is specified using
108 the -K option, the IV must explicitly be defined. When a password
109 is being specified using one of the other options, the IV is
110 generated from this password.
111
112 -p Print out the key and IV used.
113
114 -P Print out the key and IV used then immediately exit: don't do any
115 encryption or decryption.
116
117 -bufsize number
118 Set the buffer size for I/O.
119
120 -nopad
121 Disable standard block padding.
122
123 -v Verbose print; display some statistics about I/O and buffer sizes.
124
125 -debug
126 Debug the BIOs used for I/O.
127
128 -z Compress or decompress encrypted data using zlib after encryption
129 or before decryption. This option exists only if OpenSSL was
130 compiled with the zlib or zlib-dynamic option.
131
132 -none
133 Use NULL cipher (no encryption or decryption of input).
134
135 -rand files, -writerand file
136 See "Random State Options" in openssl(1) for details.
137
138 -provider name
139 -provider-path path
140 -propquery propq
141 See "Provider Options" in openssl(1), provider(7), and property(7).
142
143 -engine id
144 See "Engine Options" in openssl(1). This option is deprecated.
145
147 The program can be called either as "openssl cipher" or "openssl enc
148 -cipher". The first form doesn't work with engine-provided ciphers,
149 because this form is processed before the configuration file is read
150 and any ENGINEs loaded. Use the openssl-list(1) command to get a list
151 of supported ciphers.
152
153 Engines which provide entirely new encryption algorithms (such as the
154 ccgost engine which provides gost89 algorithm) should be configured in
155 the configuration file. Engines specified on the command line using
156 -engine option can only be used for hardware-assisted implementations
157 of ciphers which are supported by the OpenSSL core or another engine
158 specified in the configuration file.
159
160 When the enc command lists supported ciphers, ciphers provided by
161 engines, specified in the configuration files are listed too.
162
163 A password will be prompted for to derive the key and IV if necessary.
164
165 The -salt option should ALWAYS be used if the key is being derived from
166 a password unless you want compatibility with previous versions of
167 OpenSSL.
168
169 Without the -salt option it is possible to perform efficient dictionary
170 attacks on the password and to attack stream cipher encrypted data. The
171 reason for this is that without the salt the same password always
172 generates the same encryption key.
173
174 When the salt is generated at random (that means when encrypting using
175 a passphrase without explicit salt given using -S option), the first
176 bytes of the encrypted data are reserved to store the salt for later
177 decrypting.
178
179 Some of the ciphers do not have large keys and others have security
180 implications if not used correctly. A beginner is advised to just use a
181 strong block cipher, such as AES, in CBC mode.
182
183 All the block ciphers normally use PKCS#5 padding, also known as
184 standard block padding. This allows a rudimentary integrity or password
185 check to be performed. However, since the chance of random data passing
186 the test is better than 1 in 256 it isn't a very good test.
187
188 If padding is disabled then the input data must be a multiple of the
189 cipher block length.
190
191 All RC2 ciphers have the same key and effective key length.
192
193 Blowfish and RC5 algorithms use a 128 bit key.
194
196 Note that some of these ciphers can be disabled at compile time and
197 some are available only if an appropriate engine is configured in the
198 configuration file. The output when invoking this command with the
199 -list option (that is "openssl enc -list") is a list of ciphers,
200 supported by your version of OpenSSL, including ones provided by
201 configured engines.
202
203 This command does not support authenticated encryption modes like CCM
204 and GCM, and will not support such modes in the future. This is due to
205 having to begin streaming output (e.g., to standard output when -out is
206 not used) before the authentication tag could be validated. When this
207 command is used in a pipeline, the receiving end will not be able to
208 roll back upon authentication failure. The AEAD modes currently in
209 common use also suffer from catastrophic failure of confidentiality
210 and/or integrity upon reuse of key/iv/nonce, and since openssl enc
211 places the entire burden of key/iv/nonce management upon the user, the
212 risk of exposing AEAD modes is too great to allow. These key/iv/nonce
213 management issues also affect other modes currently exposed in this
214 command, but the failure modes are less extreme in these cases, and the
215 functionality cannot be removed with a stable release branch. For bulk
216 encryption of data, whether using authenticated encryption modes or
217 other modes, openssl-cms(1) is recommended, as it provides a standard
218 data format and performs the needed key/iv/nonce management.
219
220 base64 Base 64
221
222 bf-cbc Blowfish in CBC mode
223 bf Alias for bf-cbc
224 blowfish Alias for bf-cbc
225 bf-cfb Blowfish in CFB mode
226 bf-ecb Blowfish in ECB mode
227 bf-ofb Blowfish in OFB mode
228
229 cast-cbc CAST in CBC mode
230 cast Alias for cast-cbc
231 cast5-cbc CAST5 in CBC mode
232 cast5-cfb CAST5 in CFB mode
233 cast5-ecb CAST5 in ECB mode
234 cast5-ofb CAST5 in OFB mode
235
236 chacha20 ChaCha20 algorithm
237
238 des-cbc DES in CBC mode
239 des Alias for des-cbc
240 des-cfb DES in CFB mode
241 des-ofb DES in OFB mode
242 des-ecb DES in ECB mode
243
244 des-ede-cbc Two key triple DES EDE in CBC mode
245 des-ede Two key triple DES EDE in ECB mode
246 des-ede-cfb Two key triple DES EDE in CFB mode
247 des-ede-ofb Two key triple DES EDE in OFB mode
248
249 des-ede3-cbc Three key triple DES EDE in CBC mode
250 des-ede3 Three key triple DES EDE in ECB mode
251 des3 Alias for des-ede3-cbc
252 des-ede3-cfb Three key triple DES EDE CFB mode
253 des-ede3-ofb Three key triple DES EDE in OFB mode
254
255 desx DESX algorithm.
256
257 gost89 GOST 28147-89 in CFB mode (provided by ccgost engine)
258 gost89-cnt GOST 28147-89 in CNT mode (provided by ccgost engine)
259
260 idea-cbc IDEA algorithm in CBC mode
261 idea same as idea-cbc
262 idea-cfb IDEA in CFB mode
263 idea-ecb IDEA in ECB mode
264 idea-ofb IDEA in OFB mode
265
266 rc2-cbc 128 bit RC2 in CBC mode
267 rc2 Alias for rc2-cbc
268 rc2-cfb 128 bit RC2 in CFB mode
269 rc2-ecb 128 bit RC2 in ECB mode
270 rc2-ofb 128 bit RC2 in OFB mode
271 rc2-64-cbc 64 bit RC2 in CBC mode
272 rc2-40-cbc 40 bit RC2 in CBC mode
273
274 rc4 128 bit RC4
275 rc4-64 64 bit RC4
276 rc4-40 40 bit RC4
277
278 rc5-cbc RC5 cipher in CBC mode
279 rc5 Alias for rc5-cbc
280 rc5-cfb RC5 cipher in CFB mode
281 rc5-ecb RC5 cipher in ECB mode
282 rc5-ofb RC5 cipher in OFB mode
283
284 seed-cbc SEED cipher in CBC mode
285 seed Alias for seed-cbc
286 seed-cfb SEED cipher in CFB mode
287 seed-ecb SEED cipher in ECB mode
288 seed-ofb SEED cipher in OFB mode
289
290 sm4-cbc SM4 cipher in CBC mode
291 sm4 Alias for sm4-cbc
292 sm4-cfb SM4 cipher in CFB mode
293 sm4-ctr SM4 cipher in CTR mode
294 sm4-ecb SM4 cipher in ECB mode
295 sm4-ofb SM4 cipher in OFB mode
296
297 aes-[128|192|256]-cbc 128/192/256 bit AES in CBC mode
298 aes[128|192|256] Alias for aes-[128|192|256]-cbc
299 aes-[128|192|256]-cfb 128/192/256 bit AES in 128 bit CFB mode
300 aes-[128|192|256]-cfb1 128/192/256 bit AES in 1 bit CFB mode
301 aes-[128|192|256]-cfb8 128/192/256 bit AES in 8 bit CFB mode
302 aes-[128|192|256]-ctr 128/192/256 bit AES in CTR mode
303 aes-[128|192|256]-ecb 128/192/256 bit AES in ECB mode
304 aes-[128|192|256]-ofb 128/192/256 bit AES in OFB mode
305
306 aria-[128|192|256]-cbc 128/192/256 bit ARIA in CBC mode
307 aria[128|192|256] Alias for aria-[128|192|256]-cbc
308 aria-[128|192|256]-cfb 128/192/256 bit ARIA in 128 bit CFB mode
309 aria-[128|192|256]-cfb1 128/192/256 bit ARIA in 1 bit CFB mode
310 aria-[128|192|256]-cfb8 128/192/256 bit ARIA in 8 bit CFB mode
311 aria-[128|192|256]-ctr 128/192/256 bit ARIA in CTR mode
312 aria-[128|192|256]-ecb 128/192/256 bit ARIA in ECB mode
313 aria-[128|192|256]-ofb 128/192/256 bit ARIA in OFB mode
314
315 camellia-[128|192|256]-cbc 128/192/256 bit Camellia in CBC mode
316 camellia[128|192|256] Alias for camellia-[128|192|256]-cbc
317 camellia-[128|192|256]-cfb 128/192/256 bit Camellia in 128 bit CFB mode
318 camellia-[128|192|256]-cfb1 128/192/256 bit Camellia in 1 bit CFB mode
319 camellia-[128|192|256]-cfb8 128/192/256 bit Camellia in 8 bit CFB mode
320 camellia-[128|192|256]-ctr 128/192/256 bit Camellia in CTR mode
321 camellia-[128|192|256]-ecb 128/192/256 bit Camellia in ECB mode
322 camellia-[128|192|256]-ofb 128/192/256 bit Camellia in OFB mode
323
325 Just base64 encode a binary file:
326
327 openssl base64 -in file.bin -out file.b64
328
329 Decode the same file
330
331 openssl base64 -d -in file.b64 -out file.bin
332
333 Encrypt a file using AES-128 using a prompted password and PBKDF2 key
334 derivation:
335
336 openssl enc -aes128 -pbkdf2 -in file.txt -out file.aes128
337
338 Decrypt a file using a supplied password:
339
340 openssl enc -aes128 -pbkdf2 -d -in file.aes128 -out file.txt \
341 -pass pass:<password>
342
343 Encrypt a file then base64 encode it (so it can be sent via mail for
344 example) using AES-256 in CTR mode and PBKDF2 key derivation:
345
346 openssl enc -aes-256-ctr -pbkdf2 -a -in file.txt -out file.aes256
347
348 Base64 decode a file then decrypt it using a password supplied in a
349 file:
350
351 openssl enc -aes-256-ctr -pbkdf2 -d -a -in file.aes256 -out file.txt \
352 -pass file:<passfile>
353
355 The -A option when used with large files doesn't work properly.
356
357 The openssl enc command only supports a fixed number of algorithms with
358 certain parameters. So if, for example, you want to use RC2 with a 76
359 bit key or RC4 with an 84 bit key you can't use this program.
360
362 The default digest was changed from MD5 to SHA256 in OpenSSL 1.1.0.
363
364 The -list option was added in OpenSSL 1.1.1e.
365
366 The -ciphers and -engine options were deprecated in OpenSSL 3.0.
367
369 Copyright 2000-2021 The OpenSSL Project Authors. All Rights Reserved.
370
371 Licensed under the Apache License 2.0 (the "License"). You may not use
372 this file except in compliance with the License. You can obtain a copy
373 in the file LICENSE in the source distribution or at
374 <https://www.openssl.org/source/license.html>.
375
376
377
3783.0.5 2022-11-01 OPENSSL-ENC(1ossl)