Fix compatibility with PBKDF2 hashes with iteration counts that are not zero-padded

This commit is contained in:
Kijin Sung 2021-03-14 00:26:15 +09:00
parent 715e8d781c
commit 72e7532764
2 changed files with 12 additions and 3 deletions

View file

@ -128,6 +128,13 @@ class PasswordTest extends \Codeception\TestCase\Test
$salt = 'rtmIxdEUoWUk';
$hash = 'sha512:0016384:rtmIxdEUoWUk:1hrwGP3ScWvxslnqNFqyhM6Ddn4iYrwf';
$this->assertEquals($hash, Rhymix\Framework\Password::pbkdf2($password, $salt, 'sha512', 16384, 24));
$hash = 'sha512:16384:rtmIxdEUoWUk:1hrwGP3ScWvxslnqNFqyhM6Ddn4iYrwf';
$this->assertEquals($hash, Rhymix\Framework\Password::pbkdf2($password, $salt, 'sha512', 16384, 24, 5));
$salt = 'KpnA8ZAxvig32n7p2PnEjx4NN7gPpUQm';
$hash = 'sha1:12000:KpnA8ZAxvig32n7p2PnEjx4NN7gPpUQm:TeILMSF8ao/NVJ4wdk7lXDKQre9TUCht';
$this->assertEquals($hash, Rhymix\Framework\Password::pbkdf2($password, $salt, 'sha1', 12000, 24, 5));
}
public function testCountEntropyBits()