ddn.crypto.legacy.cipher.des
DES Block Cipher (FIPS 46-3).
WARNING: DEPRECATED ALGORITHM
DES is cryptographically broken due to its 56-bit key size, which is vulnerable to brute-force attacks. It is provided only for backward compatibility with legacy systems that require it, primarily as a building block for Triple DES (3DES).
Do NOT use DES for new encryption. Use AES-256 instead.
Standards
FIPS 46-3 (withdrawn 2005), NIST SP 800-67
class DES
Types 1
classDES : BlockCipher
DES block cipher implementation (FIPS 46-3).
DEPRECATED: Do not use for new encryption.
DES encrypts 64-bit blocks using a 56-bit key (stored in 8 bytes with parity bits). This implementation is provided for legacy compatibility, primarily as a building block for Triple DES.
Example:
auto des = new DES(key); // 8-byte key
ubyte[8] ciphertext;
des.encrypt(plaintext, ciphertext);Fields
private ulong[16] _subkeysprivate ubyte[64] IP_TABLEInitial Permutation (IP)private ubyte[64] FP_TABLEFinal Permutation (IP^-1)private ubyte[48] E_TABLEExpansion permutation (E)private ubyte[32] P_TABLEP-box permutationprivate ubyte[56] PC1_TABLEPermuted Choice 1 (PC-1)private ubyte[48] PC2_TABLEPermuted Choice 2 (PC-2)private ubyte[16] ROTATION_SCHEDULEKey schedule rotation amountsprivate ubyte[64][8] S_BOXESS-boxes (8 boxes, each 4 rows × 16 columns)Methods
size_t blockSize() @property const @safe pure nothrow @nogcReturns: The block size in bytes (always 8 for DES).void encrypt(const(ubyte)[] input, ubyte[] output)Encrypts a single 8-byte block.void decrypt(const(ubyte)[] input, ubyte[] output)Decrypts a single 8-byte block.private
ulong processBlock(ulong block, bool decrypt)Process a 64-bit block through the DES Feistel network.private
ulong bytesToUlong(const(ubyte)[] bytes) staticConvert 8 bytes to a 64-bit unsigned integer (big-endian).private
void ulongToBytes(ulong value, ubyte[] bytes) staticConvert a 64-bit unsigned integer to 8 bytes (big-endian).Constructors
this(const(ubyte)[] key)Constructs a DES cipher with the given key.