@@ -63,16 +63,11 @@ public function __construct(IConfig $config) {
6363
6464 if (\defined ('PASSWORD_ARGON2I ' )) {
6565 // password_hash fails, when the minimum values are undershot.
66- // In this case, ignore and revert to default
67- if ($ this ->config ->getSystemValueInt ('hashingMemoryCost ' , PASSWORD_ARGON2_DEFAULT_MEMORY_COST ) >= 8 ) {
68- $ this ->options ['memory_cost ' ] = $ this ->config ->getSystemValueInt ('hashingMemoryCost ' , PASSWORD_ARGON2_DEFAULT_MEMORY_COST );
69- }
70- if ($ this ->config ->getSystemValueInt ('hashingTimeCost ' , PASSWORD_ARGON2_DEFAULT_MEMORY_COST ) >= 1 ) {
71- $ this ->options ['time_cost ' ] = $ this ->config ->getSystemValueInt ('hashingTimeCost ' , PASSWORD_ARGON2_DEFAULT_TIME_COST );
72- }
73- if ($ this ->config ->getSystemValueInt ('hashingThreads ' , PASSWORD_ARGON2_DEFAULT_MEMORY_COST ) >= 1 ) {
74- $ this ->options ['threads ' ] = $ this ->config ->getSystemValueInt ('hashingThreads ' , PASSWORD_ARGON2_DEFAULT_THREADS );
75- }
66+ // In this case, apply minimum.
67+ $ this ->options ['threads ' ] = max ($ this ->config ->getSystemValueInt ('hashingThreads ' , PASSWORD_ARGON2_DEFAULT_THREADS ), 1 );
68+ // The minimum memory cost is 8 KiB per thread.
69+ $ this ->options ['memory_cost ' ] = max ($ this ->config ->getSystemValueInt ('hashingMemoryCost ' , PASSWORD_ARGON2_DEFAULT_MEMORY_COST ), $ this ->options ['threads ' ] * 8 );
70+ $ this ->options ['time_cost ' ] = max ($ this ->config ->getSystemValueInt ('hashingTimeCost ' , PASSWORD_ARGON2_DEFAULT_TIME_COST ), 1 );
7671 }
7772
7873 $ hashingCost = $ this ->config ->getSystemValue ('hashingCost ' , null );
0 commit comments