Added password change support for argon2i/argon2id, added matching config options and hash_X functions

This commit is contained in:
Christian Marg 2020-01-09 17:18:41 +01:00
parent 1f993c336b
commit 38a4a86e24
2 changed files with 40 additions and 1 deletions

View File

@ -596,6 +596,45 @@ class PassHash {
return ':B:'.$salt.':'.md5($salt.'-'.md5($clear));
}
/**
* Password hashing method 'argon2i'
*
* Uses php's own password_hash function to create argon2i password hash
* Default Cost and thread options are used for now.
*
* @link https://www.php.net/manual/de/function.password-hash.php
*
* @param string $clear The clear text to hash
* @param string $salt not used, defaults to null
* @return string Hashed password
*/
public function hash_argon2i($clear,$salt = null) {
if(!defined('PASSWORD_ARGON2I')) {
throw new \Exception('This PHP installation has no ARGON2I support');
}
return password_hash($clear,PASSWORD_ARGON2I);
}
/**
* Password hashing method 'argon2id'
*
* Uses php's own password_hash function to create argon2id password hash
* Default Cost and thread options are used for now.
*
* @link https://www.php.net/manual/de/function.password-hash.php
*
* @param string $clear The clear text to hash
* @param string $salt not used, defaults to null
* @return string Hashed password
*/
public function hash_argon2id($clear,$salt = null) {
if(!defined('PASSWORD_ARGON2ID')) {
throw new \Exception('This PHP installation has no ARGON2ID support');
}
return password_hash($clear,PASSWORD_ARGON2ID);
}
/**
* Wraps around native hash_hmac() or reimplents it
*

View File

@ -125,7 +125,7 @@ $meta['autopasswd'] = array('onoff');
$meta['authtype'] = array('authtype','_caution' => 'danger');
$meta['passcrypt'] = array('multichoice','_choices' => array(
'smd5','md5','apr1','sha1','ssha','lsmd5','crypt','mysql','my411','kmd5','pmd5','hmd5',
'mediawiki','bcrypt','djangomd5','djangosha1','djangopbkdf2_sha1','djangopbkdf2_sha256','sha512'
'mediawiki','bcrypt','djangomd5','djangosha1','djangopbkdf2_sha1','djangopbkdf2_sha256','sha512','argon2i','argon2id'
));
$meta['defaultgroup']= array('string');
$meta['superuser'] = array('string','_caution' => 'danger');