Browse Source

also respect max value for hashingThreads

Signed-off-by: Remi Collet <remi@php.net>
pull/45027/head
Remi Collet 1 month ago
parent
commit
abef80a6fd
1 changed files with 8 additions and 4 deletions
  1. 8
    4
      lib/private/Security/Hasher.php

+ 8
- 4
lib/private/Security/Hasher.php View File

public function __construct( public function __construct(
private IConfig $config, private IConfig $config,
) { ) {
if (\defined('PASSWORD_ARGON2ID') || \defined('PASSWORD_ARGON2I')) {
// password_hash fails, when the minimum values are undershot.
// In this case, apply minimum.
$this->options['threads'] = max($this->config->getSystemValueInt('hashingThreads', PASSWORD_ARGON2_DEFAULT_THREADS), 1);
if (\defined('PASSWORD_ARGON2_PROVIDER')) {
// password_hash fails, when the minimum values are undershot or maximum overshot
// In this case, apply minimum/maximum.
if (PASSWORD_ARGON2_PROVIDER === 'sodium') {
$this->options['threads'] = 1;
} else { // standard (libargon) or openssl
$this->options['threads'] = max($this->config->getSystemValueInt('hashingThreads', PASSWORD_ARGON2_DEFAULT_THREADS), 1);
}
// The minimum memory cost is 8 KiB per thread. // The minimum memory cost is 8 KiB per thread.
$this->options['memory_cost'] = max($this->config->getSystemValueInt('hashingMemoryCost', PASSWORD_ARGON2_DEFAULT_MEMORY_COST), $this->options['threads'] * 8); $this->options['memory_cost'] = max($this->config->getSystemValueInt('hashingMemoryCost', PASSWORD_ARGON2_DEFAULT_MEMORY_COST), $this->options['threads'] * 8);
$this->options['time_cost'] = max($this->config->getSystemValueInt('hashingTimeCost', PASSWORD_ARGON2_DEFAULT_TIME_COST), 1); $this->options['time_cost'] = max($this->config->getSystemValueInt('hashingTimeCost', PASSWORD_ARGON2_DEFAULT_TIME_COST), 1);

Loading…
Cancel
Save