Skip to content

Commit

Permalink
[Security] Do not mix usage of password_*() functions and sodium_*() …
Browse files Browse the repository at this point in the history
…ones
  • Loading branch information
Robin Chalas committed Jan 12, 2019
1 parent 7f04e55 commit d6cfde9
Showing 1 changed file with 3 additions and 1 deletion.
Expand Up @@ -60,7 +60,9 @@ public function encodePassword($raw, $salt)
*/
public function isPasswordValid($encoded, $raw, $salt)
{
if (\PHP_VERSION_ID >= 70200 && \defined('PASSWORD_ARGON2I')) {
// If $encoded was created via "sodium_crypto_pwhash_str()", the hashing algorithm may be "argon2id" instead of "argon2i".
// In this case, "password_verify()" cannot be used.
if (\PHP_VERSION_ID >= 70200 && \defined('PASSWORD_ARGON2I') && (false === strpos($encoded, '$argon2id$'))) {
return !$this->isPasswordTooLong($raw) && password_verify($raw, $encoded);
}
if (\function_exists('sodium_crypto_pwhash_str_verify')) {
Expand Down

0 comments on commit d6cfde9

Please sign in to comment.