The MCRYPT_TWOFISH constant when defined by mcrypt version 2.4.x and later is the 256 bit version of Twofish; it uses a 1-32 byte key, a 16 byte IV, and outputs 16 byte blocks in CBC mode.
Here is a list of ciphers which are currently supported by the mcrypt extension. For a complete list of supported ciphers, see the defines at the end of mcrypt.h. The general rule with the mcrypt-2.2.x API is that you can access the cipher from PHP with MCRYPT_ciphername. With the libmcrypt-2.4.x and libmcrypt-2.5.x API these constants also work, but it is possible to specify the name of the cipher as a string with a call to mcrypt_module_open().
You must (in CFB
and OFB
mode)
or can (in CBC
mode) supply an
initialization vector (IV) to the respective cipher function. The
IV must be unique and must be the same when
decrypting/encrypting. With data which is stored encrypted, you
can take the output of a function of the index under which the
data is stored (e.g. the MD5 key of the filename).
Alternatively, you can transmit the IV together with the encrypted
data (see chapter 9.3 of Applied Cryptography by Schneier (ISBN 0-471-11709-9) for a
discussion of this topic).
The MCRYPT_TWOFISH constant when defined by mcrypt version 2.4.x and later is the 256 bit version of Twofish; it uses a 1-32 byte key, a 16 byte IV, and outputs 16 byte blocks in CBC mode.
These constants can in fact be used as input to the function mcrypt_module_open() because mcrypt.php contains defines that map these constants to the appropriate string values obtained from mcrypt_list_algorithms().
Note, these are not the names you use in the function mcrypt_module_open to specify the algorithm.
Use mcrypt_list_algorithms to get the right names to stick in there
The latest patents for the IDEA algorithm have expired in 2012 and the cipher is now patent-free and free to use.
Interpretability:
mcrypt does not support PKCS#7 padding, it uses non-standard and insecure null padding. This means that for interoperability with most other implementations PKCS#7 padding will have to be added prior to encryption and/or removed after decryption. This is a major source of interoperability issues.
When interoperating with AES the mcrypt algorithm must be specified as MCRYPT_RIJNDAEL_128 since AES only supports a block size of 128-bits. There is often confusion that this specifies the key size which it does not.