ddn.crypto.legacy.cipher.blowfish

Blowfish Block Cipher.

WARNING: DEPRECATED ALGORITHM

Blowfish is deprecated due to its 64-bit block size (vulnerable to birthday attacks). Use AES-256 for new encryption.

Standards

Schneier's Blowfish specification

Types 1

Blowfish block cipher implementation (Schneier's specification).

DEPRECATED: Do not use for new encryption.

Blowfish encrypts 64-bit blocks using a variable-length key from 32 to 448 bits (4 to 56 bytes). This implementation is provided for legacy compatibility only.

Example:

auto bf = new Blowfish(key);  // 4-56 byte key
ubyte[8] ciphertext;
bf.encrypt(plaintext, ciphertext);

Fields
private uint[18] _P
private uint[256][4] _S
Methods
size_t blockSize() @property const @safe pure nothrow @nogcReturns: The block size in bytes (always 8 for Blowfish).
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 void encryptBlock(ref uint left, ref uint right)Encrypts a block using the 16-round Feistel network.
private void decryptBlock(ref uint left, ref uint right)Decrypts a block using the 16-round Feistel network in reverse.
private uint f(uint x)The Blowfish F function.
private void initializeSubkeys(const(ubyte)[] key)Initialize the P-array and S-boxes using the key.
private uint bytesToUint(const(ubyte)[] bytes) static @safe pure nothrow @nogcConverts 4 bytes to a big-endian 32-bit unsigned integer.
private void uintToBytes(uint value, ubyte[] bytes) static @safe pure nothrow @nogcConverts a 32-bit unsigned integer to 4 big-endian bytes.
Constructors
this(const(ubyte)[] key)Constructs a Blowfish cipher with the given key.

Variables 2

private varuint[18] INIT_P
private varuint[256][4] INIT_S