1 .\" Copyright (c) 1991, 1993
2 .\" The Regents of the University of California. All rights reserved.
4 .\" This code is derived from software contributed to Berkeley by
5 .\" Matt Bishop of Dartmouth College.
7 .\" Redistribution and use in source and binary forms, with or without
8 .\" modification, are permitted provided that the following conditions
10 .\" 1. Redistributions of source code must retain the above copyright
11 .\" notice, this list of conditions and the following disclaimer.
12 .\" 2. Redistributions in binary form must reproduce the above copyright
13 .\" notice, this list of conditions and the following disclaimer in the
14 .\" documentation and/or other materials provided with the distribution.
15 .\" 3. All advertising materials mentioning features or use of this software
16 .\" must display the following acknowledgement:
17 .\" This product includes software developed by the University of
18 .\" California, Berkeley and its contributors.
19 .\" 4. Neither the name of the University nor the names of its contributors
20 .\" may be used to endorse or promote products derived from this software
21 .\" without specific prior written permission.
23 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
24 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
27 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
35 .\" @(#)bdes.1 8.1 (Berkeley) 6/29/93
43 .Nd "encrypt/decrypt using the Data Encryption Standard (DES)"
56 utility implements all
58 modes of operation described in
60 including alternative cipher feedback mode and both authentication
64 utility reads from the standard input
65 and writes to the standard output.
67 the input is encrypted
68 using cipher block chaining (CBC) mode.
70 for encryption and decryption
73 All modes but the electronic code book (ECB) mode
74 require an initialization vector;
76 the zero vector is used.
79 is specified on the command line,
80 the user is prompted for one (see
84 The options are as follows:
85 .Bl -tag -width indent
87 The key and initialization vector strings
90 suppressing the special interpretation given to leading
99 the key and initialization vector.
107 alternative CFB mode.
110 must be a multiple of 7
111 between 7 and 56 inclusive
112 (this does not conform to the alternative CFB mode specification).
119 must be a multiple of 8 between 8 and 64 inclusive (this does not conform
120 to the standard CFB mode specification).
124 as the cryptographic key.
126 Compute a message authentication code (MAC) of
131 must be between 1 and 64 inclusive; if
133 is not a multiple of 8,
134 enough 0 bits will be added
135 to pad the MAC length
136 to the nearest multiple of 8.
137 Only the MAC is output.
138 MACs are only available
144 ouput feedback (OFB) mode.
147 must be a multiple of 8 between 8 and 64 inclusive (this does not conform
148 to the OFB mode specification).
150 Disable the resetting of the parity bit.
152 the parity bit of the key
155 each character be of odd parity.
156 It is used only if the key is given in
159 Set the initialization vector to
161 the vector is interpreted in the same way as the key.
162 The vector is ignored in ECB mode.
165 The key and initialization vector
166 are taken as sequences of
168 characters which are then mapped
169 into their bit representations.
170 If either begins with
175 as a sequence of hexadecimal digits
176 indicating the bit pattern;
177 if either begins with
182 as a sequence of binary digits
183 indicating the bit pattern.
185 only the leading 64 bits
186 of the key or initialization vector
188 and if fewer than 64 bits are provided,
189 enough 0 bits are appended
190 to pad the key to 64 bits.
195 the low-order bit of each character
196 in the key string is deleted.
200 set the high-order bit to 0,
201 simply deleting the low-order bit
202 effectively reduces the size of the key space
203 from 2^56 to 2^48 keys.
205 the high-order bit must be a function
206 depending in part upon the low-order bit;
208 the high-order bit is set
209 to whatever value gives odd parity.
210 This preserves the key space size.
211 Note this resetting of the parity bit is
214 is given in binary or hex,
215 and can be disabled for
221 is considered a very strong cryptosystem,
222 and other than table lookup attacks,
224 and Hellman's time-memory tradeoff
225 (all of which are very expensive and time-consuming),
226 no cryptanalytic methods
229 are known in the open literature.
230 No doubt the choice of keys
232 are the most vulnerable aspect of
234 .Sh IMPLEMENTATION NOTES
235 For implementors wishing to write
236 software compatible with this program,
237 the following notes are provided.
238 This software is believed
239 to be compatible with the implementation
240 of the data encryption standard
241 distributed by Sun Microsystems, Inc.
243 In the ECB and CBC modes,
244 plaintext is encrypted in units of 64 bits
245 (8 bytes, also called a block).
246 To ensure that the plaintext file
247 is encrypted correctly,
249 will (internally) append from 1 to 8 bytes,
250 the last byte containing an integer
251 stating how many bytes of that final block
252 are from the plaintext file,
253 and encrypt the resulting block.
256 the last block may contain from 0 to 7 characters
257 present in the plaintext file,
258 and the last byte tells how many.
259 Note that if during decryption
260 the last byte of the file
261 does not contain an integer between 0 and 7,
262 either the file has been corrupted
263 or an incorrect key has been given.
264 A similar mechanism is used
265 for the OFB and CFB modes,
267 simply require the length of the input
268 to be a multiple of the mode size,
269 and the final byte contains an integer
270 between 0 and one less than the number
271 of bytes being used as the mode.
272 (This was another reason
273 that the mode size must be
274 a multiple of 8 for those modes.)
276 Unlike Sun's implementation,
277 unused bytes of that last block
278 are not filled with random data,
280 what was in those byte positions
281 in the preceding block.
282 This is quicker and more portable,
283 and does not weaken the encryption significantly.
285 If the key is entered in
287 the parity bits of the key characters
288 are set so that each key character
290 Unlike Sun's implementation,
291 it is possible to enter binary or hexadecimal
292 keys on the command line,
298 using arbitrary bit patterns as keys.
300 The Sun implementation
301 always uses an initialization vector of 0
302 (that is, all zeroes).
306 but this may be changed
307 from the command line.
311 .%T "Data Encryption Standard"
312 .%R "Federal Information Processing Standard #46"
313 .%Q "National Bureau of Standards, U.S. Department of Commerce, Washington DC"
317 .%T "DES Modes of Operation"
318 .%R "Federal Information Processing Standard #81"
319 .%Q "National Bureau of Standards, U.S. Department of Commerce, Washington DC"
323 .%A "Dorothy Denning"
324 .%B "Cryptography and Data Security"
325 .%Q "Addison-Wesley Publishing Co., Reading, MA"
330 .%T "Implementation Notes on bdes(1)"
331 .%R "Technical Report PCS-TR-91-158"
332 .%Q "Department of Mathematics and Computer Science, Dartmouth College, Hanover, NH 03755"
337 THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
338 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
339 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
340 ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
341 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
342 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
343 OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
344 HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
345 LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
346 OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
350 There is a controversy raging over whether the
354 The advent of special-purpose hardware
355 could reduce the cost of any of the
356 methods of attack named above
357 so that they are no longer
358 computationally infeasible.
360 As the key or key schedule
362 the encryption can be
363 compromised if memory is readable.
365 programs which display programs' arguments
366 may compromise the key and initialization vector,
367 if they are specified on the command line.
370 overwrites its arguments,
373 cannot currently be avoided.
375 Certain specific keys
377 because they introduce
378 potential weaknesses;
384 keys, are (in hex notation, where
386 is either 0 or 1, and
392 .Bl -column "0x0p0p0p0p0p0p0p0p" -offset indent
393 .It "0x0p0p0p0p0p0p0p0p 0x0p1P0p1P0p0P0p0P"
394 .It "0x0pep0pep0pfp0pfp 0x0pfP0pfP0pfP0pfP"
395 .It "0x1P0p1P0p0P0p0P0p 0x1P1P1P1P0P0P0P0P"
396 .It "0x1Pep1Pep0Pfp0Pfp 0x1PfP1PfP0PfP0PfP"
397 .It "0xep0pep0pfp0pfp0p 0xep1Pep1pfp0Pfp0P"
398 .It "0xepepepepepepepep 0xepfPepfPfpfPfpfP"
399 .It "0xfP0pfP0pfP0pfP0p 0xfP1PfP1PfP0PfP0P"
400 .It "0xfPepfPepfPepfPep 0xfPfPfPfPfPfPfPfP"
403 This is inherent in the
410 .%T "Cycle structure of the DES with weak and semi-weak keys"
411 .%B "Advances in Cryptology \- Crypto '86 Proceedings"
412 .%Q "Springer-Verlag New York"