Below is a comparison of PHP’s mcrypt ciphers, block modes, block sizes and IVs. Note that some ciphers support multiple key sizes. Also note that some ciphers are made for encrypting streams of data, unchained and therefore are not supported by the other modes — and vice versa.
Cipher Name | Block Mode | Block Size | IV Size | Default Key Size | All Key Size(s) |
---|---|---|---|---|---|
CAST-128 | CBC | 8 | 8 | 16 | 16 |
CAST-128 | ECB | 8 | 8 | 16 | 16 |
CAST-128 | OFB | 8 | 8 | 16 | 16 |
CAST-128 | NOFB | 8 | 8 | 16 | 16 |
CAST-128 | CFB | 8 | 8 | 16 | 16 |
CAST-128 | NCFB | 8 | 8 | 16 | 16 |
CAST-128 | CTR | 8 | 8 | 16 | 16 |
CAST-128 not supported in STREAM mode | |||||
GOST | CBC | 8 | 8 | 32 | 32 |
GOST | ECB | 8 | 8 | 32 | 32 |
GOST | OFB | 8 | 8 | 32 | 32 |
GOST | NOFB | 8 | 8 | 32 | 32 |
GOST | CFB | 8 | 8 | 32 | 32 |
GOST | NCFB | 8 | 8 | 32 | 32 |
GOST | CTR | 8 | 8 | 32 | 32 |
GOST not supported in STREAM mode | |||||
Rijndael-128 | CBC | 16 | 16 | 32 | 16 24 32 |
Rijndael-128 | ECB | 16 | 16 | 32 | 16 24 32 |
Rijndael-128 | OFB | 16 | 16 | 32 | 16 24 32 |
Rijndael-128 | NOFB | 16 | 16 | 32 | 16 24 32 |
Rijndael-128 | CFB | 16 | 16 | 32 | 16 24 32 |
Rijndael-128 | NCFB | 16 | 16 | 32 | 16 24 32 |
Rijndael-128 | CTR | 16 | 16 | 32 | 16 24 32 |
Rijndael-128 not supported in STREAM mode | |||||
Twofish | CBC | 16 | 16 | 32 | 16 24 32 |
Twofish | ECB | 16 | 16 | 32 | 16 24 32 |
Twofish | OFB | 16 | 16 | 32 | 16 24 32 |
Twofish | NOFB | 16 | 16 | 32 | 16 24 32 |
Twofish | CFB | 16 | 16 | 32 | 16 24 32 |
Twofish | NCFB | 16 | 16 | 32 | 16 24 32 |
Twofish | CTR | 16 | 16 | 32 | 16 24 32 |
Twofish not supported in STREAM mode | |||||
RC4 not supported in CBC mode | |||||
RC4 not supported in ECB mode | |||||
RC4 not supported in OFB mode | |||||
RC4 not supported in NOFB mode | |||||
RC4 not supported in CFB mode | |||||
RC4 not supported in NCFB mode | |||||
RC4 not supported in CTR mode | |||||
RC4 | STREAM | 1 | 0 | 256 | |
CAST-256 | CBC | 16 | 16 | 32 | 16 24 32 |
CAST-256 | ECB | 16 | 16 | 32 | 16 24 32 |
CAST-256 | OFB | 16 | 16 | 32 | 16 24 32 |
CAST-256 | NOFB | 16 | 16 | 32 | 16 24 32 |
CAST-256 | CFB | 16 | 16 | 32 | 16 24 32 |
CAST-256 | NCFB | 16 | 16 | 32 | 16 24 32 |
CAST-256 | CTR | 16 | 16 | 32 | 16 24 32 |
CAST-256 not supported in STREAM mode | |||||
LOKI97 | CBC | 16 | 16 | 32 | 16 24 32 |
LOKI97 | ECB | 16 | 16 | 32 | 16 24 32 |
LOKI97 | OFB | 16 | 16 | 32 | 16 24 32 |
LOKI97 | NOFB | 16 | 16 | 32 | 16 24 32 |
LOKI97 | CFB | 16 | 16 | 32 | 16 24 32 |
LOKI97 | NCFB | 16 | 16 | 32 | 16 24 32 |
LOKI97 | CTR | 16 | 16 | 32 | 16 24 32 |
LOKI97 not supported in STREAM mode | |||||
Rijndael-192 | CBC | 24 | 24 | 32 | 16 24 32 |
Rijndael-192 | ECB | 24 | 24 | 32 | 16 24 32 |
Rijndael-192 | OFB | 24 | 24 | 32 | 16 24 32 |
Rijndael-192 | NOFB | 24 | 24 | 32 | 16 24 32 |
Rijndael-192 | CFB | 24 | 24 | 32 | 16 24 32 |
Rijndael-192 | NCFB | 24 | 24 | 32 | 16 24 32 |
Rijndael-192 | CTR | 24 | 24 | 32 | 16 24 32 |
Rijndael-192 not supported in STREAM mode | |||||
Safer+ | CBC | 16 | 16 | 32 | 16 24 32 |
Safer+ | ECB | 16 | 16 | 32 | 16 24 32 |
Safer+ | OFB | 16 | 16 | 32 | 16 24 32 |
Safer+ | NOFB | 16 | 16 | 32 | 16 24 32 |
Safer+ | CFB | 16 | 16 | 32 | 16 24 32 |
Safer+ | NCFB | 16 | 16 | 32 | 16 24 32 |
Safer+ | CTR | 16 | 16 | 32 | 16 24 32 |
Safer+ not supported in STREAM mode | |||||
WAKE not supported in CBC mode | |||||
WAKE not supported in ECB mode | |||||
WAKE not supported in OFB mode | |||||
WAKE not supported in NOFB mode | |||||
WAKE not supported in CFB mode | |||||
WAKE not supported in NCFB mode | |||||
WAKE not supported in CTR mode | |||||
WAKE | STREAM | 1 | 0 | 32 | 32 |
Blowfish | CBC | 8 | 8 | 56 | |
Blowfish | ECB | 8 | 8 | 56 | |
Blowfish | OFB | 8 | 8 | 56 | |
Blowfish | NOFB | 8 | 8 | 56 | |
Blowfish | CFB | 8 | 8 | 56 | |
Blowfish | NCFB | 8 | 8 | 56 | |
Blowfish | CTR | 8 | 8 | 56 | |
Blowfish not supported in STREAM mode | |||||
DES | CBC | 8 | 8 | 8 | 8 |
DES | ECB | 8 | 8 | 8 | 8 |
DES | OFB | 8 | 8 | 8 | 8 |
DES | NOFB | 8 | 8 | 8 | 8 |
DES | CFB | 8 | 8 | 8 | 8 |
DES | NCFB | 8 | 8 | 8 | 8 |
DES | CTR | 8 | 8 | 8 | 8 |
DES not supported in STREAM mode | |||||
Rijndael-256 | CBC | 32 | 32 | 32 | 16 24 32 |
Rijndael-256 | ECB | 32 | 32 | 32 | 16 24 32 |
Rijndael-256 | OFB | 32 | 32 | 32 | 16 24 32 |
Rijndael-256 | NOFB | 32 | 32 | 32 | 16 24 32 |
Rijndael-256 | CFB | 32 | 32 | 32 | 16 24 32 |
Rijndael-256 | NCFB | 32 | 32 | 32 | 16 24 32 |
Rijndael-256 | CTR | 32 | 32 | 32 | 16 24 32 |
Rijndael-256 not supported in STREAM mode | |||||
Serpent | CBC | 16 | 16 | 32 | 16 24 32 |
Serpent | ECB | 16 | 16 | 32 | 16 24 32 |
Serpent | OFB | 16 | 16 | 32 | 16 24 32 |
Serpent | NOFB | 16 | 16 | 32 | 16 24 32 |
Serpent | CFB | 16 | 16 | 32 | 16 24 32 |
Serpent | NCFB | 16 | 16 | 32 | 16 24 32 |
Serpent | CTR | 16 | 16 | 32 | 16 24 32 |
Serpent not supported in STREAM mode | |||||
xTEA | CBC | 8 | 8 | 16 | 16 |
xTEA | ECB | 8 | 8 | 16 | 16 |
xTEA | OFB | 8 | 8 | 16 | 16 |
xTEA | NOFB | 8 | 8 | 16 | 16 |
xTEA | CFB | 8 | 8 | 16 | 16 |
xTEA | NCFB | 8 | 8 | 16 | 16 |
xTEA | CTR | 8 | 8 | 16 | 16 |
xTEA not supported in STREAM mode | |||||
Blowfish | CBC | 8 | 8 | 56 | |
Blowfish | ECB | 8 | 8 | 56 | |
Blowfish | OFB | 8 | 8 | 56 | |
Blowfish | NOFB | 8 | 8 | 56 | |
Blowfish | CFB | 8 | 8 | 56 | |
Blowfish | NCFB | 8 | 8 | 56 | |
Blowfish | CTR | 8 | 8 | 56 | |
Blowfish not supported in STREAM mode | |||||
enigma not supported in CBC mode | |||||
enigma not supported in ECB mode | |||||
enigma not supported in OFB mode | |||||
enigma not supported in NOFB mode | |||||
enigma not supported in CFB mode | |||||
enigma not supported in NCFB mode | |||||
enigma not supported in CTR mode | |||||
enigma | STREAM | 1 | 0 | 13 | |
RC2 | CBC | 8 | 8 | 128 | |
RC2 | ECB | 8 | 8 | 128 | |
RC2 | OFB | 8 | 8 | 128 | |
RC2 | NOFB | 8 | 8 | 128 | |
RC2 | CFB | 8 | 8 | 128 | |
RC2 | NCFB | 8 | 8 | 128 | |
RC2 | CTR | 8 | 8 | 128 | |
RC2 not supported in STREAM mode | |||||
3DES | CBC | 8 | 8 | 24 | 24 |
3DES | ECB | 8 | 8 | 24 | 24 |
3DES | OFB | 8 | 8 | 24 | 24 |
3DES | NOFB | 8 | 8 | 24 | 24 |
3DES | CFB | 8 | 8 | 24 | 24 |
3DES | NCFB | 8 | 8 | 24 | 24 |
3DES | CTR | 8 | 8 | 24 | 24 |
3DES not supported in STREAM mode |
If you wish to run this code yourself…
<?php
$ciphers = mcrypt_list_algorithms();
$blockModes = array('cbc',
'ecb',
'ofb',
'nofb',
'cfb',
'ncfb',
'ctr',
'stream');
?>
<table>
<thead>
<tr>
<th>Cipher Name</th>
<th>Block Mode</th>
<th>Block Size</th>
<th>IV Size</th>
<th>Default Key Size</th>
<th>All Key Size(s)</th>
</tr>
</thead>
<tbody>
<?php
foreach($ciphers as $cipher) {
foreach($blockModes as $blockMode) {
if(@mcrypt_get_block_size($cipher, $blockMode) !== false) {
?>
<tr>
<td><?= mcrypt_get_cipher_name($cipher) ?></td>
<td><?= strtoupper($blockMode) ?></td>
<td><?= mcrypt_get_block_size($cipher, $blockMode) ?></td>
<td><?= mcrypt_get_iv_size($cipher, $blockMode) ?></td>
<td><?= mcrypt_get_key_size($cipher, $blockMode) ?></td>
<td><?php
foreach(mcrypt_module_get_supported_key_sizes($cipher) as $keySize) {
echo $keySize . ' ';
}
?></td>
</tr>
<?php
}
else {
?>
<tr>
<td colspan="6"><?= mcrypt_get_cipher_name($cipher) . ' not supported in ' . strtoupper($blockMode) . ' mode' ?></td>
</tr>
<?php
}
}
}
?>
</tbody>
</table>
Tim Bennett is a freelance web designer from Leeds. He has a First Class Honours degree in Computing from
Leeds Metropolitan University and currently runs his own one-man web design company, Texelate.