Skip to content
Snippets Groups Projects
Commit 1c594a3f authored by Tim van Dijen's avatar Tim van Dijen
Browse files

Remove remnants from PHP 5.5

parent fd166016
No related branches found
No related tags found
No related merge requests found
......@@ -417,22 +417,7 @@ class Crypto
*/
public static function secureCompare($known, $user)
{
if (function_exists('hash_equals')) {
// use hash_equals() if available (PHP >= 5.6)
return hash_equals($known, $user);
}
// compare manually in constant time
$len = mb_strlen($known, '8bit'); // see mbstring.func_overload
if ($len !== mb_strlen($user, '8bit')) {
return false; // length differs
}
$diff = 0;
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;
return hash_equals($known, $user);
}
......
......@@ -74,9 +74,7 @@ class ValidatorTest extends SigningTestCase
$signer->loadCertificate($this->good_certificate_file, true);
$signer->sign($node, $signature_parent);
// openssl x509 -in good.cert.pem -noout -sha1 -fingerprint
// Avoiding openssl_x509_fingerprint because it's >= PHP 5.6 only
$fingerprint = 'a7fb75225788a1b0d0290a4bd1ea0c01f89844a0';
$fingerprint = openssl_x509_fingerprint($this->good_certificate);
$validator = new Validator(
$doc,
......@@ -127,9 +125,7 @@ class ValidatorTest extends SigningTestCase
$signer->loadCertificate($this->good_certificate_file, true);
$signer->sign($node, $signature_parent);
// openssl x509 -in good.cert.pem -noout -sha1 -fingerprint
// Avoiding openssl_x509_fingerprint because it's >= PHP 5.6 only
$fingerprint = 'a7fb75225788a1b0d0290a4bd1ea0c01f89844a0';
$fingerprint = openssl_x509_fingerprint($this->good_certificate);
$validator = new Validator($doc, 'node');
$validator->validateFingerprint($fingerprint);
......
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