Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions lib/private/Security/Hasher.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,14 @@
public function __construct(
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') {

Check failure on line 45 in lib/private/Security/Hasher.php

View workflow job for this annotation

GitHub Actions / static-code-analysis

TypeDoesNotContainType

lib/private/Security/Hasher.php:45:8: TypeDoesNotContainType: 'sodium' cannot be identical to 'standard' (see https://psalm.dev/056)

Check failure

Code scanning / Psalm

TypeDoesNotContainType

'sodium' cannot be identical to 'standard'
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

obviously a false positive

$ php -r 'var_dump(PASSWORD_ARGON2_PROVIDER);'
string(6) "sodium"

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add it to baseline or add a comment to suppress it?

$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.
$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);
Expand Down
Loading