diff --git a/lib/password.php b/lib/password.php index f07fafb..9bd56ea 100644 --- a/lib/password.php +++ b/lib/password.php @@ -12,7 +12,7 @@ if (!defined('PASSWORD_BCRYPT')) { /** * PHPUnit Process isolation caches constants, but not function declarations. - * So we need to check if the constants are defined separately from + * So we need to check if the constants are defined separately from * the functions to enable supporting process isolation in userland * code. */ @@ -236,7 +236,7 @@ function password_verify($password, $hash) { return false; } $ret = crypt($password, $hash); - if (!is_string($ret) || PasswordCompat\binary\_strlen($ret) != PasswordCompat\binary\_strlen($hash) || PasswordCompat\binary\_strlen($ret) <= 13) { + if (!is_string($ret) || PasswordCompat\binary\_strlen($ret) != PasswordCompat\binary\_strlen($hash) || PasswordCompat\binary\_strlen($ret) < 13) { return false; } diff --git a/test/Unit/PasswordVerifyTest.php b/test/Unit/PasswordVerifyTest.php index 9f67bb9..b6d4116 100644 --- a/test/Unit/PasswordVerifyTest.php +++ b/test/Unit/PasswordVerifyTest.php @@ -1,7 +1,7 @@ assertTrue(function_exists('password_verify')); } @@ -26,4 +26,8 @@ public function testInValidHash() { $this->assertFalse(password_verify('rasmuslerdorf', '$2a$07$usesomesillystringfore2uDLvp1Ii2e./U9C8sBjqp8I90dH6hj')); } -} \ No newline at end of file + public function testDesHashesAreAccepted() { + $this->assertTrue(password_verify('rasmuslerdorf', crypt('rasmuslerdorf', 'AB'))); + } + +}