Skip to content

Commit 81badab

Browse files
author
Robin Chalas
committed
[Security] Do not mix usage of password_*() functions and sodium_*() ones
1 parent 9a91f19 commit 81badab

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

Encoder/Argon2iPasswordEncoder.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,9 @@ public function encodePassword($raw, $salt)
6060
*/
6161
public function isPasswordValid($encoded, $raw, $salt)
6262
{
63-
if (\PHP_VERSION_ID >= 70200 && \defined('PASSWORD_ARGON2I')) {
63+
// If $encoded was created via "sodium_crypto_pwhash_str()", the hashing algorithm may be "argon2id" instead of "argon2i".
64+
// In this case, "password_verify()" cannot be used.
65+
if (\PHP_VERSION_ID >= 70200 && \defined('PASSWORD_ARGON2I') && (false === strpos($encoded, '$argon2id$'))) {
6466
return !$this->isPasswordTooLong($raw) && password_verify($raw, $encoded);
6567
}
6668
if (\function_exists('sodium_crypto_pwhash_str_verify')) {

0 commit comments

Comments
 (0)