bdes implements all DES modes of operation described in FIPS PUB 81, including alternative cipher feedback mode and both authentication modes.
bdes reads from the standard input and writes to the standard output. By default, the input is encrypted using cipher block chaining mode. Using the same key for encryption and decryption preserves plain text.
All modes but the electronic code book mode require an initialization vector; if none is supplied, the zero vector is used. If no
key is specified on the command line, the user is prompted for one (see
getpass(3) for more details).
The options are as follows:
-a
The key and initialization vector strings are to be taken as ASCII, suppressing the special interpretation given to leading “0X”, “0x”, “0B”, and “0b” characters. This flag applies to both the key and initialization vector.
-b
Use electronic code book mode. This is not recommended for messages longer than 8 bytes, as patterns in the input will show through to the output.
-F N
Use N-bit alternative cipher feedback mode. Currently N must be a multiple of 7 between 7 and 56 inclusive (this does not conform to the alternative CFB mode specification).
-f N
Use N-bit cipher feedback mode. Currently N must be a multiple of 8 between 8 and 64 inclusive (this does not conform to the standard CFB mode specification).
-k key
Use key as the cryptographic key.
-m N
Compute a message authentication code (MAC) of N bits on the input. The value of N must be between 1 and 64 inclusive; if N is not a multiple of 8, enough 0 bits will be added to pad the MAC length to the nearest multiple of 8. Only the MAC is output. MACs are only available in cipher block chaining mode or in cipher feedback mode.
-o N
Use N-bit output feedback mode. Currently N must be a multiple of 8 between 8 and 64 inclusive (this does not conform to the OFB mode specification).
-p
Disable the resetting of the parity bit. This flag forces the parity bit of the key to be used as typed, rather than making each character be of odd parity. It is used only if the key is given in ASCII.
-v vector
Set the initialization vector to vector; the vector is interpreted in the same way as the key. The vector is ignored in electronic codebook mode. For best security, a different initialization vector should be used for each file.
The key and initialization vector are taken as sequences of ASCII characters which are then mapped into their bit representations. If either begins with “0X” or “0x”, that one is taken as a sequence of hexadecimal digits indicating the bit pattern; if either begins with “0B” or “0b”, that one is taken as a sequence of binary digits indicating the bit pattern. In either case, only the leading 64 bits of the key or initialization vector are used, and if fewer than 64 bits are provided, enough 0 bits are appended to pad the key to 64 bits.
According to the DES standard, the low-order bit of each character in the key string is deleted. Since most ASCII representations set the high-order bit to 0, simply deleting the low-order bit effectively reduces the size of the key space from 2**56 to 2**48 keys. To prevent this, the high-order bit must be a function depending in part upon the low-order bit; so, the high-order bit is set to whatever value gives odd parity. This preserves the key space size. Note this resetting of the parity bit is
not done if the key is given in binary or hex, and can be disabled for ASCII keys as well.
The DES is considered a very strong cryptosystem hobbled by a short key, and other than table lookup attacks, key search attacks, and Hellman's time-memory tradeoff (all of which are very expensive and time-consuming), no practical cryptanalytic methods for breaking the DES are known in the open literature. As of this writing, the best known cryptanalytic method is linear cryptanalysis, which requires an average of 2**43 known plaintext-ciphertext pairs to succeed. Unfortunately for the DES, key search attacks (requiring only a single known plaintext-ciphertext pair and trying 2**55 keys on average) are becoming practical.
As with all cryptosystems, the choice of keys and key security remain the most vulnerable aspect of
bdes.