update minimum required PHP version to 5.6 and replace slowEquals() with native hash_equals() function

This commit is contained in:
El RIDO 2020-02-05 19:30:14 +01:00
parent 2870023e9c
commit 5d54006c9e
No known key found for this signature in database
GPG key ID: 0F5C940A6BD81F92
4 changed files with 3 additions and 37 deletions

View file

@ -68,23 +68,4 @@ class Filter
}
return number_format($size, ($i ? 2 : 0), '.', ' ') . ' ' . I18n::_($iec[$i]);
}
/**
* fixed time string comparison operation to prevent timing attacks
* https://crackstation.net/hashing-security.htm?=rd#slowequals
*
* @access public
* @static
* @param string $a
* @param string $b
* @return bool
*/
public static function slowEquals($a, $b)
{
$diff = strlen($a) ^ strlen($b);
for ($i = 0; $i < strlen($a) && $i < strlen($b); ++$i) {
$diff |= ord($a[$i]) ^ ord($b[$i]);
}
return $diff === 0;
}
}