mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-28 14:18:52 +00:00
[ticket/16266] Optimize code
PHPBB3-16266
This commit is contained in:
parent
186a3d40c6
commit
5dfba1b064
2 changed files with 14 additions and 16 deletions
|
@ -37,21 +37,12 @@ class argon2i extends base_native
|
||||||
{
|
{
|
||||||
parent::__construct($config, $helper);
|
parent::__construct($config, $helper);
|
||||||
|
|
||||||
if ($this->is_sodium())
|
|
||||||
{
|
|
||||||
// For Sodium implementation, set special cost factor values (since PHP 7.4)
|
// For Sodium implementation, set special cost factor values (since PHP 7.4)
|
||||||
// See https://wiki.php.net/rfc/sodium.argon.hash and PHPBB3-16266
|
// See https://wiki.php.net/rfc/sodium.argon.hash and PHPBB3-16266
|
||||||
$this->memory_cost = max($memory_cost, 256*1024);
|
|
||||||
$this->threads = 1;
|
|
||||||
$this->time_cost = max($time_cost, 3);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Otherwise don't allow cost factors to be below default settings
|
// Otherwise don't allow cost factors to be below default settings
|
||||||
$this->memory_cost = max($memory_cost, 1024);
|
$this->memory_cost = ($this->is_sodium()) ? max($memory_cost, 256*1024) : max($memory_cost, 1024);
|
||||||
$this->threads = max($threads, 2);
|
$this->threads = ($this->is_sodium()) ? 1 : max($threads, 2);
|
||||||
$this->time_cost = max($time_cost, 2);
|
$this->time_cost = ($this->is_sodium()) ? max($time_cost, 3) : max($time_cost, 2);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -66,7 +66,14 @@ abstract class base_native extends base
|
||||||
*/
|
*/
|
||||||
public function is_sodium()
|
public function is_sodium()
|
||||||
{
|
{
|
||||||
return defined('PASSWORD_ARGON2_PROVIDER') && PASSWORD_ARGON2_PROVIDER == 'sodium';
|
static $is_sodium;
|
||||||
|
|
||||||
|
if (empty($is_sodium))
|
||||||
|
{
|
||||||
|
$is_sodium = defined('PASSWORD_ARGON2_PROVIDER') && PASSWORD_ARGON2_PROVIDER == 'sodium';
|
||||||
|
}
|
||||||
|
|
||||||
|
return $is_sodium;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Add table
Reference in a new issue