Crypt: CRYPT_BASE_USE_SAFE_INTVAL -> CRYPT_BASE_USE_REG_INTVAL

This commit is contained in:
terrafrost 2022-07-31 08:59:21 -05:00
parent 34a277ff16
commit 2d6713cd54
2 changed files with 9 additions and 9 deletions

View File

@ -530,14 +530,14 @@ class Crypt_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 5.3, per http://php.net/releases/5_3_0.php, introduced "more consistent float rounding"
case version_compare(PHP_VERSION, '5.3.0') >= 0 && (php_uname('m') & "\xDF\xDF\xDF") != 'ARM':
// PHP_OS & "\xDF\xDF\xDF" == strtoupper(substr(PHP_OS, 0, 3)), but a lot faster
case (PHP_OS & "\xDF\xDF\xDF") === 'WIN':
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) {
@ -554,10 +554,10 @@ class Crypt_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);
}
}
}
@ -2709,7 +2709,7 @@ class Crypt_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) |
@ -2724,7 +2724,7 @@ class Crypt_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
*
@ -601,7 +601,7 @@ class Crypt_Blowfish extends Crypt_Base
*/
function bcrypt_pbkdf($pass, $salt, $keylen, $rounds)
{
if (!CRYPT_BASE_USE_SAFE_INTVAL) {
if (!CRYPT_BASE_USE_REG_INTVAL) {
return false;
}
@ -797,7 +797,7 @@ class Crypt_Blowfish extends Crypt_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);