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 a default iteration count of 10000 unless
81 otherwise specified by the -iter command line option.
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
195 Please note that OpenSSL 3.0 changed the effect of the -S option. Any
196 explicit salt value specified via this option is no longer prepended to
197 the ciphertext when encrypting, and must again be explicitly provided
198 when decrypting. Conversely, when the -S option is used during
199 decryption, the ciphertext is expected to not have a prepended salt
200 value.
201
202 When using OpenSSL 3.0 or later to decrypt data that was encrypted with
203 an explicit salt under OpenSSL 1.1.1 do not use the -S option, the salt
204 will then be read from the ciphertext. To generate ciphertext that can
205 be decrypted with OpenSSL 1.1.1 do not use the -S option, the salt will
206 be then be generated randomly and prepended to the output.
207
209 Note that some of these ciphers can be disabled at compile time and
210 some are available only if an appropriate engine is configured in the
211 configuration file. The output when invoking this command with the
212 -list option (that is "openssl enc -list") is a list of ciphers,
213 supported by your version of OpenSSL, including ones provided by
214 configured engines.
215
216 This command does not support authenticated encryption modes like CCM
217 and GCM, and will not support such modes in the future. This is due to
218 having to begin streaming output (e.g., to standard output when -out is
219 not used) before the authentication tag could be validated. When this
220 command is used in a pipeline, the receiving end will not be able to
221 roll back upon authentication failure. The AEAD modes currently in
222 common use also suffer from catastrophic failure of confidentiality
223 and/or integrity upon reuse of key/iv/nonce, and since openssl enc
224 places the entire burden of key/iv/nonce management upon the user, the
225 risk of exposing AEAD modes is too great to allow. These key/iv/nonce
226 management issues also affect other modes currently exposed in this
227 command, but the failure modes are less extreme in these cases, and the
228 functionality cannot be removed with a stable release branch. For bulk
229 encryption of data, whether using authenticated encryption modes or
230 other modes, openssl-cms(1) is recommended, as it provides a standard
231 data format and performs the needed key/iv/nonce management.
232
233 base64 Base 64
234
235 bf-cbc Blowfish in CBC mode
236 bf Alias for bf-cbc
237 blowfish Alias for bf-cbc
238 bf-cfb Blowfish in CFB mode
239 bf-ecb Blowfish in ECB mode
240 bf-ofb Blowfish in OFB mode
241
242 cast-cbc CAST in CBC mode
243 cast Alias for cast-cbc
244 cast5-cbc CAST5 in CBC mode
245 cast5-cfb CAST5 in CFB mode
246 cast5-ecb CAST5 in ECB mode
247 cast5-ofb CAST5 in OFB mode
248
249 chacha20 ChaCha20 algorithm
250
251 des-cbc DES in CBC mode
252 des Alias for des-cbc
253 des-cfb DES in CFB mode
254 des-ofb DES in OFB mode
255 des-ecb DES in ECB mode
256
257 des-ede-cbc Two key triple DES EDE in CBC mode
258 des-ede Two key triple DES EDE in ECB mode
259 des-ede-cfb Two key triple DES EDE in CFB mode
260 des-ede-ofb Two key triple DES EDE in OFB mode
261
262 des-ede3-cbc Three key triple DES EDE in CBC mode
263 des-ede3 Three key triple DES EDE in ECB mode
264 des3 Alias for des-ede3-cbc
265 des-ede3-cfb Three key triple DES EDE CFB mode
266 des-ede3-ofb Three key triple DES EDE in OFB mode
267
268 desx DESX algorithm.
269
270 gost89 GOST 28147-89 in CFB mode (provided by ccgost engine)
271 gost89-cnt GOST 28147-89 in CNT mode (provided by ccgost engine)
272
273 idea-cbc IDEA algorithm in CBC mode
274 idea same as idea-cbc
275 idea-cfb IDEA in CFB mode
276 idea-ecb IDEA in ECB mode
277 idea-ofb IDEA in OFB mode
278
279 rc2-cbc 128 bit RC2 in CBC mode
280 rc2 Alias for rc2-cbc
281 rc2-cfb 128 bit RC2 in CFB mode
282 rc2-ecb 128 bit RC2 in ECB mode
283 rc2-ofb 128 bit RC2 in OFB mode
284 rc2-64-cbc 64 bit RC2 in CBC mode
285 rc2-40-cbc 40 bit RC2 in CBC mode
286
287 rc4 128 bit RC4
288 rc4-64 64 bit RC4
289 rc4-40 40 bit RC4
290
291 rc5-cbc RC5 cipher in CBC mode
292 rc5 Alias for rc5-cbc
293 rc5-cfb RC5 cipher in CFB mode
294 rc5-ecb RC5 cipher in ECB mode
295 rc5-ofb RC5 cipher in OFB mode
296
297 seed-cbc SEED cipher in CBC mode
298 seed Alias for seed-cbc
299 seed-cfb SEED cipher in CFB mode
300 seed-ecb SEED cipher in ECB mode
301 seed-ofb SEED cipher in OFB mode
302
303 sm4-cbc SM4 cipher in CBC mode
304 sm4 Alias for sm4-cbc
305 sm4-cfb SM4 cipher in CFB mode
306 sm4-ctr SM4 cipher in CTR mode
307 sm4-ecb SM4 cipher in ECB mode
308 sm4-ofb SM4 cipher in OFB mode
309
310 aes-[128|192|256]-cbc 128/192/256 bit AES in CBC mode
311 aes[128|192|256] Alias for aes-[128|192|256]-cbc
312 aes-[128|192|256]-cfb 128/192/256 bit AES in 128 bit CFB mode
313 aes-[128|192|256]-cfb1 128/192/256 bit AES in 1 bit CFB mode
314 aes-[128|192|256]-cfb8 128/192/256 bit AES in 8 bit CFB mode
315 aes-[128|192|256]-ctr 128/192/256 bit AES in CTR mode
316 aes-[128|192|256]-ecb 128/192/256 bit AES in ECB mode
317 aes-[128|192|256]-ofb 128/192/256 bit AES in OFB mode
318
319 aria-[128|192|256]-cbc 128/192/256 bit ARIA in CBC mode
320 aria[128|192|256] Alias for aria-[128|192|256]-cbc
321 aria-[128|192|256]-cfb 128/192/256 bit ARIA in 128 bit CFB mode
322 aria-[128|192|256]-cfb1 128/192/256 bit ARIA in 1 bit CFB mode
323 aria-[128|192|256]-cfb8 128/192/256 bit ARIA in 8 bit CFB mode
324 aria-[128|192|256]-ctr 128/192/256 bit ARIA in CTR mode
325 aria-[128|192|256]-ecb 128/192/256 bit ARIA in ECB mode
326 aria-[128|192|256]-ofb 128/192/256 bit ARIA in OFB mode
327
328 camellia-[128|192|256]-cbc 128/192/256 bit Camellia in CBC mode
329 camellia[128|192|256] Alias for camellia-[128|192|256]-cbc
330 camellia-[128|192|256]-cfb 128/192/256 bit Camellia in 128 bit CFB mode
331 camellia-[128|192|256]-cfb1 128/192/256 bit Camellia in 1 bit CFB mode
332 camellia-[128|192|256]-cfb8 128/192/256 bit Camellia in 8 bit CFB mode
333 camellia-[128|192|256]-ctr 128/192/256 bit Camellia in CTR mode
334 camellia-[128|192|256]-ecb 128/192/256 bit Camellia in ECB mode
335 camellia-[128|192|256]-ofb 128/192/256 bit Camellia in OFB mode
336
338 Just base64 encode a binary file:
339
340 openssl base64 -in file.bin -out file.b64
341
342 Decode the same file
343
344 openssl base64 -d -in file.b64 -out file.bin
345
346 Encrypt a file using AES-128 using a prompted password and PBKDF2 key
347 derivation:
348
349 openssl enc -aes128 -pbkdf2 -in file.txt -out file.aes128
350
351 Decrypt a file using a supplied password:
352
353 openssl enc -aes128 -pbkdf2 -d -in file.aes128 -out file.txt \
354 -pass pass:<password>
355
356 Encrypt a file then base64 encode it (so it can be sent via mail for
357 example) using AES-256 in CTR mode and PBKDF2 key derivation:
358
359 openssl enc -aes-256-ctr -pbkdf2 -a -in file.txt -out file.aes256
360
361 Base64 decode a file then decrypt it using a password supplied in a
362 file:
363
364 openssl enc -aes-256-ctr -pbkdf2 -d -a -in file.aes256 -out file.txt \
365 -pass file:<passfile>
366
368 The -A option when used with large files doesn't work properly.
369
370 The openssl enc command only supports a fixed number of algorithms with
371 certain parameters. So if, for example, you want to use RC2 with a 76
372 bit key or RC4 with an 84 bit key you can't use this program.
373
375 The default digest was changed from MD5 to SHA256 in OpenSSL 1.1.0.
376
377 The -list option was added in OpenSSL 1.1.1e.
378
379 The -ciphers and -engine options were deprecated in OpenSSL 3.0.
380
382 Copyright 2000-2023 The OpenSSL Project Authors. All Rights Reserved.
383
384 Licensed under the Apache License 2.0 (the "License"). You may not use
385 this file except in compliance with the License. You can obtain a copy
386 in the file LICENSE in the source distribution or at
387 <https://www.openssl.org/source/license.html>.
388
389
390
3913.1.1 2023-08-31 OPENSSL-ENC(1ossl)