@@ -2299,6 +2299,20 @@ function pla_password_hash($password_clear,$enc_type) {
22992299
23002300 break ;
23012301
2302+ case 'argon2i ' :
2303+ if (! defined ('PASSWORD_ARGON2I ' ))
2304+ error (_ ('Your system does not support argon2i encryption (PHP 7.2 or upper is required). ' ),'error ' ,'index.php ' );
2305+ $ new_value = sprintf ('{ARGON2}%s ' ,password_hash ($ password_clear ,PASSWORD_ARGON2I ));
2306+
2307+ break ;
2308+
2309+ case 'argon2id ' :
2310+ if (! defined ('PASSWORD_ARGON2ID ' ))
2311+ error (_ ('Your system does not support argon2id encryption (PHP 7.3 or upper is required). ' ),'error ' ,'index.php ' );
2312+ $ new_value = sprintf ('{ARGON2}%s ' ,password_hash ($ password_clear ,PASSWORD_ARGON2ID ));
2313+
2314+ break ;
2315+
23022316 case 'clear ' :
23032317 default :
23042318 $ new_value = $ password_clear ;
@@ -2534,6 +2548,14 @@ function password_check($cryptedpassword,$plainpassword,$attribute='userpassword
25342548
25352549 break ;
25362550
2551+ # Argon2 crypted passwords
2552+ case 'argon2 ' :
2553+ if (password_verify ($ plainpassword , $ cryptedpassword ))
2554+ return true ;
2555+ else
2556+ return false ;
2557+ break ;
2558+
25372559 # No crypt is given assume plaintext passwords are used
25382560 default :
25392561 if ($ plainpassword == $ cryptedpassword )
@@ -2577,6 +2599,16 @@ function get_enc_type($user_password) {
25772599
25782600 elseif (preg_match ('/{[^}]+}_+/ ' ,$ user_password ))
25792601 $ enc_type = 'ext_des ' ;
2602+
2603+ }
2604+ elseif (strcasecmp ($ enc_type ,'argon2 ' ) == 0 ) {
2605+
2606+ if (preg_match ('/{ARGON2}\$argon2i\$/ ' ,$ user_password ))
2607+ $ enc_type = 'argon2i ' ;
2608+
2609+ elseif (preg_match ('/{ARGON2}\$argon2id\$/ ' ,$ user_password ))
2610+ $ enc_type = 'argon2id ' ;
2611+
25802612 }
25812613
25822614 return $ enc_type ;
0 commit comments