Skip to content
Snippets Groups Projects
Commit 4bc62965 authored by Jaime Pérez Crespo's avatar Jaime Pérez Crespo
Browse files

bugfix: SimpleSAML\Utils\Crypto returns true for different strings using PHP < 5.6.

The reason was the lack of conversion to integer for each character of the strings before applying the XOR operator to them. The operator returns always an empty string when applied to two characters, and applying a binary-wise OR between 0 and an empty string, yields 0. Therefore, $diff is always 0, and the function returns true for every two strings with same length, regardless of their contents.
parent f931e2eb
No related branches found
No related tags found
No related merge requests found
......@@ -404,8 +404,8 @@ class Crypto
return false; // length differs
}
$diff = 0;
for ($i = 0; $i < $len; ++$i) {
$diff |= $known[$i] ^ $user[$i];
for ($i = 0; $i < $len; $i++) {
$diff |= ord($known[$i]) ^ ord($user[$i]);
}
// if all the bytes in $a and $b are identical, $diff should be equal to 0
return $diff === 0;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment