Implements the Twofish symmetric block cipher, designed by: Bruce Schneier, John Kelsey, Doug Whiting, David Wagner, Chris Hall, and Niels Ferguson.
This module provides two methods for constructiong a Twofish cipher from a 128, 192 or 256 bit key. The mkCipher function allows you to customize the number of rounds, while the mkStdCipher function gives you the standard 16 rounds.
- class (Bits a, Integral a) => Key a
- data TwofishCipher
- mkStdCipher :: Key a => a -> TwofishCipher
- mkCipher :: Key a => Int -> a -> TwofishCipher
- encrypt :: TwofishCipher -> Word128 -> Word128
- decrypt :: TwofishCipher -> Word128 -> Word128
- mkS :: Key a => a -> SVector
- mkfH :: Key a => a -> HFunc
- mkK :: Key a => a -> Int -> HFunc -> KIndexor
- mkG :: HFunc -> SVector -> GFunc
- encryptRounds :: GFunc -> KIndexor -> Int -> Block -> Block
- q0o :: Word8 -> Word8
- q1o :: Word8 -> Word8
A key is a vector of bytes of a certain size (given in bits). Twofish suppports key sizes of 128, 192, and 256 bits.
Constructs a standard Twofish cipher from the given key
Constructs an encryption/decryption cipher from the given key, and a given number of rounds (standard Twofish uses 16 rounds)
This function performs n rounds of the encryption algorithm
q0 byte vector using the algorithm specified in
the Twofish paper. This function isn't used by the cipher; instead
the pre-computed array is contained in the code.