File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -39,10 +39,15 @@ class Hasher implements IHasher {
3939 public function __construct (
4040 private IConfig $ config ,
4141 ) {
42- if (\defined ('PASSWORD_ARGON2ID ' ) || \defined ('PASSWORD_ARGON2I ' )) {
43- // password_hash fails, when the minimum values are undershot.
44- // In this case, apply minimum.
45- $ this ->options ['threads ' ] = max ($ this ->config ->getSystemValueInt ('hashingThreads ' , PASSWORD_ARGON2_DEFAULT_THREADS ), 1 );
42+ if (\defined ('PASSWORD_ARGON2_PROVIDER ' )) {
43+ // password_hash fails, when the minimum values are undershot or maximum overshot. So apply minimum/maximum.
44+ /** @psalm-suppress TypeDoesNotContainType - The constant defaults to "standard" but when sodium is installed it will be "sodium" */
45+ if (PASSWORD_ARGON2_PROVIDER === 'sodium ' ) {
46+ $ this ->options ['threads ' ] = 1 ;
47+ } else {
48+ // standard (libargon) or openssl
49+ $ this ->options ['threads ' ] = max ($ this ->config ->getSystemValueInt ('hashingThreads ' , PASSWORD_ARGON2_DEFAULT_THREADS ), 1 );
50+ }
4651 // The minimum memory cost is 8 KiB per thread.
4752 $ this ->options ['memory_cost ' ] = max ($ this ->config ->getSystemValueInt ('hashingMemoryCost ' , PASSWORD_ARGON2_DEFAULT_MEMORY_COST ), $ this ->options ['threads ' ] * 8 );
4853 $ this ->options ['time_cost ' ] = max ($ this ->config ->getSystemValueInt ('hashingTimeCost ' , PASSWORD_ARGON2_DEFAULT_TIME_COST ), 1 );
You can’t perform that action at this time.
0 commit comments