1 .\" $NetBSD: libcrypto.pl,v 1.3 2007/11/27 22:16:03 christos Exp $
3 .\" Automatically generated by Pod::Man 2.16 (Pod::Simple 3.05)
6 .\" ========================================================================
7 .de Sh \" Subsection heading
15 .de Sp \" Vertical space (when we can't use .PP)
19 .de Vb \" Begin verbatim text
24 .de Ve \" End verbatim text
28 .\" Set up some character translations and predefined strings. \*(-- will
29 .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
30 .\" double quote, and \*(R" will give a right double quote. \*(C+ will
31 .\" give a nicer C++. Capital omega is used to do unbreakable dashes and
32 .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff,
33 .\" nothing in troff, for use with C<>.
35 .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
39 . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
40 . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch
53 .\" Escape single quotes in literal strings from groff's Unicode transform.
57 .\" If the F register is turned on, we'll generate index entries on stderr for
58 .\" titles (.TH), headers (.SH), subsections (.Sh), items (.Ip), and index
59 .\" entries marked with X<> in POD. Of course, you'll have to process the
60 .\" output yourself in some meaningful fashion.
63 . tm Index:\\$1\t\\n%\t"\\$2"
73 .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
74 .\" Fear. Run. Save yourself. No user-serviceable parts.
75 . \" fudge factors for nroff and troff
84 . ds #H ((1u-(\\\\n(.fu%2u))*.13m)
90 . \" simple accents for nroff and troff
100 . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
101 . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
102 . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
103 . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
104 . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
105 . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
107 . \" troff and (daisy-wheel) nroff accents
108 .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
109 .ds 8 \h'\*(#H'\(*b\h'-\*(#H'
110 .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
111 .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
112 .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
113 .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
114 .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
115 .ds ae a\h'-(\w'a'u*4/10)'e
116 .ds Ae A\h'-(\w'A'u*4/10)'E
117 . \" corrections for vroff
118 .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
119 .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
120 . \" for low resolution devices (crt and lpr)
121 .if \n(.H>23 .if \n(.V>19 \
134 .\" ========================================================================
137 .TH ENC 1 "2009-04-15" "1.1.0-dev" "OpenSSL"
138 .\" For nroff, turn off justification. Always turn off hyphenation; it makes
139 .\" way too many mistakes in technical documents.
143 enc \- symmetric cipher routines
147 .IX Header "SYNOPSIS"
148 \&\fBopenssl enc \-ciphername\fR
149 [\fB\-in filename\fR]
150 [\fB\-out filename\fR]
157 [\fB\-kfile filename\fR]
159 [\fB\-iv \s-1IV\s0\fR]
167 [\fB\-bufsize number\fR]
173 .IX Header "DESCRIPTION"
174 The symmetric cipher commands allow data to be encrypted or decrypted
175 using various block and stream ciphers using keys based on passwords
176 or explicitly provided. Base64 encoding or decoding can also be performed
177 either by itself or in addition to the encryption or decryption.
180 .IP "\fB\-in filename\fR" 4
181 .IX Item "-in filename"
182 the input filename, standard input by default.
183 .IP "\fB\-out filename\fR" 4
184 .IX Item "-out filename"
185 the output filename, standard output by default.
186 .IP "\fB\-pass arg\fR" 4
188 the password source. For more information about the format of \fBarg\fR
189 see the \fB\s-1PASS\s0 \s-1PHRASE\s0 \s-1ARGUMENTS\s0\fR section in \fIopenssl\fR\|(1).
192 use a salt in the key derivation routines. This option should \fB\s-1ALWAYS\s0\fR
193 be used unless compatibility with previous versions of OpenSSL or SSLeay
194 is required. This option is only present on OpenSSL versions 0.9.5 or
196 .IP "\fB\-nosalt\fR" 4
198 don't use a salt in the key derivation routines. This is the default for
199 compatibility with previous versions of OpenSSL and SSLeay.
202 encrypt the input data: this is the default.
205 decrypt the input data.
208 base64 process the data. This means that if encryption is taking place
209 the data is base64 encoded after encryption. If decryption is set then
210 the input data is base64 decoded before being decrypted.
211 .IP "\fB\-base64\fR" 4
216 if the \fB\-a\fR option is set then base64 process the data on one line.
217 .IP "\fB\-k password\fR" 4
218 .IX Item "-k password"
219 the password to derive the key from. This is for compatibility with previous
220 versions of OpenSSL. Superseded by the \fB\-pass\fR argument.
221 .IP "\fB\-kfile filename\fR" 4
222 .IX Item "-kfile filename"
223 read the password to derive the key from the first line of \fBfilename\fR.
224 This is for compatibility with previous versions of OpenSSL. Superseded by
225 the \fB\-pass\fR argument.
226 .IP "\fB\-nosalt\fR" 4
231 use salt (randomly generated or provide with \fB\-S\fR option) when
232 encrypting (this is the default).
233 .IP "\fB\-S salt\fR" 4
235 the actual salt to use: this must be represented as a string of hex digits.
236 .IP "\fB\-K key\fR" 4
238 the actual key to use: this must be represented as a string comprised only
239 of hex digits. If only the key is specified, the \s-1IV\s0 must additionally specified
240 using the \fB\-iv\fR option. When both a key and a password are specified, the
241 key given with the \fB\-K\fR option will be used and the \s-1IV\s0 generated from the
242 password will be taken. It probably does not make much sense to specify
243 both key and password.
244 .IP "\fB\-iv \s-1IV\s0\fR" 4
246 the actual \s-1IV\s0 to use: this must be represented as a string comprised only
247 of hex digits. When only the key is specified using the \fB\-K\fR option, the
248 \&\s-1IV\s0 must explicitly be defined. When a password is being specified using
249 one of the other options, the \s-1IV\s0 is generated from this password.
252 print out the key and \s-1IV\s0 used.
255 print out the key and \s-1IV\s0 used then immediately exit: don't do any encryption
257 .IP "\fB\-bufsize number\fR" 4
258 .IX Item "-bufsize number"
259 set the buffer size for I/O
260 .IP "\fB\-nopad\fR" 4
262 disable standard block padding
263 .IP "\fB\-debug\fR" 4
265 debug the BIOs used for I/O.
268 Compress or decompress clear text using zlib before encryption or after
269 decryption. This option exists only if OpenSSL with compiled with zlib
270 or zlib-dynamic option.
273 Use \s-1NULL\s0 cipher (no encryption or decryption of input).
276 The program can be called either as \fBopenssl ciphername\fR or
277 \&\fBopenssl enc \-ciphername\fR. But the first form doesn't work with
278 engine-provided ciphers, because this form is processed before the
279 configuration file is read and any ENGINEs loaded.
281 Engines which provide entirely new encryption algorithms (such as ccgost
282 engine which provides gost89 algorithm) should be configured in the
283 configuration file. Engines, specified in the command line using \-engine
284 options can only be used for hadrware-assisted implementations of
285 ciphers, which are supported by OpenSSL core or other engine, specified
286 in the configuration file.
288 When enc command lists supported ciphers, ciphers provided by engines,
289 specified in the configuration files are listed too.
291 A password will be prompted for to derive the key and \s-1IV\s0 if necessary.
293 The \fB\-salt\fR option should \fB\s-1ALWAYS\s0\fR be used if the key is being derived
294 from a password unless you want compatibility with previous versions of
297 Without the \fB\-salt\fR option it is possible to perform efficient dictionary
298 attacks on the password and to attack stream cipher encrypted data. The reason
299 for this is that without the salt the same password always generates the same
300 encryption key. When the salt is being used the first eight bytes of the
301 encrypted data are reserved for the salt: it is generated at random when
302 encrypting a file and read from the encrypted file when it is decrypted.
304 Some of the ciphers do not have large keys and others have security
305 implications if not used correctly. A beginner is advised to just use
306 a strong block cipher in \s-1CBC\s0 mode such as bf or des3.
308 All the block ciphers normally use PKCS#5 padding also known as standard block
309 padding: this allows a rudimentary integrity or password check to be
310 performed. However since the chance of random data passing the test is
311 better than 1 in 256 it isn't a very good test.
313 If padding is disabled then the input data must be a multiple of the cipher
316 All \s-1RC2\s0 ciphers have the same key and effective key length.
318 Blowfish and \s-1RC5\s0 algorithms use a 128 bit key.
319 .SH "SUPPORTED CIPHERS"
320 .IX Header "SUPPORTED CIPHERS"
321 Note that some of these ciphers can be disabled at compile time
322 and some are available only if an appropriate engine is configured
323 in the configuration file. The output of the \fBenc\fR command run with
324 unsupported options (for example \fBopenssl enc \-help\fR) includes a
325 list of ciphers, supported by your versesion of OpenSSL, including
326 ones provided by configured engines.
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
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
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
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
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
361 \& desx DESX algorithm.
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)
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
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
381 \& rc4\-64 64 bit RC4
382 \& rc4\-40 40 bit RC4
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
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
399 .IX Header "EXAMPLES"
400 Just base64 encode a binary file:
403 \& openssl base64 \-in file.bin \-out file.b64
409 \& openssl base64 \-d \-in file.b64 \-out file.bin
412 Encrypt a file using triple \s-1DES\s0 in \s-1CBC\s0 mode using a prompted password:
415 \& openssl des3 \-salt \-in file.txt \-out file.des3
418 Decrypt a file using a supplied password:
421 \& openssl des3 \-d \-salt \-in file.des3 \-out file.txt \-k mypassword
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:
428 \& openssl bf \-a \-salt \-in file.txt \-out file.bf
431 Base64 decode a file then decrypt it:
434 \& openssl bf \-d \-salt \-a \-in file.bf \-out file.txt
437 Decrypt some data using a supplied 40 bit \s-1RC4\s0 key:
440 \& openssl rc4\-40 \-in file.rc4 \-out file.txt \-K 0102030405
444 The \fB\-A\fR option when used with large files doesn't work properly.
446 There should be an option to allow an iteration count to be included.
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.