From c852bae3c8f170d597950371df1a1b3225eaac33 Mon Sep 17 00:00:00 2001 From: terrafrost Date: Wed, 30 Nov 2016 15:19:23 -0600 Subject: [PATCH] use short array syntax for arrays --- phpseclib/Crypt/Blowfish.php | 38 ++--- phpseclib/Crypt/Common/SymmetricKey.php | 18 +- phpseclib/Crypt/DES.php | 136 +++++++-------- phpseclib/Crypt/Hash.php | 42 ++--- phpseclib/Crypt/RC2.php | 22 +-- phpseclib/Crypt/RC4.php | 6 +- phpseclib/Crypt/RSA.php | 40 ++--- phpseclib/Crypt/RSA/MSBLOB.php | 8 +- phpseclib/Crypt/RSA/OpenSSH.php | 6 +- phpseclib/Crypt/RSA/PuTTY.php | 18 +- phpseclib/Crypt/RSA/Raw.php | 4 +- phpseclib/Crypt/RSA/XML.php | 12 +- phpseclib/Crypt/Random.php | 2 +- phpseclib/Crypt/Rijndael.php | 54 +++--- phpseclib/Crypt/TripleDES.php | 4 +- phpseclib/Crypt/Twofish.php | 48 +++--- phpseclib/File/ANSI.php | 8 +- phpseclib/File/X509.php | 170 +++++++++--------- phpseclib/Math/BigInteger.php | 218 ++++++++++++------------ phpseclib/Net/SFTP.php | 90 +++++----- phpseclib/Net/SFTP/Stream.php | 4 +- phpseclib/Net/SSH1.php | 62 +++---- phpseclib/Net/SSH2.php | 126 +++++++------- phpseclib/System/SSH/Agent.php | 4 +- 24 files changed, 570 insertions(+), 570 deletions(-) diff --git a/phpseclib/Crypt/Blowfish.php b/phpseclib/Crypt/Blowfish.php index a94367eb..f72e5db5 100644 --- a/phpseclib/Crypt/Blowfish.php +++ b/phpseclib/Crypt/Blowfish.php @@ -84,7 +84,7 @@ class Blowfish extends BlockCipher * @access private * @var array */ - var $sbox0 = array( + var $sbox0 = [ 0xd1310ba6, 0x98dfb5ac, 0x2ffd72db, 0xd01adfb7, 0xb8e1afed, 0x6a267e96, 0xba7c9045, 0xf12c7f99, 0x24a19947, 0xb3916cf7, 0x0801f2e2, 0x858efc16, 0x636920d8, 0x71574e69, 0xa458fea3, 0xf4933d7e, 0x0d95748f, 0x728eb658, 0x718bcd58, 0x82154aee, 0x7b54a41d, 0xc25a59b5, 0x9c30d539, 0x2af26013, @@ -117,7 +117,7 @@ class Blowfish extends BlockCipher 0x83260376, 0x6295cfa9, 0x11c81968, 0x4e734a41, 0xb3472dca, 0x7b14a94a, 0x1b510052, 0x9a532915, 0xd60f573f, 0xbc9bc6e4, 0x2b60a476, 0x81e67400, 0x08ba6fb5, 0x571be91f, 0xf296ec6b, 0x2a0dd915, 0xb6636521, 0xe7b9f9b6, 0xff34052e, 0xc5855664, 0x53b02d5d, 0xa99f8fa1, 0x08ba4799, 0x6e85076a - ); + ]; /** * S-Box 1 @@ -125,7 +125,7 @@ class Blowfish extends BlockCipher * @access private * @var array */ - var $sbox1 = array( + var $sbox1 = [ 0x4b7a70e9, 0xb5b32944, 0xdb75092e, 0xc4192623, 0xad6ea6b0, 0x49a7df7d, 0x9cee60b8, 0x8fedb266, 0xecaa8c71, 0x699a17ff, 0x5664526c, 0xc2b19ee1, 0x193602a5, 0x75094c29, 0xa0591340, 0xe4183a3e, 0x3f54989a, 0x5b429d65, 0x6b8fe4d6, 0x99f73fd6, 0xa1d29c07, 0xefe830f5, 0x4d2d38e6, 0xf0255dc1, @@ -158,7 +158,7 @@ class Blowfish extends BlockCipher 0xa6078084, 0x19f8509e, 0xe8efd855, 0x61d99735, 0xa969a7aa, 0xc50c06c2, 0x5a04abfc, 0x800bcadc, 0x9e447a2e, 0xc3453484, 0xfdd56705, 0x0e1e9ec9, 0xdb73dbd3, 0x105588cd, 0x675fda79, 0xe3674340, 0xc5c43465, 0x713e38d8, 0x3d28f89e, 0xf16dff20, 0x153e21e7, 0x8fb03d4a, 0xe6e39f2b, 0xdb83adf7 - ); + ]; /** * S-Box 2 @@ -166,7 +166,7 @@ class Blowfish extends BlockCipher * @access private * @var array */ - var $sbox2 = array( + var $sbox2 = [ 0xe93d5a68, 0x948140f7, 0xf64c261c, 0x94692934, 0x411520f7, 0x7602d4f7, 0xbcf46b2e, 0xd4a20068, 0xd4082471, 0x3320f46a, 0x43b7d4b7, 0x500061af, 0x1e39f62e, 0x97244546, 0x14214f74, 0xbf8b8840, 0x4d95fc1d, 0x96b591af, 0x70f4ddd3, 0x66a02f45, 0xbfbc09ec, 0x03bd9785, 0x7fac6dd0, 0x31cb8504, @@ -199,7 +199,7 @@ class Blowfish extends BlockCipher 0x6f05e409, 0x4b7c0188, 0x39720a3d, 0x7c927c24, 0x86e3725f, 0x724d9db9, 0x1ac15bb4, 0xd39eb8fc, 0xed545578, 0x08fca5b5, 0xd83d7cd3, 0x4dad0fc4, 0x1e50ef5e, 0xb161e6f8, 0xa28514d9, 0x6c51133c, 0x6fd5c7e7, 0x56e14ec4, 0x362abfce, 0xddc6c837, 0xd79a3234, 0x92638212, 0x670efa8e, 0x406000e0 - ); + ]; /** * S-Box 3 @@ -207,7 +207,7 @@ class Blowfish extends BlockCipher * @access private * @var array */ - var $sbox3 = array( + var $sbox3 = [ 0x3a39ce37, 0xd3faf5cf, 0xabc27737, 0x5ac52d1b, 0x5cb0679e, 0x4fa33742, 0xd3822740, 0x99bc9bbe, 0xd5118e9d, 0xbf0f7315, 0xd62d1c7e, 0xc700c47b, 0xb78c1b6b, 0x21a19045, 0xb26eb1be, 0x6a366eb4, 0x5748ab2f, 0xbc946e79, 0xc6a376d2, 0x6549c2c8, 0x530ff8ee, 0x468dde7d, 0xd5730a1d, 0x4cd04dc6, @@ -240,7 +240,7 @@ class Blowfish extends BlockCipher 0x53113ec0, 0x1640e3d3, 0x38abbd60, 0x2547adf0, 0xba38209c, 0xf746ce76, 0x77afa1c5, 0x20756060, 0x85cbfe4e, 0x8ae88dd8, 0x7aaaf9b0, 0x4cf9aa7e, 0x1948c25c, 0x02fb8a8c, 0x01c36ae4, 0xd6ebe1f9, 0x90d4f869, 0xa65cdea0, 0x3f09252d, 0xc208e69f, 0xb74e6132, 0xce77e25b, 0x578fdfe3, 0x3ac372e6 - ); + ]; /** * P-Array consists of 18 32-bit subkeys @@ -248,11 +248,11 @@ class Blowfish extends BlockCipher * @var array * @access private */ - var $parray = array( + var $parray = [ 0x243f6a88, 0x85a308d3, 0x13198a2e, 0x03707344, 0xa4093822, 0x299f31d0, 0x082efa98, 0xec4e6c89, 0x452821e6, 0x38d01377, 0xbe5466cf, 0x34e90c6c, 0xc0ac29b7, 0xc97c50dd, 0x3f84d5b5, 0xb5470917, 0x9216d5d9, 0x8979fb1b - ); + ]; /** * The BCTX-working Array @@ -355,18 +355,18 @@ class Blowfish extends BlockCipher // already expanded return; } - $this->kl = array('key' => $this->key); + $this->kl = ['key' => $this->key]; /* key-expanding p[] and S-Box building sb[] */ - $this->bctx = array( - 'p' => array(), - 'sb' => array( + $this->bctx = [ + 'p' => [], + 'sb' => [ $this->sbox0, $this->sbox1, $this->sbox2, $this->sbox3 - ) - ); + ] + ]; // unpack binary string in unsigned chars $key = array_values(unpack('C*', $this->key)); @@ -506,7 +506,7 @@ class Blowfish extends BlockCipher '; break; default: - $p = array(); + $p = []; for ($i = 0; $i < 18; ++$i) { $p[] = '$p_' . $i; } @@ -576,13 +576,13 @@ class Blowfish extends BlockCipher '; $lambda_functions[$code_hash] = $this->_createInlineCryptFunction( - array( + [ 'init_crypt' => $init_crypt, 'init_encrypt' => '', 'init_decrypt' => '', 'encrypt_block' => $encrypt_block, 'decrypt_block' => $decrypt_block - ) + ] ); } $this->inline_crypt = $lambda_functions[$code_hash]; diff --git a/phpseclib/Crypt/Common/SymmetricKey.php b/phpseclib/Crypt/Common/SymmetricKey.php index e2c775bc..da718880 100644 --- a/phpseclib/Crypt/Common/SymmetricKey.php +++ b/phpseclib/Crypt/Common/SymmetricKey.php @@ -1806,11 +1806,11 @@ abstract class SymmetricKey { $this->engine = null; - $candidateEngines = array( + $candidateEngines = [ $this->preferredEngine, self::ENGINE_OPENSSL, self::ENGINE_MCRYPT - ); + ]; foreach ($candidateEngines as $engine) { if ($this->isValidEngine($engine)) { $this->engine = $engine; @@ -1935,14 +1935,14 @@ abstract class SymmetricKey $this->enchanged = $this->dechanged = true; if (!isset($this->enmcrypt)) { - static $mcrypt_modes = array( + static $mcrypt_modes = [ self::MODE_CTR => 'ctr', self::MODE_ECB => MCRYPT_MODE_ECB, self::MODE_CBC => MCRYPT_MODE_CBC, self::MODE_CFB => 'ncfb', self::MODE_OFB => MCRYPT_MODE_NOFB, self::MODE_STREAM => MCRYPT_MODE_STREAM, - ); + ]; $this->demcrypt = @mcrypt_module_open($this->cipher_name_mcrypt, '', $mcrypt_modes[$this->mode], ''); $this->enmcrypt = @mcrypt_module_open($this->cipher_name_mcrypt, '', $mcrypt_modes[$this->mode], ''); @@ -2033,9 +2033,9 @@ abstract class SymmetricKey */ function _clearBuffers() { - $this->enbuffer = $this->debuffer = array('ciphertext' => '', 'xor' => '', 'pos' => 0, 'enmcrypt_init' => true); + $this->enbuffer = $this->debuffer = ['ciphertext' => '', 'xor' => '', 'pos' => 0, 'enmcrypt_init' => true]; - if ($this->iv === false && !in_array($this->mode, array(self::MODE_STREAM, self::MODE_ECB))) { + if ($this->iv === false && !in_array($this->mode, [self::MODE_STREAM, self::MODE_ECB])) { throw new \UnexpectedValueException('No IV has been defined'); } @@ -2262,13 +2262,13 @@ abstract class SymmetricKey * * Structure of: * - * $cipher_code = array( + * $cipher_code = [ * 'init_crypt' => (string) '', // optional * 'init_encrypt' => (string) '', // optional * 'init_decrypt' => (string) '', // optional * 'encrypt_block' => (string) '', // required * 'decrypt_block' => (string) '' // required - * ); + * ]; * * * @see self::_setupInlineCrypt() @@ -2647,7 +2647,7 @@ abstract class SymmetricKey */ function &_getLambdaFunctions() { - static $functions = array(); + static $functions = []; return $functions; } diff --git a/phpseclib/Crypt/DES.php b/phpseclib/Crypt/DES.php index 978df81b..856dfc53 100644 --- a/phpseclib/Crypt/DES.php +++ b/phpseclib/Crypt/DES.php @@ -102,13 +102,13 @@ class DES extends BlockCipher * @var array * @access private */ - var $openssl_mode_names = array( + var $openssl_mode_names = [ self::MODE_ECB => 'des-ecb', self::MODE_CBC => 'des-cbc', self::MODE_CFB => 'des-cfb', self::MODE_OFB => 'des-ofb' // self::MODE_CTR is undefined for DES - ); + ]; /** * Optimizing value while CFB-encrypting @@ -161,7 +161,7 @@ class DES extends BlockCipher * @var array * @access private */ - var $shuffle = array( + var $shuffle = [ "\x00\x00\x00\x00\x00\x00\x00\x00", "\x00\x00\x00\x00\x00\x00\x00\xFF", "\x00\x00\x00\x00\x00\x00\xFF\x00", "\x00\x00\x00\x00\x00\x00\xFF\xFF", "\x00\x00\x00\x00\x00\xFF\x00\x00", "\x00\x00\x00\x00\x00\xFF\x00\xFF", @@ -290,7 +290,7 @@ class DES extends BlockCipher "\xFF\xFF\xFF\xFF\xFF\x00\xFF\x00", "\xFF\xFF\xFF\xFF\xFF\x00\xFF\xFF", "\xFF\xFF\xFF\xFF\xFF\xFF\x00\x00", "\xFF\xFF\xFF\xFF\xFF\xFF\x00\xFF", "\xFF\xFF\xFF\xFF\xFF\xFF\xFF\x00", "\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF" - ); + ]; /** * IP mapping helper table. @@ -300,7 +300,7 @@ class DES extends BlockCipher * @var array * @access private */ - var $ipmap = array( + var $ipmap = [ 0x00, 0x10, 0x01, 0x11, 0x20, 0x30, 0x21, 0x31, 0x02, 0x12, 0x03, 0x13, 0x22, 0x32, 0x23, 0x33, 0x40, 0x50, 0x41, 0x51, 0x60, 0x70, 0x61, 0x71, @@ -333,7 +333,7 @@ class DES extends BlockCipher 0x8E, 0x9E, 0x8F, 0x9F, 0xAE, 0xBE, 0xAF, 0xBF, 0xCC, 0xDC, 0xCD, 0xDD, 0xEC, 0xFC, 0xED, 0xFD, 0xCE, 0xDE, 0xCF, 0xDF, 0xEE, 0xFE, 0xEF, 0xFF - ); + ]; /** * Inverse IP mapping helper table. @@ -342,7 +342,7 @@ class DES extends BlockCipher * @var array * @access private */ - var $invipmap = array( + var $invipmap = [ 0x00, 0x80, 0x40, 0xC0, 0x20, 0xA0, 0x60, 0xE0, 0x10, 0x90, 0x50, 0xD0, 0x30, 0xB0, 0x70, 0xF0, 0x08, 0x88, 0x48, 0xC8, 0x28, 0xA8, 0x68, 0xE8, @@ -375,7 +375,7 @@ class DES extends BlockCipher 0x17, 0x97, 0x57, 0xD7, 0x37, 0xB7, 0x77, 0xF7, 0x0F, 0x8F, 0x4F, 0xCF, 0x2F, 0xAF, 0x6F, 0xEF, 0x1F, 0x9F, 0x5F, 0xDF, 0x3F, 0xBF, 0x7F, 0xFF - ); + ]; /** * Pre-permuted S-box1 @@ -386,7 +386,7 @@ class DES extends BlockCipher * @var array * @access private */ - var $sbox1 = array( + var $sbox1 = [ 0x00808200, 0x00000000, 0x00008000, 0x00808202, 0x00808002, 0x00008202, 0x00000002, 0x00008000, 0x00000200, 0x00808200, 0x00808202, 0x00000200, @@ -403,7 +403,7 @@ class DES extends BlockCipher 0x00800002, 0x00000202, 0x00008202, 0x00808200, 0x00000202, 0x00800200, 0x00800200, 0x00000000, 0x00008002, 0x00008200, 0x00000000, 0x00808002 - ); + ]; /** * Pre-permuted S-box2 @@ -411,7 +411,7 @@ class DES extends BlockCipher * @var array * @access private */ - var $sbox2 = array( + var $sbox2 = [ 0x40084010, 0x40004000, 0x00004000, 0x00084010, 0x00080000, 0x00000010, 0x40080010, 0x40004010, 0x40000010, 0x40084010, 0x40084000, 0x40000000, @@ -428,7 +428,7 @@ class DES extends BlockCipher 0x00080010, 0x40004010, 0x40000010, 0x00080010, 0x00084000, 0x00000000, 0x40004000, 0x00004010, 0x40000000, 0x40080010, 0x40084010, 0x00084000 - ); + ]; /** * Pre-permuted S-box3 @@ -436,7 +436,7 @@ class DES extends BlockCipher * @var array * @access private */ - var $sbox3 = array( + var $sbox3 = [ 0x00000104, 0x04010100, 0x00000000, 0x04010004, 0x04000100, 0x00000000, 0x00010104, 0x04000100, 0x00010004, 0x04000004, 0x04000004, 0x00010000, @@ -453,7 +453,7 @@ class DES extends BlockCipher 0x00000004, 0x00010104, 0x00010100, 0x04000004, 0x04010000, 0x04000104, 0x00000104, 0x04010000, 0x00010104, 0x00000004, 0x04010004, 0x00010100 - ); + ]; /** * Pre-permuted S-box4 @@ -461,7 +461,7 @@ class DES extends BlockCipher * @var array * @access private */ - var $sbox4 = array( + var $sbox4 = [ 0x80401000, 0x80001040, 0x80001040, 0x00000040, 0x00401040, 0x80400040, 0x80400000, 0x80001000, 0x00000000, 0x00401000, 0x00401000, 0x80401040, @@ -478,7 +478,7 @@ class DES extends BlockCipher 0x80400000, 0x80001000, 0x00401040, 0x80400040, 0x80001000, 0x00001040, 0x00400000, 0x80401000, 0x00000040, 0x00400000, 0x00001000, 0x00401040 - ); + ]; /** * Pre-permuted S-box5 @@ -486,7 +486,7 @@ class DES extends BlockCipher * @var array * @access private */ - var $sbox5 = array( + var $sbox5 = [ 0x00000080, 0x01040080, 0x01040000, 0x21000080, 0x00040000, 0x00000080, 0x20000000, 0x01040000, 0x20040080, 0x00040000, 0x01000080, 0x20040080, @@ -503,7 +503,7 @@ class DES extends BlockCipher 0x01040000, 0x00000000, 0x20040000, 0x21000000, 0x00040080, 0x01000080, 0x20000080, 0x00040000, 0x00000000, 0x20040000, 0x01040080, 0x20000080 - ); + ]; /** * Pre-permuted S-box6 @@ -511,7 +511,7 @@ class DES extends BlockCipher * @var array * @access private */ - var $sbox6 = array( + var $sbox6 = [ 0x10000008, 0x10200000, 0x00002000, 0x10202008, 0x10200000, 0x00000008, 0x10202008, 0x00200000, 0x10002000, 0x00202008, 0x00200000, 0x10000008, @@ -528,7 +528,7 @@ class DES extends BlockCipher 0x00000008, 0x00002000, 0x10200000, 0x00202008, 0x00002000, 0x00200008, 0x10002008, 0x00000000, 0x10202000, 0x10000000, 0x00200008, 0x10002008 - ); + ]; /** * Pre-permuted S-box7 @@ -536,7 +536,7 @@ class DES extends BlockCipher * @var array * @access private */ - var $sbox7 = array( + var $sbox7 = [ 0x00100000, 0x02100001, 0x02000401, 0x00000000, 0x00000400, 0x02000401, 0x00100401, 0x02100400, 0x02100401, 0x00100000, 0x00000000, 0x02000001, @@ -553,7 +553,7 @@ class DES extends BlockCipher 0x00100400, 0x00000000, 0x00000001, 0x02100401, 0x00000000, 0x00100401, 0x02100000, 0x00000400, 0x02000001, 0x02000400, 0x00000400, 0x00100001 - ); + ]; /** * Pre-permuted S-box8 @@ -561,7 +561,7 @@ class DES extends BlockCipher * @var array * @access private */ - var $sbox8 = array( + var $sbox8 = [ 0x08000820, 0x00000800, 0x00020000, 0x08020820, 0x08000000, 0x08000820, 0x00000020, 0x08000000, 0x00020020, 0x08020000, 0x08020820, 0x00020800, @@ -578,7 +578,7 @@ class DES extends BlockCipher 0x08020000, 0x08000800, 0x08000820, 0x00000000, 0x08020820, 0x00020800, 0x00020800, 0x00000820, 0x00000820, 0x00020020, 0x08000000, 0x08020800 - ); + ]; /** * Default Constructor. @@ -707,7 +707,7 @@ class DES extends BlockCipher // Do the initial IP permutation. $t = unpack('Nl/Nr', $block); - list($l, $r) = array($t['l'], $t['r']); + list($l, $r) = [$t['l'], $t['r']]; $block = ($shuffleip[ $r & 0xFF] & "\x80\x80\x80\x80\x80\x80\x80\x80") | ($shuffleip[($r >> 8) & 0xFF] & "\x40\x40\x40\x40\x40\x40\x40\x40") | ($shuffleip[($r >> 16) & 0xFF] & "\x20\x20\x20\x20\x20\x20\x20\x20") | @@ -719,7 +719,7 @@ class DES extends BlockCipher // Extract L0 and R0. $t = unpack('Nl/Nr', $block); - list($l, $r) = array($t['l'], $t['r']); + list($l, $r) = [$t['l'], $t['r']]; for ($des_round = 0; $des_round < $this->des_rounds; ++$des_round) { // Perform the 16 steps. @@ -770,13 +770,13 @@ class DES extends BlockCipher // already expanded return; } - $this->kl = array('key' => $this->key, 'des_rounds' => $this->des_rounds); + $this->kl = ['key' => $this->key, 'des_rounds' => $this->des_rounds]; - static $shifts = array( // number of key bits shifted per round + static $shifts = [ // number of key bits shifted per round 1, 1, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 1 - ); + ]; - static $pc1map = array( + static $pc1map = [ 0x00, 0x00, 0x08, 0x08, 0x04, 0x04, 0x0C, 0x0C, 0x02, 0x02, 0x0A, 0x0A, 0x06, 0x06, 0x0E, 0x0E, 0x10, 0x10, 0x18, 0x18, 0x14, 0x14, 0x1C, 0x1C, @@ -809,16 +809,16 @@ class DES extends BlockCipher 0xE2, 0xE2, 0xEA, 0xEA, 0xE6, 0xE6, 0xEE, 0xEE, 0xF0, 0xF0, 0xF8, 0xF8, 0xF4, 0xF4, 0xFC, 0xFC, 0xF2, 0xF2, 0xFA, 0xFA, 0xF6, 0xF6, 0xFE, 0xFE - ); + ]; // Mapping tables for the PC-2 transformation. - static $pc2mapc1 = array( + static $pc2mapc1 = [ 0x00000000, 0x00000400, 0x00200000, 0x00200400, 0x00000001, 0x00000401, 0x00200001, 0x00200401, 0x02000000, 0x02000400, 0x02200000, 0x02200400, 0x02000001, 0x02000401, 0x02200001, 0x02200401 - ); - static $pc2mapc2 = array( + ]; + static $pc2mapc2 = [ 0x00000000, 0x00000800, 0x08000000, 0x08000800, 0x00010000, 0x00010800, 0x08010000, 0x08010800, 0x00000000, 0x00000800, 0x08000000, 0x08000800, @@ -883,8 +883,8 @@ class DES extends BlockCipher 0x01050110, 0x01050910, 0x09050110, 0x09050910, 0x01040110, 0x01040910, 0x09040110, 0x09040910, 0x01050110, 0x01050910, 0x09050110, 0x09050910 - ); - static $pc2mapc3 = array( + ]; + static $pc2mapc3 = [ 0x00000000, 0x00000004, 0x00001000, 0x00001004, 0x00000000, 0x00000004, 0x00001000, 0x00001004, 0x10000000, 0x10000004, 0x10001000, 0x10001004, @@ -949,8 +949,8 @@ class DES extends BlockCipher 0x20080022, 0x20080026, 0x20081022, 0x20081026, 0x30080022, 0x30080026, 0x30081022, 0x30081026, 0x30080022, 0x30080026, 0x30081022, 0x30081026 - ); - static $pc2mapc4 = array( + ]; + static $pc2mapc4 = [ 0x00000000, 0x00100000, 0x00000008, 0x00100008, 0x00000200, 0x00100200, 0x00000208, 0x00100208, 0x00000000, 0x00100000, 0x00000008, 0x00100008, @@ -1015,14 +1015,14 @@ class DES extends BlockCipher 0x04022200, 0x04122200, 0x04022208, 0x04122208, 0x04022000, 0x04122000, 0x04022008, 0x04122008, 0x04022200, 0x04122200, 0x04022208, 0x04122208 - ); - static $pc2mapd1 = array( + ]; + static $pc2mapd1 = [ 0x00000000, 0x00000001, 0x08000000, 0x08000001, 0x00200000, 0x00200001, 0x08200000, 0x08200001, 0x00000002, 0x00000003, 0x08000002, 0x08000003, 0x00200002, 0x00200003, 0x08200002, 0x08200003 - ); - static $pc2mapd2 = array( + ]; + static $pc2mapd2 = [ 0x00000000, 0x00100000, 0x00000800, 0x00100800, 0x00000000, 0x00100000, 0x00000800, 0x00100800, 0x04000000, 0x04100000, 0x04000800, 0x04100800, @@ -1087,8 +1087,8 @@ class DES extends BlockCipher 0x00020204, 0x00120204, 0x00020A04, 0x00120A04, 0x04020204, 0x04120204, 0x04020A04, 0x04120A04, 0x04020204, 0x04120204, 0x04020A04, 0x04120A04 - ); - static $pc2mapd3 = array( + ]; + static $pc2mapd3 = [ 0x00000000, 0x00010000, 0x02000000, 0x02010000, 0x00000020, 0x00010020, 0x02000020, 0x02010020, 0x00040000, 0x00050000, 0x02040000, 0x02050000, @@ -1153,8 +1153,8 @@ class DES extends BlockCipher 0x20002030, 0x20012030, 0x22002030, 0x22012030, 0x20042010, 0x20052010, 0x22042010, 0x22052010, 0x20042030, 0x20052030, 0x22042030, 0x22052030 - ); - static $pc2mapd4 = array( + ]; + static $pc2mapd4 = [ 0x00000000, 0x00000400, 0x01000000, 0x01000400, 0x00000000, 0x00000400, 0x01000000, 0x01000400, 0x00000100, 0x00000500, 0x01000100, 0x01000500, @@ -1219,16 +1219,16 @@ class DES extends BlockCipher 0x10081008, 0x10081408, 0x11081008, 0x11081408, 0x10081108, 0x10081508, 0x11081108, 0x11081508, 0x10081108, 0x10081508, 0x11081108, 0x11081508 - ); + ]; - $keys = array(); + $keys = []; for ($des_round = 0; $des_round < $this->des_rounds; ++$des_round) { // pad the key and remove extra characters as appropriate. $key = str_pad(substr($this->key, $des_round * 8, 8), 8, "\0"); // Perform the PC/1 transformation and compute C and D. $t = unpack('Nl/Nr', $key); - list($l, $r) = array($t['l'], $t['r']); + list($l, $r) = [$t['l'], $t['r']]; $key = ($this->shuffle[$pc1map[ $r & 0xFF]] & "\x80\x80\x80\x80\x80\x80\x80\x00") | ($this->shuffle[$pc1map[($r >> 8) & 0xFF]] & "\x40\x40\x40\x40\x40\x40\x40\x00") | ($this->shuffle[$pc1map[($r >> 16) & 0xFF]] & "\x20\x20\x20\x20\x20\x20\x20\x00") | @@ -1241,10 +1241,10 @@ class DES extends BlockCipher $c = ( $key['c'] >> 4) & 0x0FFFFFFF; $d = (($key['d'] >> 4) & 0x0FFFFFF0) | ($key['c'] & 0x0F); - $keys[$des_round] = array( - self::ENCRYPT => array(), + $keys[$des_round] = [ + self::ENCRYPT => [], self::DECRYPT => array_fill(0, 32, 0) - ); + ]; for ($i = 0, $ki = 31; $i < 16; ++$i, $ki-= 2) { $c <<= $shifts[$i]; $c = ($c | ($c >> 28)) & 0x0FFFFFFF; @@ -1271,7 +1271,7 @@ class DES extends BlockCipher switch ($this->des_rounds) { case 3: // 3DES keys - $this->keys = array( + $this->keys = [ self::ENCRYPT => array_merge( $keys[0][self::ENCRYPT], $keys[1][self::DECRYPT], @@ -1282,14 +1282,14 @@ class DES extends BlockCipher $keys[1][self::ENCRYPT], $keys[0][self::DECRYPT] ) - ); + ]; break; // case 1: // DES keys default: - $this->keys = array( + $this->keys = [ self::ENCRYPT => $keys[0][self::ENCRYPT], self::DECRYPT => $keys[0][self::DECRYPT] - ); + ]; } } @@ -1351,20 +1351,20 @@ class DES extends BlockCipher // In Hi-optimized code mode, we use our [3]DES key schedule as hardcoded integers. // No futher initialisation of the $keys schedule is necessary. // That is the extra performance boost. - $k = array( + $k = [ self::ENCRYPT => $this->keys[self::ENCRYPT], self::DECRYPT => $this->keys[self::DECRYPT] - ); + ]; $init_encrypt = ''; $init_decrypt = ''; break; default: // In generic optimized code mode, we have to use, as the best compromise [currently], // our key schedule as $ke/$kd arrays. (with hardcoded indexes...) - $k = array( - self::ENCRYPT => array(), - self::DECRYPT => array() - ); + $k = [ + self::ENCRYPT => [], + self::DECRYPT => [] + ]; for ($i = 0, $c = count($this->keys[self::ENCRYPT]); $i < $c; ++$i) { $k[self::ENCRYPT][$i] = '$ke[' . $i . ']'; $k[self::DECRYPT][$i] = '$kd[' . $i . ']'; @@ -1375,8 +1375,8 @@ class DES extends BlockCipher } // Creating code for en- and decryption. - $crypt_block = array(); - foreach (array(self::ENCRYPT, self::DECRYPT) as $c) { + $crypt_block = []; + foreach ([self::ENCRYPT, self::DECRYPT] as $c) { /* Do the initial IP permutation. */ $crypt_block[$c] = ' $in = unpack("N*", $in); @@ -1419,9 +1419,9 @@ class DES extends BlockCipher // end of "the Feistel (F) function" // swap L & R - list($l, $r) = array($r, $l); + list($l, $r) = [$r, $l]; } - list($l, $r) = array($r, $l); + list($l, $r) = [$r, $l]; } // Perform the inverse IP permutation. @@ -1439,13 +1439,13 @@ class DES extends BlockCipher // Creates the inline-crypt function $lambda_functions[$code_hash] = $this->_createInlineCryptFunction( - array( + [ 'init_crypt' => $init_crypt, 'init_encrypt' => $init_encrypt, 'init_decrypt' => $init_decrypt, 'encrypt_block' => $crypt_block[self::ENCRYPT], 'decrypt_block' => $crypt_block[self::DECRYPT] - ) + ] ); } diff --git a/phpseclib/Crypt/Hash.php b/phpseclib/Crypt/Hash.php index 1ae4f231..d042a639 100644 --- a/phpseclib/Crypt/Hash.php +++ b/phpseclib/Crypt/Hash.php @@ -223,14 +223,14 @@ class Hash if ($hash == 'sha512/224' || $hash == 'sha512/256') { // from http://csrc.nist.gov/publications/fips/fips180-4/fips-180-4.pdf#page=24 $this->initial = $hash == 'sha512/256' ? - array( + [ '22312194FC2BF72C', '9F555FA3C84C64C2', '2393B86B6F53B151', '963877195940EABD', '96283EE2A88EFFE3', 'BE5E1E2553863992', '2B0199FC2C85B8AA', '0EB72DDC81C52CA2' - ) : - array( + ] : + [ '8C3D37C819544DA2', '73E1996689DCD4D6', '1DFAB7AE32FF9C82', '679DD514582F9FCF', '0F6D2B697BD44DA8', '77E36F7304C48942', '3F9D85A86A1D36C8', '1112E6AD91D692A1' - ); + ]; for ($i = 0; $i < 8; $i++) { $this->initial[$i] = new BigInteger($this->initial[$i], 16); $this->initial[$i]->setPrecision(64); @@ -337,7 +337,7 @@ class Hash if (!isset($k)) { // Initialize table of round constants // (first 64 bits of the fractional parts of the cube roots of the first 80 primes 2..409) - $k = array( + $k = [ '428a2f98d728ae22', '7137449123ef65cd', 'b5c0fbcfec4d3b2f', 'e9b5dba58189dbbc', '3956c25bf348b538', '59f111f1b605d019', '923f82a4af194f9b', 'ab1c5ed5da6d8118', 'd807aa98a3030242', '12835b0145706fbe', '243185be4ee4b28c', '550c7dc3d5ffb4e2', @@ -358,7 +358,7 @@ class Hash '06f067aa72176fba', '0a637dc5a2c898a6', '113f9804bef90dae', '1b710b35131c471b', '28db77f523047d84', '32caab7b40c72493', '3c9ebe0a15c9bebc', '431d67c49c100d4c', '4cc5d4becb3e42b6', '597f299cfc657e2a', '5fcb6fab3ad6faec', '6c44198c4a475817' - ); + ]; for ($i = 0; $i < 80; $i++) { $k[$i] = new BigInteger($k[$i], 16); @@ -376,7 +376,7 @@ class Hash // Process the message in successive 1024-bit chunks $chunks = str_split($m, 128); foreach ($chunks as $chunk) { - $w = array(); + $w = []; for ($i = 0; $i < 16; $i++) { $temp = new BigInteger(Strings::shift($chunk, 8), 256); $temp->setPrecision(64); @@ -385,18 +385,18 @@ class Hash // Extend the sixteen 32-bit words into eighty 32-bit words for ($i = 16; $i < 80; $i++) { - $temp = array( + $temp = [ $w[$i - 15]->bitwise_rightRotate(1), $w[$i - 15]->bitwise_rightRotate(8), $w[$i - 15]->bitwise_rightShift(7) - ); + ]; $s0 = $temp[0]->bitwise_xor($temp[1]); $s0 = $s0->bitwise_xor($temp[2]); - $temp = array( + $temp = [ $w[$i - 2]->bitwise_rightRotate(19), $w[$i - 2]->bitwise_rightRotate(61), $w[$i - 2]->bitwise_rightShift(6) - ); + ]; $s1 = $temp[0]->bitwise_xor($temp[1]); $s1 = $s1->bitwise_xor($temp[2]); $w[$i] = clone $w[$i - 16]; @@ -417,33 +417,33 @@ class Hash // Main loop for ($i = 0; $i < 80; $i++) { - $temp = array( + $temp = [ $a->bitwise_rightRotate(28), $a->bitwise_rightRotate(34), $a->bitwise_rightRotate(39) - ); + ]; $s0 = $temp[0]->bitwise_xor($temp[1]); $s0 = $s0->bitwise_xor($temp[2]); - $temp = array( + $temp = [ $a->bitwise_and($b), $a->bitwise_and($c), $b->bitwise_and($c) - ); + ]; $maj = $temp[0]->bitwise_xor($temp[1]); $maj = $maj->bitwise_xor($temp[2]); $t2 = $s0->add($maj); - $temp = array( + $temp = [ $e->bitwise_rightRotate(14), $e->bitwise_rightRotate(18), $e->bitwise_rightRotate(41) - ); + ]; $s1 = $temp[0]->bitwise_xor($temp[1]); $s1 = $s1->bitwise_xor($temp[2]); - $temp = array( + $temp = [ $e->bitwise_and($f), $g->bitwise_and($e->bitwise_not()) - ); + ]; $ch = $temp[0]->bitwise_xor($temp[1]); $t1 = $h->add($s1); $t1 = $t1->add($ch); @@ -461,7 +461,7 @@ class Hash } // Add this chunk's hash to result so far - $hash = array( + $hash = [ $hash[0]->add($a), $hash[1]->add($b), $hash[2]->add($c), @@ -470,7 +470,7 @@ class Hash $hash[5]->add($f), $hash[6]->add($g), $hash[7]->add($h) - ); + ]; } // Produce the final hash value (big-endian) diff --git a/phpseclib/Crypt/RC2.php b/phpseclib/Crypt/RC2.php index aaa63f06..ddd35321 100644 --- a/phpseclib/Crypt/RC2.php +++ b/phpseclib/Crypt/RC2.php @@ -152,7 +152,7 @@ class RC2 extends BlockCipher * @var array * @access private */ - var $pitable = array( + var $pitable = [ 0xD9, 0x78, 0xF9, 0xC4, 0x19, 0xDD, 0xB5, 0xED, 0x28, 0xE9, 0xFD, 0x79, 0x4A, 0xA0, 0xD8, 0x9D, 0xC6, 0x7E, 0x37, 0x83, 0x2B, 0x76, 0x53, 0x8E, @@ -217,7 +217,7 @@ class RC2 extends BlockCipher 0xBB, 0x48, 0x0C, 0x5F, 0xB9, 0xB1, 0xCD, 0x2E, 0xC5, 0xF3, 0xDB, 0x47, 0xE5, 0xA5, 0x9C, 0x77, 0x0A, 0xA6, 0x20, 0x68, 0xFE, 0x7F, 0xC1, 0xAD - ); + ]; /** * Inverse key expansion randomization table. @@ -226,7 +226,7 @@ class RC2 extends BlockCipher * @var array * @access private */ - var $invpitable = array( + var $invpitable = [ 0xD1, 0xDA, 0xB9, 0x6F, 0x9C, 0xC8, 0x78, 0x66, 0x80, 0x2C, 0xF8, 0x37, 0xEA, 0xE0, 0x62, 0xA4, 0xCB, 0x71, 0x50, 0x27, 0x4B, 0x95, 0xD9, 0x20, @@ -259,7 +259,7 @@ class RC2 extends BlockCipher 0x81, 0x09, 0x82, 0x33, 0x9F, 0x07, 0x86, 0x75, 0x38, 0x4E, 0x69, 0xF1, 0xAD, 0x23, 0x73, 0x87, 0x70, 0x02, 0xC2, 0x1E, 0xB8, 0x0A, 0xFC, 0xE6 - ); + ]; /** * Default Constructor. @@ -458,7 +458,7 @@ class RC2 extends BlockCipher list($r0, $r1, $r2, $r3) = array_values(unpack('v*', $in)); $keys = $this->keys; $limit = 20; - $actions = array($limit => 44, 44 => 64); + $actions = [$limit => 44, 44 => 64]; $j = 0; for (;;) { @@ -503,7 +503,7 @@ class RC2 extends BlockCipher list($r0, $r1, $r2, $r3) = array_values(unpack('v*', $in)); $keys = $this->keys; $limit = 44; - $actions = array($limit => 20, 20 => 0); + $actions = [$limit => 20, 20 => 0]; $j = 64; for (;;) { @@ -602,7 +602,7 @@ class RC2 extends BlockCipher case $gen_hi_opt_code: $keys = $this->keys; default: - $keys = array(); + $keys = []; foreach ($this->keys as $k => $v) { $keys[$k] = '$keys[' . $k . ']'; } @@ -619,7 +619,7 @@ class RC2 extends BlockCipher // Create code for encryption. $limit = 20; - $actions = array($limit => 44, 44 => 64); + $actions = [$limit => 44, 44 => 64]; $j = 0; for (;;) { @@ -657,7 +657,7 @@ class RC2 extends BlockCipher // Create code for decryption. $limit = 44; - $actions = array($limit => 20, 20 => 0); + $actions = [$limit => 20, 20 => 0]; $j = 64; for (;;) { @@ -695,11 +695,11 @@ class RC2 extends BlockCipher // Creates the inline-crypt function $lambda_functions[$code_hash] = $this->_createInlineCryptFunction( - array( + [ 'init_crypt' => $init_crypt, 'encrypt_block' => $encrypt_block, 'decrypt_block' => $decrypt_block - ) + ] ); } diff --git a/phpseclib/Crypt/RC4.php b/phpseclib/Crypt/RC4.php index e7ad0bae..19afe0c8 100644 --- a/phpseclib/Crypt/RC4.php +++ b/phpseclib/Crypt/RC4.php @@ -292,12 +292,12 @@ class RC4 extends StreamCipher $keyStream[$j] = $temp; } - $this->stream = array(); - $this->stream[self::DECRYPT] = $this->stream[self::ENCRYPT] = array( + $this->stream = []; + $this->stream[self::DECRYPT] = $this->stream[self::ENCRYPT] = [ 0, // index $i 0, // index $j $keyStream - ); + ]; } /** diff --git a/phpseclib/Crypt/RSA.php b/phpseclib/Crypt/RSA.php index 506c3443..e637078f 100644 --- a/phpseclib/Crypt/RSA.php +++ b/phpseclib/Crypt/RSA.php @@ -363,7 +363,7 @@ class RSA self::$configFile = __DIR__ . '/../openssl.cnf'; if (self::$fileFormats === false) { - self::$fileFormats = array(); + self::$fileFormats = []; foreach (glob(__DIR__ . '/RSA/*.php') as $file) { $name = pathinfo($file, PATHINFO_FILENAME); $type = 'phpseclib\Crypt\RSA\\' . $name; @@ -474,11 +474,11 @@ class RSA // OpenSSL uses 65537 as the exponent and requires RSA keys be 384 bits minimum if (self::$engine == self::ENGINE_OPENSSL && $bits >= 384 && self::$defaultExponent == 65537) { - $config = array(); + $config = []; if (isset(self::$configFile)) { $config['config'] = self::$configFile; } - $rsa = openssl_pkey_new(array('private_key_bits' => $bits) + $config); + $rsa = openssl_pkey_new(['private_key_bits' => $bits] + $config); openssl_pkey_export($rsa, $privatekeystr, null, $config); $privatekey = new RSA(); $privatekey->load($privatekeystr); @@ -491,11 +491,11 @@ class RSA while (openssl_error_string() !== false) { } - return array( + return [ 'privatekey' => $privatekey, 'publickey' => $publickey, 'partialkey' => false - ); + ]; } static $e; @@ -512,11 +512,11 @@ class RSA } $n = clone self::$one; - $exponents = $coefficients = $primes = array(); - $lcm = array( + $exponents = $coefficients = $primes = []; + $lcm = [ 'top' => clone self::$one, 'bottom' => false - ); + ]; do { for ($i = 1; $i <= $num_primes; $i++) { @@ -588,10 +588,10 @@ class RSA $publickey->k = $bits >> 3; $publickey->exponent = $e; - return array( + return [ 'privatekey' => $privatekey, 'publickey' => $publickey - ); + ]; } /** @@ -667,9 +667,9 @@ class RSA $this->publicExponent = clone $key->publicExponent; } - $this->primes = array(); - $this->exponents = array(); - $this->coefficients = array(); + $this->primes = []; + $this->exponents = []; + $this->coefficients = []; foreach ($this->primes as $prime) { $this->primes[] = clone $prime; @@ -720,9 +720,9 @@ class RSA $this->coefficients = $components['coefficients']; $this->publicExponent = $components['publicExponent']; } else { - $this->primes = array(); - $this->exponents = array(); - $this->coefficients = array(); + $this->primes = []; + $this->exponents = []; + $this->coefficients = []; $this->publicExponent = false; } @@ -1244,10 +1244,10 @@ class RSA $num_primes = count($this->primes); if (defined('CRYPT_RSA_DISABLE_BLINDING')) { - $m_i = array( + $m_i = [ 1 => $x->modPow($this->exponents[1], $this->primes[1]), 2 => $x->modPow($this->exponents[2], $this->primes[2]) - ); + ]; $h = $m_i[1]->subtract($m_i[2]); $h = $h->multiply($this->coefficients[2]); list(, $h) = $h->divide($this->primes[1]); @@ -1275,10 +1275,10 @@ class RSA $r = BigInteger::randomRange(self::$one, $smallest->subtract(self::$one)); - $m_i = array( + $m_i = [ 1 => $this->_blind($x, $r, 1), 2 => $this->_blind($x, $r, 2) - ); + ]; $h = $m_i[1]->subtract($m_i[2]); $h = $h->multiply($this->coefficients[2]); list(, $h) = $h->divide($this->primes[1]); diff --git a/phpseclib/Crypt/RSA/MSBLOB.php b/phpseclib/Crypt/RSA/MSBLOB.php index 3992267b..28ce4aab 100644 --- a/phpseclib/Crypt/RSA/MSBLOB.php +++ b/phpseclib/Crypt/RSA/MSBLOB.php @@ -100,7 +100,7 @@ class MSBLOB return false; } - $components = array('isPublicKey' => $publickey); + $components = ['isPublicKey' => $publickey]; // https://msdn.microsoft.com/en-us/library/windows/desktop/aa375549(v=vs.85).aspx switch ($algo) { @@ -140,15 +140,15 @@ class MSBLOB $components['isPublicKey'] = false; // BYTE prime1[rsapubkey.bitlen/16] - $components['primes'] = array(1 => new BigInteger(strrev(Strings::shift($key, $bitlen / 16)), 256)); + $components['primes'] = [1 => new BigInteger(strrev(Strings::shift($key, $bitlen / 16)), 256)]; // BYTE prime2[rsapubkey.bitlen/16] $components['primes'][] = new BigInteger(strrev(Strings::shift($key, $bitlen / 16)), 256); // BYTE exponent1[rsapubkey.bitlen/16] - $components['exponents'] = array(1 => new BigInteger(strrev(Strings::shift($key, $bitlen / 16)), 256)); + $components['exponents'] = [1 => new BigInteger(strrev(Strings::shift($key, $bitlen / 16)), 256)]; // BYTE exponent2[rsapubkey.bitlen/16] $components['exponents'][] = new BigInteger(strrev(Strings::shift($key, $bitlen / 16)), 256); // BYTE coefficient[rsapubkey.bitlen/16] - $components['coefficients'] = array(2 => new BigInteger(strrev(Strings::shift($key, $bitlen / 16)), 256)); + $components['coefficients'] = [2 => new BigInteger(strrev(Strings::shift($key, $bitlen / 16)), 256)]; if (isset($components['privateExponent'])) { $components['publicExponent'] = $components['privateExponent']; } diff --git a/phpseclib/Crypt/RSA/OpenSSH.php b/phpseclib/Crypt/RSA/OpenSSH.php index 0edfc3ba..65135ed4 100644 --- a/phpseclib/Crypt/RSA/OpenSSH.php +++ b/phpseclib/Crypt/RSA/OpenSSH.php @@ -46,7 +46,7 @@ class OpenSSH */ static function setComment($comment) { - self::$comment = str_replace(array("\r", "\n"), '', $comment); + self::$comment = str_replace(["\r", "\n"], '', $comment); } /** @@ -93,12 +93,12 @@ class OpenSSH } $modulus = new BigInteger(Strings::shift($key, $length), -256); - return array( + return [ 'isPublicKey' => true, 'modulus' => $modulus, 'publicExponent' => $publicExponent, 'comment' => $comment - ); + ]; } /** diff --git a/phpseclib/Crypt/RSA/PuTTY.php b/phpseclib/Crypt/RSA/PuTTY.php index f2187abc..e7014c5c 100644 --- a/phpseclib/Crypt/RSA/PuTTY.php +++ b/phpseclib/Crypt/RSA/PuTTY.php @@ -47,7 +47,7 @@ class PuTTY */ static function setComment($comment) { - self::$comment = str_replace(array("\r", "\n"), '', $comment); + self::$comment = str_replace(["\r", "\n"], '', $comment); } /** @@ -102,12 +102,12 @@ class PuTTY if (!preg_match('#Comment: "(.+)"#', $key, $matches)) { return false; } - $components['comment'] = str_replace(array('\\\\', '\"'), array('\\', '"'), $matches[1]); + $components['comment'] = str_replace(['\\\\', '\"'], ['\\', '"'], $matches[1]); return $components; } - $components = array('isPublicKey' => false); + $components = ['isPublicKey' => false]; $key = preg_split('#\r\n|\r|\n#', $key); $type = trim(preg_replace('#PuTTY-User-Key-File-2: (.+)#', '$1', $key[0])); if ($type != 'ssh-rsa') { @@ -149,7 +149,7 @@ class PuTTY if (strlen($private) < $length) { return false; } - $components['primes'] = array(1 => new BigInteger(Strings::shift($private, $length), -256)); + $components['primes'] = [1 => new BigInteger(Strings::shift($private, $length), -256)]; extract(unpack('Nlength', Strings::shift($private, 4))); if (strlen($private) < $length) { return false; @@ -157,7 +157,7 @@ class PuTTY $components['primes'][] = new BigInteger(Strings::shift($private, $length), -256); $temp = $components['primes'][1]->subtract($one); - $components['exponents'] = array(1 => $components['publicExponent']->modInverse($temp)); + $components['exponents'] = [1 => $components['publicExponent']->modInverse($temp)]; $temp = $components['primes'][2]->subtract($one); $components['exponents'][] = $components['publicExponent']->modInverse($temp); @@ -165,7 +165,7 @@ class PuTTY if (strlen($private) < $length) { return false; } - $components['coefficients'] = array(2 => new BigInteger(Strings::shift($private, $length), -256)); + $components['coefficients'] = [2 => new BigInteger(Strings::shift($private, $length), -256)]; return $components; } @@ -189,7 +189,7 @@ class PuTTY return false; } - $raw = array( + $raw = [ 'modulus' => $n->toBytes(true), 'publicExponent' => $e->toBytes(true), 'privateExponent' => $d->toBytes(true), @@ -198,7 +198,7 @@ class PuTTY 'exponent1' => $exponents[1]->toBytes(true), 'exponent2' => $exponents[2]->toBytes(true), 'coefficient' => $coefficients[2]->toBytes(true) - ); + ]; $key = "PuTTY-User-Key-File-2: ssh-rsa\r\nEncryption: "; $encryption = (!empty($password) || is_string($password)) ? 'aes256-cbc' : 'none'; @@ -286,7 +286,7 @@ class PuTTY $n ); $key = "---- BEGIN SSH2 PUBLIC KEY ----\r\n" . - 'Comment: "' . str_replace(array('\\', '"'), array('\\\\', '\"'), self::$comment) . "\"\r\n" . + 'Comment: "' . str_replace(['\\', '"'], ['\\\\', '\"'], self::$comment) . "\"\r\n" . chunk_split(Base64::encode($key), 64) . '---- END SSH2 PUBLIC KEY ----'; diff --git a/phpseclib/Crypt/RSA/Raw.php b/phpseclib/Crypt/RSA/Raw.php index d35bce8f..74f50688 100644 --- a/phpseclib/Crypt/RSA/Raw.php +++ b/phpseclib/Crypt/RSA/Raw.php @@ -59,7 +59,7 @@ class Raw } } } - $components = array('isPublicKey' => true); + $components = ['isPublicKey' => true]; switch (true) { case isset($key['e']): $components['publicExponent'] = $key['e']; @@ -99,6 +99,6 @@ class Raw */ static function savePublicKey(BigInteger $n, BigInteger $e) { - return array('e' => clone $e, 'n' => clone $n); + return ['e' => clone $e, 'n' => clone $n]; } } diff --git a/phpseclib/Crypt/RSA/XML.php b/phpseclib/Crypt/RSA/XML.php index 59b7ac0e..d606b361 100644 --- a/phpseclib/Crypt/RSA/XML.php +++ b/phpseclib/Crypt/RSA/XML.php @@ -46,12 +46,12 @@ class XML return false; } - $components = array( + $components = [ 'isPublicKey' => false, - 'primes' => array(), - 'exponents' => array(), - 'coefficients' => array() - ); + 'primes' => [], + 'exponents' => [], + 'coefficients' => [] + ]; $use_errors = libxml_use_internal_errors(true); @@ -60,7 +60,7 @@ class XML return false; } $xpath = new \DOMXPath($dom); - $keys = array('modulus', 'exponent', 'p', 'q', 'dp', 'dq', 'inverseq', 'd'); + $keys = ['modulus', 'exponent', 'p', 'q', 'dp', 'dq', 'inverseq', 'd']; foreach ($keys as $key) { // $dom->getElementsByTagName($key) is case-sensitive $temp = $xpath->query("//*[translate(local-name(), 'ABCDEFGHIJKLMNOPQRSTUVWXYZ','abcdefghijklmnopqrstuvwxyz')='$key']"); diff --git a/phpseclib/Crypt/Random.php b/phpseclib/Crypt/Random.php index 3ab2db8d..3035035c 100644 --- a/phpseclib/Crypt/Random.php +++ b/phpseclib/Crypt/Random.php @@ -208,7 +208,7 @@ abstract class Random if (isset($arr['__phpseclib_marker'])) { return ''; } - $safearr = array(); + $safearr = []; $arr['__phpseclib_marker'] = true; foreach (array_keys($arr) as $key) { // do not recurse on the '__phpseclib_marker' key itself, for smaller memory usage diff --git a/phpseclib/Crypt/Rijndael.php b/phpseclib/Crypt/Rijndael.php index a5010a80..127b190d 100644 --- a/phpseclib/Crypt/Rijndael.php +++ b/phpseclib/Crypt/Rijndael.php @@ -326,7 +326,7 @@ class Rijndael extends BlockCipher $t3 = $tables[3]; $sbox = $tables[4]; - $state = array(); + $state = []; $words = unpack('N*', $in); $c = $this->c; @@ -348,7 +348,7 @@ class Rijndael extends BlockCipher // equation (7.4.7) is supposed to use addition instead of subtraction, so we'll do that here, as well. // [1] http://fp.gladman.plus.com/cryptography_technology/rijndael/aes.spec.v316.pdf - $temp = array(); + $temp = []; for ($round = 1; $round < $Nr; ++$round) { $i = 0; // $c[0] == 0 $j = $c[1]; @@ -427,7 +427,7 @@ class Rijndael extends BlockCipher $dt3 = $invtables[3]; $isbox = $invtables[4]; - $state = array(); + $state = []; $words = unpack('N*', $in); $c = $this->c; @@ -441,7 +441,7 @@ class Rijndael extends BlockCipher $state[] = $word ^ $dw[++$wc]; } - $temp = array(); + $temp = []; for ($round = $Nr - 1; $round > 0; --$round) { $i = 0; // $c[0] == 0 $j = $Nb - $c[1]; @@ -508,20 +508,20 @@ class Rijndael extends BlockCipher { // Each number in $rcon is equal to the previous number multiplied by two in Rijndael's finite field. // See http://en.wikipedia.org/wiki/Finite_field_arithmetic#Multiplicative_inverse - static $rcon = array(0, + static $rcon = [0, 0x01000000, 0x02000000, 0x04000000, 0x08000000, 0x10000000, 0x20000000, 0x40000000, 0x80000000, 0x1B000000, 0x36000000, 0x6C000000, 0xD8000000, 0xAB000000, 0x4D000000, 0x9A000000, 0x2F000000, 0x5E000000, 0xBC000000, 0x63000000, 0xC6000000, 0x97000000, 0x35000000, 0x6A000000, 0xD4000000, 0xB3000000, 0x7D000000, 0xFA000000, 0xEF000000, 0xC5000000, 0x91000000 - ); + ]; if (isset($this->kl['key']) && $this->key === $this->kl['key'] && $this->key_length === $this->kl['key_length'] && $this->block_size === $this->kl['block_size']) { // already expanded return; } - $this->kl = array('key' => $this->key, 'key_length' => $this->key_length, 'block_size' => $this->block_size); + $this->kl = ['key' => $this->key, 'key_length' => $this->key_length, 'block_size' => $this->block_size]; $this->Nk = $this->key_length >> 2; // see Rijndael-ammended.pdf#page=44 @@ -535,13 +535,13 @@ class Rijndael extends BlockCipher case 4: case 5: case 6: - $this->c = array(0, 1, 2, 3); + $this->c = [0, 1, 2, 3]; break; case 7: - $this->c = array(0, 1, 2, 4); + $this->c = [0, 1, 2, 4]; break; case 8: - $this->c = array(0, 1, 3, 4); + $this->c = [0, 1, 3, 4]; } $w = array_values(unpack('N*words', $this->key)); @@ -570,7 +570,7 @@ class Rijndael extends BlockCipher // 2. Apply InvMixColumn to all Round Keys except the first and the last one." // also, see fips-197.pdf#page=27, "5.3.5 Equivalent Inverse Cipher" list($dt0, $dt1, $dt2, $dt3) = $this->_getInvTables(); - $temp = $this->w = $this->dw = array(); + $temp = $this->w = $this->dw = []; for ($i = $row = $col = 0; $i < $length; $i++, $col++) { if ($col == $this->Nb) { if ($row == 0) { @@ -646,7 +646,7 @@ class Rijndael extends BlockCipher // according to (section 5.2.1), // precomputed tables can be used in the mixColumns phase. in that example, they're assigned t0...t3, so // those are the names we'll use. - $t3 = array_map('intval', array( + $t3 = array_map('intval', [ // with array_map('intval', ...) we ensure we have only int's and not // some slower floats converted by php automatically on high values 0x6363A5C6, 0x7C7C84F8, 0x777799EE, 0x7B7B8DF6, 0xF2F20DFF, 0x6B6BBDD6, 0x6F6FB1DE, 0xC5C55491, @@ -681,7 +681,7 @@ class Rijndael extends BlockCipher 0x9B9BB62D, 0x1E1E223C, 0x87879215, 0xE9E920C9, 0xCECE4987, 0x5555FFAA, 0x28287850, 0xDFDF7AA5, 0x8C8C8F03, 0xA1A1F859, 0x89898009, 0x0D0D171A, 0xBFBFDA65, 0xE6E631D7, 0x4242C684, 0x6868B8D0, 0x4141C382, 0x9999B029, 0x2D2D775A, 0x0F0F111E, 0xB0B0CB7B, 0x5454FCA8, 0xBBBBD66D, 0x16163A2C - )); + ]); foreach ($t3 as $t3i) { $t0[] = (($t3i << 24) & 0xFF000000) | (($t3i >> 8) & 0x00FFFFFF); @@ -689,14 +689,14 @@ class Rijndael extends BlockCipher $t2[] = (($t3i << 8) & 0xFFFFFF00) | (($t3i >> 24) & 0x000000FF); } - $tables = array( + $tables = [ // The Precomputed mixColumns tables t0 - t3 $t0, $t1, $t2, $t3, // The SubByte S-Box - array( + [ 0x63, 0x7C, 0x77, 0x7B, 0xF2, 0x6B, 0x6F, 0xC5, 0x30, 0x01, 0x67, 0x2B, 0xFE, 0xD7, 0xAB, 0x76, 0xCA, 0x82, 0xC9, 0x7D, 0xFA, 0x59, 0x47, 0xF0, 0xAD, 0xD4, 0xA2, 0xAF, 0x9C, 0xA4, 0x72, 0xC0, 0xB7, 0xFD, 0x93, 0x26, 0x36, 0x3F, 0xF7, 0xCC, 0x34, 0xA5, 0xE5, 0xF1, 0x71, 0xD8, 0x31, 0x15, @@ -713,8 +713,8 @@ class Rijndael extends BlockCipher 0x70, 0x3E, 0xB5, 0x66, 0x48, 0x03, 0xF6, 0x0E, 0x61, 0x35, 0x57, 0xB9, 0x86, 0xC1, 0x1D, 0x9E, 0xE1, 0xF8, 0x98, 0x11, 0x69, 0xD9, 0x8E, 0x94, 0x9B, 0x1E, 0x87, 0xE9, 0xCE, 0x55, 0x28, 0xDF, 0x8C, 0xA1, 0x89, 0x0D, 0xBF, 0xE6, 0x42, 0x68, 0x41, 0x99, 0x2D, 0x0F, 0xB0, 0x54, 0xBB, 0x16 - ) - ); + ] + ]; } return $tables; } @@ -732,7 +732,7 @@ class Rijndael extends BlockCipher { static $tables; if (empty($tables)) { - $dt3 = array_map('intval', array( + $dt3 = array_map('intval', [ 0xF4A75051, 0x4165537E, 0x17A4C31A, 0x275E963A, 0xAB6BCB3B, 0x9D45F11F, 0xFA58ABAC, 0xE303934B, 0x30FA5520, 0x766DF6AD, 0xCC769188, 0x024C25F5, 0xE5D7FC4F, 0x2ACBD7C5, 0x35448026, 0x62A38FB5, 0xB15A49DE, 0xBA1B6725, 0xEA0E9845, 0xFEC0E15D, 0x2F7502C3, 0x4CF01281, 0x4697A38D, 0xD3F9C66B, @@ -765,7 +765,7 @@ class Rijndael extends BlockCipher 0xD2DF599C, 0xF2733F55, 0x14CE7918, 0xC737BF73, 0xF7CDEA53, 0xFDAA5B5F, 0x3D6F14DF, 0x44DB8678, 0xAFF381CA, 0x68C43EB9, 0x24342C38, 0xA3405FC2, 0x1DC37216, 0xE2250CBC, 0x3C498B28, 0x0D9541FF, 0xA8017139, 0x0CB3DE08, 0xB4E49CD8, 0x56C19064, 0xCB84617B, 0x32B670D5, 0x6C5C7448, 0xB85742D0 - )); + ]); foreach ($dt3 as $dt3i) { $dt0[] = (($dt3i << 24) & 0xFF000000) | (($dt3i >> 8) & 0x00FFFFFF); @@ -773,14 +773,14 @@ class Rijndael extends BlockCipher $dt2[] = (($dt3i << 8) & 0xFFFFFF00) | (($dt3i >> 24) & 0x000000FF); }; - $tables = array( + $tables = [ // The Precomputed inverse mixColumns tables dt0 - dt3 $dt0, $dt1, $dt2, $dt3, // The inverse SubByte S-Box - array( + [ 0x52, 0x09, 0x6A, 0xD5, 0x30, 0x36, 0xA5, 0x38, 0xBF, 0x40, 0xA3, 0x9E, 0x81, 0xF3, 0xD7, 0xFB, 0x7C, 0xE3, 0x39, 0x82, 0x9B, 0x2F, 0xFF, 0x87, 0x34, 0x8E, 0x43, 0x44, 0xC4, 0xDE, 0xE9, 0xCB, 0x54, 0x7B, 0x94, 0x32, 0xA6, 0xC2, 0x23, 0x3D, 0xEE, 0x4C, 0x95, 0x0B, 0x42, 0xFA, 0xC3, 0x4E, @@ -797,8 +797,8 @@ class Rijndael extends BlockCipher 0x60, 0x51, 0x7F, 0xA9, 0x19, 0xB5, 0x4A, 0x0D, 0x2D, 0xE5, 0x7A, 0x9F, 0x93, 0xC9, 0x9C, 0xEF, 0xA0, 0xE0, 0x3B, 0x4D, 0xAE, 0x2A, 0xF5, 0xB0, 0xC8, 0xEB, 0xBB, 0x3C, 0x83, 0x53, 0x99, 0x61, 0x17, 0x2B, 0x04, 0x7E, 0xBA, 0x77, 0xD6, 0x26, 0xE1, 0x69, 0x14, 0x63, 0x55, 0x21, 0x0C, 0x7D - ) - ); + ] + ]; } return $tables; } @@ -875,7 +875,7 @@ class Rijndael extends BlockCipher // Mainrounds: shiftRows + subWord + mixColumns + addRoundKey for ($round = 1; $round < $Nr; ++$round) { - list($s, $e) = array($e, $s); + list($s, $e) = [$e, $s]; for ($i = 0; $i < $Nb; ++$i) { $encrypt_block.= '$'.$e.$i.' = @@ -932,7 +932,7 @@ class Rijndael extends BlockCipher // Mainrounds: shiftRows + subWord + mixColumns + addRoundKey for ($round = 1; $round < $Nr; ++$round) { - list($s, $e) = array($e, $s); + list($s, $e) = [$e, $s]; for ($i = 0; $i < $Nb; ++$i) { $decrypt_block.= '$'.$e.$i.' = @@ -965,13 +965,13 @@ class Rijndael extends BlockCipher $decrypt_block .= ');'; $lambda_functions[$code_hash] = $this->_createInlineCryptFunction( - array( + [ 'init_crypt' => '', 'init_encrypt' => $init_encrypt, 'init_decrypt' => $init_decrypt, 'encrypt_block' => $encrypt_block, 'decrypt_block' => $decrypt_block - ) + ] ); } $this->inline_crypt = $lambda_functions[$code_hash]; diff --git a/phpseclib/Crypt/TripleDES.php b/phpseclib/Crypt/TripleDES.php index 11cf976d..e3613b0e 100644 --- a/phpseclib/Crypt/TripleDES.php +++ b/phpseclib/Crypt/TripleDES.php @@ -159,11 +159,11 @@ class TripleDES extends DES $this->mode_3cbc = true; // This three $des'es will do the 3CBC work (if $key > 64bits) - $this->des = array( + $this->des = [ new DES(self::MODE_CBC), new DES(self::MODE_CBC), new DES(self::MODE_CBC), - ); + ]; // we're going to be doing the padding, ourselves, so disable it in the \phpseclib\Crypt\DES objects $this->des[0]->disablePadding(); diff --git a/phpseclib/Crypt/Twofish.php b/phpseclib/Crypt/Twofish.php index 250974ea..61abe728 100644 --- a/phpseclib/Crypt/Twofish.php +++ b/phpseclib/Crypt/Twofish.php @@ -73,7 +73,7 @@ class Twofish extends BlockCipher * @var array * @access private */ - var $q0 = array( + var $q0 = [ 0xA9, 0x67, 0xB3, 0xE8, 0x04, 0xFD, 0xA3, 0x76, 0x9A, 0x92, 0x80, 0x78, 0xE4, 0xDD, 0xD1, 0x38, 0x0D, 0xC6, 0x35, 0x98, 0x18, 0xF7, 0xEC, 0x6C, @@ -106,7 +106,7 @@ class Twofish extends BlockCipher 0xC8, 0xA8, 0x2B, 0x40, 0xDC, 0xFE, 0x32, 0xA4, 0xCA, 0x10, 0x21, 0xF0, 0xD3, 0x5D, 0x0F, 0x00, 0x6F, 0x9D, 0x36, 0x42, 0x4A, 0x5E, 0xC1, 0xE0 - ); + ]; /** * Q-Table @@ -114,7 +114,7 @@ class Twofish extends BlockCipher * @var array * @access private */ - var $q1 = array( + var $q1 = [ 0x75, 0xF3, 0xC6, 0xF4, 0xDB, 0x7B, 0xFB, 0xC8, 0x4A, 0xD3, 0xE6, 0x6B, 0x45, 0x7D, 0xE8, 0x4B, 0xD6, 0x32, 0xD8, 0xFD, 0x37, 0x71, 0xF1, 0xE1, @@ -147,7 +147,7 @@ class Twofish extends BlockCipher 0x12, 0xA2, 0x0D, 0x52, 0xBB, 0x02, 0x2F, 0xA9, 0xD7, 0x61, 0x1E, 0xB4, 0x50, 0x04, 0xF6, 0xC2, 0x16, 0x25, 0x86, 0x56, 0x55, 0x09, 0xBE, 0x91 - ); + ]; /** * M-Table @@ -155,7 +155,7 @@ class Twofish extends BlockCipher * @var array * @access private */ - var $m0 = array( + var $m0 = [ 0xBCBC3275, 0xECEC21F3, 0x202043C6, 0xB3B3C9F4, 0xDADA03DB, 0x02028B7B, 0xE2E22BFB, 0x9E9EFAC8, 0xC9C9EC4A, 0xD4D409D3, 0x18186BE6, 0x1E1E9F6B, 0x98980E45, 0xB2B2387D, 0xA6A6D2E8, 0x2626B74B, 0x3C3C57D6, 0x93938A32, 0x8282EED8, 0x525298FD, 0x7B7BD437, 0xBBBB3771, 0x5B5B97F1, 0x474783E1, @@ -188,7 +188,7 @@ class Twofish extends BlockCipher 0xABABA212, 0x6F6F3EA2, 0xE6E6540D, 0xDBDBF252, 0x92927BBB, 0xB7B7B602, 0x6969CA2F, 0x3939D9A9, 0xD3D30CD7, 0xA7A72361, 0xA2A2AD1E, 0xC3C399B4, 0x6C6C4450, 0x07070504, 0x04047FF6, 0x272746C2, 0xACACA716, 0xD0D07625, 0x50501386, 0xDCDCF756, 0x84841A55, 0xE1E15109, 0x7A7A25BE, 0x1313EF91 - ); + ]; /** * M-Table @@ -196,7 +196,7 @@ class Twofish extends BlockCipher * @var array * @access private */ - var $m1 = array( + var $m1 = [ 0xA9D93939, 0x67901717, 0xB3719C9C, 0xE8D2A6A6, 0x04050707, 0xFD985252, 0xA3658080, 0x76DFE4E4, 0x9A084545, 0x92024B4B, 0x80A0E0E0, 0x78665A5A, 0xE4DDAFAF, 0xDDB06A6A, 0xD1BF6363, 0x38362A2A, 0x0D54E6E6, 0xC6432020, 0x3562CCCC, 0x98BEF2F2, 0x181E1212, 0xF724EBEB, 0xECD7A1A1, 0x6C774141, @@ -229,7 +229,7 @@ class Twofish extends BlockCipher 0xC8FA9E9E, 0xA882D6D6, 0x2BCF6E6E, 0x40507070, 0xDCEB8585, 0xFE750A0A, 0x328A9393, 0xA48DDFDF, 0xCA4C2929, 0x10141C1C, 0x2173D7D7, 0xF0CCB4B4, 0xD309D4D4, 0x5D108A8A, 0x0FE25151, 0x00000000, 0x6F9A1919, 0x9DE01A1A, 0x368F9494, 0x42E6C7C7, 0x4AECC9C9, 0x5EFDD2D2, 0xC1AB7F7F, 0xE0D8A8A8 - ); + ]; /** * M-Table @@ -237,7 +237,7 @@ class Twofish extends BlockCipher * @var array * @access private */ - var $m2 = array( + var $m2 = [ 0xBC75BC32, 0xECF3EC21, 0x20C62043, 0xB3F4B3C9, 0xDADBDA03, 0x027B028B, 0xE2FBE22B, 0x9EC89EFA, 0xC94AC9EC, 0xD4D3D409, 0x18E6186B, 0x1E6B1E9F, 0x9845980E, 0xB27DB238, 0xA6E8A6D2, 0x264B26B7, 0x3CD63C57, 0x9332938A, 0x82D882EE, 0x52FD5298, 0x7B377BD4, 0xBB71BB37, 0x5BF15B97, 0x47E14783, @@ -270,7 +270,7 @@ class Twofish extends BlockCipher 0xAB12ABA2, 0x6FA26F3E, 0xE60DE654, 0xDB52DBF2, 0x92BB927B, 0xB702B7B6, 0x692F69CA, 0x39A939D9, 0xD3D7D30C, 0xA761A723, 0xA21EA2AD, 0xC3B4C399, 0x6C506C44, 0x07040705, 0x04F6047F, 0x27C22746, 0xAC16ACA7, 0xD025D076, 0x50865013, 0xDC56DCF7, 0x8455841A, 0xE109E151, 0x7ABE7A25, 0x139113EF - ); + ]; /** * M-Table @@ -278,7 +278,7 @@ class Twofish extends BlockCipher * @var array * @access private */ - var $m3 = array( + var $m3 = [ 0xD939A9D9, 0x90176790, 0x719CB371, 0xD2A6E8D2, 0x05070405, 0x9852FD98, 0x6580A365, 0xDFE476DF, 0x08459A08, 0x024B9202, 0xA0E080A0, 0x665A7866, 0xDDAFE4DD, 0xB06ADDB0, 0xBF63D1BF, 0x362A3836, 0x54E60D54, 0x4320C643, 0x62CC3562, 0xBEF298BE, 0x1E12181E, 0x24EBF724, 0xD7A1ECD7, 0x77416C77, @@ -311,7 +311,7 @@ class Twofish extends BlockCipher 0xFA9EC8FA, 0x82D6A882, 0xCF6E2BCF, 0x50704050, 0xEB85DCEB, 0x750AFE75, 0x8A93328A, 0x8DDFA48D, 0x4C29CA4C, 0x141C1014, 0x73D72173, 0xCCB4F0CC, 0x09D4D309, 0x108A5D10, 0xE2510FE2, 0x00000000, 0x9A196F9A, 0xE01A9DE0, 0x8F94368F, 0xE6C742E6, 0xECC94AEC, 0xFDD25EFD, 0xAB7FC1AB, 0xD8A8E0D8 - ); + ]; /** * The Key Schedule Array @@ -319,7 +319,7 @@ class Twofish extends BlockCipher * @var array * @access private */ - var $K = array(); + var $K = []; /** * The Key depended S-Table 0 @@ -327,7 +327,7 @@ class Twofish extends BlockCipher * @var array * @access private */ - var $S0 = array(); + var $S0 = []; /** * The Key depended S-Table 1 @@ -335,7 +335,7 @@ class Twofish extends BlockCipher * @var array * @access private */ - var $S1 = array(); + var $S1 = []; /** * The Key depended S-Table 2 @@ -343,7 +343,7 @@ class Twofish extends BlockCipher * @var array * @access private */ - var $S2 = array(); + var $S2 = []; /** * The Key depended S-Table 3 @@ -351,7 +351,7 @@ class Twofish extends BlockCipher * @var array * @access private */ - var $S3 = array(); + var $S3 = []; /** * Holds the last used key @@ -444,7 +444,7 @@ class Twofish extends BlockCipher // already expanded return; } - $this->kl = array('key' => $this->key); + $this->kl = ['key' => $this->key]; /* Key expanding and generating the key-depended s-boxes */ $le_longs = unpack('V*', $this->key); @@ -456,7 +456,7 @@ class Twofish extends BlockCipher $q0 = $this->q0; $q1 = $this->q1; - $K = $S0 = $S1 = $S2 = $S3 = array(); + $K = $S0 = $S1 = $S2 = $S3 = []; switch (strlen($this->key)) { case 16: @@ -580,11 +580,11 @@ class Twofish extends BlockCipher $B^= ($u << 24) | ($u << 8); } - return array( + return [ 0xff & $B >> 24, 0xff & $B >> 16, 0xff & $B >> 8, - 0xff & $B); + 0xff & $B]; } /** @@ -736,7 +736,7 @@ class Twofish extends BlockCipher '; break; default: - $K = array(); + $K = []; for ($i = 0; $i < 40; ++$i) { $K[] = '$K_' . $i; } @@ -834,13 +834,13 @@ class Twofish extends BlockCipher '; $lambda_functions[$code_hash] = $this->_createInlineCryptFunction( - array( + [ 'init_crypt' => $init_crypt, 'init_encrypt' => '', 'init_decrypt' => '', 'encrypt_block' => $encrypt_block, 'decrypt_block' => $decrypt_block - ) + ] ); } $this->inline_crypt = $lambda_functions[$code_hash]; diff --git a/phpseclib/File/ANSI.php b/phpseclib/File/ANSI.php index 1f3eecb3..2d6f4763 100644 --- a/phpseclib/File/ANSI.php +++ b/phpseclib/File/ANSI.php @@ -193,7 +193,7 @@ class ANSI $this->max_x = $x - 1; $this->max_y = $y - 1; $this->x = $this->y = 0; - $this->history = $this->history_attrs = array(); + $this->history = $this->history_attrs = []; $this->attr_row = array_fill(0, $this->max_x + 2, $this->base_attr_cell); $this->screen = array_fill(0, $this->max_y + 1, ''); $this->attrs = array_fill(0, $this->max_y + 1, $this->attr_row); @@ -232,7 +232,7 @@ class ANSI */ function appendString($source) { - $this->tokenization = array(''); + $this->tokenization = ['']; for ($i = 0; $i < strlen($source); $i++) { if (strlen($this->ansi)) { $this->ansi.= $source[$i]; @@ -438,10 +438,10 @@ class ANSI //} while ($this->y >= $this->max_y) { - $this->history = array_merge($this->history, array(array_shift($this->screen))); + $this->history = array_merge($this->history, [array_shift($this->screen)]); $this->screen[] = ''; - $this->history_attrs = array_merge($this->history_attrs, array(array_shift($this->attrs))); + $this->history_attrs = array_merge($this->history_attrs, [array_shift($this->attrs)]); $this->attrs[] = $this->attr_row; if (count($this->history) >= $this->max_history) { diff --git a/phpseclib/File/X509.php b/phpseclib/File/X509.php index ba766b3f..60e6a359 100644 --- a/phpseclib/File/X509.php +++ b/phpseclib/File/X509.php @@ -530,8 +530,8 @@ class X509 } } - $filters = array(); - $type_utf8_string = array('type' => ASN1::TYPE_UTF8_STRING); + $filters = []; + $type_utf8_string = ['type' => ASN1::TYPE_UTF8_STRING]; $filters['tbsCertificate']['signature']['parameters'] = $type_utf8_string; $filters['tbsCertificate']['signature']['issuer']['rdnSequence']['value'] = $type_utf8_string; $filters['tbsCertificate']['issuer']['rdnSequence']['value'] = $type_utf8_string; @@ -548,7 +548,7 @@ class X509 characters. */ $filters['policyQualifiers']['qualifier'] - = array('type' => ASN1::TYPE_IA5_STRING); + = ['type' => ASN1::TYPE_IA5_STRING]; ASN1::setFilters($filters); @@ -588,7 +588,7 @@ class X509 corresponding to the extension type identified by extnID */ $map = $this->_getMapping($id); if (!is_bool($map)) { - $mapped = ASN1::asn1map($decoded[0], $map, array('iPAddress' => array($this, '_decodeIP'))); + $mapped = ASN1::asn1map($decoded[0], $map, ['iPAddress' => [$this, '_decodeIP']]); $value = $mapped === false ? $decoded[0] : $mapped; if ($id == 'id-ce-certificatePolicies') { @@ -671,7 +671,7 @@ class X509 unset($extensions[$i]); } } else { - $value = ASN1::encodeDER($value, $map, array('iPAddress' => array($this, '_encodeIP'))); + $value = ASN1::encodeDER($value, $map, ['iPAddress' => [$this, '_encodeIP']]); } } } @@ -1006,7 +1006,7 @@ class X509 if ($names = $this->getExtension('id-ce-subjectAltName')) { foreach ($names as $key => $value) { - $value = str_replace(array('.', '*'), array('\.', '[^.]*'), $value); + $value = str_replace(['.', '*'], ['\.', '[^.]*'], $value); switch ($key) { case 'dNSName': /* From RFC2818 "HTTP over TLS": @@ -1035,7 +1035,7 @@ class X509 } if ($value = $this->getDNProp('id-at-commonName')) { - $value = str_replace(array('.', '*'), array('\.', '[^.]*'), $value[0]); + $value = str_replace(['.', '*'], ['\.', '[^.]*'], $value[0]); return preg_match('#^' . $value . '$#', $components['host']); } @@ -1401,7 +1401,7 @@ class X509 function setDNProp($propName, $propValue, $type = 'utf8String') { if (empty($this->dn)) { - $this->dn = array('rdnSequence' => array()); + $this->dn = ['rdnSequence' => []]; } if (($propName = $this->_translateDNProp($propName)) === false) { @@ -1410,14 +1410,14 @@ class X509 foreach ((array) $propValue as $v) { if (!is_array($v) && isset($type)) { - $v = array($type => $v); + $v = [$type => $v]; } - $this->dn['rdnSequence'][] = array( - array( + $this->dn['rdnSequence'][] = [ + [ 'type' => $propName, 'value'=> $v - ) - ); + ] + ]; } return true; @@ -1473,12 +1473,12 @@ class X509 return false; } - $filters = array(); - $filters['value'] = array('type' => ASN1::TYPE_UTF8_STRING); + $filters = []; + $filters['value'] = ['type' => ASN1::TYPE_UTF8_STRING]; ASN1::setFilters($filters); $this->_mapOutDNs($dn, 'rdnSequence'); $dn = $dn['rdnSequence']; - $result = array(); + $result = []; for ($i = 0; $i < count($dn); $i++) { if ($dn[$i][0]['type'] == $propName) { $v = $dn[$i][0]['value']; @@ -1573,8 +1573,8 @@ class X509 case self::DN_ARRAY: return $dn; case self::DN_ASN1: - $filters = array(); - $filters['rdnSequence']['value'] = array('type' => ASN1::TYPE_UTF8_STRING); + $filters = []; + $filters['rdnSequence']['value'] = ['type' => ASN1::TYPE_UTF8_STRING]; ASN1::setFilters($filters); $this->_mapOutDNs($dn, 'rdnSequence'); return ASN1::encodeDER($dn, Maps\Name::MAP); @@ -1582,8 +1582,8 @@ class X509 // No SEQUENCE around RDNs and all string values normalized as // trimmed lowercase UTF-8 with all spacing as one blank. // constructed RDNs will not be canonicalized - $filters = array(); - $filters['value'] = array('type' => ASN1::TYPE_UTF8_STRING); + $filters = []; + $filters['value'] = ['type' => ASN1::TYPE_UTF8_STRING]; ASN1::setFilters($filters); $result = ''; $this->_mapOutDNs($dn, 'rdnSequence'); @@ -1619,9 +1619,9 @@ class X509 $start = true; $output = ''; - $result = array(); - $filters = array(); - $filters['rdnSequence']['value'] = array('type' => ASN1::TYPE_UTF8_STRING); + $result = []; + $filters = []; + $filters['rdnSequence']['value'] = ['type' => ASN1::TYPE_UTF8_STRING]; ASN1::setFilters($filters); $this->_mapOutDNs($dn, 'rdnSequence'); @@ -1688,7 +1688,7 @@ class X509 } $output.= $desc . '=' . $value; $result[$desc] = isset($result[$desc]) ? - array_merge((array) $dn[$prop], array($value)) : + array_merge((array) $dn[$prop], [$value]) : $value; $start = false; } @@ -1795,7 +1795,7 @@ class X509 */ function getChain() { - $chain = array($this->currentCert); + $chain = [$this->currentCert]; if (!is_array($this->currentCert) || !isset($this->currentCert['tbsCertificate'])) { return false; @@ -1888,7 +1888,7 @@ class X509 } if (isset($this->currentCert) && is_array($this->currentCert)) { - foreach (array('tbsCertificate/subjectPublicKeyInfo', 'certificationRequestInfo/subjectPKInfo') as $path) { + foreach (['tbsCertificate/subjectPublicKeyInfo', 'certificationRequestInfo/subjectPKInfo'] as $path) { $keyinfo = $this->_subArray($this->currentCert, $path); if (!empty($keyinfo)) { break; @@ -2021,9 +2021,9 @@ class X509 } } - $filters = array(); + $filters = []; $filters['certificationRequestInfo']['subject']['rdnSequence']['value'] - = array('type' => ASN1::TYPE_UTF8_STRING); + = ['type' => ASN1::TYPE_UTF8_STRING]; ASN1::setFilters($filters); @@ -2232,22 +2232,22 @@ class X509 return false; } - $filters = array(); + $filters = []; $filters['tbsCertList']['issuer']['rdnSequence']['value'] - = array('type' => ASN1::TYPE_UTF8_STRING); + = ['type' => ASN1::TYPE_UTF8_STRING]; $filters['tbsCertList']['signature']['parameters'] - = array('type' => ASN1::TYPE_UTF8_STRING); + = ['type' => ASN1::TYPE_UTF8_STRING]; $filters['signatureAlgorithm']['parameters'] - = array('type' => ASN1::TYPE_UTF8_STRING); + = ['type' => ASN1::TYPE_UTF8_STRING]; if (empty($crl['tbsCertList']['signature']['parameters'])) { $filters['tbsCertList']['signature']['parameters'] - = array('type' => ASN1::TYPE_NULL); + = ['type' => ASN1::TYPE_NULL]; } if (empty($crl['signatureAlgorithm']['parameters'])) { $filters['signatureAlgorithm']['parameters'] - = array('type' => ASN1::TYPE_NULL); + = ['type' => ASN1::TYPE_NULL]; } ASN1::setFilters($filters); @@ -2288,9 +2288,9 @@ class X509 { $year = @gmdate("Y", @strtotime($date)); // the same way ASN1.php parses this if ($year < 2050) { - return array('utcTime' => $date); + return ['utcTime' => $date]; } else { - return array('generalTime' => $date); + return ['generalTime' => $date]; } } @@ -2364,23 +2364,23 @@ class X509 $this->serialNumber : new BigInteger(Random::string(20) & ("\x7F" . str_repeat("\xFF", 19)), 256); - $this->currentCert = array( + $this->currentCert = [ 'tbsCertificate' => array( 'version' => 'v3', 'serialNumber' => $serialNumber, // $this->setserialNumber() 'signature' => array('algorithm' => $signatureAlgorithm), 'issuer' => false, // this is going to be overwritten later - 'validity' => array( + 'validity' => [ 'notBefore' => $this->_timeField($startDate), // $this->setStartDate() 'notAfter' => $this->_timeField($endDate) // $this->setEndDate() - ), + ], 'subject' => $subject->dn, 'subjectPublicKeyInfo' => $subjectPublicKey ), - 'signatureAlgorithm' => array('algorithm' => $signatureAlgorithm), + 'signatureAlgorithm' => ['algorithm' => $signatureAlgorithm], 'signature' => false // this is going to be overwritten later - ); + ]; // Copy extensions from CSR. $csrexts = $subject->getAttribute('pkcs-9-at-extensionRequest', 0); @@ -2393,14 +2393,14 @@ class X509 $this->currentCert['tbsCertificate']['issuer'] = $issuer->dn; if (isset($issuer->currentKeyIdentifier)) { - $this->setExtension('id-ce-authorityKeyIdentifier', array( + $this->setExtension('id-ce-authorityKeyIdentifier', [ //'authorityCertIssuer' => array( // array( // 'directoryName' => $issuer->dn // ) //), 'keyIdentifier' => $issuer->currentKeyIdentifier - )); + ]); //$extensions = &$this->currentCert['tbsCertificate']['extensions']; //if (isset($issuer->serialNumber)) { // $extensions[count($extensions) - 1]['authorityCertSerialNumber'] = $issuer->serialNumber; @@ -2412,16 +2412,16 @@ class X509 $this->setExtension('id-ce-subjectKeyIdentifier', $subject->currentKeyIdentifier); } - $altName = array(); + $altName = []; if (isset($subject->domains) && count($subject->domains) > 1) { - $altName = array_map(array('X509', '_dnsName'), $subject->domains); + $altName = array_map(['X509', '_dnsName'], $subject->domains); } if (isset($subject->ipAddresses) && count($subject->ipAddresses)) { // should an IP address appear as the CN if no domain name is specified? idk //$ips = count($subject->domains) ? $subject->ipAddresses : array_slice($subject->ipAddresses, 1); - $ipAddresses = array(); + $ipAddresses = []; foreach ($subject->ipAddresses as $ipAddress) { $encoded = $subject->_ipAddress($ipAddress); if ($encoded !== false) { @@ -2440,22 +2440,22 @@ class X509 if ($this->caFlag) { $keyUsage = $this->getExtension('id-ce-keyUsage'); if (!$keyUsage) { - $keyUsage = array(); + $keyUsage = []; } $this->setExtension( 'id-ce-keyUsage', - array_values(array_unique(array_merge($keyUsage, array('cRLSign', 'keyCertSign')))) + array_values(array_unique(array_merge($keyUsage, ['cRLSign', 'keyCertSign']))) ); $basicConstraints = $this->getExtension('id-ce-basicConstraints'); if (!$basicConstraints) { - $basicConstraints = array(); + $basicConstraints = []; } $this->setExtension( 'id-ce-basicConstraints', - array_unique(array_merge(array('cA' => true), $basicConstraints)), + array_unique(array_merge(['cA' => true], $basicConstraints)), true ); @@ -2510,16 +2510,16 @@ class X509 } $this->currentCert['certificationRequestInfo']['subjectPKInfo'] = $publicKey; } else { - $this->currentCert = array( + $this->currentCert = [ 'certificationRequestInfo' => - array( + [ 'version' => 'v1', 'subject' => $this->dn, 'subjectPKInfo' => $publicKey - ), - 'signatureAlgorithm' => array('algorithm' => $signatureAlgorithm), + ], + 'signatureAlgorithm' => ['algorithm' => $signatureAlgorithm], 'signature' => false // this is going to be overwritten later - ); + ]; } // resync $this->signatureSubject @@ -2571,9 +2571,9 @@ class X509 $this->currentCert['publicKeyAndChallenge']['challenge'] = $this->challenge & str_repeat("\x7F", strlen($this->challenge)); } } else { - $this->currentCert = array( + $this->currentCert = [ 'publicKeyAndChallenge' => - array( + [ 'spki' => $publicKey, // quoting , // "A challenge string that is submitted along with the public key. Defaults to an empty string if not specified." @@ -2581,10 +2581,10 @@ class X509 // we could alternatively do this instead if we ignored the specs: // Random::string(8) & str_repeat("\x7F", 8) 'challenge' => !empty($this->challenge) ? $this->challenge : '' - ), - 'signatureAlgorithm' => array('algorithm' => $signatureAlgorithm), + ], + 'signatureAlgorithm' => ['algorithm' => $signatureAlgorithm], 'signature' => false // this is going to be overwritten later - ); + ]; } // resync $this->signatureSubject @@ -2627,17 +2627,17 @@ class X509 $this->currentCert['tbsCertList']['signature']['algorithm'] = $signatureAlgorithm; $this->currentCert['signatureAlgorithm']['algorithm'] = $signatureAlgorithm; } else { - $this->currentCert = array( + $this->currentCert = [ 'tbsCertList' => - array( + [ 'version' => 'v2', - 'signature' => array('algorithm' => $signatureAlgorithm), + 'signature' => ['algorithm' => $signatureAlgorithm], 'issuer' => false, // this is going to be overwritten later 'thisUpdate' => $this->_timeField($thisUpdate) // $this->setStartDate() - ), - 'signatureAlgorithm' => array('algorithm' => $signatureAlgorithm), + ], + 'signatureAlgorithm' => ['algorithm' => $signatureAlgorithm], 'signature' => false // this is going to be overwritten later - ); + ]; } $tbsCertList = &$this->currentCert['tbsCertList']; @@ -2690,14 +2690,14 @@ class X509 } if (isset($issuer->currentKeyIdentifier)) { - $this->setExtension('id-ce-authorityKeyIdentifier', array( + $this->setExtension('id-ce-authorityKeyIdentifier', [ //'authorityCertIssuer' => array( - // array( + // ] // 'directoryName' => $issuer->dn - // ) + // ] //), 'keyIdentifier' => $issuer->currentKeyIdentifier - )); + ]); //$extensions = &$tbsCertList['crlExtensions']; //if (isset($issuer->serialNumber)) { // $extensions[count($extensions) - 1]['authorityCertSerialNumber'] = $issuer->serialNumber; @@ -2881,7 +2881,7 @@ class X509 return $false; } - $root[$i] = array(); + $root[$i] = []; } $root = &$root[$i]; @@ -2917,7 +2917,7 @@ class X509 return $false; } - $root[$i] = array(); + $root[$i] = []; } $root = &$root[$i]; @@ -2964,7 +2964,7 @@ class X509 } if ($create) { $key = count($attributes); - $attributes[] = array('type' => 'pkcs-9-at-extensionRequest', 'value' => array()); + $attributes[] = ['type' => 'pkcs-9-at-extensionRequest', 'value' => []]; $path = "$pth/$key/value/0"; } } @@ -3048,7 +3048,7 @@ class X509 function _getExtensions($cert = null, $path = null) { $exts = $this->_extensions($cert, $path); - $extensions = array(); + $extensions = []; if (is_array($exts)) { foreach ($exts as $extension) { @@ -3078,7 +3078,7 @@ class X509 return false; } - $newext = array('extnId' => $id, 'critical' => $critical, 'extnValue' => $value); + $newext = ['extnId' => $id, 'critical' => $critical, 'extnValue' => $value]; foreach ($extensions as $key => $value) { if ($value['extnId'] == $id) { @@ -3255,7 +3255,7 @@ class X509 } $attributes = $this->_subArray($csr, 'certificationRequestInfo/attributes'); - $attrs = array(); + $attrs = []; if (is_array($attributes)) { foreach ($attributes as $attribute) { @@ -3315,7 +3315,7 @@ class X509 $attributes[$last]['value'][] = $value; break; default: - $attributes[] = array('type' => $id, 'value' => $disposition == self::ATTR_ALL ? $value: array($value)); + $attributes[] = ['type' => $id, 'value' => $disposition == self::ATTR_ALL ? $value: [$value]]; break; } @@ -3378,7 +3378,7 @@ class X509 if (empty($decoded)) { return false; } - $raw = ASN1::asn1map($decoded[0], array('type' => ASN1::TYPE_BIT_STRING)); + $raw = ASN1::asn1map($decoded[0], ['type' => ASN1::TYPE_BIT_STRING]); if (empty($raw)) { return false; } @@ -3435,10 +3435,10 @@ class X509 // the following two return statements do the same thing. i dunno.. i just prefer the later for some reason. // the former is a good example of how to do fuzzing on the public key //return new Element(preg_replace('#-.+-|[\r\n]#', '', $this->publicKey->getPublicKey())); - return array( + return [ 'algorithm' => array('algorithm' => 'rsaEncryption'), 'subjectPublicKey' => $this->publicKey->getPublicKey('PKCS1') - ); + ]; } return false; @@ -3483,7 +3483,7 @@ class X509 */ function _dnsName($domain) { - return array('dNSName' => $domain); + return ['dNSName' => $domain]; } /** @@ -3497,7 +3497,7 @@ class X509 */ function _iPAddress($address) { - return array('iPAddress' => $address); + return ['iPAddress' => $address]; } /** @@ -3524,8 +3524,8 @@ class X509 } $i = count($rclist); - $rclist[] = array('userCertificate' => $serial, - 'revocationDate' => $this->_timeField(@date('D, d M Y H:i:s O'))); + $rclist[] = ['userCertificate' => $serial, + 'revocationDate' => $this->_timeField(@date('D, d M Y H:i:s O'))]; return $i; } @@ -3611,7 +3611,7 @@ class X509 return false; } - $result = array(); + $result = []; if (is_array($rclist = $this->_subArray($crl, 'tbsCertList/revokedCertificates'))) { foreach ($rclist as $rc) { diff --git a/phpseclib/Math/BigInteger.php b/phpseclib/Math/BigInteger.php index 7163be1d..f25a2f09 100644 --- a/phpseclib/Math/BigInteger.php +++ b/phpseclib/Math/BigInteger.php @@ -20,7 +20,7 @@ * base is being used should more than compensate. * * Numbers are stored in {@link http://en.wikipedia.org/wiki/Endianness little endian} format. ie. - * (new \phpseclib\Math\BigInteger(pow(2, 26)))->value = array(0, 1) + * (new \phpseclib\Math\BigInteger(pow(2, 26)))->value = [0, 1] * * Useful resources are as follows: * @@ -313,7 +313,7 @@ class BigInteger $this->value = '0'; break; default: - $this->value = array(); + $this->value = []; } // '0' counts as empty() but when the base is 256 '0' is equal to ord('0') or 48 @@ -423,7 +423,7 @@ class BigInteger $temp = new static(); $multiplier = new static(); - $multiplier->value = array(self::$max10); + $multiplier->value = [self::$max10]; if ($x[0] == '-') { $this->is_negative = true; @@ -665,7 +665,7 @@ class BigInteger $temp->is_negative = false; $divisor = new static(); - $divisor->value = array(self::$max10); + $divisor->value = [self::$max10]; $result = ''; while (count($temp->value)) { list($temp, $mod) = $temp->divide($divisor); @@ -708,7 +708,7 @@ class BigInteger function __sleep() { $this->hex = $this->toHex(true); - $vars = array('hex'); + $vars = ['hex']; if ($this->precision > 0) { $vars[] = 'precision'; } @@ -743,7 +743,7 @@ class BigInteger */ function __debugInfo() { - $opts = array(); + $opts = []; switch (MATH_BIGINTEGER_MODE) { case self::MODE_GMP: $engine = 'gmp'; @@ -761,10 +761,10 @@ class BigInteger if (!empty($opts)) { $engine.= ' (' . implode($opts, ', ') . ')'; } - return array( + return [ 'value' => '0x' . $this->toHex(true), 'engine' => $engine - ); + ]; } /** @@ -827,24 +827,24 @@ class BigInteger $y_size = count($y_value); if ($x_size == 0) { - return array( + return [ self::VALUE => $y_value, self::SIGN => $y_negative - ); + ]; } elseif ($y_size == 0) { - return array( + return [ self::VALUE => $x_value, self::SIGN => $x_negative - ); + ]; } // subtract, if appropriate if ($x_negative != $y_negative) { if ($x_value == $y_value) { - return array( + return [ self::VALUE => array(), self::SIGN => false - ); + ]; } $temp = self::_subtract($x_value, false, $y_value, false); @@ -890,10 +890,10 @@ class BigInteger ++$value[$i]; } - return array( + return [ self::VALUE => self::_trim($value), self::SIGN => $x_negative - ); + ]; } /** @@ -956,15 +956,15 @@ class BigInteger $y_size = count($y_value); if ($x_size == 0) { - return array( + return [ self::VALUE => $y_value, self::SIGN => !$y_negative - ); + ]; } elseif ($y_size == 0) { - return array( + return [ self::VALUE => $x_value, self::SIGN => $x_negative - ); + ]; } // add, if appropriate (ie. -$x - +$y or +$x - -$y) @@ -978,10 +978,10 @@ class BigInteger $diff = self::_compare($x_value, $x_negative, $y_value, $y_negative); if (!$diff) { - return array( - self::VALUE => array(), + return [ + self::VALUE => [], self::SIGN => false - ); + ]; } // switch $x and $y around, if appropriate. @@ -1024,10 +1024,10 @@ class BigInteger --$x_value[$i]; } - return array( + return [ self::VALUE => self::_trim($x_value), self::SIGN => $x_negative - ); + ]; } /** @@ -1086,28 +1086,28 @@ class BigInteger static function _multiply($x_value, $x_negative, $y_value, $y_negative) { //if ( $x_value == $y_value ) { - // return array( + // return [ // self::VALUE => $this->_square($x_value), // self::SIGN => $x_sign != $y_value - // ); + // ]; //} $x_length = count($x_value); $y_length = count($y_value); if (!$x_length || !$y_length) { // a 0 is being multiplied - return array( - self::VALUE => array(), + return [ + self::VALUE => [], self::SIGN => false - ); + ]; } - return array( + return [ self::VALUE => min($x_length, $y_length) < 2 * self::KARATSUBA_CUTOFF ? self::_trim(self::_regularMultiply($x_value, $y_value)) : self::_trim(self::_karatsuba($x_value, $y_value)), self::SIGN => $x_negative != $y_negative - ); + ]; } /** @@ -1126,7 +1126,7 @@ class BigInteger $y_length = count($y_value); if (!$x_length || !$y_length) { // a 0 is being multiplied - return array(); + return []; } if ($x_length < $y_length) { @@ -1243,7 +1243,7 @@ class BigInteger static function _baseSquare($value) { if (empty($value)) { - return array(); + return []; } $square_value = self::_array_repeat(0, 2 * count($value)); @@ -1347,7 +1347,7 @@ class BigInteger $remainder->value = gmp_add($remainder->value, gmp_abs($y->value)); } - return array($this->_normalize($quotient), $this->_normalize($remainder)); + return [$this->_normalize($quotient), $this->_normalize($remainder)]; case self::MODE_BCMATH: $quotient = new static(); $remainder = new static(); @@ -1359,7 +1359,7 @@ class BigInteger $remainder->value = bcadd($remainder->value, $y->value[0] == '-' ? substr($y->value, 1) : $y->value, 0); } - return array($this->_normalize($quotient), $this->_normalize($remainder)); + return [$this->_normalize($quotient), $this->_normalize($remainder)]; } if (count($y->value) == 1) { @@ -1367,9 +1367,9 @@ class BigInteger $quotient = new static(); $remainder = new static(); $quotient->value = $q; - $remainder->value = array($r); + $remainder->value = [$r]; $quotient->is_negative = $this->is_negative != $y->is_negative; - return array($this->_normalize($quotient), $this->_normalize($remainder)); + return [$this->_normalize($quotient), $this->_normalize($remainder)]; } static $zero; @@ -1389,9 +1389,9 @@ class BigInteger if (!$diff) { $temp = new static(); - $temp->value = array(1); + $temp->value = [1]; $temp->is_negative = $x_sign != $y_sign; - return array($this->_normalize($temp), $this->_normalize(new static())); + return [$this->_normalize($temp), $this->_normalize(new static())]; } if ($diff < 0) { @@ -1399,7 +1399,7 @@ class BigInteger if ($x_sign) { $x = $y->subtract($x); } - return array($this->_normalize(new static()), $this->_normalize($x)); + return [$this->_normalize(new static()), $this->_normalize($x)]; } // normalize $x and $y as described in HAC 14.23 / 14.24 @@ -1439,15 +1439,15 @@ class BigInteger for ($i = $x_max; $i >= $y_max + 1; --$i) { $x_value = &$x->value; - $x_window = array( + $x_window = [ isset($x_value[$i]) ? $x_value[$i] : 0, isset($x_value[$i - 1]) ? $x_value[$i - 1] : 0, isset($x_value[$i - 2]) ? $x_value[$i - 2] : 0 - ); - $y_window = array( + ]; + $y_window = [ $y_value[$y_max], ($y_max > 0) ? $y_value[$y_max - 1] : 0 - ); + ]; $q_index = $i - $y_max - 1; if ($x_window[0] == $y_window[0]) { @@ -1459,22 +1459,22 @@ class BigInteger ); } - $temp_value = array($y_window[1], $y_window[0]); + $temp_value = [$y_window[1], $y_window[0]]; - $lhs->value = array($quotient_value[$q_index]); + $lhs->value = [$quotient_value[$q_index]]; $lhs = $lhs->multiply($temp); - $rhs_value = array($x_window[2], $x_window[1], $x_window[0]); + $rhs_value = [$x_window[2], $x_window[1], $x_window[0]]; while ($lhs->compare($rhs) > 0) { --$quotient_value[$q_index]; - $lhs->value = array($quotient_value[$q_index]); + $lhs->value = [$quotient_value[$q_index]]; $lhs = $lhs->multiply($temp); } $adjust = $this->_array_repeat(0, $q_index); - $temp_value = array($quotient_value[$q_index]); + $temp_value = [$quotient_value[$q_index]]; $temp = $temp->multiply($y); $temp_value = &$temp->value; $temp_value = array_merge($adjust, $temp_value); @@ -1502,7 +1502,7 @@ class BigInteger $x = $y->subtract($x); } - return array($this->_normalize($quotient), $this->_normalize($x)); + return [$this->_normalize($quotient), $this->_normalize($x)]; } /** @@ -1518,7 +1518,7 @@ class BigInteger static function _divide_digit($dividend, $divisor) { $carry = 0; - $result = array(); + $result = []; for ($i = count($dividend) - 1; $i >= 0; --$i) { $temp = self::$baseFull * $carry + $dividend[$i]; @@ -1526,7 +1526,7 @@ class BigInteger $carry = (int) ($temp - $divisor * $result[$i]); } - return array($result, $carry); + return [$result, $carry]; } /** @@ -1597,15 +1597,15 @@ class BigInteger } if (defined('MATH_BIGINTEGER_OPENSSL_ENABLED')) { - $components = array( + $components = [ 'modulus' => $n->toBytes(true), 'publicExponent' => $e->toBytes(true) - ); + ]; - $components = array( + $components = [ 'modulus' => pack('Ca*a*', 2, ASN1::encodeLength(strlen($components['modulus'])), $components['modulus']), 'publicExponent' => pack('Ca*a*', 2, ASN1::encodeLength(strlen($components['publicExponent'])), $components['publicExponent']) - ); + ]; $RSAPublicKey = pack( 'Ca*a*a*', @@ -1646,16 +1646,16 @@ class BigInteger if (empty($e->value)) { $temp = new static(); - $temp->value = array(1); + $temp->value = [1]; return $this->_normalize($temp); } - if ($e->value == array(1)) { + if ($e->value == [1]) { list(, $temp) = $this->divide($n); return $this->_normalize($temp); } - if ($e->value == array(2)) { + if ($e->value == [2]) { $temp = new static(); $temp->value = self::_square($this->value); list(, $temp) = $temp->divide($n); @@ -1689,10 +1689,10 @@ class BigInteger $mod1 = clone $n; $mod1->_rshift($j); $mod2 = new static(); - $mod2->value = array(1); + $mod2->value = [1]; $mod2->_lshift($j); - $part1 = ($mod1->value != array(1)) ? $this->_slidingWindow($e, $mod1, self::MONTGOMERY) : new static(); + $part1 = ($mod1->value != [1]) ? $this->_slidingWindow($e, $mod1, self::MONTGOMERY) : new static(); $part2 = $this->_slidingWindow($e, $mod2, self::POWEROF2); $y1 = $mod2->modInverse($mod1); @@ -1741,8 +1741,8 @@ class BigInteger */ function _slidingWindow($e, $n, $mode) { - static $window_ranges = array(7, 25, 81, 241, 673, 1793); // from BigInteger.java's oddModPow function - //static $window_ranges = array(0, 7, 36, 140, 450, 1303, 3529); // from MPM 7.3.1 + static $window_ranges = [7, 25, 81, 241, 673, 1793]; // from BigInteger.java's oddModPow function + //static $window_ranges = [0, 7, 36, 140, 450, 1303, 3529]; // from MPM 7.3.1 $e_value = $e->value; $e_length = count($e_value) - 1; @@ -1761,7 +1761,7 @@ class BigInteger $n_value = $n->value; // precompute $this^0 through $this^$window_size - $powers = array(); + $powers = []; $powers[1] = self::_prepareReduce($this->value, $n_value, $mode); $powers[2] = self::_squareReduce($powers[1], $n_value, $mode); @@ -1773,7 +1773,7 @@ class BigInteger $powers[$i2 + 1] = self::_multiplyReduce($powers[$i2 - 1], $powers[2], $n_value, $mode); } - $result = array(1); + $result = [1]; $result = self::_prepareReduce($result, $n_value, $mode); for ($i = 0; $i < $e_length;) { @@ -1913,7 +1913,7 @@ class BigInteger function _mod2($n) { $temp = new static(); - $temp->value = array(1); + $temp->value = [1]; return $this->bitwise_and($n->subtract($temp)); } @@ -1943,10 +1943,10 @@ class BigInteger */ static function _barrett($n, $m) { - static $cache = array( - self::VARIABLE => array(), - self::DATA => array() - ); + static $cache = [ + self::VARIABLE => [], + self::DATA => [] + ]; $m_length = count($m); @@ -1982,10 +1982,10 @@ class BigInteger $u = $u->value; $m1 = $m1->value; - $cache[self::DATA][] = array( + $cache[self::DATA][] = [ 'u' => $u, // m.length >> 1 (technically (m.length >> 1) + 1) 'm1'=> $m1 // m.length - ); + ]; } else { extract($cache[self::DATA][$key]); } @@ -2040,10 +2040,10 @@ class BigInteger */ static function _regularBarrett($x, $n) { - static $cache = array( - self::VARIABLE => array(), - self::DATA => array() - ); + static $cache = [ + self::VARIABLE => [], + self::DATA => [] + ]; $n_length = count($n); @@ -2118,10 +2118,10 @@ class BigInteger $y_length = count($y_value); if (!$x_length || !$y_length) { // a 0 is being multiplied - return array( - self::VALUE => array(), + return [ + self::VALUE => [], self::SIGN => false - ); + ]; } if ($x_length < $y_length) { @@ -2170,10 +2170,10 @@ class BigInteger } } - return array( + return [ self::VALUE => self::_trim($product_value), self::SIGN => $x_negative != $y_negative - ); + ]; } /** @@ -2193,10 +2193,10 @@ class BigInteger */ static function _montgomery($x, $n) { - static $cache = array( - self::VARIABLE => array(), - self::DATA => array() - ); + static $cache = [ + self::VARIABLE => [], + self::DATA => [] + ]; if (($key = array_search($n, $cache[self::VARIABLE])) === false) { $key = count($cache[self::VARIABLE]); @@ -2206,12 +2206,12 @@ class BigInteger $k = count($n); - $result = array(self::VALUE => $x); + $result = [self::VALUE => $x]; for ($i = 0; $i < $k; ++$i) { $temp = $result[self::VALUE][$i] * $cache[self::DATA][$key]; $temp = $temp - self::$baseFull * (self::$base === 26 ? intval($temp / 0x4000000) : ($temp >> 31)); - $temp = self::_regularMultiply(array($temp), $n); + $temp = self::_regularMultiply([$temp], $n); $temp = array_merge($this->_array_repeat(0, $i), $temp); $result = self::_add($result[self::VALUE], false, $temp, false); } @@ -2249,10 +2249,10 @@ class BigInteger // perform better under different circumstances. in lieu of deleting it it's just been // made uncallable - static $cache = array( - self::VARIABLE => array(), - self::DATA => array() - ); + static $cache = [ + self::VARIABLE => [], + self::DATA => [] + ]; if (($key = array_search($m, $cache[self::VARIABLE])) === false) { $key = count($cache[self::VARIABLE]); @@ -2264,13 +2264,13 @@ class BigInteger $x = array_pad($x, $n, 0); $y = array_pad($y, $n, 0); $m = array_pad($m, $n, 0); - $a = array(self::VALUE => self::_array_repeat(0, $n + 1)); + $a = [self::VALUE => self::_array_repeat(0, $n + 1)]; for ($i = 0; $i < $n; ++$i) { $temp = $a[self::VALUE][0] + $x[$i] * $y[0]; $temp = $temp - self::$baseFull * (self::$base === 26 ? intval($temp / 0x4000000) : ($temp >> 31)); $temp = $temp * $cache[self::DATA][$key]; $temp = $temp - self::$baseFull * (self::$base === 26 ? intval($temp / 0x4000000) : ($temp >> 31)); - $temp = self::_add(self::_regularMultiply(array($x[$i]), $y), false, self::_regularMultiply(array($temp), $m), false); + $temp = self::_add(self::_regularMultiply([$x[$i]], $y), false, self::_regularMultiply([$temp], $m), false); $a = self::_add($a[self::VALUE], false, $temp[self::VALUE], false); $a[self::VALUE] = array_slice($a[self::VALUE], 1); } @@ -2435,11 +2435,11 @@ class BigInteger case self::MODE_GMP: extract(gmp_gcdext($this->value, $n->value)); - return array( + return [ 'gcd' => $this->_normalize(new static($g)), 'x' => $this->_normalize(new static($s)), 'y' => $this->_normalize(new static($t)) - ); + ]; case self::MODE_BCMATH: // it might be faster to use the binary xGCD algorithim here, as well, but (1) that algorithim works // best when the base is a power of 2 and (2) i don't think it'd make much difference, anyway. as is, @@ -2469,17 +2469,17 @@ class BigInteger $d = bcsub($temp, bcmul($b, $q, 0), 0); } - return array( + return [ 'gcd' => $this->_normalize(new static($u)), 'x' => $this->_normalize(new static($a)), 'y' => $this->_normalize(new static($b)) - ); + ]; } $y = clone $n; $x = clone $this; $g = new static(); - $g->value = array(1); + $g->value = [1]; while (!(($x->value[0] & 1)|| ($y->value[0] & 1))) { $x->_rshift(1); @@ -2495,8 +2495,8 @@ class BigInteger $c = new static(); $d = new static(); - $a->value = $d->value = $g->value = array(1); - $b->value = $c->value = array(); + $a->value = $d->value = $g->value = [1]; + $b->value = $c->value = []; while (!empty($u->value)) { while (!($u->value[0] & 1)) { @@ -2530,11 +2530,11 @@ class BigInteger } } - return array( + return [ 'gcd' => $this->_normalize($g->multiply($v)), 'x' => $this->_normalize($c), 'y' => $this->_normalize($d) - ); + ]; } /** @@ -3029,10 +3029,10 @@ class BigInteger } else { $min[0] = chr(0x80); } - return array( + return [ 'min' => new static($min, 256), 'max' => new static($max, 256) - ); + ]; } /** @@ -3295,7 +3295,7 @@ class BigInteger } break; default: - if ($this->value == array(2)) { + if ($this->value == [2]) { return true; } if (~$this->value[0] & 1) { @@ -3306,7 +3306,7 @@ class BigInteger static $primes, $zero, $one, $two; if (!isset($primes)) { - $primes = array( + $primes = [ 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, @@ -3318,7 +3318,7 @@ class BigInteger 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997 - ); + ]; if (MATH_BIGINTEGER_MODE != self::MODE_INTERNAL) { for ($i = 0; $i < count($primes); ++$i) { @@ -3550,7 +3550,7 @@ class BigInteger */ static function _array_repeat($input, $multiplier) { - return ($multiplier) ? array_fill(0, $multiplier, $input) : array(); + return ($multiplier) ? array_fill(0, $multiplier, $input) : []; } /** diff --git a/phpseclib/Net/SFTP.php b/phpseclib/Net/SFTP.php index 915e23fd..cc90d5f8 100644 --- a/phpseclib/Net/SFTP.php +++ b/phpseclib/Net/SFTP.php @@ -96,7 +96,7 @@ class SFTP extends SSH2 * @var array * @access private */ - var $packet_types = array(); + var $packet_types = []; /** * Status Codes @@ -105,7 +105,7 @@ class SFTP extends SSH2 * @var array * @access private */ - var $status_codes = array(); + var $status_codes = []; /** * The Request ID @@ -147,7 +147,7 @@ class SFTP extends SSH2 * @see self::_initChannel() * @access private */ - var $extensions = array(); + var $extensions = []; /** * Server SFTP version @@ -175,7 +175,7 @@ class SFTP extends SSH2 * @var array * @access private */ - var $packet_type_log = array(); + var $packet_type_log = []; /** * Packet Log @@ -184,7 +184,7 @@ class SFTP extends SSH2 * @var array * @access private */ - var $packet_log = array(); + var $packet_log = []; /** * Error information @@ -194,7 +194,7 @@ class SFTP extends SSH2 * @var string * @access private */ - var $sftp_errors = array(); + var $sftp_errors = []; /** * Stat Cache @@ -208,7 +208,7 @@ class SFTP extends SSH2 * @var array * @access private */ - var $stat_cache = array(); + var $stat_cache = []; /** * Max SFTP Packet Size @@ -238,7 +238,7 @@ class SFTP extends SSH2 * @var array * @access private */ - var $sortOptions = array(); + var $sortOptions = []; /** * Default Constructor. @@ -257,7 +257,7 @@ class SFTP extends SSH2 $this->max_sftp_packet = 1 << 15; - $this->packet_types = array( + $this->packet_types = [ 1 => 'NET_SFTP_INIT', 2 => 'NET_SFTP_VERSION', /* the format of SSH_FXP_OPEN changed between SFTPv4 and SFTPv5+: @@ -293,8 +293,8 @@ class SFTP extends SSH2 105=> 'NET_SFTP_ATTRS', 200=> 'NET_SFTP_EXTENDED' - ); - $this->status_codes = array( + ]; + $this->status_codes = [ 0 => 'NET_SFTP_STATUS_OK', 1 => 'NET_SFTP_STATUS_EOF', 2 => 'NET_SFTP_STATUS_NO_SUCH_FILE', @@ -327,10 +327,10 @@ class SFTP extends SSH2 29 => 'NET_SFTP_STATUS_OWNER_INVALID', 30 => 'NET_SFTP_STATUS_GROUP_INVALID', 31 => 'NET_SFTP_STATUS_NO_MATCHING_BYTE_RANGE_LOCK' - ); + ]; // http://tools.ietf.org/html/draft-ietf-secsh-filexfer-13#section-7.1 // the order, in this case, matters quite a lot - see \phpseclib\Net\SFTP::_parseAttributes() to understand why - $this->attributes = array( + $this->attributes = [ 0x00000001 => 'NET_SFTP_ATTR_SIZE', 0x00000002 => 'NET_SFTP_ATTR_UIDGID', // defined in SFTPv3, removed in SFTPv4+ 0x00000004 => 'NET_SFTP_ATTR_PERMISSIONS', @@ -340,21 +340,21 @@ class SFTP extends SSH2 // two's compliment, consists of all 1 bits) by 31. on 64-bit systems this'll yield 0xFFFFFFFF80000000. // that's not a problem, however, and 'anded' and a 32-bit number, as all the leading 1 bits are ignored. -1 << 31 => 'NET_SFTP_ATTR_EXTENDED' - ); + ]; // http://tools.ietf.org/html/draft-ietf-secsh-filexfer-04#section-6.3 // the flag definitions change somewhat in SFTPv5+. if SFTPv5+ support is added to this library, maybe name // the array for that $this->open5_flags and similarly alter the constant names. - $this->open_flags = array( + $this->open_flags = [ 0x00000001 => 'NET_SFTP_OPEN_READ', 0x00000002 => 'NET_SFTP_OPEN_WRITE', 0x00000004 => 'NET_SFTP_OPEN_APPEND', 0x00000008 => 'NET_SFTP_OPEN_CREATE', 0x00000010 => 'NET_SFTP_OPEN_TRUNCATE', 0x00000020 => 'NET_SFTP_OPEN_EXCL' - ); + ]; // http://tools.ietf.org/html/draft-ietf-secsh-filexfer-04#section-5.2 // see \phpseclib\Net\SFTP::_parseLongname() for an explanation - $this->file_types = array( + $this->file_types = [ 1 => 'NET_SFTP_TYPE_REGULAR', 2 => 'NET_SFTP_TYPE_DIRECTORY', 3 => 'NET_SFTP_TYPE_SYMLINK', @@ -366,7 +366,7 @@ class SFTP extends SSH2 7 => 'NET_SFTP_TYPE_CHAR_DEVICE', 8 => 'NET_SFTP_TYPE_BLOCK_DEVICE', 9 => 'NET_SFTP_TYPE_FIFO' - ); + ]; $this->_define_array( $this->packet_types, $this->status_codes, @@ -535,7 +535,7 @@ class SFTP extends SSH2 $this->pwd = $this->_realpath('.'); - $this->_update_stat_cache($this->pwd, array()); + $this->_update_stat_cache($this->pwd, []); return true; } @@ -567,7 +567,7 @@ class SFTP extends SSH2 */ function clearStatCache() { - $this->stat_cache = array(); + $this->stat_cache = []; } /** @@ -661,7 +661,7 @@ class SFTP extends SSH2 } $path = explode('/', $path); - $new = array(); + $new = []; foreach ($path as $dir) { if (!strlen($dir)) { continue; @@ -735,7 +735,7 @@ class SFTP extends SSH2 return false; } - $this->_update_stat_cache($dir, array()); + $this->_update_stat_cache($dir, []); $this->pwd = $dir; return true; @@ -771,7 +771,7 @@ class SFTP extends SSH2 return $files; } - $result = array(); + $result = []; foreach ($files as $value) { if ($value == '.' || $value == '..') { if ($relativeDir == '') { @@ -865,9 +865,9 @@ class SFTP extends SSH2 throw new \UnexpectedValueException('Expected SSH_FXP_HANDLE or SSH_FXP_STATUS'); } - $this->_update_stat_cache($dir, array()); + $this->_update_stat_cache($dir, []); - $contents = array(); + $contents = []; while (true) { // http://tools.ietf.org/html/draft-ietf-secsh-filexfer-13#section-8.2.2 // why multiple SSH_FXP_READDIR packets would be sent when the response to a single one can span arbitrarily many @@ -892,17 +892,17 @@ class SFTP extends SSH2 $attributes['type'] = $fileType; } } - $contents[$shortname] = $attributes + array('filename' => $shortname); + $contents[$shortname] = $attributes + ['filename' => $shortname]; if (isset($attributes['type']) && $attributes['type'] == NET_SFTP_TYPE_DIRECTORY && ($shortname != '.' && $shortname != '..')) { - $this->_update_stat_cache($dir . '/' . $shortname, array()); + $this->_update_stat_cache($dir . '/' . $shortname, []); } else { if ($shortname == '..') { $temp = $this->_realpath($dir . '/..') . '/.'; } else { $temp = $dir . '/' . $shortname; } - $this->_update_stat_cache($temp, (object) array('lstat' => $attributes)); + $this->_update_stat_cache($temp, (object) ['lstat' => $attributes]); } // SFTPv6 has an optional boolean end-of-list field, but we'll ignore that, since the // final SSH_FXP_STATUS packet should tell us that, already. @@ -925,7 +925,7 @@ class SFTP extends SSH2 } if (count($this->sortOptions)) { - uasort($contents, array(&$this, '_comparator')); + uasort($contents, [&$this, '_comparator']); } return $raw ? $contents : array_keys($contents); @@ -1017,7 +1017,7 @@ class SFTP extends SSH2 */ function setListOrder() { - $this->sortOptions = array(); + $this->sortOptions = []; $args = func_get_args(); if (empty($args)) { return; @@ -1027,7 +1027,7 @@ class SFTP extends SSH2 $this->sortOptions[$args[$i]] = $args[$i + 1]; } if (!count($this->sortOptions)) { - $this->sortOptions = array('bogus' => true); + $this->sortOptions = ['bogus' => true]; } } @@ -1076,10 +1076,10 @@ class SFTP extends SSH2 // 1. a file was deleted and changed to a directory behind phpseclib's back // 2. it's a symlink. when lstat is done it's unclear what it's a symlink to if (is_object($temp)) { - $temp = array(); + $temp = []; } if (!isset($temp[$dir])) { - $temp[$dir] = array(); + $temp[$dir] = []; } if ($i === $max) { if (is_object($temp[$dir])) { @@ -1184,7 +1184,7 @@ class SFTP extends SSH2 if ($stat['type'] == NET_SFTP_TYPE_DIRECTORY) { $filename.= '/.'; } - $this->_update_stat_cache($filename, (object) array('stat' => $stat)); + $this->_update_stat_cache($filename, (object) ['stat' => $stat]); return $stat; } @@ -1197,7 +1197,7 @@ class SFTP extends SSH2 if ($stat['type'] == NET_SFTP_TYPE_DIRECTORY) { $filename.= '/.'; } - $this->_update_stat_cache($filename, (object) array('stat' => $stat)); + $this->_update_stat_cache($filename, (object) ['stat' => $stat]); return $stat; } @@ -1241,15 +1241,15 @@ class SFTP extends SSH2 if ($lstat['type'] == NET_SFTP_TYPE_DIRECTORY) { $filename.= '/.'; } - $this->_update_stat_cache($filename, (object) array('lstat' => $lstat)); + $this->_update_stat_cache($filename, (object) ['lstat' => $lstat]); return $lstat; } $stat = $this->_stat($filename, NET_SFTP_STAT); if ($lstat != $stat) { - $lstat = array_merge($lstat, array('type' => NET_SFTP_TYPE_SYMLINK)); - $this->_update_stat_cache($filename, (object) array('lstat' => $lstat)); + $lstat = array_merge($lstat, ['type' => NET_SFTP_TYPE_SYMLINK]); + $this->_update_stat_cache($filename, (object) ['lstat' => $lstat]); return $stat; } @@ -1262,7 +1262,7 @@ class SFTP extends SSH2 if ($lstat['type'] == NET_SFTP_TYPE_DIRECTORY) { $filename.= '/.'; } - $this->_update_stat_cache($filename, (object) array('lstat' => $lstat)); + $this->_update_stat_cache($filename, (object) ['lstat' => $lstat]); return $lstat; } @@ -2652,7 +2652,7 @@ class SFTP extends SSH2 */ function _parseAttributes(&$response) { - $attr = array(); + $attr = []; extract(unpack('Nflags', Strings::shift($response, 4))); // SFTPv4+ have a type field (a byte) that follows the above flag field foreach ($this->attributes as $key => $value) { @@ -2673,10 +2673,10 @@ class SFTP extends SSH2 $attr+= unpack('Npermissions', Strings::shift($response, 4)); // mode == permissions; permissions was the original array key and is retained for bc purposes. // mode was added because that's the more industry standard terminology - $attr+= array('mode' => $attr['permissions']); + $attr+= ['mode' => $attr['permissions']]; $fileType = $this->_parseMode($attr['permissions']); if ($fileType !== false) { - $attr+= array('type' => $fileType); + $attr+= ['type' => $fileType]; } break; case NET_SFTP_ATTR_ACCESSTIME: // 0x00000008 @@ -2797,7 +2797,7 @@ class SFTP extends SSH2 $packet_type = '-> ' . $this->packet_types[$type] . ' (' . round($stop - $start, 4) . 's)'; if (NET_SFTP_LOGGING == self::LOG_REALTIME) { - echo "
\r\n" . $this->_format_log(array($data), array($packet_type)) . "\r\n
\r\n"; + echo "
\r\n" . $this->_format_log([$data], [$packet_type]) . "\r\n
\r\n"; flush(); ob_flush(); } else { @@ -2873,7 +2873,7 @@ class SFTP extends SSH2 $packet_type = '<- ' . $this->packet_types[$this->packet_type] . ' (' . round($stop - $start, 4) . 's)'; if (NET_SFTP_LOGGING == self::LOG_REALTIME) { - echo "
\r\n" . $this->_format_log(array($packet), array($packet_type)) . "\r\n
\r\n"; + echo "
\r\n" . $this->_format_log([$packet], [$packet_type]) . "\r\n
\r\n"; flush(); ob_flush(); } else { @@ -2941,7 +2941,7 @@ class SFTP extends SSH2 */ function getSupportedVersions() { - $temp = array('version' => $this->version); + $temp = ['version' => $this->version]; if (isset($this->extensions['versions'])) { $temp['extensions'] = $this->extensions['versions']; } diff --git a/phpseclib/Net/SFTP/Stream.php b/phpseclib/Net/SFTP/Stream.php index d19d08b8..3ee95f76 100644 --- a/phpseclib/Net/SFTP/Stream.php +++ b/phpseclib/Net/SFTP/Stream.php @@ -155,7 +155,7 @@ class Stream function _parse_path($path) { $orig = $path; - extract(parse_url($path) + array('port' => 22)); + extract(parse_url($path) + ['port' => 22]); if (isset($query)) { $path.= '?' . $query; } elseif (preg_match('/(\?|\?#)$/', $orig)) { @@ -790,6 +790,6 @@ class Stream if (!method_exists($this, $name)) { return false; } - return call_user_func_array(array($this, $name), $arguments); + return call_user_func_array([$this, $name], $arguments); } } diff --git a/phpseclib/Net/SSH1.php b/phpseclib/Net/SSH1.php index ea42d052..0fb34906 100644 --- a/phpseclib/Net/SSH1.php +++ b/phpseclib/Net/SSH1.php @@ -311,7 +311,7 @@ class SSH1 * @var array * @access private */ - var $supported_ciphers = array( + var $supported_ciphers = [ self::CIPHER_NONE => 'No encryption', self::CIPHER_IDEA => 'IDEA in CFB mode', self::CIPHER_DES => 'DES in CBC mode', @@ -319,7 +319,7 @@ class SSH1 self::CIPHER_BROKEN_TSS => 'TRI\'s Simple Stream encryption CBC', self::CIPHER_RC4 => 'RC4', self::CIPHER_BLOWFISH => 'Blowfish' - ); + ]; /** * Supported Authentications @@ -330,12 +330,12 @@ class SSH1 * @var array * @access private */ - var $supported_authentications = array( + var $supported_authentications = [ self::AUTH_RHOSTS => '.rhosts or /etc/hosts.equiv', self::AUTH_RSA => 'pure RSA authentication', self::AUTH_PASSWORD => 'password authentication', self::AUTH_RHOSTS_RSA => '.rhosts with RSA host authentication' - ); + ]; /** * Server Identification @@ -353,7 +353,7 @@ class SSH1 * @var array * @access private */ - var $protocol_flags = array(); + var $protocol_flags = []; /** * Protocol Flag Log @@ -362,7 +362,7 @@ class SSH1 * @var array * @access private */ - var $protocol_flag_log = array(); + var $protocol_flag_log = []; /** * Message Log @@ -371,7 +371,7 @@ class SSH1 * @var array * @access private */ - var $message_log = array(); + var $message_log = []; /** * Real-time log file pointer @@ -508,7 +508,7 @@ class SSH1 */ function __construct($host, $port = 22, $timeout = 10, $cipher = self::CIPHER_3DES) { - $this->protocol_flags = array( + $this->protocol_flags = [ 1 => 'NET_SSH1_MSG_DISCONNECT', 2 => 'NET_SSH1_SMSG_PUBLIC_KEY', 3 => 'NET_SSH1_CMSG_SESSION_KEY', @@ -525,7 +525,7 @@ class SSH1 19 => 'NET_SSH1_CMSG_EOF', 20 => 'NET_SSH1_SMSG_EXITSTATUS', 33 => 'NET_SSH1_CMSG_EXIT_CONFIRMATION' - ); + ]; $this->_define_array($this->protocol_flags); @@ -619,32 +619,32 @@ class SSH1 if ($server_key_public_modulus->compare($host_key_public_modulus) < 0) { $double_encrypted_session_key = $this->_rsa_crypt( $double_encrypted_session_key, - array( + [ $server_key_public_exponent, $server_key_public_modulus - ) + ] ); $double_encrypted_session_key = $this->_rsa_crypt( $double_encrypted_session_key, - array( + [ $host_key_public_exponent, $host_key_public_modulus - ) + ] ); } else { $double_encrypted_session_key = $this->_rsa_crypt( $double_encrypted_session_key, - array( + [ $host_key_public_exponent, $host_key_public_modulus - ) + ] ); $double_encrypted_session_key = $this->_rsa_crypt( $double_encrypted_session_key, - array( + [ $server_key_public_exponent, $server_key_public_modulus - ) + ] ); } @@ -984,7 +984,7 @@ class SSH1 throw new \RuntimeException('Unable to initiate an interactive shell session'); } - $read = array($this->fsock); + $read = [$this->fsock]; $write = $except = null; if (stream_select($read, $write, $except, 0)) { $response = $this->_get_binary_packet(); @@ -1031,7 +1031,7 @@ class SSH1 /* $response = $this->_get_binary_packet(); if ($response === true) { - $response = array(self::RESPONSE_TYPE => -1); + $response = [self::RESPONSE_TYPE => -1]; } switch ($response[self::RESPONSE_TYPE]) { case NET_SSH1_SMSG_EXITSTATUS: @@ -1069,7 +1069,7 @@ class SSH1 } if ($this->curTimeout) { - $read = array($this->fsock); + $read = [$this->fsock]; $write = $except = null; $start = strtok(microtime(), ' ') + strtok(''); // http://php.net/microtime#61838 @@ -1122,10 +1122,10 @@ class SSH1 $this->_append_log($temp, $data); } - return array( + return [ self::RESPONSE_TYPE => $type, self::RESPONSE_DATA => $data - ); + ]; } /** @@ -1188,7 +1188,7 @@ class SSH1 */ function _crc($data) { - static $crc_lookup_table = array( + static $crc_lookup_table = [ 0x00000000, 0x77073096, 0xEE0E612C, 0x990951BA, 0x076DC419, 0x706AF48F, 0xE963A535, 0x9E6495A3, 0x0EDB8832, 0x79DCB8A4, 0xE0D5E91E, 0x97D2D988, @@ -1253,7 +1253,7 @@ class SSH1 0xBAD03605, 0xCDD70693, 0x54DE5729, 0x23D967BF, 0xB3667A2E, 0xC4614AB8, 0x5D681B02, 0x2A6F2B94, 0xB40BBE37, 0xC30C8EA1, 0x5A05DF1B, 0x2D02EF8D - ); + ]; // For this function to yield the same output as PHP's crc32 function, $crc would have to be // set to 0xFFFFFFFF, initially - not 0x00000000 as it currently is. @@ -1394,7 +1394,7 @@ class SSH1 $output.= str_pad(dechex($j), 7, '0', STR_PAD_LEFT) . '0 '; } $fragment = Strings::shift($current_log, $this->log_short_width); - $hex = substr(preg_replace_callback('#.#s', array($this, '_format_log_helper'), $fragment), strlen($this->log_boundary)); + $hex = substr(preg_replace_callback('#.#s', [$this, '_format_log_helper'], $fragment), strlen($this->log_boundary)); // replace non ASCII printable characters with dots // http://en.wikipedia.org/wiki/ASCII#ASCII_printable_characters // also replace < with a . since < messes up the output on web browsers @@ -1486,8 +1486,8 @@ class SSH1 * Return a list of ciphers supported by SSH1 server. * * Just because a cipher is supported by an SSH1 server doesn't mean it's supported by this library. If $raw_output - * is set to true, returns, instead, an array of constants. ie. instead of array('Triple-DES in CBC mode'), you'll - * get array(self::CIPHER_3DES). + * is set to true, returns, instead, an array of constants. ie. instead of ['Triple-DES in CBC mode'], you'll + * get [self::CIPHER_3DES]. * * @param bool $raw_output * @return array @@ -1502,8 +1502,8 @@ class SSH1 * Return a list of authentications supported by SSH1 server. * * Just because a cipher is supported by an SSH1 server doesn't mean it's supported by this library. If $raw_output - * is set to true, returns, instead, an array of constants. ie. instead of array('password authentication'), you'll - * get array(self::AUTH_PASSWORD). + * is set to true, returns, instead, an array of constants. ie. instead of ['password authentication'], you'll + * get [self::AUTH_PASSWORD]. * * @param bool $raw_output * @return array @@ -1555,7 +1555,7 @@ class SSH1 // passwords won't be filtered out and select other packets may not be correctly // identified case self::LOG_REALTIME: - echo "
\r\n" . $this->_format_log(array($message), array($protocol_flags)) . "\r\n
\r\n"; + echo "
\r\n" . $this->_format_log([$message], [$protocol_flags]) . "\r\n
\r\n"; @flush(); @ob_flush(); break; @@ -1573,7 +1573,7 @@ class SSH1 if (!is_resource($this->realtime_log_file)) { break; } - $entry = $this->_format_log(array($message), array($protocol_flags)); + $entry = $this->_format_log([$message], [$protocol_flags]); if ($this->realtime_log_wrap) { $temp = "<<< START >>>\r\n"; $entry.= $temp; diff --git a/phpseclib/Net/SSH2.php b/phpseclib/Net/SSH2.php index 13349b3d..961c9f0c 100644 --- a/phpseclib/Net/SSH2.php +++ b/phpseclib/Net/SSH2.php @@ -184,7 +184,7 @@ class SSH2 * @var string * @access private */ - var $errors = array(); + var $errors = []; /** * Server Identifier @@ -430,7 +430,7 @@ class SSH2 * @var array * @access private */ - var $message_numbers = array(); + var $message_numbers = []; /** * Disconnection Message 'reason codes' defined in RFC4253 @@ -439,7 +439,7 @@ class SSH2 * @var array * @access private */ - var $disconnect_reasons = array(); + var $disconnect_reasons = []; /** * SSH_MSG_CHANNEL_OPEN_FAILURE 'reason codes', defined in RFC4254 @@ -448,7 +448,7 @@ class SSH2 * @var array * @access private */ - var $channel_open_failure_reasons = array(); + var $channel_open_failure_reasons = []; /** * Terminal Modes @@ -458,7 +458,7 @@ class SSH2 * @var array * @access private */ - var $terminal_modes = array(); + var $terminal_modes = []; /** * SSH_MSG_CHANNEL_EXTENDED_DATA's data_type_codes @@ -468,7 +468,7 @@ class SSH2 * @var array * @access private */ - var $channel_extended_data_type_codes = array(); + var $channel_extended_data_type_codes = []; /** * Send Sequence Number @@ -502,7 +502,7 @@ class SSH2 * @var array * @access private */ - var $server_channels = array(); + var $server_channels = []; /** * Channel Buffers @@ -515,7 +515,7 @@ class SSH2 * @var array * @access private */ - var $channel_buffers = array(); + var $channel_buffers = []; /** * Channel Status @@ -526,7 +526,7 @@ class SSH2 * @var array * @access private */ - var $channel_status = array(); + var $channel_status = []; /** * Packet Size @@ -537,7 +537,7 @@ class SSH2 * @var array * @access private */ - var $packet_size_client_to_server = array(); + var $packet_size_client_to_server = []; /** * Message Number Log @@ -546,7 +546,7 @@ class SSH2 * @var array * @access private */ - var $message_number_log = array(); + var $message_number_log = []; /** * Message Log @@ -555,7 +555,7 @@ class SSH2 * @var array * @access private */ - var $message_log = array(); + var $message_log = []; /** * The Window Size @@ -578,7 +578,7 @@ class SSH2 * @var array * @access private */ - var $window_size_server_to_client = array(); + var $window_size_server_to_client = []; /** * Window size, client to server @@ -589,7 +589,7 @@ class SSH2 * @var array * @access private */ - var $window_size_client_to_server = array(); + var $window_size_client_to_server = []; /** * Server signature @@ -758,7 +758,7 @@ class SSH2 * @var array * @access private */ - var $keyboard_requests_responses = array(); + var $keyboard_requests_responses = []; /** * Banner Message @@ -891,7 +891,7 @@ class SSH2 */ function __construct($host, $port = 22, $timeout = 10) { - $this->message_numbers = array( + $this->message_numbers = [ 1 => 'NET_SSH2_MSG_DISCONNECT', 2 => 'NET_SSH2_MSG_IGNORE', 3 => 'NET_SSH2_MSG_UNIMPLEMENTED', @@ -921,8 +921,8 @@ class SSH2 98 => 'NET_SSH2_MSG_CHANNEL_REQUEST', 99 => 'NET_SSH2_MSG_CHANNEL_SUCCESS', 100 => 'NET_SSH2_MSG_CHANNEL_FAILURE' - ); - $this->disconnect_reasons = array( + ]; + $this->disconnect_reasons = [ 1 => 'NET_SSH2_DISCONNECT_HOST_NOT_ALLOWED_TO_CONNECT', 2 => 'NET_SSH2_DISCONNECT_PROTOCOL_ERROR', 3 => 'NET_SSH2_DISCONNECT_KEY_EXCHANGE_FAILED', @@ -938,16 +938,16 @@ class SSH2 13 => 'NET_SSH2_DISCONNECT_AUTH_CANCELLED_BY_USER', 14 => 'NET_SSH2_DISCONNECT_NO_MORE_AUTH_METHODS_AVAILABLE', 15 => 'NET_SSH2_DISCONNECT_ILLEGAL_USER_NAME' - ); - $this->channel_open_failure_reasons = array( + ]; + $this->channel_open_failure_reasons = [ 1 => 'NET_SSH2_OPEN_ADMINISTRATIVELY_PROHIBITED' - ); - $this->terminal_modes = array( + ]; + $this->terminal_modes = [ 0 => 'NET_SSH2_TTY_OP_END' - ); - $this->channel_extended_data_type_codes = array( + ]; + $this->channel_extended_data_type_codes = [ 1 => 'NET_SSH2_EXTENDED_DATA_STDERR' - ); + ]; $this->_define_array( $this->message_numbers, @@ -955,19 +955,19 @@ class SSH2 $this->channel_open_failure_reasons, $this->terminal_modes, $this->channel_extended_data_type_codes, - array(60 => 'NET_SSH2_MSG_USERAUTH_PASSWD_CHANGEREQ'), - array(60 => 'NET_SSH2_MSG_USERAUTH_PK_OK'), - array(60 => 'NET_SSH2_MSG_USERAUTH_INFO_REQUEST', - 61 => 'NET_SSH2_MSG_USERAUTH_INFO_RESPONSE'), + [60 => 'NET_SSH2_MSG_USERAUTH_PASSWD_CHANGEREQ'], + [60 => 'NET_SSH2_MSG_USERAUTH_PK_OK'], + [60 => 'NET_SSH2_MSG_USERAUTH_INFO_REQUEST', + 61 => 'NET_SSH2_MSG_USERAUTH_INFO_RESPONSE'], // RFC 4419 - diffie-hellman-group-exchange-sha{1,256} - array(30 => 'NET_SSH2_MSG_KEXDH_GEX_REQUEST_OLD', + [30 => 'NET_SSH2_MSG_KEXDH_GEX_REQUEST_OLD', 31 => 'NET_SSH2_MSG_KEXDH_GEX_GROUP', 32 => 'NET_SSH2_MSG_KEXDH_GEX_INIT', 33 => 'NET_SSH2_MSG_KEXDH_GEX_REPLY', - 34 => 'NET_SSH2_MSG_KEXDH_GEX_REQUEST'), + 34 => 'NET_SSH2_MSG_KEXDH_GEX_REQUEST'], // RFC 5656 - Elliptic Curves (for curve25519-sha256@libssh.org) - array(30 => 'NET_SSH2_MSG_KEX_ECDH_INIT', - 31 => 'NET_SSH2_MSG_KEX_ECDH_REPLY') + [30 => 'NET_SSH2_MSG_KEX_ECDH_INIT', + 31 => 'NET_SSH2_MSG_KEX_ECDH_REPLY'] ); self::$connections[$this->getResourceId()] = $this; @@ -1055,7 +1055,7 @@ class SSH2 $this->is_timeout = true; return false; } - $read = array($this->fsock); + $read = [$this->fsock]; $write = $except = null; $start = microtime(true); $sec = floor($this->curTimeout); @@ -1143,7 +1143,7 @@ class SSH2 { $identifier = 'SSH-2.0-phpseclib_2.0'; - $ext = array(); + $ext = []; if (extension_loaded('libsodium')) { $ext[] = 'libsodium'; } @@ -1178,7 +1178,7 @@ class SSH2 */ function _key_exchange($kexinit_payload_server) { - $kex_algorithms = array( + $kex_algorithms = [ // Elliptic Curve Diffie-Hellman Key Agreement (ECDH) using // Curve25519. See doc/curve25519-sha256@libssh.org.txt in the // libssh repository for more information. @@ -1190,20 +1190,20 @@ class SSH2 'diffie-hellman-group14-sha1', // REQUIRED 'diffie-hellman-group-exchange-sha1', // RFC 4419 'diffie-hellman-group-exchange-sha256', // RFC 4419 - ); + ]; if (!function_exists('\\Sodium\\library_version_major')) { $kex_algorithms = array_diff( $kex_algorithms, - array('curve25519-sha256@libssh.org') + ['curve25519-sha256@libssh.org'] ); } - $server_host_key_algorithms = array( + $server_host_key_algorithms = [ 'ssh-rsa', // RECOMMENDED sign Raw RSA Key 'ssh-dss' // REQUIRED sign Raw DSS Key - ); + ]; - $encryption_algorithms = array( + $encryption_algorithms = [ // from : 'arcfour256', 'arcfour128', @@ -1237,50 +1237,50 @@ class SSH2 '3des-cbc', // REQUIRED three-key 3DES in CBC mode //'none' // OPTIONAL no encryption; NOT RECOMMENDED - ); + ]; if (extension_loaded('openssl') && !extension_loaded('mcrypt')) { // OpenSSL does not support arcfour256 in any capacity and arcfour128 / arcfour support is limited to // instances that do not use continuous buffers $encryption_algorithms = array_diff( $encryption_algorithms, - array('arcfour256', 'arcfour128', 'arcfour') + ['arcfour256', 'arcfour128', 'arcfour'] ); } if (class_exists('\phpseclib\Crypt\RC4') === false) { $encryption_algorithms = array_diff( $encryption_algorithms, - array('arcfour256', 'arcfour128', 'arcfour') + ['arcfour256', 'arcfour128', 'arcfour'] ); } if (class_exists('\phpseclib\Crypt\Rijndael') === false) { $encryption_algorithms = array_diff( $encryption_algorithms, - array('aes128-ctr', 'aes192-ctr', 'aes256-ctr', 'aes128-cbc', 'aes192-cbc', 'aes256-cbc') + ['aes128-ctr', 'aes192-ctr', 'aes256-ctr', 'aes128-cbc', 'aes192-cbc', 'aes256-cbc'] ); } if (class_exists('\phpseclib\Crypt\Twofish') === false) { $encryption_algorithms = array_diff( $encryption_algorithms, - array('twofish128-ctr', 'twofish192-ctr', 'twofish256-ctr', 'twofish128-cbc', 'twofish192-cbc', 'twofish256-cbc', 'twofish-cbc') + ['twofish128-ctr', 'twofish192-ctr', 'twofish256-ctr', 'twofish128-cbc', 'twofish192-cbc', 'twofish256-cbc', 'twofish-cbc'] ); } if (class_exists('\phpseclib\Crypt\Blowfish') === false) { $encryption_algorithms = array_diff( $encryption_algorithms, - array('blowfish-ctr', 'blowfish-cbc') + ['blowfish-ctr', 'blowfish-cbc'] ); } if (class_exists('\phpseclib\Crypt\TripleDES') === false) { $encryption_algorithms = array_diff( $encryption_algorithms, - array('3des-ctr', '3des-cbc') + ['3des-ctr', '3des-cbc'] ); } $encryption_algorithms = array_values($encryption_algorithms); - $mac_algorithms = array( + $mac_algorithms = [ // from : 'hmac-sha2-256',// RECOMMENDED HMAC-SHA256 (digest length = key length = 32) @@ -1289,19 +1289,19 @@ class SSH2 'hmac-md5-96', // OPTIONAL first 96 bits of HMAC-MD5 (digest length = 12, key length = 16) 'hmac-md5', // OPTIONAL HMAC-MD5 (digest length = key length = 16) //'none' // OPTIONAL no MAC; NOT RECOMMENDED - ); + ]; - $compression_algorithms = array( + $compression_algorithms = [ 'none' // REQUIRED no compression //'zlib' // OPTIONAL ZLIB (LZ77) compression - ); + ]; // some SSH servers have buggy implementations of some of the above algorithms switch ($this->server_identifier) { case 'SSH-2.0-SSHD': $mac_algorithms = array_values(array_diff( $mac_algorithms, - array('hmac-sha1-96', 'hmac-md5-96') + ['hmac-sha1-96', 'hmac-md5-96'] )); } @@ -1882,7 +1882,7 @@ class SSH2 function login($username) { $args = func_get_args(); - return call_user_func_array(array(&$this, '_login'), $args); + return call_user_func_array([&$this, '_login'], $args); } /** @@ -2274,10 +2274,10 @@ class SSH2 return false; } - $publickey = array( + $publickey = [ 'e' => $publickey['e']->toBytes(true), 'n' => $publickey['n']->toBytes(true) - ); + ]; $publickey = pack( 'Na*Na*Na*', strlen('ssh-rsa'), @@ -3206,7 +3206,7 @@ class SSH2 return true; } - $read = array($this->fsock); + $read = [$this->fsock]; $write = $except = null; $start = microtime(true); @@ -3319,7 +3319,7 @@ class SSH2 return $data; } if (!isset($this->channel_buffers[$channel])) { - $this->channel_buffers[$channel] = array(); + $this->channel_buffers[$channel] = []; } $this->channel_buffers[$channel][] = $data; break; @@ -3340,7 +3340,7 @@ class SSH2 return $data; } if (!isset($this->channel_buffers[$channel])) { - $this->channel_buffers[$channel] = array(); + $this->channel_buffers[$channel] = []; } $this->channel_buffers[$channel][] = $data; break; @@ -3503,7 +3503,7 @@ class SSH2 $start = '
';
                         $stop = '
