Merge branch 'bcrypt' into bcrypt2

This commit is contained in:
terrafrost 2022-07-31 09:04:54 -05:00
commit af7a69a66f
2 changed files with 9 additions and 9 deletions

View File

@ -506,13 +506,13 @@ abstract class Base
$this->use_inline_crypt = version_compare(PHP_VERSION, '5.3.0') >= 0 || function_exists('create_function');
}
if (!defined('CRYPT_BASE_USE_SAFE_INTVAL')) {
if (!defined('CRYPT_BASE_USE_REG_INTVAL')) {
switch (true) {
// PHP_OS & "\xDF\xDF\xDF" == strtoupper(substr(PHP_OS, 0, 3)), but a lot faster
case (PHP_OS & "\xDF\xDF\xDF") === 'WIN':
case (php_uname('m') & "\xDF\xDF\xDF") != 'ARM':
case defined('PHP_INT_SIZE') && PHP_INT_SIZE == 8:
define('CRYPT_BASE_USE_SAFE_INTVAL', true);
define('CRYPT_BASE_USE_REG_INTVAL', true);
break;
case (php_uname('m') & "\xDF\xDF\xDF") == 'ARM':
switch (true) {
@ -527,10 +527,10 @@ abstract class Base
affected versions of PHP are: 7.0.x, 7.1.0 - 7.1.23 and 7.2.0 - 7.2.11 */
case PHP_VERSION_ID >= 70000 && PHP_VERSION_ID <= 70123:
case PHP_VERSION_ID >= 70200 && PHP_VERSION_ID <= 70211:
define('CRYPT_BASE_USE_SAFE_INTVAL', true);
define('CRYPT_BASE_USE_REG_INTVAL', false);
break;
default:
define('CRYPT_BASE_USE_SAFE_INTVAL', false);
define('CRYPT_BASE_USE_REG_INTVAL', true);
}
}
}
@ -2858,7 +2858,7 @@ abstract class Base
*/
function safe_intval($x)
{
if (CRYPT_BASE_USE_SAFE_INTVAL || is_int($x)) {
if (!CRYPT_BASE_USE_REG_INTVAL || is_int($x)) {
return $x;
}
return (fmod($x, 0x80000000) & 0x7FFFFFFF) |
@ -2873,7 +2873,7 @@ abstract class Base
*/
function safe_intval_inline()
{
if (CRYPT_BASE_USE_SAFE_INTVAL) {
if (CRYPT_BASE_USE_REG_INTVAL) {
return '%s';
}

View File

@ -59,7 +59,7 @@
*
* This explains 3 of the 4 _encryptBlock() implementations. the last _encryptBlock()
* implementation can best be understood by doing Ctrl + F and searching for where
* CRYPT_BASE_USE_SAFE_INTVAL is defined.
* CRYPT_BASE_USE_REG_INTVAL is defined.
*
* # phpseclib's three different _setupKey() implementations
*
@ -528,7 +528,7 @@ class Blowfish extends Base
*/
function bcrypt_pbkdf($pass, $salt, $keylen, $rounds)
{
if (!CRYPT_BASE_USE_SAFE_INTVAL) {
if (!CRYPT_BASE_USE_REG_INTVAL) {
return false;
}
@ -720,7 +720,7 @@ class Blowfish extends Base
$l = $in[1];
$r = $in[2];
list($r, $l) = CRYPT_BASE_USE_SAFE_INTVAL ?
list($r, $l) = CRYPT_BASE_USE_REG_INTVAL ?
$this->_encryptBlockHelperFast($l, $r, $sb_0, $sb_1, $sb_2, $sb_3, $p) :
$this->_encryptBlockHelperSlow($l, $r, $sb_0, $sb_1, $sb_2, $sb_3, $p);