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