When verifying a password, argon2_verify() calls argon2_hash() to recreate the hash to compare. The recreated hash is then compared to the stored hash.
However, argon2_hash() could fail, e.g., because of an out-of-memory condition. In this case, the existing code will return ARGON2_VERIFY_MISMATCH instead of the error reported by argon2_hash(). This will cause the client code of libsodium to incorrectly believe the password did not match and report that back to the user.
With this patch, argon2_verify() will propagate the error from argon2_hash() if it fails. Only if it argon2_hash() succeeds, the existing hash and the recreated hash will be compared and if not matching ARGON2_VERIFY_MISMATCH will be returned.
When verifying a password, argon2_verify() calls argon2_hash() to recreate the hash to compare. The recreated hash is then compared to the stored hash.
However, argon2_hash() could fail, e.g., because of an out-of-memory condition. In this case, the existing code will return ARGON2_VERIFY_MISMATCH instead of the error reported by argon2_hash(). This will cause the client code of libsodium to incorrectly believe the password did not match and report that back to the user.
With this patch, argon2_verify() will propagate the error from argon2_hash() if it fails. Only if it argon2_hash() succeeds, the existing hash and the recreated hash will be compared and if not matching ARGON2_VERIFY_MISMATCH will be returned.