'; } - echo $start . $this->_format_log(array($message), array($message_number)) . $stop; + echo $start . $this->_format_log([$message], [$message_number]) . $stop; @flush(); @ob_flush(); break; @@ -3521,7 +3521,7 @@ class SSH2 if (!is_resource($this->realtime_log_file)) { break; } - $entry = $this->_format_log(array($message), array($message_number)); + $entry = $this->_format_log([$message], [$message_number]); if ($this->realtime_log_wrap) { $temp = "<<< START >>>\r\n"; $entry.= $temp; @@ -3709,7 +3709,7 @@ class SSH2 $output.= str_pad(dechex($j), 7, '0', STR_PAD_LEFT) . '0 '; } $fragment = Strings::shift($current_log, $this->log_short_width); - $hex = substr(preg_replace_callback('#.#s', array($this, '_format_log_helper'), $fragment), strlen($this->log_boundary)); + $hex = substr(preg_replace_callback('#.#s', [$this, '_format_log_helper'], $fragment), strlen($this->log_boundary)); // replace non ASCII printable characters with dots // http://en.wikipedia.org/wiki/ASCII#ASCII_printable_characters // also replace < with a . since < messes up the output on web browsers @@ -4060,7 +4060,7 @@ class SSH2 $signature = Strings::shift($signature, $temp['length']); $rsa = new RSA(); - $rsa->load(array('e' => $e, 'n' => $n), 'raw'); + $rsa->load(['e' => $e, 'n' => $n], 'raw'); $rsa->setHash('sha1'); if (!$rsa->verify($this->exchange_hash, $signature, RSA::PADDING_PKCS1)) { //user_error('Bad server signature'); diff --git a/phpseclib/System/SSH/Agent.php b/phpseclib/System/SSH/Agent.php index 23bf027a..2bf638d2 100644 --- a/phpseclib/System/SSH/Agent.php +++ b/phpseclib/System/SSH/Agent.php @@ -153,7 +153,7 @@ class Agent function requestIdentities() { if (!$this->fsock) { - return array(); + return []; } $packet = pack('NC', 1, self::SSH_AGENTC_REQUEST_IDENTITIES); @@ -167,7 +167,7 @@ class Agent throw new \RuntimeException('Unable to request identities'); } - $identities = array(); + $identities = []; $keyCount = current(unpack('N', fread($this->fsock, 4))); for ($i = 0; $i < $keyCount; $i++) { $length = current(unpack('N', fread($this->fsock, 4)));