From 35fd2888eae0b94434215572e7b2d42dabde2e45 Mon Sep 17 00:00:00 2001 From: terrafrost Date: Wed, 13 Aug 2014 09:56:49 -0500 Subject: [PATCH 01/11] Rijndael, AES: adjustments to what key sizes are and aren't allowed --- phpseclib/Crypt/AES.php | 52 ++++++++++++++++++++++++++++++++++++ phpseclib/Crypt/Rijndael.php | 6 +++++ 2 files changed, 58 insertions(+) diff --git a/phpseclib/Crypt/AES.php b/phpseclib/Crypt/AES.php index 14a0a627..900be03d 100644 --- a/phpseclib/Crypt/AES.php +++ b/phpseclib/Crypt/AES.php @@ -152,4 +152,56 @@ class Crypt_AES extends Crypt_Rijndael { return; } + + /** + * Sets the key length + * + * Valid key lengths are 128, 192, and 256. If the length is less than 128, it will be rounded up to + * 128. If the length is greater than 128 and invalid, it will be rounded down to the closest valid amount. + * + * @see Crypt_Rijndael:setKeyLength() + * @access public + * @param Integer $length + */ + function setKeyLength($length) + { + switch ($length) { + case 160: + $length = 192; + break; + case 224: + $length = 256; + } + parent::setKeyLength($length); + } + + /** + * Sets the key. + * + * Rijndael supports 5x different key lengths, AES only supports 3x different key lengths. + * + * @see Crypt_Rijndael:setKey() + * @see setKeyLength() + * @access public + * @param String $key + */ + function setKey($key) + { + parent::setKey($key); + + if (!$this->explicit_key_length) { + $length = strlen($key); + switch (true) { + case $length <= 16: + $this->key_size = 16; + break; + case $length <= 24: + $this->key_size = 24; + break; + default: + $this->key_size = 32; + } + $this->_setupEngine(); + } + } } diff --git a/phpseclib/Crypt/Rijndael.php b/phpseclib/Crypt/Rijndael.php index a43283f1..dcc0c19e 100644 --- a/phpseclib/Crypt/Rijndael.php +++ b/phpseclib/Crypt/Rijndael.php @@ -702,9 +702,15 @@ class Crypt_Rijndael extends Crypt_Base case $length <= 16: $this->key_size = 16; break; + case $length <= 20: + $this->key_size = 20; + break; case $length <= 24: $this->key_size = 24; break; + case $length <= 28: + $this->key_size = 28; + break; default: $this->key_size = 32; } From 8cf6af94dde5087c84def672a1975dc1df2e9abd Mon Sep 17 00:00:00 2001 From: terrafrost Date: Thu, 14 Aug 2014 10:03:01 -0500 Subject: [PATCH 02/11] AES: first attempt at unit tests for key padding --- tests/Unit/Crypt/AES/ContinuousBufferTest.php | 72 -------------- tests/Unit/Crypt/AES/InternalTest.php | 16 ++++ tests/Unit/Crypt/AES/TestCase.php | 94 ++++++++++++++++--- tests/Unit/Crypt/AES/mcryptTest.php | 16 ++++ 4 files changed, 115 insertions(+), 83 deletions(-) delete mode 100644 tests/Unit/Crypt/AES/ContinuousBufferTest.php create mode 100644 tests/Unit/Crypt/AES/InternalTest.php create mode 100644 tests/Unit/Crypt/AES/mcryptTest.php diff --git a/tests/Unit/Crypt/AES/ContinuousBufferTest.php b/tests/Unit/Crypt/AES/ContinuousBufferTest.php deleted file mode 100644 index e032dab6..00000000 --- a/tests/Unit/Crypt/AES/ContinuousBufferTest.php +++ /dev/null @@ -1,72 +0,0 @@ - - * @copyright MMXIII Andreas Fischer - * @license http://www.opensource.org/licenses/mit-license.html MIT License - */ - -class Unit_Crypt_AES_ContinuousBufferTest extends Unit_Crypt_AES_TestCase -{ - // String intented - protected $modes = array( - 'CRYPT_AES_MODE_CTR', - 'CRYPT_AES_MODE_OFB', - 'CRYPT_AES_MODE_CFB', - ); - - protected $plaintexts = array( - '', - '12345678901234567', // https://github.com/phpseclib/phpseclib/issues/39 - "\xDE\xAD\xBE\xAF", - ':-):-):-):-):-):-)', // https://github.com/phpseclib/phpseclib/pull/43 - ); - - protected $ivs = array( - '', - 'test123', - ); - - protected $keys = array( - '', - ':-8', // https://github.com/phpseclib/phpseclib/pull/43 - 'FOOBARZ', - ); - - /** - * Produces all combinations of test values. - * - * @return array - */ - public function allCombinations() - { - $result = array(); - - // @codingStandardsIgnoreStart - foreach ($this->modes as $mode) - foreach ($this->plaintexts as $plaintext) - foreach ($this->ivs as $iv) - foreach ($this->keys as $key) - $result[] = array($mode, $plaintext, $iv, $key); - // @codingStandardsIgnoreEnd - - return $result; - } - - /** - * @dataProvider allCombinations - */ - public function testEncryptDecrypt($mode, $plaintext, $iv, $key) - { - $aes = new Crypt_AES(constant($mode)); - $aes->enableContinuousBuffer(); - $aes->setIV($iv); - $aes->setKey($key); - - $actual = ''; - for ($i = 0, $strlen = strlen($plaintext); $i < $strlen; ++$i) { - $actual .= $aes->decrypt($aes->encrypt($plaintext[$i])); - } - - $this->assertEquals($plaintext, $actual); - } -} diff --git a/tests/Unit/Crypt/AES/InternalTest.php b/tests/Unit/Crypt/AES/InternalTest.php new file mode 100644 index 00000000..17293363 --- /dev/null +++ b/tests/Unit/Crypt/AES/InternalTest.php @@ -0,0 +1,16 @@ + + * @copyright MMXIII Andreas Fischer + * @license http://www.opensource.org/licenses/mit-license.html MIT License + */ + +class Unit_Crypt_AES_InternalTest extends Unit_Crypt_AES_TestCase +{ + static public function setUpBeforeClass() + { + parent::setUpBeforeClass(); + + self::ensureConstant('CRYPT_AES_MODE', CRYPT_AES_MODE_INTERNAL); + } +} \ No newline at end of file diff --git a/tests/Unit/Crypt/AES/TestCase.php b/tests/Unit/Crypt/AES/TestCase.php index c4bf57e6..a98d95d9 100644 --- a/tests/Unit/Crypt/AES/TestCase.php +++ b/tests/Unit/Crypt/AES/TestCase.php @@ -5,23 +5,95 @@ * @license http://www.opensource.org/licenses/mit-license.html MIT License */ -require_once 'Crypt/AES.php'; - -abstract class Unit_Crypt_AES_TestCase extends PhpseclibTestCase +abstract class Unit_Crypt_AES_Test extends PhpSeclibTestcase { static public function setUpBeforeClass() { - if (!defined('CRYPT_AES_MODE')) { - define('CRYPT_AES_MODE', CRYPT_AES_MODE_INTERNAL); - } + parent::setUpBeforeClass(); + + self::reRequireFile('Crypt/Rijndael.php'); + self::reRequireFile('Crypt/AES.php'); } - public function setUp() + /** + * Produces all combinations of test values. + * + * @return array + */ + public function continuousBufferCombos() { - if (defined('CRYPT_AES_MODE') && CRYPT_AES_MODE !== CRYPT_AES_MODE_INTERNAL) { - $this->markTestSkipped( - 'Skipping test because CRYPT_AES_MODE is not defined as CRYPT_AES_MODE_INTERNAL.' - ); + $modes = array( + 'CRYPT_AES_MODE_CTR', + 'CRYPT_AES_MODE_OFB', + 'CRYPT_AES_MODE_CFB', + ); + $plaintexts = array( + '', + '12345678901234567', // https://github.com/phpseclib/phpseclib/issues/39 + "\xDE\xAD\xBE\xAF", + ':-):-):-):-):-):-)', // https://github.com/phpseclib/phpseclib/pull/43 + ); + $ivs = array( + '', + 'test123', + ); + $keys = array( + '', + ':-8', // https://github.com/phpseclib/phpseclib/pull/43 + 'FOOBARZ', + ); + + $result = array(); + + // @codingStandardsIgnoreStart + foreach ($this->modes as $mode) + foreach ($this->plaintexts as $plaintext) + foreach ($this->ivs as $iv) + foreach ($this->keys as $key) + $result[] = array($mode, $plaintext, $iv, $key); + // @codingStandardsIgnoreEnd + + return $result; + } + + /** + * @dataProvider continuousBufferCombos + */ + public function testEncryptDecryptWithContinuousBuffer($mode, $plaintext, $iv, $key) + { + $aes = new Crypt_AES(constant($mode)); + $aes->enableContinuousBuffer(); + $aes->setIV($iv); + $aes->setKey($key); + + $actual = ''; + for ($i = 0, $strlen = strlen($plaintext); $i < $strlen; ++$i) { + $actual .= $aes->decrypt($aes->encrypt($plaintext[$i])); } + + $this->assertEquals($plaintext, $actual); + } + + public function testKeyPaddingRijndael() + { + // this test case is from the following URL: + // https://web.archive.org/web/20070209120224/http://fp.gladman.plus.com/cryptography_technology/rijndael/aesdvec.zip + + $aes = new Crypt_Rijndael(); + $aes->disablePadding(); + $aes->setKey(pack('H*', '2b7e151628aed2a6abf7158809cf4f3c762e7160')); // 160-bit key. Valid in Rijndael. + $ciphertext = $aes->encrypt(pack('H*', '3243f6a8885a308d313198a2e0370734')); + $this->assertEquals($ciphertext, pack('H*', '231d844639b31b412211cfe93712b880')); + } + + public function testKeyPaddingAES() + { + // same as the above - just with a different ciphertext + + $aes = new Crypt_AES(); + $aes->disablePadding(); + $aes->setKey(pack('H*', '2b7e151628aed2a6abf7158809cf4f3c762e7160')); // 160-bit key. AES should null pad to 192-bits + $ciphertext = $aes->encrypt(pack('H*', '3243f6a8885a308d313198a2e0370734')); + $this->assertEquals($ciphertext, pack('H*', 'c109292b173f841b88e0ee49f13db8c0')); } } diff --git a/tests/Unit/Crypt/AES/mcryptTest.php b/tests/Unit/Crypt/AES/mcryptTest.php new file mode 100644 index 00000000..f91e3bb5 --- /dev/null +++ b/tests/Unit/Crypt/AES/mcryptTest.php @@ -0,0 +1,16 @@ + + * @copyright MMXIII Andreas Fischer + * @license http://www.opensource.org/licenses/mit-license.html MIT License + */ + +class Unit_Crypt_AES_mcryptTest extends Unit_Crypt_AES_mcryptCase +{ + static public function setUpBeforeClass() + { + parent::setUpBeforeClass(); + + self::ensureConstant('CRYPT_AES_MODE', CRYPT_AES_MODE_MCRYPT); + } +} \ No newline at end of file From d88b7ed6dd47160d4627291042c61896a2a2cd55 Mon Sep 17 00:00:00 2001 From: terrafrost Date: Thu, 14 Aug 2014 10:06:25 -0500 Subject: [PATCH 03/11] AES: CS adjustments to unit tests --- tests/Unit/Crypt/AES/TestCase.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tests/Unit/Crypt/AES/TestCase.php b/tests/Unit/Crypt/AES/TestCase.php index a98d95d9..fa4ec265 100644 --- a/tests/Unit/Crypt/AES/TestCase.php +++ b/tests/Unit/Crypt/AES/TestCase.php @@ -74,6 +74,9 @@ abstract class Unit_Crypt_AES_Test extends PhpSeclibTestcase $this->assertEquals($plaintext, $actual); } + /** + * @group github451 + */ public function testKeyPaddingRijndael() { // this test case is from the following URL: @@ -86,6 +89,9 @@ abstract class Unit_Crypt_AES_Test extends PhpSeclibTestcase $this->assertEquals($ciphertext, pack('H*', '231d844639b31b412211cfe93712b880')); } + /** + * @group github451 + */ public function testKeyPaddingAES() { // same as the above - just with a different ciphertext @@ -96,4 +102,4 @@ abstract class Unit_Crypt_AES_Test extends PhpSeclibTestcase $ciphertext = $aes->encrypt(pack('H*', '3243f6a8885a308d313198a2e0370734')); $this->assertEquals($ciphertext, pack('H*', 'c109292b173f841b88e0ee49f13db8c0')); } -} +} \ No newline at end of file From 42e5c6845cf09e2861faa18c61e41c734e419b23 Mon Sep 17 00:00:00 2001 From: terrafrost Date: Thu, 14 Aug 2014 10:31:57 -0500 Subject: [PATCH 04/11] AES: add new lines to end of unit tests --- tests/Unit/Crypt/AES/InternalTest.php | 2 +- tests/Unit/Crypt/AES/TestCase.php | 2 +- tests/Unit/Crypt/AES/mcryptTest.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/Unit/Crypt/AES/InternalTest.php b/tests/Unit/Crypt/AES/InternalTest.php index 17293363..873f7ebf 100644 --- a/tests/Unit/Crypt/AES/InternalTest.php +++ b/tests/Unit/Crypt/AES/InternalTest.php @@ -13,4 +13,4 @@ class Unit_Crypt_AES_InternalTest extends Unit_Crypt_AES_TestCase self::ensureConstant('CRYPT_AES_MODE', CRYPT_AES_MODE_INTERNAL); } -} \ No newline at end of file +} diff --git a/tests/Unit/Crypt/AES/TestCase.php b/tests/Unit/Crypt/AES/TestCase.php index fa4ec265..3d41a012 100644 --- a/tests/Unit/Crypt/AES/TestCase.php +++ b/tests/Unit/Crypt/AES/TestCase.php @@ -102,4 +102,4 @@ abstract class Unit_Crypt_AES_Test extends PhpSeclibTestcase $ciphertext = $aes->encrypt(pack('H*', '3243f6a8885a308d313198a2e0370734')); $this->assertEquals($ciphertext, pack('H*', 'c109292b173f841b88e0ee49f13db8c0')); } -} \ No newline at end of file +} diff --git a/tests/Unit/Crypt/AES/mcryptTest.php b/tests/Unit/Crypt/AES/mcryptTest.php index f91e3bb5..ade89970 100644 --- a/tests/Unit/Crypt/AES/mcryptTest.php +++ b/tests/Unit/Crypt/AES/mcryptTest.php @@ -13,4 +13,4 @@ class Unit_Crypt_AES_mcryptTest extends Unit_Crypt_AES_mcryptCase self::ensureConstant('CRYPT_AES_MODE', CRYPT_AES_MODE_MCRYPT); } -} \ No newline at end of file +} From 3fdd5731d1f394b04915564b2076fa09d1b4092e Mon Sep 17 00:00:00 2001 From: terrafrost Date: Thu, 14 Aug 2014 10:37:10 -0500 Subject: [PATCH 05/11] AES: more unit test fixes --- tests/Unit/Crypt/AES/TestCase.php | 4 ++-- tests/Unit/Crypt/AES/mcryptTest.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/Unit/Crypt/AES/TestCase.php b/tests/Unit/Crypt/AES/TestCase.php index 3d41a012..f082c939 100644 --- a/tests/Unit/Crypt/AES/TestCase.php +++ b/tests/Unit/Crypt/AES/TestCase.php @@ -5,7 +5,7 @@ * @license http://www.opensource.org/licenses/mit-license.html MIT License */ -abstract class Unit_Crypt_AES_Test extends PhpSeclibTestcase +abstract class Unit_Crypt_AES_TestCase extends PhpSeclibTestcase { static public function setUpBeforeClass() { @@ -102,4 +102,4 @@ abstract class Unit_Crypt_AES_Test extends PhpSeclibTestcase $ciphertext = $aes->encrypt(pack('H*', '3243f6a8885a308d313198a2e0370734')); $this->assertEquals($ciphertext, pack('H*', 'c109292b173f841b88e0ee49f13db8c0')); } -} +} \ No newline at end of file diff --git a/tests/Unit/Crypt/AES/mcryptTest.php b/tests/Unit/Crypt/AES/mcryptTest.php index ade89970..f8542103 100644 --- a/tests/Unit/Crypt/AES/mcryptTest.php +++ b/tests/Unit/Crypt/AES/mcryptTest.php @@ -5,7 +5,7 @@ * @license http://www.opensource.org/licenses/mit-license.html MIT License */ -class Unit_Crypt_AES_mcryptTest extends Unit_Crypt_AES_mcryptCase +class Unit_Crypt_AES_mcryptTest extends Unit_Crypt_AES_TestCase { static public function setUpBeforeClass() { From 085ec03b53455362ed175772b10477b275f30761 Mon Sep 17 00:00:00 2001 From: terrafrost Date: Thu, 14 Aug 2014 10:47:26 -0500 Subject: [PATCH 06/11] AES: unit test updates --- tests/Unit/Crypt/AES/TestCase.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/Unit/Crypt/AES/TestCase.php b/tests/Unit/Crypt/AES/TestCase.php index f082c939..16a4089b 100644 --- a/tests/Unit/Crypt/AES/TestCase.php +++ b/tests/Unit/Crypt/AES/TestCase.php @@ -5,7 +5,9 @@ * @license http://www.opensource.org/licenses/mit-license.html MIT License */ -abstract class Unit_Crypt_AES_TestCase extends PhpSeclibTestcase +require_once 'Crypt/AES.php'; + +abstract class Unit_Crypt_AES_TestCase extends PhpseclibTestCase { static public function setUpBeforeClass() { From d01c1b1eb7567e015039ddc6c5455243e9cb38c6 Mon Sep 17 00:00:00 2001 From: terrafrost Date: Thu, 14 Aug 2014 10:59:37 -0500 Subject: [PATCH 07/11] AES: more unit test fixes --- tests/Unit/Crypt/AES/TestCase.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/Unit/Crypt/AES/TestCase.php b/tests/Unit/Crypt/AES/TestCase.php index 16a4089b..823acfa1 100644 --- a/tests/Unit/Crypt/AES/TestCase.php +++ b/tests/Unit/Crypt/AES/TestCase.php @@ -48,10 +48,10 @@ abstract class Unit_Crypt_AES_TestCase extends PhpseclibTestCase $result = array(); // @codingStandardsIgnoreStart - foreach ($this->modes as $mode) - foreach ($this->plaintexts as $plaintext) - foreach ($this->ivs as $iv) - foreach ($this->keys as $key) + foreach ($modes as $mode) + foreach ($plaintexts as $plaintext) + foreach ($ivs as $iv) + foreach ($keys as $key) $result[] = array($mode, $plaintext, $iv, $key); // @codingStandardsIgnoreEnd From 4d72d1b48dae4e14f72e690f71f3467d38eca998 Mon Sep 17 00:00:00 2001 From: terrafrost Date: Thu, 14 Aug 2014 11:09:54 -0500 Subject: [PATCH 08/11] AES: CS changes to unit tests --- tests/Unit/Crypt/AES/TestCase.php | 2 +- tests/Unit/Crypt/AES/mcryptTest.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/Unit/Crypt/AES/TestCase.php b/tests/Unit/Crypt/AES/TestCase.php index 823acfa1..91cb9792 100644 --- a/tests/Unit/Crypt/AES/TestCase.php +++ b/tests/Unit/Crypt/AES/TestCase.php @@ -104,4 +104,4 @@ abstract class Unit_Crypt_AES_TestCase extends PhpseclibTestCase $ciphertext = $aes->encrypt(pack('H*', '3243f6a8885a308d313198a2e0370734')); $this->assertEquals($ciphertext, pack('H*', 'c109292b173f841b88e0ee49f13db8c0')); } -} \ No newline at end of file +} diff --git a/tests/Unit/Crypt/AES/mcryptTest.php b/tests/Unit/Crypt/AES/mcryptTest.php index f8542103..443f168d 100644 --- a/tests/Unit/Crypt/AES/mcryptTest.php +++ b/tests/Unit/Crypt/AES/mcryptTest.php @@ -5,7 +5,7 @@ * @license http://www.opensource.org/licenses/mit-license.html MIT License */ -class Unit_Crypt_AES_mcryptTest extends Unit_Crypt_AES_TestCase +class Unit_Crypt_AES_McryptTest extends Unit_Crypt_AES_TestCase { static public function setUpBeforeClass() { From 7a1b1df600fb6e25fba8efc3cb03c9cf91faca12 Mon Sep 17 00:00:00 2001 From: terrafrost Date: Thu, 14 Aug 2014 11:27:27 -0500 Subject: [PATCH 09/11] AES: set CRYPT_RIJNDAEL_MODE as well in unit tests --- tests/Unit/Crypt/AES/InternalTest.php | 1 + tests/Unit/Crypt/AES/mcryptTest.php | 1 + 2 files changed, 2 insertions(+) diff --git a/tests/Unit/Crypt/AES/InternalTest.php b/tests/Unit/Crypt/AES/InternalTest.php index 873f7ebf..2a9652ca 100644 --- a/tests/Unit/Crypt/AES/InternalTest.php +++ b/tests/Unit/Crypt/AES/InternalTest.php @@ -12,5 +12,6 @@ class Unit_Crypt_AES_InternalTest extends Unit_Crypt_AES_TestCase parent::setUpBeforeClass(); self::ensureConstant('CRYPT_AES_MODE', CRYPT_AES_MODE_INTERNAL); + self::ensureConstant('CRYPT_RIJNDAEL_MODE', CRYPT_RIJNDAEL_MODE_INTERNAL); } } diff --git a/tests/Unit/Crypt/AES/mcryptTest.php b/tests/Unit/Crypt/AES/mcryptTest.php index 443f168d..f1df6227 100644 --- a/tests/Unit/Crypt/AES/mcryptTest.php +++ b/tests/Unit/Crypt/AES/mcryptTest.php @@ -12,5 +12,6 @@ class Unit_Crypt_AES_McryptTest extends Unit_Crypt_AES_TestCase parent::setUpBeforeClass(); self::ensureConstant('CRYPT_AES_MODE', CRYPT_AES_MODE_MCRYPT); + self::ensureConstant('CRYPT_RIJNDAEL_MODE', CRYPT_RIJNDAEL_MODE_MCRYPT); } } From aa0e7347ef212828bacb40cc38e87e3e2752623c Mon Sep 17 00:00:00 2001 From: terrafrost Date: Thu, 14 Aug 2014 23:09:17 -0500 Subject: [PATCH 10/11] AES: a few final changes --- phpseclib/Crypt/AES.php | 2 +- tests/Unit/Crypt/AES/{mcryptTest.php => McryptTest.php} | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename tests/Unit/Crypt/AES/{mcryptTest.php => McryptTest.php} (100%) diff --git a/phpseclib/Crypt/AES.php b/phpseclib/Crypt/AES.php index 900be03d..9085a8f1 100644 --- a/phpseclib/Crypt/AES.php +++ b/phpseclib/Crypt/AES.php @@ -178,7 +178,7 @@ class Crypt_AES extends Crypt_Rijndael /** * Sets the key. * - * Rijndael supports 5x different key lengths, AES only supports 3x different key lengths. + * Rijndael supports five different key lengths, AES only supports three. * * @see Crypt_Rijndael:setKey() * @see setKeyLength() diff --git a/tests/Unit/Crypt/AES/mcryptTest.php b/tests/Unit/Crypt/AES/McryptTest.php similarity index 100% rename from tests/Unit/Crypt/AES/mcryptTest.php rename to tests/Unit/Crypt/AES/McryptTest.php From 0d6fbb9e300d405eff11cee3a6edb8a18e94c91b Mon Sep 17 00:00:00 2001 From: terrafrost Date: Fri, 15 Aug 2014 09:23:55 -0500 Subject: [PATCH 11/11] AES: don't do mcrypt unit tests if mcrypt extension is not available --- tests/Unit/Crypt/AES/McryptTest.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/Unit/Crypt/AES/McryptTest.php b/tests/Unit/Crypt/AES/McryptTest.php index f1df6227..4327c7ea 100644 --- a/tests/Unit/Crypt/AES/McryptTest.php +++ b/tests/Unit/Crypt/AES/McryptTest.php @@ -9,6 +9,10 @@ class Unit_Crypt_AES_McryptTest extends Unit_Crypt_AES_TestCase { static public function setUpBeforeClass() { + if (!extension_loaded('mcrypt')) { + self::markTestSkipped('mcrypt extension is not available.'); + } + parent::setUpBeforeClass(); self::ensureConstant('CRYPT_AES_MODE', CRYPT_AES_MODE_MCRYPT);