mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-08 04:18:52 +00:00
Merge branch '3.3.x'
This commit is contained in:
commit
d6fd2b4e2f
2 changed files with 80 additions and 33 deletions
|
@ -13,10 +13,8 @@
|
||||||
|
|
||||||
namespace phpbb\passwords\driver;
|
namespace phpbb\passwords\driver;
|
||||||
|
|
||||||
class argon2i extends base
|
class argon2i extends base_native
|
||||||
{
|
{
|
||||||
const PREFIX = '$argon2i$';
|
|
||||||
|
|
||||||
/** @var int Maximum memory (in bytes) that may be used to compute the Argon2 hash */
|
/** @var int Maximum memory (in bytes) that may be used to compute the Argon2 hash */
|
||||||
protected $memory_cost;
|
protected $memory_cost;
|
||||||
|
|
||||||
|
@ -48,15 +46,13 @@ class argon2i extends base
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function check($password, $hash, $user_row = [])
|
public function get_algo_name()
|
||||||
{
|
{
|
||||||
return password_verify($password, $hash);
|
return 'PASSWORD_ARGON2I';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the options set for this driver instance
|
* {@inheritdoc}
|
||||||
*
|
|
||||||
* @return array
|
|
||||||
*/
|
*/
|
||||||
public function get_options()
|
public function get_options()
|
||||||
{
|
{
|
||||||
|
@ -72,30 +68,6 @@ class argon2i extends base
|
||||||
*/
|
*/
|
||||||
public function get_prefix()
|
public function get_prefix()
|
||||||
{
|
{
|
||||||
return self::PREFIX;
|
return '$argon2i$';
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
public function hash($password)
|
|
||||||
{
|
|
||||||
return password_hash($password, PASSWORD_ARGON2I, $this->get_options());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
public function is_supported()
|
|
||||||
{
|
|
||||||
return defined('PASSWORD_ARGON2I') && function_exists('password_hash') && function_exists('password_needs_rehash') && function_exists('password_verify');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
public function needs_rehash($hash)
|
|
||||||
{
|
|
||||||
return password_needs_rehash($hash, PASSWORD_ARGON2I, $this->get_options());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
75
phpBB/phpbb/passwords/driver/base_native.php
Normal file
75
phpBB/phpbb/passwords/driver/base_native.php
Normal file
|
@ -0,0 +1,75 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* This file is part of the phpBB Forum Software package.
|
||||||
|
*
|
||||||
|
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
||||||
|
* @license GNU General Public License, version 2 (GPL-2.0)
|
||||||
|
*
|
||||||
|
* For full copyright and license information, please see
|
||||||
|
* the docs/CREDITS.txt file.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace phpbb\passwords\driver;
|
||||||
|
|
||||||
|
abstract class base_native extends base
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Return the constant name for this driver's algorithm
|
||||||
|
*
|
||||||
|
* @link https://www.php.net/manual/en/password.constants.php
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
abstract public function get_algo_name();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the options set for this driver instance
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
abstract public function get_options();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function check($password, $hash, $user_row = [])
|
||||||
|
{
|
||||||
|
return password_verify($password, $hash);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the value for this driver's algorithm
|
||||||
|
*
|
||||||
|
* @return integer
|
||||||
|
*/
|
||||||
|
public function get_algo_value()
|
||||||
|
{
|
||||||
|
return constant($this->get_algo_name());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function hash($password)
|
||||||
|
{
|
||||||
|
return password_hash($password, $this->get_algo_value(), $this->get_options());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function is_supported()
|
||||||
|
{
|
||||||
|
return defined($this->get_algo_name()) && function_exists('password_hash') && function_exists('password_needs_rehash') && function_exists('password_verify');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function needs_rehash($hash)
|
||||||
|
{
|
||||||
|
return password_needs_rehash($hash, $this->get_algo_value(), $this->get_options());
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue