mirror of
https://github.com/phpseclib/phpseclib.git
synced 2025-02-04 12:58:28 +00:00
Merge branch 'bcrypt' into bcrypt2
This commit is contained in:
commit
af7a69a66f
@ -506,13 +506,13 @@ abstract class Base
|
|||||||
$this->use_inline_crypt = version_compare(PHP_VERSION, '5.3.0') >= 0 || function_exists('create_function');
|
$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) {
|
switch (true) {
|
||||||
// PHP_OS & "\xDF\xDF\xDF" == strtoupper(substr(PHP_OS, 0, 3)), but a lot faster
|
// PHP_OS & "\xDF\xDF\xDF" == strtoupper(substr(PHP_OS, 0, 3)), but a lot faster
|
||||||
case (PHP_OS & "\xDF\xDF\xDF") === 'WIN':
|
case (PHP_OS & "\xDF\xDF\xDF") === 'WIN':
|
||||||
case (php_uname('m') & "\xDF\xDF\xDF") != 'ARM':
|
case (php_uname('m') & "\xDF\xDF\xDF") != 'ARM':
|
||||||
case defined('PHP_INT_SIZE') && PHP_INT_SIZE == 8:
|
case defined('PHP_INT_SIZE') && PHP_INT_SIZE == 8:
|
||||||
define('CRYPT_BASE_USE_SAFE_INTVAL', true);
|
define('CRYPT_BASE_USE_REG_INTVAL', true);
|
||||||
break;
|
break;
|
||||||
case (php_uname('m') & "\xDF\xDF\xDF") == 'ARM':
|
case (php_uname('m') & "\xDF\xDF\xDF") == 'ARM':
|
||||||
switch (true) {
|
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 */
|
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 >= 70000 && PHP_VERSION_ID <= 70123:
|
||||||
case PHP_VERSION_ID >= 70200 && PHP_VERSION_ID <= 70211:
|
case PHP_VERSION_ID >= 70200 && PHP_VERSION_ID <= 70211:
|
||||||
define('CRYPT_BASE_USE_SAFE_INTVAL', true);
|
define('CRYPT_BASE_USE_REG_INTVAL', false);
|
||||||
break;
|
break;
|
||||||
default:
|
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)
|
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 $x;
|
||||||
}
|
}
|
||||||
return (fmod($x, 0x80000000) & 0x7FFFFFFF) |
|
return (fmod($x, 0x80000000) & 0x7FFFFFFF) |
|
||||||
@ -2873,7 +2873,7 @@ abstract class Base
|
|||||||
*/
|
*/
|
||||||
function safe_intval_inline()
|
function safe_intval_inline()
|
||||||
{
|
{
|
||||||
if (CRYPT_BASE_USE_SAFE_INTVAL) {
|
if (CRYPT_BASE_USE_REG_INTVAL) {
|
||||||
return '%s';
|
return '%s';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -59,7 +59,7 @@
|
|||||||
*
|
*
|
||||||
* This explains 3 of the 4 _encryptBlock() implementations. the last _encryptBlock()
|
* This explains 3 of the 4 _encryptBlock() implementations. the last _encryptBlock()
|
||||||
* implementation can best be understood by doing Ctrl + F and searching for where
|
* 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
|
* # phpseclib's three different _setupKey() implementations
|
||||||
*
|
*
|
||||||
@ -528,7 +528,7 @@ class Blowfish extends Base
|
|||||||
*/
|
*/
|
||||||
function bcrypt_pbkdf($pass, $salt, $keylen, $rounds)
|
function bcrypt_pbkdf($pass, $salt, $keylen, $rounds)
|
||||||
{
|
{
|
||||||
if (!CRYPT_BASE_USE_SAFE_INTVAL) {
|
if (!CRYPT_BASE_USE_REG_INTVAL) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -720,7 +720,7 @@ class Blowfish extends Base
|
|||||||
$l = $in[1];
|
$l = $in[1];
|
||||||
$r = $in[2];
|
$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->_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);
|
$this->_encryptBlockHelperSlow($l, $r, $sb_0, $sb_1, $sb_2, $sb_3, $p);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user