Skip to content
Snippets Groups Projects
Commit 6f9868d5 authored by Phy's avatar Phy
Browse files

fix sha512 failing test, and add test to crypt-style sha512 hash

parent d4424692
No related branches found
No related tags found
No related merge requests found
......@@ -110,4 +110,15 @@ class auth_password_test extends DokuWikiTest {
$this->assertTrue($except);
}
/**
* issue #2629, support PHP's crypt() format (with rounds=0 parameter)
*/
function test_verifyPassword_sha512_crypt() {
if(defined('CRYPT_SHA512') && CRYPT_SHA512 == 1) {
$this->assertTrue(auth_verifyPassword('Qwerty123', '$6$rounds=3000$9in6UciYPFG6ydsJ$YBjypQ7XoRqvJoX1a2.spSysSVHcdreVXi1Xh5SyOxo2yNSxDjlUCun2YXrwk9.YP6vmRvCWrhp0fbPgSOT7..'));
} else {
$this->markTestSkipped('SHA512 not available in this PHP environment');
}
}
}
......@@ -562,7 +562,7 @@ class PassHash {
throw new Exception('This PHP installation has no SHA512 support');
}
$this->init_salt($salt, 8, false);
if(is_null($magic)) {
if(empty($magic)) {
return crypt($clear, '$6$'.$salt.'$');
}else{
return crypt($clear, '$6$'.$magic.'$'.$salt.'$');
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment