ddn.crypto.legacy.cipher.des3
Triple DES (3DES / TDEA) Block Cipher (NIST SP 800-67).
WARNING: DEPRECATED ALGORITHM
Triple DES is deprecated due to its 64-bit block size (vulnerable to birthday attacks) and slow performance. Use AES-256 for new encryption.
Triple DES applies the DES cipher three times with three independent keys using the Encrypt-Decrypt-Encrypt (EDE) scheme, providing an effective key strength of 168 bits (three 56-bit DES keys).
Operation:
- Encryption: C = E_K1(D_K2(E_K3(P)))
- Decryption: P = D_K3(E_K2(D_K1(C)))
Where K1, K2, K3 are the three 8-byte DES keys extracted from the 24-byte Triple DES key.
Standards
Copyright
License
Types 1
Triple DES (3DES / TDEA) block cipher implementation (NIST SP 800-67).
DEPRECATED: Do not use for new encryption. Use AES-256 instead.
Triple DES encrypts 64-bit blocks using three independent 56-bit DES keys (stored in 24 bytes with parity bits). The EDE (Encrypt-Decrypt-Encrypt) scheme provides backward compatibility with single DES when K1 = K2 = K3.
Example:
// 24-byte key (three 8-byte DES keys)
auto key = cast(ubyte[24]) x"0123456789ABCDEF" ~
x"23456789ABCDEF01" ~
x"456789ABCDEF0123";
auto des3 = new DES3(key);
ubyte[8] ciphertext;
des3.encrypt(plaintext, ciphertext);size_t blockSize() @property const @safe pure nothrow @nogcReturns: The block size in bytes (always 8 for Triple DES).void encrypt(const(ubyte)[] input, ubyte[] output)Encrypts a single 8-byte block using EDE mode.void decrypt(const(ubyte)[] input, ubyte[] output)Decrypts a single 8-byte block using EDE mode.this(const(ubyte)[] key)Constructs a Triple DES cipher with the given key.