Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hash algo fix for PHP 5.4 + #18

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion protected/helpers/RandHash.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,11 @@ public static function get($prefix='abc') {
// 12 rounds of HMAC must be reproduced / created verbatim, no known shortcuts.
// Salsa20 returns more than enough bytes.
for ($i = 0; $i < 12; $i++) {
$bytes = hash_hmac('salsa20', microtime() . $bytes, $key, true);
// Support for Salsa20 was removed in PHP 5.4.0
if (version_compare(PHP_VERSION, '5.4.0') >= 0)
$bytes = hash_hmac('sha1', microtime() . $bytes, $key, true);
else
$bytes = hash_hmac('salsa20', microtime() . $bytes, $key, true);
usleep(10);
}
}
Expand Down
6 changes: 5 additions & 1 deletion protected/helpers/bCrypt.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,11 @@ private function getBytes() {
// 12 rounds of HMAC must be reproduced / created verbatim, no known shortcuts.
// Salsa20 returns more than enough bytes.
for ($i = 0; $i < 12; $i++) {
$bytes = hash_hmac('salsa20', microtime() . $bytes, $key, true);
// Support for Salsa20 was removed in PHP 5.4.0
if (version_compare(PHP_VERSION, '5.4.0') >= 0)
$bytes = hash_hmac('sha1', microtime() . $bytes, $key, true);
else
$bytes = hash_hmac('salsa20', microtime() . $bytes, $key, true);
usleep(10);
}
}
Expand Down