diff --git a/src/Key/Derivation/SaltedS2k.php b/src/Key/Derivation/SaltedS2k.php index c3dbda4..16bfd38 100644 --- a/src/Key/Derivation/SaltedS2k.php +++ b/src/Key/Derivation/SaltedS2k.php @@ -24,18 +24,18 @@ class SaltedS2k 'md4' => MHASH_MD4, 'md5' => MHASH_MD5, 'sha1' => MHASH_SHA1, - 'sha224' => MHASH_SHA224, - 'sha256' => MHASH_SHA256, - 'sha382' => MHASH_SHA384, - 'sha512' => MHASH_SHA512, - 'ripemd128' => MHASH_RIPEMD128, - 'ripemd256' => MHASH_RIPEMD256, - 'ripemd320' => MHASH_RIPEMD320, - 'haval128,3' => MHASH_HAVAL128, - 'haval160,3' => MHASH_HAVAL160, - 'haval192,3' => MHASH_HAVAL192, - 'haval224,3' => MHASH_HAVAL224, - 'haval256,3' => MHASH_HAVAL256, + 'sha224' => MHASH_SHA224, + 'sha256' => MHASH_SHA256, + 'sha382' => MHASH_SHA384, + 'sha512' => MHASH_SHA512, + 'ripemd128' => MHASH_RIPEMD128, + 'ripemd256' => MHASH_RIPEMD256, + 'ripemd320' => MHASH_RIPEMD320, + 'haval128,3' => MHASH_HAVAL128, + 'haval160,3' => MHASH_HAVAL160, + 'haval192,3' => MHASH_HAVAL192, + 'haval224,3' => MHASH_HAVAL224, + 'haval256,3' => MHASH_HAVAL256, 'tiger128,3' => MHASH_TIGER128, 'riger160,3' => MHASH_TIGER160, 'whirpool' => MHASH_WHIRLPOOL, diff --git a/test/Key/Derivation/SaltedS2kTest.php b/test/Key/Derivation/SaltedS2kTest.php index 6706689..6298006 100644 --- a/test/Key/Derivation/SaltedS2kTest.php +++ b/test/Key/Derivation/SaltedS2kTest.php @@ -44,6 +44,10 @@ public function setUp() public function testCalc() { + if (!extension_loaded('mhash')) { + $this->markTestSkipped('The mhash extension is not available'); + return; + } $password = SaltedS2k::calc('sha256', 'test', $this->salt, 32); $this->assertEquals(32, strlen($password)); $this->assertEquals('qzQISUBUSP1iqYtwe/druhdOVqluc/Y2TetdSHSbaw8=', base64_encode($password)); @@ -51,6 +55,10 @@ public function testCalc() public function testCalcWithWrongHash() { + if (!extension_loaded('mhash')) { + $this->markTestSkipped('The mhash extension is not available'); + return; + } $this->setExpectedException('Zend\Crypt\Key\Derivation\Exception\InvalidArgumentException', 'The hash algorihtm wrong is not supported by Zend\Crypt\Key\Derivation\SaltedS2k'); $password = SaltedS2k::calc('wrong', 'test', $this->salt, 32); @@ -58,6 +66,10 @@ public function testCalcWithWrongHash() public function testCalcWithWrongSalt() { + if (!extension_loaded('mhash')) { + $this->markTestSkipped('The mhash extension is not available'); + return; + } $this->setExpectedException('Zend\Crypt\Key\Derivation\Exception\InvalidArgumentException', 'The salt size must be at least of 8 bytes'); $password = SaltedS2k::calc('sha256', 'test', substr($this->salt,-1), 32);