From ea9f6540f3ea4be1b517f116c0e0d728a4c319e2 Mon Sep 17 00:00:00 2001 From: Jack Worman Date: Wed, 16 Feb 2022 20:25:59 -0600 Subject: [PATCH 1/3] PSR12 fixes PSR12 fixes --- .travis.yml | 2 +- README.md | 6 +- build/build.xml | 25 - build/code-sniffer-ruleset-tests.xml | 17 - build/code-sniffer-ruleset.xml | 35 - build/composer.json | 1 + build/phpcs_ruleset.xml | 22 + composer.json | 4 +- phpseclib/Common/Functions/Strings.php | 34 +- phpseclib/Crypt/Blowfish.php | 32 +- phpseclib/Crypt/ChaCha20.php | 1018 +++++++++++------ phpseclib/Crypt/Common/AsymmetricKey.php | 8 +- .../Crypt/Common/Formats/Keys/OpenSSH.php | 2 +- phpseclib/Crypt/Common/Formats/Keys/PKCS.php | 2 +- phpseclib/Crypt/Common/Formats/Keys/PKCS1.php | 6 +- phpseclib/Crypt/Common/Formats/Keys/PKCS8.php | 19 +- phpseclib/Crypt/Common/Formats/Keys/PuTTY.php | 40 +- phpseclib/Crypt/Common/SymmetricKey.php | 332 +++--- phpseclib/Crypt/Common/Traits/Fingerprint.php | 2 +- phpseclib/Crypt/DES.php | 8 +- phpseclib/Crypt/DH.php | 13 +- phpseclib/Crypt/DH/Formats/Keys/PKCS8.php | 2 +- phpseclib/Crypt/DSA.php | 18 +- .../Crypt/DSA/Formats/Signature/SSH2.php | 4 +- phpseclib/Crypt/EC.php | 14 +- .../Crypt/EC/BaseCurves/KoblitzPrime.php | 7 +- phpseclib/Crypt/EC/BaseCurves/Montgomery.php | 2 +- phpseclib/Crypt/EC/BaseCurves/Prime.php | 52 +- .../Crypt/EC/BaseCurves/TwistedEdwards.php | 2 +- phpseclib/Crypt/EC/Curves/Curve25519.php | 6 +- phpseclib/Crypt/EC/Curves/Curve448.php | 12 +- phpseclib/Crypt/EC/Curves/Ed448.php | 12 +- phpseclib/Crypt/EC/Curves/brainpoolP160r1.php | 2 +- phpseclib/Crypt/EC/Curves/brainpoolP160t1.php | 2 +- phpseclib/Crypt/EC/Curves/brainpoolP192r1.php | 2 +- phpseclib/Crypt/EC/Curves/brainpoolP192t1.php | 2 +- phpseclib/Crypt/EC/Curves/brainpoolP224r1.php | 2 +- phpseclib/Crypt/EC/Curves/brainpoolP224t1.php | 2 +- phpseclib/Crypt/EC/Curves/brainpoolP256r1.php | 2 +- phpseclib/Crypt/EC/Curves/brainpoolP320r1.php | 2 +- phpseclib/Crypt/EC/Curves/brainpoolP320t1.php | 2 +- phpseclib/Crypt/EC/Curves/brainpoolP384r1.php | 26 +- phpseclib/Crypt/EC/Curves/brainpoolP384t1.php | 26 +- phpseclib/Crypt/EC/Curves/brainpoolP512r1.php | 26 +- phpseclib/Crypt/EC/Curves/brainpoolP512t1.php | 26 +- phpseclib/Crypt/EC/Curves/nistb233.php | 2 +- phpseclib/Crypt/EC/Curves/nistb409.php | 2 +- phpseclib/Crypt/EC/Curves/nistk163.php | 2 +- phpseclib/Crypt/EC/Curves/nistk233.php | 2 +- phpseclib/Crypt/EC/Curves/nistk283.php | 2 +- phpseclib/Crypt/EC/Curves/nistk409.php | 2 +- phpseclib/Crypt/EC/Curves/nistp192.php | 2 +- phpseclib/Crypt/EC/Curves/nistp224.php | 2 +- phpseclib/Crypt/EC/Curves/nistp256.php | 2 +- phpseclib/Crypt/EC/Curves/nistp384.php | 2 +- phpseclib/Crypt/EC/Curves/nistp521.php | 2 +- phpseclib/Crypt/EC/Curves/nistt571.php | 2 +- phpseclib/Crypt/EC/Curves/prime192v1.php | 2 +- phpseclib/Crypt/EC/Curves/prime192v2.php | 2 +- phpseclib/Crypt/EC/Curves/prime192v3.php | 2 +- phpseclib/Crypt/EC/Curves/prime239v1.php | 2 +- phpseclib/Crypt/EC/Curves/prime239v2.php | 2 +- phpseclib/Crypt/EC/Curves/prime239v3.php | 2 +- phpseclib/Crypt/EC/Curves/prime256v1.php | 2 +- phpseclib/Crypt/EC/Curves/secp112r1.php | 2 +- phpseclib/Crypt/EC/Curves/secp112r2.php | 2 +- phpseclib/Crypt/EC/Curves/secp128r1.php | 2 +- phpseclib/Crypt/EC/Curves/secp128r2.php | 2 +- phpseclib/Crypt/EC/Curves/secp160k1.php | 2 +- phpseclib/Crypt/EC/Curves/secp160r1.php | 2 +- phpseclib/Crypt/EC/Curves/secp160r2.php | 2 +- phpseclib/Crypt/EC/Curves/secp192k1.php | 2 +- phpseclib/Crypt/EC/Curves/secp192r1.php | 4 +- phpseclib/Crypt/EC/Curves/secp224k1.php | 2 +- phpseclib/Crypt/EC/Curves/secp256k1.php | 2 +- phpseclib/Crypt/EC/Curves/secp384r1.php | 2 +- phpseclib/Crypt/EC/Curves/secp521r1.php | 2 +- phpseclib/Crypt/EC/Curves/sect113r1.php | 2 +- phpseclib/Crypt/EC/Curves/sect113r2.php | 2 +- phpseclib/Crypt/EC/Curves/sect131r1.php | 2 +- phpseclib/Crypt/EC/Curves/sect131r2.php | 2 +- phpseclib/Crypt/EC/Curves/sect163k1.php | 2 +- phpseclib/Crypt/EC/Curves/sect163r1.php | 2 +- phpseclib/Crypt/EC/Curves/sect409k1.php | 3 +- phpseclib/Crypt/EC/Curves/sect409r1.php | 3 +- phpseclib/Crypt/EC/Curves/sect571k1.php | 3 +- phpseclib/Crypt/EC/Curves/sect571r1.php | 3 +- phpseclib/Crypt/EC/Formats/Keys/Common.php | 4 +- .../EC/Formats/Keys/MontgomeryPrivate.php | 4 +- .../EC/Formats/Keys/MontgomeryPublic.php | 4 +- phpseclib/Crypt/EC/Formats/Keys/OpenSSH.php | 4 +- phpseclib/Crypt/EC/Formats/Keys/PuTTY.php | 2 +- phpseclib/Crypt/EC/Formats/Keys/XML.php | 10 +- phpseclib/Crypt/Hash.php | 56 +- phpseclib/Crypt/PublicKeyLoader.php | 12 +- phpseclib/Crypt/RC2.php | 2 +- phpseclib/Crypt/RSA.php | 22 +- phpseclib/Crypt/RSA/Formats/Keys/MSBLOB.php | 20 +- phpseclib/Crypt/RSA/Formats/Keys/PKCS1.php | 2 +- phpseclib/Crypt/RSA/Formats/Keys/Raw.php | 14 +- phpseclib/Crypt/RSA/PrivateKey.php | 8 +- phpseclib/Crypt/RSA/PublicKey.php | 6 +- phpseclib/Crypt/Random.php | 2 +- phpseclib/Crypt/Rijndael.php | 93 +- phpseclib/Crypt/Salsa20.php | 46 +- phpseclib/Crypt/TripleDES.php | 6 +- phpseclib/Crypt/Twofish.php | 68 +- phpseclib/File/ANSI.php | 36 +- phpseclib/File/ASN1.php | 58 +- phpseclib/File/ASN1/Maps/Attribute.php | 2 +- .../File/ASN1/Maps/AttributeTypeAndValue.php | 2 +- .../File/ASN1/Maps/Characteristic_two.php | 2 +- phpseclib/File/ASN1/Maps/DSAPrivateKey.php | 2 +- phpseclib/File/ASN1/Maps/FieldID.php | 2 +- phpseclib/File/ASN1/Maps/HashAlgorithm.php | 2 +- .../ASN1/Maps/IssuingDistributionPoint.php | 2 +- phpseclib/File/ASN1/Maps/MaskGenAlgorithm.php | 2 +- phpseclib/File/ASN1/Maps/OneAsymmetricKey.php | 2 +- phpseclib/File/ASN1/Maps/PBES2params.php | 2 +- phpseclib/File/ASN1/Maps/PBKDF2params.php | 4 +- phpseclib/File/ASN1/Maps/PBMAC1params.php | 4 +- phpseclib/File/ASN1/Maps/PKCS9String.php | 6 +- phpseclib/File/ASN1/Maps/Pentanomial.php | 2 +- phpseclib/File/ASN1/Maps/Prime_p.php | 2 +- phpseclib/File/ASN1/Maps/PrivateKeyInfo.php | 2 +- phpseclib/File/ASN1/Maps/PublicKeyInfo.php | 2 +- phpseclib/File/ASN1/Maps/RC2CBCParameter.php | 4 +- phpseclib/File/ASN1/Maps/Trinomial.php | 2 +- phpseclib/File/X509.php | 26 +- phpseclib/Math/BigInteger.php | 32 +- phpseclib/Math/BigInteger/Engines/BCMath.php | 32 +- .../Math/BigInteger/Engines/BCMath/Base.php | 2 +- .../BigInteger/Engines/BCMath/BuiltIn.php | 2 +- .../Engines/BCMath/DefaultEngine.php | 2 +- .../BigInteger/Engines/BCMath/OpenSSL.php | 2 +- .../Engines/BCMath/Reductions/Barrett.php | 2 +- .../Engines/BCMath/Reductions/EvalBarrett.php | 6 +- phpseclib/Math/BigInteger/Engines/Engine.php | 14 +- phpseclib/Math/BigInteger/Engines/GMP.php | 20 +- .../BigInteger/Engines/GMP/DefaultEngine.php | 2 +- phpseclib/Math/BigInteger/Engines/OpenSSL.php | 2 +- phpseclib/Math/BigInteger/Engines/PHP.php | 96 +- .../Math/BigInteger/Engines/PHP/Base.php | 4 +- .../BigInteger/Engines/PHP/DefaultEngine.php | 2 +- .../BigInteger/Engines/PHP/Montgomery.php | 4 +- .../Math/BigInteger/Engines/PHP/OpenSSL.php | 2 +- .../Engines/PHP/Reductions/Barrett.php | 4 +- .../Engines/PHP/Reductions/Classic.php | 2 +- .../Engines/PHP/Reductions/EvalBarrett.php | 134 +-- .../Engines/PHP/Reductions/Montgomery.php | 2 +- .../Engines/PHP/Reductions/MontgomeryMult.php | 3 +- .../Engines/PHP/Reductions/PowerOfTwo.php | 2 +- phpseclib/Math/BigInteger/Engines/PHP32.php | 9 +- phpseclib/Math/BigInteger/Engines/PHP64.php | 13 +- phpseclib/Math/BinaryField.php | 6 +- phpseclib/Math/BinaryField/Integer.php | 12 +- phpseclib/Math/Common/FiniteField.php | 2 +- phpseclib/Math/Common/FiniteField/Integer.php | 2 +- phpseclib/Math/PrimeField.php | 2 +- phpseclib/Math/PrimeField/Integer.php | 2 +- phpseclib/Net/SFTP.php | 72 +- phpseclib/Net/SFTP/Stream.php | 18 +- phpseclib/Net/SSH2.php | 140 +-- phpseclib/System/SSH/Agent.php | 4 +- phpseclib/bootstrap.php | 1 + tests/Functional/Net/SFTPUserStoryTest.php | 20 +- tests/Functional/Net/SFTPWrongServerTest.php | 4 +- tests/Functional/Net/SSH2AgentTest.php | 2 +- tests/PhpseclibFunctionalTestCase.php | 1 + tests/PhpseclibTestCase.php | 1 + tests/Unit/Crypt/AES/EvalTest.php | 1 + tests/Unit/Crypt/AES/McryptTest.php | 1 + tests/Unit/Crypt/AES/OpenSSLTest.php | 1 + tests/Unit/Crypt/AES/PurePHPTest.php | 1 + tests/Unit/Crypt/AES/TestCase.php | 9 +- tests/Unit/Crypt/BlowfishTest.php | 1 + tests/Unit/Crypt/ChaCha20Test.php | 5 +- tests/Unit/Crypt/DHTest.php | 10 +- tests/Unit/Crypt/DSA/LoadDSAKeyTest.php | 1 + tests/Unit/Crypt/EC/CurveTest.php | 4 +- tests/Unit/Crypt/EC/KeyTest.php | 2 +- tests/Unit/Crypt/GCMTest.php | 1 + tests/Unit/Crypt/HashTest.php | 1 + tests/Unit/Crypt/RC2Test.php | 5 +- tests/Unit/Crypt/RC4Test.php | 1 + tests/Unit/Crypt/RSA/LoadKeyTest.php | 15 +- tests/Unit/Crypt/RSA/ModeTest.php | 1 + tests/Unit/Crypt/RandomTest.php | 1 + tests/Unit/Crypt/Salsa20Test.php | 1 + tests/Unit/Crypt/TripleDESTest.php | 3 +- tests/Unit/Crypt/TwofishTest.php | 1 + tests/Unit/File/ANSITest.php | 29 +- tests/Unit/File/ASN1Test.php | 1 + tests/Unit/File/X509/CRLTest.php | 1 + tests/Unit/File/X509/CSRTest.php | 5 +- tests/Unit/File/X509/SPKACTest.php | 1 + tests/Unit/File/X509/X509ExtensionTest.php | 1 + tests/Unit/File/X509/X509Test.php | 11 +- tests/Unit/Math/BigInteger/BCMathTest.php | 1 + tests/Unit/Math/BigInteger/DefaultTest.php | 1 + tests/Unit/Math/BigInteger/GMPTest.php | 1 + tests/Unit/Math/BigInteger/PHP32Test.php | 1 + .../Unit/Math/BigInteger/PHP64OpenSSLTest.php | 1 + tests/Unit/Math/BigInteger/PHP64Test.php | 1 + tests/Unit/Math/BigInteger/TestCase.php | 11 +- tests/Unit/Math/BigIntegerTest.php | 102 +- tests/Unit/Net/SFTPStreamUnitTest.php | 1 + tests/bootstrap.php | 1 + 208 files changed, 1940 insertions(+), 1504 deletions(-) delete mode 100644 build/build.xml delete mode 100644 build/code-sniffer-ruleset-tests.xml delete mode 100644 build/code-sniffer-ruleset.xml create mode 100644 build/phpcs_ruleset.xml diff --git a/.travis.yml b/.travis.yml index 27ef1e35..66d41680 100644 --- a/.travis.yml +++ b/.travis.yml @@ -33,7 +33,7 @@ install: - travis/setup-composer.sh script: - - sh -c "if [ '$TRAVIS_PHP_VERSION' = '5.5' ]; then vendor/bin/phing -f build/build.xml sniff; fi" + - sh -c "if [ -d build/vendor ]; then build/vendor/bin/phpcs --standard=build/phpcs_ruleset.xml; fi" - sh -c "if [ -d build/vendor ]; then build/vendor/bin/php-cs-fixer fix --config=build/php-cs-fixer.php --diff --dry-run; fi" - sh -c "if [ -d build/vendor ]; then build/vendor/bin/psalm --config="build/psalm.xml" --no-cache --long-progress --report-show-info=false --output-format=text; fi" - travis/run-phpunit.sh diff --git a/README.md b/README.md index 774bba96..b5853c8b 100644 --- a/README.md +++ b/README.md @@ -82,6 +82,7 @@ Special Thanks to our $50+ sponsors!: 3. Install Development Dependencies ```sh composer install + composer install --no-interaction --working-dir=build ``` 4. Create a Feature Branch @@ -89,10 +90,9 @@ Special Thanks to our $50+ sponsors!: 5. Run continuous integration checks: ```sh vendor/bin/phpunit - vendor/bin/phing -f build/build.xml sniff - # The following tools are from the build specific composer.json: - composer install --no-interaction --working-dir=build + # The following tools are from the build specific composer.json using the most recent PHP version: + build/vendor/bin/phpcs --standard=build/phpcs_ruleset.xml build/vendor/bin/php-cs-fixer fix --config=build/php-cs-fixer.php --diff --dry-run build/vendor/bin/psalm --config=build/psalm.xml --no-cache --long-progress --report-show-info=false --output-format=text ``` diff --git a/build/build.xml b/build/build.xml deleted file mode 100644 index 26ab24b8..00000000 --- a/build/build.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - - - - - - - - - diff --git a/build/code-sniffer-ruleset-tests.xml b/build/code-sniffer-ruleset-tests.xml deleted file mode 100644 index 8767eee9..00000000 --- a/build/code-sniffer-ruleset-tests.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - phpseclib coding standard for tests - - - - - - - - - - - - diff --git a/build/code-sniffer-ruleset.xml b/build/code-sniffer-ruleset.xml deleted file mode 100644 index 2e399139..00000000 --- a/build/code-sniffer-ruleset.xml +++ /dev/null @@ -1,35 +0,0 @@ - - - - phpseclib coding standard - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/build/composer.json b/build/composer.json index cf54ef9d..f8848b4b 100644 --- a/build/composer.json +++ b/build/composer.json @@ -6,6 +6,7 @@ "require": { "php": "^8.1.0", "friendsofphp/php-cs-fixer": "^3.5", + "squizlabs/php_codesniffer": "^3.6", "vimeo/psalm": "^4.19" }, "config": { diff --git a/build/phpcs_ruleset.xml b/build/phpcs_ruleset.xml new file mode 100644 index 00000000..1dee7de8 --- /dev/null +++ b/build/phpcs_ruleset.xml @@ -0,0 +1,22 @@ + + + ../build/php-cs-fixer.php + ../phpseclib/ + ../tests/ + + + + + + + + + + + + + + + + + diff --git a/composer.json b/composer.json index 34dc9993..d773bd89 100644 --- a/composer.json +++ b/composer.json @@ -56,9 +56,7 @@ "php": ">=5.6.1" }, "require-dev": { - "phing/phing": "~2.7", - "phpunit/phpunit": "^5.7|^6.0|^9.4", - "squizlabs/php_codesniffer": "~2.0" + "phpunit/phpunit": "^5.7|^6.0|^9.4" }, "suggest": { "ext-libsodium": "SSH2/SFTP can make use of some algorithms provided by the libsodium-php extension.", diff --git a/phpseclib/Common/Functions/Strings.php b/phpseclib/Common/Functions/Strings.php index 10314aed..23bb2428 100644 --- a/phpseclib/Common/Functions/Strings.php +++ b/phpseclib/Common/Functions/Strings.php @@ -130,7 +130,7 @@ abstract class Strings // you need > 32-bit precision doesn't mean you need the full 64-bit precision extract(unpack('Nupper/Nlower', self::shift($data, 8))); $temp = $upper ? 4294967296 * $upper : 0; - $temp+= $lower < 0 ? ($lower & 0x7FFFFFFFF) + 0x80000000 : $lower; + $temp += $lower < 0 ? ($lower & 0x7FFFFFFFF) + 0x80000000 : $lower; // $temp = hexdec(bin2hex(self::shift($data, 8))); $result[] = $temp; continue 2; @@ -177,20 +177,20 @@ abstract class Strings if (!is_int($element)) { throw new \InvalidArgumentException('Bytes must be represented as an integer between 0 and 255, inclusive.'); } - $result.= pack('C', $element); + $result .= pack('C', $element); break; case 'b': if (!is_bool($element)) { throw new \InvalidArgumentException('A boolean parameter was expected.'); } - $result.= $element ? "\1" : "\0"; + $result .= $element ? "\1" : "\0"; break; case 'Q': if (!is_int($element) && !is_float($element)) { throw new \InvalidArgumentException('An integer was expected.'); } // 4294967296 == 1 << 32 - $result.= pack('NN', $element / 4294967296, $element); + $result .= pack('NN', $element / 4294967296, $element); break; case 'N': if (is_float($element)) { @@ -199,27 +199,27 @@ abstract class Strings if (!is_int($element)) { throw new \InvalidArgumentException('An integer was expected.'); } - $result.= pack('N', $element); + $result .= pack('N', $element); break; case 's': if (!self::is_stringable($element)) { throw new \InvalidArgumentException('A string was expected.'); } - $result.= pack('Na*', strlen($element), $element); + $result .= pack('Na*', strlen($element), $element); break; case 'i': if (!$element instanceof BigInteger && !$element instanceof FiniteField\Integer) { throw new \InvalidArgumentException('A phpseclib3\Math\BigInteger or phpseclib3\Math\Common\FiniteField\Integer object was expected.'); } $element = $element->toBytes(true); - $result.= pack('Na*', strlen($element), $element); + $result .= pack('Na*', strlen($element), $element); break; case 'L': if (!is_array($element)) { throw new \InvalidArgumentException('An array was expected.'); } $element = implode(',', $element); - $result.= pack('Na*', strlen($element), $element); + $result .= pack('Na*', strlen($element), $element); break; default: throw new \InvalidArgumentException('$format contains an invalid character'); @@ -241,10 +241,10 @@ abstract class Strings { $parts = preg_split('#(\d+)#', $format, -1, PREG_SPLIT_DELIM_CAPTURE); $format = ''; - for ($i = 1; $i < count($parts); $i+=2) { - $format.= substr($parts[$i - 1], 0, -1) . str_repeat(substr($parts[$i - 1], -1), $parts[$i]); + for ($i = 1; $i < count($parts); $i += 2) { + $format .= substr($parts[$i - 1], 0, -1) . str_repeat(substr($parts[$i - 1], -1), $parts[$i]); } - $format.= $parts[$i - 1]; + $format .= $parts[$i - 1]; return $format; } @@ -293,7 +293,7 @@ abstract class Strings foreach ($parts as $part) { $xor = $part[0] == '1' ? PHP_INT_MIN : 0; $part[0] = '0'; - $str.= pack( + $str .= pack( PHP_INT_SIZE == 4 ? 'N' : 'J', $xor ^ eval('return 0b' . $part . ';') ); @@ -328,12 +328,12 @@ abstract class Strings if (PHP_INT_SIZE == 4) { $digits = unpack('N*', $x); foreach ($digits as $digit) { - $bits.= sprintf('%032b', $digit); + $bits .= sprintf('%032b', $digit); } } else { $digits = unpack('J*', $x); foreach ($digits as $digit) { - $bits.= sprintf('%064b', $digit); + $bits .= sprintf('%064b', $digit); } } @@ -355,13 +355,13 @@ abstract class Strings if (PHP_INT_SIZE === 8) { // 3 operations // from http://graphics.stanford.edu/~seander/bithacks.html#ReverseByteWith64BitsDiv - $r.= chr((($b * 0x0202020202) & 0x010884422010) % 1023); + $r .= chr((($b * 0x0202020202) & 0x010884422010) % 1023); } else { // 7 operations // from http://graphics.stanford.edu/~seander/bithacks.html#ReverseByteWith32Bits $p1 = ($b * 0x0802) & 0x22110; $p2 = ($b * 0x8020) & 0x88440; - $r.= chr( + $r .= chr( (($p1 | $p2) * 0x10101) >> 16 ); } @@ -385,7 +385,7 @@ abstract class Strings return $var; } - for ($i = 4; $i <= strlen($var); $i+= 4) { + for ($i = 4; $i <= strlen($var); $i += 4) { $temp = substr($var, -$i, 4); switch ($temp) { case "\xFF\xFF\xFF\xFF": diff --git a/phpseclib/Crypt/Blowfish.php b/phpseclib/Crypt/Blowfish.php index 417d5d28..9b14abab 100644 --- a/phpseclib/Crypt/Blowfish.php +++ b/phpseclib/Crypt/Blowfish.php @@ -422,14 +422,14 @@ class Blowfish extends BlockCipher $l = $in[1]; $r = $in[2]; - for ($i = 0; $i < 16; $i+= 2) { - $l^= $p[$i]; - $r^= self::safe_intval((self::safe_intval($sb_0[$l >> 24 & 0xff] + $sb_1[$l >> 16 & 0xff]) ^ + for ($i = 0; $i < 16; $i += 2) { + $l ^= $p[$i]; + $r ^= self::safe_intval((self::safe_intval($sb_0[$l >> 24 & 0xff] + $sb_1[$l >> 16 & 0xff]) ^ $sb_2[$l >> 8 & 0xff]) + $sb_3[$l & 0xff]); - $r^= $p[$i + 1]; - $l^= self::safe_intval((self::safe_intval($sb_0[$r >> 24 & 0xff] + $sb_1[$r >> 16 & 0xff]) ^ + $r ^= $p[$i + 1]; + $l ^= self::safe_intval((self::safe_intval($sb_0[$r >> 24 & 0xff] + $sb_1[$r >> 16 & 0xff]) ^ $sb_2[$r >> 8 & 0xff]) + $sb_3[$r & 0xff]); } @@ -455,14 +455,14 @@ class Blowfish extends BlockCipher $l = $in[1]; $r = $in[2]; - for ($i = 17; $i > 2; $i-= 2) { - $l^= $p[$i]; - $r^= self::safe_intval((self::safe_intval($sb_0[$l >> 24 & 0xff] + $sb_1[$l >> 16 & 0xff]) ^ + for ($i = 17; $i > 2; $i -= 2) { + $l ^= $p[$i]; + $r ^= self::safe_intval((self::safe_intval($sb_0[$l >> 24 & 0xff] + $sb_1[$l >> 16 & 0xff]) ^ $sb_2[$l >> 8 & 0xff]) + $sb_3[$l & 0xff]); - $r^= $p[$i - 1]; - $l^= self::safe_intval((self::safe_intval($sb_0[$r >> 24 & 0xff] + $sb_1[$r >> 16 & 0xff]) ^ + $r ^= $p[$i - 1]; + $l ^= self::safe_intval((self::safe_intval($sb_0[$r >> 24 & 0xff] + $sb_1[$r >> 16 & 0xff]) ^ $sb_2[$r >> 8 & 0xff]) + $sb_3[$r & 0xff]); } @@ -496,8 +496,8 @@ class Blowfish extends BlockCipher $l = $in[1]; $r = $in[2]; '; - for ($i = 0; $i < 16; $i+= 2) { - $encrypt_block.= ' + for ($i = 0; $i < 16; $i += 2) { + $encrypt_block .= ' $l^= ' . $p[$i] . '; $r^= ' . sprintf($safeint, '(' . sprintf($safeint, '$sb_0[$l >> 24 & 0xff] + $sb_1[$l >> 16 & 0xff]') . ' ^ $sb_2[$l >> 8 & 0xff]) + @@ -509,7 +509,7 @@ class Blowfish extends BlockCipher $sb_3[$r & 0xff]') . '; '; } - $encrypt_block.= ' + $encrypt_block .= ' $in = pack("N*", $r ^ ' . $p[17] . ', $l ^ ' . $p[16] . ' @@ -522,8 +522,8 @@ class Blowfish extends BlockCipher $r = $in[2]; '; - for ($i = 17; $i > 2; $i-= 2) { - $decrypt_block.= ' + for ($i = 17; $i > 2; $i -= 2) { + $decrypt_block .= ' $l^= ' . $p[$i] . '; $r^= ' . sprintf($safeint, '(' . sprintf($safeint, '$sb_0[$l >> 24 & 0xff] + $sb_1[$l >> 16 & 0xff]') . ' ^ $sb_2[$l >> 8 & 0xff]) + @@ -536,7 +536,7 @@ class Blowfish extends BlockCipher '; } - $decrypt_block.= ' + $decrypt_block .= ' $in = pack("N*", $r ^ ' . $p[0] . ', $l ^ ' . $p[1] . ' diff --git a/phpseclib/Crypt/ChaCha20.php b/phpseclib/Crypt/ChaCha20.php index 83686f19..dc77136b 100644 --- a/phpseclib/Crypt/ChaCha20.php +++ b/phpseclib/Crypt/ChaCha20.php @@ -258,7 +258,7 @@ class ChaCha20 extends Salsa20 $key = $this->key; if (strlen($key) == 16) { $constant = 'expand 16-byte k'; - $key.= $key; + $key .= $key; } else { $constant = 'expand 32-byte k'; } @@ -280,10 +280,14 @@ class ChaCha20 extends Salsa20 */ protected static function quarterRound(&$a, &$b, &$c, &$d) { - $a+= $b; $d = self::leftRotate($d ^ $a, 16); - $c+= $d; $b = self::leftRotate($b ^ $c, 12); - $a+= $b; $d = self::leftRotate($d ^ $a, 8); - $c+= $d; $b = self::leftRotate($b ^ $c, 7); + $a += $b; + $d = self::leftRotate($d ^ $a, 16); + $c += $d; + $b = self::leftRotate($b ^ $c, 12); + $a += $b; + $d = self::leftRotate($d ^ $a, 8); + $c += $d; + $b = self::leftRotate($b ^ $c, 7); } /** @@ -309,15 +313,15 @@ class ChaCha20 extends Salsa20 protected static function doubleRound(&$x0, &$x1, &$x2, &$x3, &$x4, &$x5, &$x6, &$x7, &$x8, &$x9, &$x10, &$x11, &$x12, &$x13, &$x14, &$x15) { // columnRound - static::quarterRound($x0, $x4, $x8, $x12); - static::quarterRound($x1, $x5, $x9, $x13); - static::quarterRound($x2, $x6, $x10, $x14); - static::quarterRound($x3, $x7, $x11, $x15); + static::quarterRound($x0, $x4, $x8, $x12); + static::quarterRound($x1, $x5, $x9, $x13); + static::quarterRound($x2, $x6, $x10, $x14); + static::quarterRound($x3, $x7, $x11, $x15); // rowRound static::quarterRound($x0, $x5, $x10, $x15); static::quarterRound($x1, $x6, $x11, $x12); - static::quarterRound($x2, $x7, $x8, $x13); - static::quarterRound($x3, $x4, $x9, $x14); + static::quarterRound($x2, $x7, $x8, $x13); + static::quarterRound($x3, $x4, $x9, $x14); } /** @@ -356,441 +360,761 @@ class ChaCha20 extends Salsa20 $z15 = $x15; // columnRound - $x0+= $x4; $x12 = self::leftRotate($x12 ^ $x0, 16); - $x8+= $x12; $x4 = self::leftRotate($x4 ^ $x8, 12); - $x0+= $x4; $x12 = self::leftRotate($x12 ^ $x0, 8); - $x8+= $x12; $x4 = self::leftRotate($x4 ^ $x8, 7); + $x0 += $x4; + $x12 = self::leftRotate($x12 ^ $x0, 16); + $x8 += $x12; + $x4 = self::leftRotate($x4 ^ $x8, 12); + $x0 += $x4; + $x12 = self::leftRotate($x12 ^ $x0, 8); + $x8 += $x12; + $x4 = self::leftRotate($x4 ^ $x8, 7); - $x1+= $x5; $x13 = self::leftRotate($x13 ^ $x1, 16); - $x9+= $x13; $x5 = self::leftRotate($x5 ^ $x9, 12); - $x1+= $x5; $x13 = self::leftRotate($x13 ^ $x1, 8); - $x9+= $x13; $x5 = self::leftRotate($x5 ^ $x9, 7); + $x1 += $x5; + $x13 = self::leftRotate($x13 ^ $x1, 16); + $x9 += $x13; + $x5 = self::leftRotate($x5 ^ $x9, 12); + $x1 += $x5; + $x13 = self::leftRotate($x13 ^ $x1, 8); + $x9 += $x13; + $x5 = self::leftRotate($x5 ^ $x9, 7); - $x2+= $x6; $x14 = self::leftRotate($x14 ^ $x2, 16); - $x10+= $x14; $x6 = self::leftRotate($x6 ^ $x10, 12); - $x2+= $x6; $x14 = self::leftRotate($x14 ^ $x2, 8); - $x10+= $x14; $x6 = self::leftRotate($x6 ^ $x10, 7); + $x2 += $x6; + $x14 = self::leftRotate($x14 ^ $x2, 16); + $x10 += $x14; + $x6 = self::leftRotate($x6 ^ $x10, 12); + $x2 += $x6; + $x14 = self::leftRotate($x14 ^ $x2, 8); + $x10 += $x14; + $x6 = self::leftRotate($x6 ^ $x10, 7); - $x3+= $x7; $x15 = self::leftRotate($x15 ^ $x3, 16); - $x11+= $x15; $x7 = self::leftRotate($x7 ^ $x11, 12); - $x3+= $x7; $x15 = self::leftRotate($x15 ^ $x3, 8); - $x11+= $x15; $x7 = self::leftRotate($x7 ^ $x11, 7); + $x3 += $x7; + $x15 = self::leftRotate($x15 ^ $x3, 16); + $x11 += $x15; + $x7 = self::leftRotate($x7 ^ $x11, 12); + $x3 += $x7; + $x15 = self::leftRotate($x15 ^ $x3, 8); + $x11 += $x15; + $x7 = self::leftRotate($x7 ^ $x11, 7); // rowRound - $x0+= $x5; $x15 = self::leftRotate($x15 ^ $x0, 16); - $x10+= $x15; $x5 = self::leftRotate($x5 ^ $x10, 12); - $x0+= $x5; $x15 = self::leftRotate($x15 ^ $x0, 8); - $x10+= $x15; $x5 = self::leftRotate($x5 ^ $x10, 7); + $x0 += $x5; + $x15 = self::leftRotate($x15 ^ $x0, 16); + $x10 += $x15; + $x5 = self::leftRotate($x5 ^ $x10, 12); + $x0 += $x5; + $x15 = self::leftRotate($x15 ^ $x0, 8); + $x10 += $x15; + $x5 = self::leftRotate($x5 ^ $x10, 7); - $x1+= $x6; $x12 = self::leftRotate($x12 ^ $x1, 16); - $x11+= $x12; $x6 = self::leftRotate($x6 ^ $x11, 12); - $x1+= $x6; $x12 = self::leftRotate($x12 ^ $x1, 8); - $x11+= $x12; $x6 = self::leftRotate($x6 ^ $x11, 7); + $x1 += $x6; + $x12 = self::leftRotate($x12 ^ $x1, 16); + $x11 += $x12; + $x6 = self::leftRotate($x6 ^ $x11, 12); + $x1 += $x6; + $x12 = self::leftRotate($x12 ^ $x1, 8); + $x11 += $x12; + $x6 = self::leftRotate($x6 ^ $x11, 7); - $x2+= $x7; $x13 = self::leftRotate($x13 ^ $x2, 16); - $x8+= $x13; $x7 = self::leftRotate($x7 ^ $x8, 12); - $x2+= $x7; $x13 = self::leftRotate($x13 ^ $x2, 8); - $x8+= $x13; $x7 = self::leftRotate($x7 ^ $x8, 7); + $x2 += $x7; + $x13 = self::leftRotate($x13 ^ $x2, 16); + $x8 += $x13; + $x7 = self::leftRotate($x7 ^ $x8, 12); + $x2 += $x7; + $x13 = self::leftRotate($x13 ^ $x2, 8); + $x8 += $x13; + $x7 = self::leftRotate($x7 ^ $x8, 7); - $x3+= $x4; $x14 = self::leftRotate($x14 ^ $x3, 16); - $x9+= $x14; $x4 = self::leftRotate($x4 ^ $x9, 12); - $x3+= $x4; $x14 = self::leftRotate($x14 ^ $x3, 8); - $x9+= $x14; $x4 = self::leftRotate($x4 ^ $x9, 7); + $x3 += $x4; + $x14 = self::leftRotate($x14 ^ $x3, 16); + $x9 += $x14; + $x4 = self::leftRotate($x4 ^ $x9, 12); + $x3 += $x4; + $x14 = self::leftRotate($x14 ^ $x3, 8); + $x9 += $x14; + $x4 = self::leftRotate($x4 ^ $x9, 7); // columnRound - $x0+= $x4; $x12 = self::leftRotate($x12 ^ $x0, 16); - $x8+= $x12; $x4 = self::leftRotate($x4 ^ $x8, 12); - $x0+= $x4; $x12 = self::leftRotate($x12 ^ $x0, 8); - $x8+= $x12; $x4 = self::leftRotate($x4 ^ $x8, 7); + $x0 += $x4; + $x12 = self::leftRotate($x12 ^ $x0, 16); + $x8 += $x12; + $x4 = self::leftRotate($x4 ^ $x8, 12); + $x0 += $x4; + $x12 = self::leftRotate($x12 ^ $x0, 8); + $x8 += $x12; + $x4 = self::leftRotate($x4 ^ $x8, 7); - $x1+= $x5; $x13 = self::leftRotate($x13 ^ $x1, 16); - $x9+= $x13; $x5 = self::leftRotate($x5 ^ $x9, 12); - $x1+= $x5; $x13 = self::leftRotate($x13 ^ $x1, 8); - $x9+= $x13; $x5 = self::leftRotate($x5 ^ $x9, 7); + $x1 += $x5; + $x13 = self::leftRotate($x13 ^ $x1, 16); + $x9 += $x13; + $x5 = self::leftRotate($x5 ^ $x9, 12); + $x1 += $x5; + $x13 = self::leftRotate($x13 ^ $x1, 8); + $x9 += $x13; + $x5 = self::leftRotate($x5 ^ $x9, 7); - $x2+= $x6; $x14 = self::leftRotate($x14 ^ $x2, 16); - $x10+= $x14; $x6 = self::leftRotate($x6 ^ $x10, 12); - $x2+= $x6; $x14 = self::leftRotate($x14 ^ $x2, 8); - $x10+= $x14; $x6 = self::leftRotate($x6 ^ $x10, 7); + $x2 += $x6; + $x14 = self::leftRotate($x14 ^ $x2, 16); + $x10 += $x14; + $x6 = self::leftRotate($x6 ^ $x10, 12); + $x2 += $x6; + $x14 = self::leftRotate($x14 ^ $x2, 8); + $x10 += $x14; + $x6 = self::leftRotate($x6 ^ $x10, 7); - $x3+= $x7; $x15 = self::leftRotate($x15 ^ $x3, 16); - $x11+= $x15; $x7 = self::leftRotate($x7 ^ $x11, 12); - $x3+= $x7; $x15 = self::leftRotate($x15 ^ $x3, 8); - $x11+= $x15; $x7 = self::leftRotate($x7 ^ $x11, 7); + $x3 += $x7; + $x15 = self::leftRotate($x15 ^ $x3, 16); + $x11 += $x15; + $x7 = self::leftRotate($x7 ^ $x11, 12); + $x3 += $x7; + $x15 = self::leftRotate($x15 ^ $x3, 8); + $x11 += $x15; + $x7 = self::leftRotate($x7 ^ $x11, 7); // rowRound - $x0+= $x5; $x15 = self::leftRotate($x15 ^ $x0, 16); - $x10+= $x15; $x5 = self::leftRotate($x5 ^ $x10, 12); - $x0+= $x5; $x15 = self::leftRotate($x15 ^ $x0, 8); - $x10+= $x15; $x5 = self::leftRotate($x5 ^ $x10, 7); + $x0 += $x5; + $x15 = self::leftRotate($x15 ^ $x0, 16); + $x10 += $x15; + $x5 = self::leftRotate($x5 ^ $x10, 12); + $x0 += $x5; + $x15 = self::leftRotate($x15 ^ $x0, 8); + $x10 += $x15; + $x5 = self::leftRotate($x5 ^ $x10, 7); - $x1+= $x6; $x12 = self::leftRotate($x12 ^ $x1, 16); - $x11+= $x12; $x6 = self::leftRotate($x6 ^ $x11, 12); - $x1+= $x6; $x12 = self::leftRotate($x12 ^ $x1, 8); - $x11+= $x12; $x6 = self::leftRotate($x6 ^ $x11, 7); + $x1 += $x6; + $x12 = self::leftRotate($x12 ^ $x1, 16); + $x11 += $x12; + $x6 = self::leftRotate($x6 ^ $x11, 12); + $x1 += $x6; + $x12 = self::leftRotate($x12 ^ $x1, 8); + $x11 += $x12; + $x6 = self::leftRotate($x6 ^ $x11, 7); - $x2+= $x7; $x13 = self::leftRotate($x13 ^ $x2, 16); - $x8+= $x13; $x7 = self::leftRotate($x7 ^ $x8, 12); - $x2+= $x7; $x13 = self::leftRotate($x13 ^ $x2, 8); - $x8+= $x13; $x7 = self::leftRotate($x7 ^ $x8, 7); + $x2 += $x7; + $x13 = self::leftRotate($x13 ^ $x2, 16); + $x8 += $x13; + $x7 = self::leftRotate($x7 ^ $x8, 12); + $x2 += $x7; + $x13 = self::leftRotate($x13 ^ $x2, 8); + $x8 += $x13; + $x7 = self::leftRotate($x7 ^ $x8, 7); - $x3+= $x4; $x14 = self::leftRotate($x14 ^ $x3, 16); - $x9+= $x14; $x4 = self::leftRotate($x4 ^ $x9, 12); - $x3+= $x4; $x14 = self::leftRotate($x14 ^ $x3, 8); - $x9+= $x14; $x4 = self::leftRotate($x4 ^ $x9, 7); + $x3 += $x4; + $x14 = self::leftRotate($x14 ^ $x3, 16); + $x9 += $x14; + $x4 = self::leftRotate($x4 ^ $x9, 12); + $x3 += $x4; + $x14 = self::leftRotate($x14 ^ $x3, 8); + $x9 += $x14; + $x4 = self::leftRotate($x4 ^ $x9, 7); // columnRound - $x0+= $x4; $x12 = self::leftRotate($x12 ^ $x0, 16); - $x8+= $x12; $x4 = self::leftRotate($x4 ^ $x8, 12); - $x0+= $x4; $x12 = self::leftRotate($x12 ^ $x0, 8); - $x8+= $x12; $x4 = self::leftRotate($x4 ^ $x8, 7); + $x0 += $x4; + $x12 = self::leftRotate($x12 ^ $x0, 16); + $x8 += $x12; + $x4 = self::leftRotate($x4 ^ $x8, 12); + $x0 += $x4; + $x12 = self::leftRotate($x12 ^ $x0, 8); + $x8 += $x12; + $x4 = self::leftRotate($x4 ^ $x8, 7); - $x1+= $x5; $x13 = self::leftRotate($x13 ^ $x1, 16); - $x9+= $x13; $x5 = self::leftRotate($x5 ^ $x9, 12); - $x1+= $x5; $x13 = self::leftRotate($x13 ^ $x1, 8); - $x9+= $x13; $x5 = self::leftRotate($x5 ^ $x9, 7); + $x1 += $x5; + $x13 = self::leftRotate($x13 ^ $x1, 16); + $x9 += $x13; + $x5 = self::leftRotate($x5 ^ $x9, 12); + $x1 += $x5; + $x13 = self::leftRotate($x13 ^ $x1, 8); + $x9 += $x13; + $x5 = self::leftRotate($x5 ^ $x9, 7); - $x2+= $x6; $x14 = self::leftRotate($x14 ^ $x2, 16); - $x10+= $x14; $x6 = self::leftRotate($x6 ^ $x10, 12); - $x2+= $x6; $x14 = self::leftRotate($x14 ^ $x2, 8); - $x10+= $x14; $x6 = self::leftRotate($x6 ^ $x10, 7); + $x2 += $x6; + $x14 = self::leftRotate($x14 ^ $x2, 16); + $x10 += $x14; + $x6 = self::leftRotate($x6 ^ $x10, 12); + $x2 += $x6; + $x14 = self::leftRotate($x14 ^ $x2, 8); + $x10 += $x14; + $x6 = self::leftRotate($x6 ^ $x10, 7); - $x3+= $x7; $x15 = self::leftRotate($x15 ^ $x3, 16); - $x11+= $x15; $x7 = self::leftRotate($x7 ^ $x11, 12); - $x3+= $x7; $x15 = self::leftRotate($x15 ^ $x3, 8); - $x11+= $x15; $x7 = self::leftRotate($x7 ^ $x11, 7); + $x3 += $x7; + $x15 = self::leftRotate($x15 ^ $x3, 16); + $x11 += $x15; + $x7 = self::leftRotate($x7 ^ $x11, 12); + $x3 += $x7; + $x15 = self::leftRotate($x15 ^ $x3, 8); + $x11 += $x15; + $x7 = self::leftRotate($x7 ^ $x11, 7); // rowRound - $x0+= $x5; $x15 = self::leftRotate($x15 ^ $x0, 16); - $x10+= $x15; $x5 = self::leftRotate($x5 ^ $x10, 12); - $x0+= $x5; $x15 = self::leftRotate($x15 ^ $x0, 8); - $x10+= $x15; $x5 = self::leftRotate($x5 ^ $x10, 7); + $x0 += $x5; + $x15 = self::leftRotate($x15 ^ $x0, 16); + $x10 += $x15; + $x5 = self::leftRotate($x5 ^ $x10, 12); + $x0 += $x5; + $x15 = self::leftRotate($x15 ^ $x0, 8); + $x10 += $x15; + $x5 = self::leftRotate($x5 ^ $x10, 7); - $x1+= $x6; $x12 = self::leftRotate($x12 ^ $x1, 16); - $x11+= $x12; $x6 = self::leftRotate($x6 ^ $x11, 12); - $x1+= $x6; $x12 = self::leftRotate($x12 ^ $x1, 8); - $x11+= $x12; $x6 = self::leftRotate($x6 ^ $x11, 7); + $x1 += $x6; + $x12 = self::leftRotate($x12 ^ $x1, 16); + $x11 += $x12; + $x6 = self::leftRotate($x6 ^ $x11, 12); + $x1 += $x6; + $x12 = self::leftRotate($x12 ^ $x1, 8); + $x11 += $x12; + $x6 = self::leftRotate($x6 ^ $x11, 7); - $x2+= $x7; $x13 = self::leftRotate($x13 ^ $x2, 16); - $x8+= $x13; $x7 = self::leftRotate($x7 ^ $x8, 12); - $x2+= $x7; $x13 = self::leftRotate($x13 ^ $x2, 8); - $x8+= $x13; $x7 = self::leftRotate($x7 ^ $x8, 7); + $x2 += $x7; + $x13 = self::leftRotate($x13 ^ $x2, 16); + $x8 += $x13; + $x7 = self::leftRotate($x7 ^ $x8, 12); + $x2 += $x7; + $x13 = self::leftRotate($x13 ^ $x2, 8); + $x8 += $x13; + $x7 = self::leftRotate($x7 ^ $x8, 7); - $x3+= $x4; $x14 = self::leftRotate($x14 ^ $x3, 16); - $x9+= $x14; $x4 = self::leftRotate($x4 ^ $x9, 12); - $x3+= $x4; $x14 = self::leftRotate($x14 ^ $x3, 8); - $x9+= $x14; $x4 = self::leftRotate($x4 ^ $x9, 7); + $x3 += $x4; + $x14 = self::leftRotate($x14 ^ $x3, 16); + $x9 += $x14; + $x4 = self::leftRotate($x4 ^ $x9, 12); + $x3 += $x4; + $x14 = self::leftRotate($x14 ^ $x3, 8); + $x9 += $x14; + $x4 = self::leftRotate($x4 ^ $x9, 7); // columnRound - $x0+= $x4; $x12 = self::leftRotate($x12 ^ $x0, 16); - $x8+= $x12; $x4 = self::leftRotate($x4 ^ $x8, 12); - $x0+= $x4; $x12 = self::leftRotate($x12 ^ $x0, 8); - $x8+= $x12; $x4 = self::leftRotate($x4 ^ $x8, 7); + $x0 += $x4; + $x12 = self::leftRotate($x12 ^ $x0, 16); + $x8 += $x12; + $x4 = self::leftRotate($x4 ^ $x8, 12); + $x0 += $x4; + $x12 = self::leftRotate($x12 ^ $x0, 8); + $x8 += $x12; + $x4 = self::leftRotate($x4 ^ $x8, 7); - $x1+= $x5; $x13 = self::leftRotate($x13 ^ $x1, 16); - $x9+= $x13; $x5 = self::leftRotate($x5 ^ $x9, 12); - $x1+= $x5; $x13 = self::leftRotate($x13 ^ $x1, 8); - $x9+= $x13; $x5 = self::leftRotate($x5 ^ $x9, 7); + $x1 += $x5; + $x13 = self::leftRotate($x13 ^ $x1, 16); + $x9 += $x13; + $x5 = self::leftRotate($x5 ^ $x9, 12); + $x1 += $x5; + $x13 = self::leftRotate($x13 ^ $x1, 8); + $x9 += $x13; + $x5 = self::leftRotate($x5 ^ $x9, 7); - $x2+= $x6; $x14 = self::leftRotate($x14 ^ $x2, 16); - $x10+= $x14; $x6 = self::leftRotate($x6 ^ $x10, 12); - $x2+= $x6; $x14 = self::leftRotate($x14 ^ $x2, 8); - $x10+= $x14; $x6 = self::leftRotate($x6 ^ $x10, 7); + $x2 += $x6; + $x14 = self::leftRotate($x14 ^ $x2, 16); + $x10 += $x14; + $x6 = self::leftRotate($x6 ^ $x10, 12); + $x2 += $x6; + $x14 = self::leftRotate($x14 ^ $x2, 8); + $x10 += $x14; + $x6 = self::leftRotate($x6 ^ $x10, 7); - $x3+= $x7; $x15 = self::leftRotate($x15 ^ $x3, 16); - $x11+= $x15; $x7 = self::leftRotate($x7 ^ $x11, 12); - $x3+= $x7; $x15 = self::leftRotate($x15 ^ $x3, 8); - $x11+= $x15; $x7 = self::leftRotate($x7 ^ $x11, 7); + $x3 += $x7; + $x15 = self::leftRotate($x15 ^ $x3, 16); + $x11 += $x15; + $x7 = self::leftRotate($x7 ^ $x11, 12); + $x3 += $x7; + $x15 = self::leftRotate($x15 ^ $x3, 8); + $x11 += $x15; + $x7 = self::leftRotate($x7 ^ $x11, 7); // rowRound - $x0+= $x5; $x15 = self::leftRotate($x15 ^ $x0, 16); - $x10+= $x15; $x5 = self::leftRotate($x5 ^ $x10, 12); - $x0+= $x5; $x15 = self::leftRotate($x15 ^ $x0, 8); - $x10+= $x15; $x5 = self::leftRotate($x5 ^ $x10, 7); + $x0 += $x5; + $x15 = self::leftRotate($x15 ^ $x0, 16); + $x10 += $x15; + $x5 = self::leftRotate($x5 ^ $x10, 12); + $x0 += $x5; + $x15 = self::leftRotate($x15 ^ $x0, 8); + $x10 += $x15; + $x5 = self::leftRotate($x5 ^ $x10, 7); - $x1+= $x6; $x12 = self::leftRotate($x12 ^ $x1, 16); - $x11+= $x12; $x6 = self::leftRotate($x6 ^ $x11, 12); - $x1+= $x6; $x12 = self::leftRotate($x12 ^ $x1, 8); - $x11+= $x12; $x6 = self::leftRotate($x6 ^ $x11, 7); + $x1 += $x6; + $x12 = self::leftRotate($x12 ^ $x1, 16); + $x11 += $x12; + $x6 = self::leftRotate($x6 ^ $x11, 12); + $x1 += $x6; + $x12 = self::leftRotate($x12 ^ $x1, 8); + $x11 += $x12; + $x6 = self::leftRotate($x6 ^ $x11, 7); - $x2+= $x7; $x13 = self::leftRotate($x13 ^ $x2, 16); - $x8+= $x13; $x7 = self::leftRotate($x7 ^ $x8, 12); - $x2+= $x7; $x13 = self::leftRotate($x13 ^ $x2, 8); - $x8+= $x13; $x7 = self::leftRotate($x7 ^ $x8, 7); + $x2 += $x7; + $x13 = self::leftRotate($x13 ^ $x2, 16); + $x8 += $x13; + $x7 = self::leftRotate($x7 ^ $x8, 12); + $x2 += $x7; + $x13 = self::leftRotate($x13 ^ $x2, 8); + $x8 += $x13; + $x7 = self::leftRotate($x7 ^ $x8, 7); - $x3+= $x4; $x14 = self::leftRotate($x14 ^ $x3, 16); - $x9+= $x14; $x4 = self::leftRotate($x4 ^ $x9, 12); - $x3+= $x4; $x14 = self::leftRotate($x14 ^ $x3, 8); - $x9+= $x14; $x4 = self::leftRotate($x4 ^ $x9, 7); + $x3 += $x4; + $x14 = self::leftRotate($x14 ^ $x3, 16); + $x9 += $x14; + $x4 = self::leftRotate($x4 ^ $x9, 12); + $x3 += $x4; + $x14 = self::leftRotate($x14 ^ $x3, 8); + $x9 += $x14; + $x4 = self::leftRotate($x4 ^ $x9, 7); // columnRound - $x0+= $x4; $x12 = self::leftRotate($x12 ^ $x0, 16); - $x8+= $x12; $x4 = self::leftRotate($x4 ^ $x8, 12); - $x0+= $x4; $x12 = self::leftRotate($x12 ^ $x0, 8); - $x8+= $x12; $x4 = self::leftRotate($x4 ^ $x8, 7); + $x0 += $x4; + $x12 = self::leftRotate($x12 ^ $x0, 16); + $x8 += $x12; + $x4 = self::leftRotate($x4 ^ $x8, 12); + $x0 += $x4; + $x12 = self::leftRotate($x12 ^ $x0, 8); + $x8 += $x12; + $x4 = self::leftRotate($x4 ^ $x8, 7); - $x1+= $x5; $x13 = self::leftRotate($x13 ^ $x1, 16); - $x9+= $x13; $x5 = self::leftRotate($x5 ^ $x9, 12); - $x1+= $x5; $x13 = self::leftRotate($x13 ^ $x1, 8); - $x9+= $x13; $x5 = self::leftRotate($x5 ^ $x9, 7); + $x1 += $x5; + $x13 = self::leftRotate($x13 ^ $x1, 16); + $x9 += $x13; + $x5 = self::leftRotate($x5 ^ $x9, 12); + $x1 += $x5; + $x13 = self::leftRotate($x13 ^ $x1, 8); + $x9 += $x13; + $x5 = self::leftRotate($x5 ^ $x9, 7); - $x2+= $x6; $x14 = self::leftRotate($x14 ^ $x2, 16); - $x10+= $x14; $x6 = self::leftRotate($x6 ^ $x10, 12); - $x2+= $x6; $x14 = self::leftRotate($x14 ^ $x2, 8); - $x10+= $x14; $x6 = self::leftRotate($x6 ^ $x10, 7); + $x2 += $x6; + $x14 = self::leftRotate($x14 ^ $x2, 16); + $x10 += $x14; + $x6 = self::leftRotate($x6 ^ $x10, 12); + $x2 += $x6; + $x14 = self::leftRotate($x14 ^ $x2, 8); + $x10 += $x14; + $x6 = self::leftRotate($x6 ^ $x10, 7); - $x3+= $x7; $x15 = self::leftRotate($x15 ^ $x3, 16); - $x11+= $x15; $x7 = self::leftRotate($x7 ^ $x11, 12); - $x3+= $x7; $x15 = self::leftRotate($x15 ^ $x3, 8); - $x11+= $x15; $x7 = self::leftRotate($x7 ^ $x11, 7); + $x3 += $x7; + $x15 = self::leftRotate($x15 ^ $x3, 16); + $x11 += $x15; + $x7 = self::leftRotate($x7 ^ $x11, 12); + $x3 += $x7; + $x15 = self::leftRotate($x15 ^ $x3, 8); + $x11 += $x15; + $x7 = self::leftRotate($x7 ^ $x11, 7); // rowRound - $x0+= $x5; $x15 = self::leftRotate($x15 ^ $x0, 16); - $x10+= $x15; $x5 = self::leftRotate($x5 ^ $x10, 12); - $x0+= $x5; $x15 = self::leftRotate($x15 ^ $x0, 8); - $x10+= $x15; $x5 = self::leftRotate($x5 ^ $x10, 7); + $x0 += $x5; + $x15 = self::leftRotate($x15 ^ $x0, 16); + $x10 += $x15; + $x5 = self::leftRotate($x5 ^ $x10, 12); + $x0 += $x5; + $x15 = self::leftRotate($x15 ^ $x0, 8); + $x10 += $x15; + $x5 = self::leftRotate($x5 ^ $x10, 7); - $x1+= $x6; $x12 = self::leftRotate($x12 ^ $x1, 16); - $x11+= $x12; $x6 = self::leftRotate($x6 ^ $x11, 12); - $x1+= $x6; $x12 = self::leftRotate($x12 ^ $x1, 8); - $x11+= $x12; $x6 = self::leftRotate($x6 ^ $x11, 7); + $x1 += $x6; + $x12 = self::leftRotate($x12 ^ $x1, 16); + $x11 += $x12; + $x6 = self::leftRotate($x6 ^ $x11, 12); + $x1 += $x6; + $x12 = self::leftRotate($x12 ^ $x1, 8); + $x11 += $x12; + $x6 = self::leftRotate($x6 ^ $x11, 7); - $x2+= $x7; $x13 = self::leftRotate($x13 ^ $x2, 16); - $x8+= $x13; $x7 = self::leftRotate($x7 ^ $x8, 12); - $x2+= $x7; $x13 = self::leftRotate($x13 ^ $x2, 8); - $x8+= $x13; $x7 = self::leftRotate($x7 ^ $x8, 7); + $x2 += $x7; + $x13 = self::leftRotate($x13 ^ $x2, 16); + $x8 += $x13; + $x7 = self::leftRotate($x7 ^ $x8, 12); + $x2 += $x7; + $x13 = self::leftRotate($x13 ^ $x2, 8); + $x8 += $x13; + $x7 = self::leftRotate($x7 ^ $x8, 7); - $x3+= $x4; $x14 = self::leftRotate($x14 ^ $x3, 16); - $x9+= $x14; $x4 = self::leftRotate($x4 ^ $x9, 12); - $x3+= $x4; $x14 = self::leftRotate($x14 ^ $x3, 8); - $x9+= $x14; $x4 = self::leftRotate($x4 ^ $x9, 7); + $x3 += $x4; + $x14 = self::leftRotate($x14 ^ $x3, 16); + $x9 += $x14; + $x4 = self::leftRotate($x4 ^ $x9, 12); + $x3 += $x4; + $x14 = self::leftRotate($x14 ^ $x3, 8); + $x9 += $x14; + $x4 = self::leftRotate($x4 ^ $x9, 7); // columnRound - $x0+= $x4; $x12 = self::leftRotate($x12 ^ $x0, 16); - $x8+= $x12; $x4 = self::leftRotate($x4 ^ $x8, 12); - $x0+= $x4; $x12 = self::leftRotate($x12 ^ $x0, 8); - $x8+= $x12; $x4 = self::leftRotate($x4 ^ $x8, 7); + $x0 += $x4; + $x12 = self::leftRotate($x12 ^ $x0, 16); + $x8 += $x12; + $x4 = self::leftRotate($x4 ^ $x8, 12); + $x0 += $x4; + $x12 = self::leftRotate($x12 ^ $x0, 8); + $x8 += $x12; + $x4 = self::leftRotate($x4 ^ $x8, 7); - $x1+= $x5; $x13 = self::leftRotate($x13 ^ $x1, 16); - $x9+= $x13; $x5 = self::leftRotate($x5 ^ $x9, 12); - $x1+= $x5; $x13 = self::leftRotate($x13 ^ $x1, 8); - $x9+= $x13; $x5 = self::leftRotate($x5 ^ $x9, 7); + $x1 += $x5; + $x13 = self::leftRotate($x13 ^ $x1, 16); + $x9 += $x13; + $x5 = self::leftRotate($x5 ^ $x9, 12); + $x1 += $x5; + $x13 = self::leftRotate($x13 ^ $x1, 8); + $x9 += $x13; + $x5 = self::leftRotate($x5 ^ $x9, 7); - $x2+= $x6; $x14 = self::leftRotate($x14 ^ $x2, 16); - $x10+= $x14; $x6 = self::leftRotate($x6 ^ $x10, 12); - $x2+= $x6; $x14 = self::leftRotate($x14 ^ $x2, 8); - $x10+= $x14; $x6 = self::leftRotate($x6 ^ $x10, 7); + $x2 += $x6; + $x14 = self::leftRotate($x14 ^ $x2, 16); + $x10 += $x14; + $x6 = self::leftRotate($x6 ^ $x10, 12); + $x2 += $x6; + $x14 = self::leftRotate($x14 ^ $x2, 8); + $x10 += $x14; + $x6 = self::leftRotate($x6 ^ $x10, 7); - $x3+= $x7; $x15 = self::leftRotate($x15 ^ $x3, 16); - $x11+= $x15; $x7 = self::leftRotate($x7 ^ $x11, 12); - $x3+= $x7; $x15 = self::leftRotate($x15 ^ $x3, 8); - $x11+= $x15; $x7 = self::leftRotate($x7 ^ $x11, 7); + $x3 += $x7; + $x15 = self::leftRotate($x15 ^ $x3, 16); + $x11 += $x15; + $x7 = self::leftRotate($x7 ^ $x11, 12); + $x3 += $x7; + $x15 = self::leftRotate($x15 ^ $x3, 8); + $x11 += $x15; + $x7 = self::leftRotate($x7 ^ $x11, 7); // rowRound - $x0+= $x5; $x15 = self::leftRotate($x15 ^ $x0, 16); - $x10+= $x15; $x5 = self::leftRotate($x5 ^ $x10, 12); - $x0+= $x5; $x15 = self::leftRotate($x15 ^ $x0, 8); - $x10+= $x15; $x5 = self::leftRotate($x5 ^ $x10, 7); + $x0 += $x5; + $x15 = self::leftRotate($x15 ^ $x0, 16); + $x10 += $x15; + $x5 = self::leftRotate($x5 ^ $x10, 12); + $x0 += $x5; + $x15 = self::leftRotate($x15 ^ $x0, 8); + $x10 += $x15; + $x5 = self::leftRotate($x5 ^ $x10, 7); - $x1+= $x6; $x12 = self::leftRotate($x12 ^ $x1, 16); - $x11+= $x12; $x6 = self::leftRotate($x6 ^ $x11, 12); - $x1+= $x6; $x12 = self::leftRotate($x12 ^ $x1, 8); - $x11+= $x12; $x6 = self::leftRotate($x6 ^ $x11, 7); + $x1 += $x6; + $x12 = self::leftRotate($x12 ^ $x1, 16); + $x11 += $x12; + $x6 = self::leftRotate($x6 ^ $x11, 12); + $x1 += $x6; + $x12 = self::leftRotate($x12 ^ $x1, 8); + $x11 += $x12; + $x6 = self::leftRotate($x6 ^ $x11, 7); - $x2+= $x7; $x13 = self::leftRotate($x13 ^ $x2, 16); - $x8+= $x13; $x7 = self::leftRotate($x7 ^ $x8, 12); - $x2+= $x7; $x13 = self::leftRotate($x13 ^ $x2, 8); - $x8+= $x13; $x7 = self::leftRotate($x7 ^ $x8, 7); + $x2 += $x7; + $x13 = self::leftRotate($x13 ^ $x2, 16); + $x8 += $x13; + $x7 = self::leftRotate($x7 ^ $x8, 12); + $x2 += $x7; + $x13 = self::leftRotate($x13 ^ $x2, 8); + $x8 += $x13; + $x7 = self::leftRotate($x7 ^ $x8, 7); - $x3+= $x4; $x14 = self::leftRotate($x14 ^ $x3, 16); - $x9+= $x14; $x4 = self::leftRotate($x4 ^ $x9, 12); - $x3+= $x4; $x14 = self::leftRotate($x14 ^ $x3, 8); - $x9+= $x14; $x4 = self::leftRotate($x4 ^ $x9, 7); + $x3 += $x4; + $x14 = self::leftRotate($x14 ^ $x3, 16); + $x9 += $x14; + $x4 = self::leftRotate($x4 ^ $x9, 12); + $x3 += $x4; + $x14 = self::leftRotate($x14 ^ $x3, 8); + $x9 += $x14; + $x4 = self::leftRotate($x4 ^ $x9, 7); // columnRound - $x0+= $x4; $x12 = self::leftRotate($x12 ^ $x0, 16); - $x8+= $x12; $x4 = self::leftRotate($x4 ^ $x8, 12); - $x0+= $x4; $x12 = self::leftRotate($x12 ^ $x0, 8); - $x8+= $x12; $x4 = self::leftRotate($x4 ^ $x8, 7); + $x0 += $x4; + $x12 = self::leftRotate($x12 ^ $x0, 16); + $x8 += $x12; + $x4 = self::leftRotate($x4 ^ $x8, 12); + $x0 += $x4; + $x12 = self::leftRotate($x12 ^ $x0, 8); + $x8 += $x12; + $x4 = self::leftRotate($x4 ^ $x8, 7); - $x1+= $x5; $x13 = self::leftRotate($x13 ^ $x1, 16); - $x9+= $x13; $x5 = self::leftRotate($x5 ^ $x9, 12); - $x1+= $x5; $x13 = self::leftRotate($x13 ^ $x1, 8); - $x9+= $x13; $x5 = self::leftRotate($x5 ^ $x9, 7); + $x1 += $x5; + $x13 = self::leftRotate($x13 ^ $x1, 16); + $x9 += $x13; + $x5 = self::leftRotate($x5 ^ $x9, 12); + $x1 += $x5; + $x13 = self::leftRotate($x13 ^ $x1, 8); + $x9 += $x13; + $x5 = self::leftRotate($x5 ^ $x9, 7); - $x2+= $x6; $x14 = self::leftRotate($x14 ^ $x2, 16); - $x10+= $x14; $x6 = self::leftRotate($x6 ^ $x10, 12); - $x2+= $x6; $x14 = self::leftRotate($x14 ^ $x2, 8); - $x10+= $x14; $x6 = self::leftRotate($x6 ^ $x10, 7); + $x2 += $x6; + $x14 = self::leftRotate($x14 ^ $x2, 16); + $x10 += $x14; + $x6 = self::leftRotate($x6 ^ $x10, 12); + $x2 += $x6; + $x14 = self::leftRotate($x14 ^ $x2, 8); + $x10 += $x14; + $x6 = self::leftRotate($x6 ^ $x10, 7); - $x3+= $x7; $x15 = self::leftRotate($x15 ^ $x3, 16); - $x11+= $x15; $x7 = self::leftRotate($x7 ^ $x11, 12); - $x3+= $x7; $x15 = self::leftRotate($x15 ^ $x3, 8); - $x11+= $x15; $x7 = self::leftRotate($x7 ^ $x11, 7); + $x3 += $x7; + $x15 = self::leftRotate($x15 ^ $x3, 16); + $x11 += $x15; + $x7 = self::leftRotate($x7 ^ $x11, 12); + $x3 += $x7; + $x15 = self::leftRotate($x15 ^ $x3, 8); + $x11 += $x15; + $x7 = self::leftRotate($x7 ^ $x11, 7); // rowRound - $x0+= $x5; $x15 = self::leftRotate($x15 ^ $x0, 16); - $x10+= $x15; $x5 = self::leftRotate($x5 ^ $x10, 12); - $x0+= $x5; $x15 = self::leftRotate($x15 ^ $x0, 8); - $x10+= $x15; $x5 = self::leftRotate($x5 ^ $x10, 7); + $x0 += $x5; + $x15 = self::leftRotate($x15 ^ $x0, 16); + $x10 += $x15; + $x5 = self::leftRotate($x5 ^ $x10, 12); + $x0 += $x5; + $x15 = self::leftRotate($x15 ^ $x0, 8); + $x10 += $x15; + $x5 = self::leftRotate($x5 ^ $x10, 7); - $x1+= $x6; $x12 = self::leftRotate($x12 ^ $x1, 16); - $x11+= $x12; $x6 = self::leftRotate($x6 ^ $x11, 12); - $x1+= $x6; $x12 = self::leftRotate($x12 ^ $x1, 8); - $x11+= $x12; $x6 = self::leftRotate($x6 ^ $x11, 7); + $x1 += $x6; + $x12 = self::leftRotate($x12 ^ $x1, 16); + $x11 += $x12; + $x6 = self::leftRotate($x6 ^ $x11, 12); + $x1 += $x6; + $x12 = self::leftRotate($x12 ^ $x1, 8); + $x11 += $x12; + $x6 = self::leftRotate($x6 ^ $x11, 7); - $x2+= $x7; $x13 = self::leftRotate($x13 ^ $x2, 16); - $x8+= $x13; $x7 = self::leftRotate($x7 ^ $x8, 12); - $x2+= $x7; $x13 = self::leftRotate($x13 ^ $x2, 8); - $x8+= $x13; $x7 = self::leftRotate($x7 ^ $x8, 7); + $x2 += $x7; + $x13 = self::leftRotate($x13 ^ $x2, 16); + $x8 += $x13; + $x7 = self::leftRotate($x7 ^ $x8, 12); + $x2 += $x7; + $x13 = self::leftRotate($x13 ^ $x2, 8); + $x8 += $x13; + $x7 = self::leftRotate($x7 ^ $x8, 7); - $x3+= $x4; $x14 = self::leftRotate($x14 ^ $x3, 16); - $x9+= $x14; $x4 = self::leftRotate($x4 ^ $x9, 12); - $x3+= $x4; $x14 = self::leftRotate($x14 ^ $x3, 8); - $x9+= $x14; $x4 = self::leftRotate($x4 ^ $x9, 7); + $x3 += $x4; + $x14 = self::leftRotate($x14 ^ $x3, 16); + $x9 += $x14; + $x4 = self::leftRotate($x4 ^ $x9, 12); + $x3 += $x4; + $x14 = self::leftRotate($x14 ^ $x3, 8); + $x9 += $x14; + $x4 = self::leftRotate($x4 ^ $x9, 7); // columnRound - $x0+= $x4; $x12 = self::leftRotate($x12 ^ $x0, 16); - $x8+= $x12; $x4 = self::leftRotate($x4 ^ $x8, 12); - $x0+= $x4; $x12 = self::leftRotate($x12 ^ $x0, 8); - $x8+= $x12; $x4 = self::leftRotate($x4 ^ $x8, 7); + $x0 += $x4; + $x12 = self::leftRotate($x12 ^ $x0, 16); + $x8 += $x12; + $x4 = self::leftRotate($x4 ^ $x8, 12); + $x0 += $x4; + $x12 = self::leftRotate($x12 ^ $x0, 8); + $x8 += $x12; + $x4 = self::leftRotate($x4 ^ $x8, 7); - $x1+= $x5; $x13 = self::leftRotate($x13 ^ $x1, 16); - $x9+= $x13; $x5 = self::leftRotate($x5 ^ $x9, 12); - $x1+= $x5; $x13 = self::leftRotate($x13 ^ $x1, 8); - $x9+= $x13; $x5 = self::leftRotate($x5 ^ $x9, 7); + $x1 += $x5; + $x13 = self::leftRotate($x13 ^ $x1, 16); + $x9 += $x13; + $x5 = self::leftRotate($x5 ^ $x9, 12); + $x1 += $x5; + $x13 = self::leftRotate($x13 ^ $x1, 8); + $x9 += $x13; + $x5 = self::leftRotate($x5 ^ $x9, 7); - $x2+= $x6; $x14 = self::leftRotate($x14 ^ $x2, 16); - $x10+= $x14; $x6 = self::leftRotate($x6 ^ $x10, 12); - $x2+= $x6; $x14 = self::leftRotate($x14 ^ $x2, 8); - $x10+= $x14; $x6 = self::leftRotate($x6 ^ $x10, 7); + $x2 += $x6; + $x14 = self::leftRotate($x14 ^ $x2, 16); + $x10 += $x14; + $x6 = self::leftRotate($x6 ^ $x10, 12); + $x2 += $x6; + $x14 = self::leftRotate($x14 ^ $x2, 8); + $x10 += $x14; + $x6 = self::leftRotate($x6 ^ $x10, 7); - $x3+= $x7; $x15 = self::leftRotate($x15 ^ $x3, 16); - $x11+= $x15; $x7 = self::leftRotate($x7 ^ $x11, 12); - $x3+= $x7; $x15 = self::leftRotate($x15 ^ $x3, 8); - $x11+= $x15; $x7 = self::leftRotate($x7 ^ $x11, 7); + $x3 += $x7; + $x15 = self::leftRotate($x15 ^ $x3, 16); + $x11 += $x15; + $x7 = self::leftRotate($x7 ^ $x11, 12); + $x3 += $x7; + $x15 = self::leftRotate($x15 ^ $x3, 8); + $x11 += $x15; + $x7 = self::leftRotate($x7 ^ $x11, 7); // rowRound - $x0+= $x5; $x15 = self::leftRotate($x15 ^ $x0, 16); - $x10+= $x15; $x5 = self::leftRotate($x5 ^ $x10, 12); - $x0+= $x5; $x15 = self::leftRotate($x15 ^ $x0, 8); - $x10+= $x15; $x5 = self::leftRotate($x5 ^ $x10, 7); + $x0 += $x5; + $x15 = self::leftRotate($x15 ^ $x0, 16); + $x10 += $x15; + $x5 = self::leftRotate($x5 ^ $x10, 12); + $x0 += $x5; + $x15 = self::leftRotate($x15 ^ $x0, 8); + $x10 += $x15; + $x5 = self::leftRotate($x5 ^ $x10, 7); - $x1+= $x6; $x12 = self::leftRotate($x12 ^ $x1, 16); - $x11+= $x12; $x6 = self::leftRotate($x6 ^ $x11, 12); - $x1+= $x6; $x12 = self::leftRotate($x12 ^ $x1, 8); - $x11+= $x12; $x6 = self::leftRotate($x6 ^ $x11, 7); + $x1 += $x6; + $x12 = self::leftRotate($x12 ^ $x1, 16); + $x11 += $x12; + $x6 = self::leftRotate($x6 ^ $x11, 12); + $x1 += $x6; + $x12 = self::leftRotate($x12 ^ $x1, 8); + $x11 += $x12; + $x6 = self::leftRotate($x6 ^ $x11, 7); - $x2+= $x7; $x13 = self::leftRotate($x13 ^ $x2, 16); - $x8+= $x13; $x7 = self::leftRotate($x7 ^ $x8, 12); - $x2+= $x7; $x13 = self::leftRotate($x13 ^ $x2, 8); - $x8+= $x13; $x7 = self::leftRotate($x7 ^ $x8, 7); + $x2 += $x7; + $x13 = self::leftRotate($x13 ^ $x2, 16); + $x8 += $x13; + $x7 = self::leftRotate($x7 ^ $x8, 12); + $x2 += $x7; + $x13 = self::leftRotate($x13 ^ $x2, 8); + $x8 += $x13; + $x7 = self::leftRotate($x7 ^ $x8, 7); - $x3+= $x4; $x14 = self::leftRotate($x14 ^ $x3, 16); - $x9+= $x14; $x4 = self::leftRotate($x4 ^ $x9, 12); - $x3+= $x4; $x14 = self::leftRotate($x14 ^ $x3, 8); - $x9+= $x14; $x4 = self::leftRotate($x4 ^ $x9, 7); + $x3 += $x4; + $x14 = self::leftRotate($x14 ^ $x3, 16); + $x9 += $x14; + $x4 = self::leftRotate($x4 ^ $x9, 12); + $x3 += $x4; + $x14 = self::leftRotate($x14 ^ $x3, 8); + $x9 += $x14; + $x4 = self::leftRotate($x4 ^ $x9, 7); // columnRound - $x0+= $x4; $x12 = self::leftRotate($x12 ^ $x0, 16); - $x8+= $x12; $x4 = self::leftRotate($x4 ^ $x8, 12); - $x0+= $x4; $x12 = self::leftRotate($x12 ^ $x0, 8); - $x8+= $x12; $x4 = self::leftRotate($x4 ^ $x8, 7); + $x0 += $x4; + $x12 = self::leftRotate($x12 ^ $x0, 16); + $x8 += $x12; + $x4 = self::leftRotate($x4 ^ $x8, 12); + $x0 += $x4; + $x12 = self::leftRotate($x12 ^ $x0, 8); + $x8 += $x12; + $x4 = self::leftRotate($x4 ^ $x8, 7); - $x1+= $x5; $x13 = self::leftRotate($x13 ^ $x1, 16); - $x9+= $x13; $x5 = self::leftRotate($x5 ^ $x9, 12); - $x1+= $x5; $x13 = self::leftRotate($x13 ^ $x1, 8); - $x9+= $x13; $x5 = self::leftRotate($x5 ^ $x9, 7); + $x1 += $x5; + $x13 = self::leftRotate($x13 ^ $x1, 16); + $x9 += $x13; + $x5 = self::leftRotate($x5 ^ $x9, 12); + $x1 += $x5; + $x13 = self::leftRotate($x13 ^ $x1, 8); + $x9 += $x13; + $x5 = self::leftRotate($x5 ^ $x9, 7); - $x2+= $x6; $x14 = self::leftRotate($x14 ^ $x2, 16); - $x10+= $x14; $x6 = self::leftRotate($x6 ^ $x10, 12); - $x2+= $x6; $x14 = self::leftRotate($x14 ^ $x2, 8); - $x10+= $x14; $x6 = self::leftRotate($x6 ^ $x10, 7); + $x2 += $x6; + $x14 = self::leftRotate($x14 ^ $x2, 16); + $x10 += $x14; + $x6 = self::leftRotate($x6 ^ $x10, 12); + $x2 += $x6; + $x14 = self::leftRotate($x14 ^ $x2, 8); + $x10 += $x14; + $x6 = self::leftRotate($x6 ^ $x10, 7); - $x3+= $x7; $x15 = self::leftRotate($x15 ^ $x3, 16); - $x11+= $x15; $x7 = self::leftRotate($x7 ^ $x11, 12); - $x3+= $x7; $x15 = self::leftRotate($x15 ^ $x3, 8); - $x11+= $x15; $x7 = self::leftRotate($x7 ^ $x11, 7); + $x3 += $x7; + $x15 = self::leftRotate($x15 ^ $x3, 16); + $x11 += $x15; + $x7 = self::leftRotate($x7 ^ $x11, 12); + $x3 += $x7; + $x15 = self::leftRotate($x15 ^ $x3, 8); + $x11 += $x15; + $x7 = self::leftRotate($x7 ^ $x11, 7); // rowRound - $x0+= $x5; $x15 = self::leftRotate($x15 ^ $x0, 16); - $x10+= $x15; $x5 = self::leftRotate($x5 ^ $x10, 12); - $x0+= $x5; $x15 = self::leftRotate($x15 ^ $x0, 8); - $x10+= $x15; $x5 = self::leftRotate($x5 ^ $x10, 7); + $x0 += $x5; + $x15 = self::leftRotate($x15 ^ $x0, 16); + $x10 += $x15; + $x5 = self::leftRotate($x5 ^ $x10, 12); + $x0 += $x5; + $x15 = self::leftRotate($x15 ^ $x0, 8); + $x10 += $x15; + $x5 = self::leftRotate($x5 ^ $x10, 7); - $x1+= $x6; $x12 = self::leftRotate($x12 ^ $x1, 16); - $x11+= $x12; $x6 = self::leftRotate($x6 ^ $x11, 12); - $x1+= $x6; $x12 = self::leftRotate($x12 ^ $x1, 8); - $x11+= $x12; $x6 = self::leftRotate($x6 ^ $x11, 7); + $x1 += $x6; + $x12 = self::leftRotate($x12 ^ $x1, 16); + $x11 += $x12; + $x6 = self::leftRotate($x6 ^ $x11, 12); + $x1 += $x6; + $x12 = self::leftRotate($x12 ^ $x1, 8); + $x11 += $x12; + $x6 = self::leftRotate($x6 ^ $x11, 7); - $x2+= $x7; $x13 = self::leftRotate($x13 ^ $x2, 16); - $x8+= $x13; $x7 = self::leftRotate($x7 ^ $x8, 12); - $x2+= $x7; $x13 = self::leftRotate($x13 ^ $x2, 8); - $x8+= $x13; $x7 = self::leftRotate($x7 ^ $x8, 7); + $x2 += $x7; + $x13 = self::leftRotate($x13 ^ $x2, 16); + $x8 += $x13; + $x7 = self::leftRotate($x7 ^ $x8, 12); + $x2 += $x7; + $x13 = self::leftRotate($x13 ^ $x2, 8); + $x8 += $x13; + $x7 = self::leftRotate($x7 ^ $x8, 7); - $x3+= $x4; $x14 = self::leftRotate($x14 ^ $x3, 16); - $x9+= $x14; $x4 = self::leftRotate($x4 ^ $x9, 12); - $x3+= $x4; $x14 = self::leftRotate($x14 ^ $x3, 8); - $x9+= $x14; $x4 = self::leftRotate($x4 ^ $x9, 7); + $x3 += $x4; + $x14 = self::leftRotate($x14 ^ $x3, 16); + $x9 += $x14; + $x4 = self::leftRotate($x4 ^ $x9, 12); + $x3 += $x4; + $x14 = self::leftRotate($x14 ^ $x3, 8); + $x9 += $x14; + $x4 = self::leftRotate($x4 ^ $x9, 7); // columnRound - $x0+= $x4; $x12 = self::leftRotate($x12 ^ $x0, 16); - $x8+= $x12; $x4 = self::leftRotate($x4 ^ $x8, 12); - $x0+= $x4; $x12 = self::leftRotate($x12 ^ $x0, 8); - $x8+= $x12; $x4 = self::leftRotate($x4 ^ $x8, 7); + $x0 += $x4; + $x12 = self::leftRotate($x12 ^ $x0, 16); + $x8 += $x12; + $x4 = self::leftRotate($x4 ^ $x8, 12); + $x0 += $x4; + $x12 = self::leftRotate($x12 ^ $x0, 8); + $x8 += $x12; + $x4 = self::leftRotate($x4 ^ $x8, 7); - $x1+= $x5; $x13 = self::leftRotate($x13 ^ $x1, 16); - $x9+= $x13; $x5 = self::leftRotate($x5 ^ $x9, 12); - $x1+= $x5; $x13 = self::leftRotate($x13 ^ $x1, 8); - $x9+= $x13; $x5 = self::leftRotate($x5 ^ $x9, 7); + $x1 += $x5; + $x13 = self::leftRotate($x13 ^ $x1, 16); + $x9 += $x13; + $x5 = self::leftRotate($x5 ^ $x9, 12); + $x1 += $x5; + $x13 = self::leftRotate($x13 ^ $x1, 8); + $x9 += $x13; + $x5 = self::leftRotate($x5 ^ $x9, 7); - $x2+= $x6; $x14 = self::leftRotate($x14 ^ $x2, 16); - $x10+= $x14; $x6 = self::leftRotate($x6 ^ $x10, 12); - $x2+= $x6; $x14 = self::leftRotate($x14 ^ $x2, 8); - $x10+= $x14; $x6 = self::leftRotate($x6 ^ $x10, 7); + $x2 += $x6; + $x14 = self::leftRotate($x14 ^ $x2, 16); + $x10 += $x14; + $x6 = self::leftRotate($x6 ^ $x10, 12); + $x2 += $x6; + $x14 = self::leftRotate($x14 ^ $x2, 8); + $x10 += $x14; + $x6 = self::leftRotate($x6 ^ $x10, 7); - $x3+= $x7; $x15 = self::leftRotate($x15 ^ $x3, 16); - $x11+= $x15; $x7 = self::leftRotate($x7 ^ $x11, 12); - $x3+= $x7; $x15 = self::leftRotate($x15 ^ $x3, 8); - $x11+= $x15; $x7 = self::leftRotate($x7 ^ $x11, 7); + $x3 += $x7; + $x15 = self::leftRotate($x15 ^ $x3, 16); + $x11 += $x15; + $x7 = self::leftRotate($x7 ^ $x11, 12); + $x3 += $x7; + $x15 = self::leftRotate($x15 ^ $x3, 8); + $x11 += $x15; + $x7 = self::leftRotate($x7 ^ $x11, 7); // rowRound - $x0+= $x5; $x15 = self::leftRotate($x15 ^ $x0, 16); - $x10+= $x15; $x5 = self::leftRotate($x5 ^ $x10, 12); - $x0+= $x5; $x15 = self::leftRotate($x15 ^ $x0, 8); - $x10+= $x15; $x5 = self::leftRotate($x5 ^ $x10, 7); + $x0 += $x5; + $x15 = self::leftRotate($x15 ^ $x0, 16); + $x10 += $x15; + $x5 = self::leftRotate($x5 ^ $x10, 12); + $x0 += $x5; + $x15 = self::leftRotate($x15 ^ $x0, 8); + $x10 += $x15; + $x5 = self::leftRotate($x5 ^ $x10, 7); - $x1+= $x6; $x12 = self::leftRotate($x12 ^ $x1, 16); - $x11+= $x12; $x6 = self::leftRotate($x6 ^ $x11, 12); - $x1+= $x6; $x12 = self::leftRotate($x12 ^ $x1, 8); - $x11+= $x12; $x6 = self::leftRotate($x6 ^ $x11, 7); + $x1 += $x6; + $x12 = self::leftRotate($x12 ^ $x1, 16); + $x11 += $x12; + $x6 = self::leftRotate($x6 ^ $x11, 12); + $x1 += $x6; + $x12 = self::leftRotate($x12 ^ $x1, 8); + $x11 += $x12; + $x6 = self::leftRotate($x6 ^ $x11, 7); - $x2+= $x7; $x13 = self::leftRotate($x13 ^ $x2, 16); - $x8+= $x13; $x7 = self::leftRotate($x7 ^ $x8, 12); - $x2+= $x7; $x13 = self::leftRotate($x13 ^ $x2, 8); - $x8+= $x13; $x7 = self::leftRotate($x7 ^ $x8, 7); + $x2 += $x7; + $x13 = self::leftRotate($x13 ^ $x2, 16); + $x8 += $x13; + $x7 = self::leftRotate($x7 ^ $x8, 12); + $x2 += $x7; + $x13 = self::leftRotate($x13 ^ $x2, 8); + $x8 += $x13; + $x7 = self::leftRotate($x7 ^ $x8, 7); - $x3+= $x4; $x14 = self::leftRotate($x14 ^ $x3, 16); - $x9+= $x14; $x4 = self::leftRotate($x4 ^ $x9, 12); - $x3+= $x4; $x14 = self::leftRotate($x14 ^ $x3, 8); - $x9+= $x14; $x4 = self::leftRotate($x4 ^ $x9, 7); + $x3 += $x4; + $x14 = self::leftRotate($x14 ^ $x3, 16); + $x9 += $x14; + $x4 = self::leftRotate($x4 ^ $x9, 12); + $x3 += $x4; + $x14 = self::leftRotate($x14 ^ $x3, 8); + $x9 += $x14; + $x4 = self::leftRotate($x4 ^ $x9, 7); - $x0+= $z0; - $x1+= $z1; - $x2+= $z2; - $x3+= $z3; - $x4+= $z4; - $x5+= $z5; - $x6+= $z6; - $x7+= $z7; - $x8+= $z8; - $x9+= $z9; - $x10+= $z10; - $x11+= $z11; - $x12+= $z12; - $x13+= $z13; - $x14+= $z14; - $x15+= $z15; + $x0 += $z0; + $x1 += $z1; + $x2 += $z2; + $x3 += $z3; + $x4 += $z4; + $x5 += $z5; + $x6 += $z6; + $x7 += $z7; + $x8 += $z8; + $x9 += $z9; + $x10 += $z10; + $x11 += $z11; + $x12 += $z12; + $x13 += $z13; + $x14 += $z14; + $x15 += $z15; return pack('V*', $x0, $x1, $x2, $x3, $x4, $x5, $x6, $x7, $x8, $x9, $x10, $x11, $x12, $x13, $x14, $x15); } diff --git a/phpseclib/Crypt/Common/AsymmetricKey.php b/phpseclib/Crypt/Common/AsymmetricKey.php index d5fa46dc..4512eb85 100644 --- a/phpseclib/Crypt/Common/AsymmetricKey.php +++ b/phpseclib/Crypt/Common/AsymmetricKey.php @@ -145,7 +145,7 @@ abstract class AsymmetricKey protected static function initialize_static_variables() { if (!isset(self::$zero)) { - self::$zero= new BigInteger(0); + self::$zero = new BigInteger(0); self::$one = new BigInteger(1); } @@ -337,7 +337,7 @@ abstract class AsymmetricKey * @param string $method optional * @return mixed */ - protected static function validatePlugin($format, $type, $method = NULL) + protected static function validatePlugin($format, $type, $method = null) { $type = strtolower($type); if (!isset(self::$plugins[static::ALGORITHM][$format][$type])) { @@ -519,7 +519,7 @@ abstract class AsymmetricKey */ public function getHash() { - return clone $this->hash; + return clone $this->hash; } /** @@ -581,7 +581,7 @@ abstract class AsymmetricKey $rolen = $this->q->getLengthInBytes(); if (strlen($out) < $rolen) { return str_pad($out, $rolen, "\0", STR_PAD_LEFT); - } else if (strlen($out) > $rolen) { + } elseif (strlen($out) > $rolen) { return substr($out, -$rolen); } else { return $out; diff --git a/phpseclib/Crypt/Common/Formats/Keys/OpenSSH.php b/phpseclib/Crypt/Common/Formats/Keys/OpenSSH.php index b06f5af9..7ed84a12 100644 --- a/phpseclib/Crypt/Common/Formats/Keys/OpenSSH.php +++ b/phpseclib/Crypt/Common/Formats/Keys/OpenSSH.php @@ -222,7 +222,7 @@ abstract class OpenSSH */ $paddingLength = (7 * strlen($paddedKey)) % 8; for ($i = 1; $i <= $paddingLength; $i++) { - $paddedKey.= chr($i); + $paddedKey .= chr($i); } $key = Strings::packSSH2('sssNss', 'none', 'none', '', 1, $publicKey, $paddedKey); $key = "openssh-key-v1\0$key"; diff --git a/phpseclib/Crypt/Common/Formats/Keys/PKCS.php b/phpseclib/Crypt/Common/Formats/Keys/PKCS.php index 3550cc53..6566f278 100644 --- a/phpseclib/Crypt/Common/Formats/Keys/PKCS.php +++ b/phpseclib/Crypt/Common/Formats/Keys/PKCS.php @@ -77,4 +77,4 @@ abstract class PKCS { self::$format = self::MODE_ANY; } -} \ No newline at end of file +} diff --git a/phpseclib/Crypt/Common/Formats/Keys/PKCS1.php b/phpseclib/Crypt/Common/Formats/Keys/PKCS1.php index ee0d2c7e..e9948ce8 100644 --- a/phpseclib/Crypt/Common/Formats/Keys/PKCS1.php +++ b/phpseclib/Crypt/Common/Formats/Keys/PKCS1.php @@ -113,7 +113,7 @@ abstract class PKCS1 extends PKCS $symkey = ''; $iv = substr($iv, 0, 8); while (strlen($symkey) < $length) { - $symkey.= md5($symkey . $password . $iv, true); + $symkey .= md5($symkey . $password . $iv, true); } return substr($symkey, 0, $length); } @@ -200,7 +200,7 @@ abstract class PKCS1 extends PKCS $iv = strtoupper(Hex::encode($iv)); return "-----BEGIN $type PRIVATE KEY-----\r\n" . "Proc-Type: 4,ENCRYPTED\r\n" . - "DEK-Info: " . $encryptionAlgorithm. ",$iv\r\n" . + "DEK-Info: " . $encryptionAlgorithm . ",$iv\r\n" . "\r\n" . chunk_split(Base64::encode($cipher->encrypt($key)), 64) . "-----END $type PRIVATE KEY-----"; @@ -220,4 +220,4 @@ abstract class PKCS1 extends PKCS chunk_split(Base64::encode($key), 64) . "-----END $type PUBLIC KEY-----"; } -} \ No newline at end of file +} diff --git a/phpseclib/Crypt/Common/Formats/Keys/PKCS8.php b/phpseclib/Crypt/Common/Formats/Keys/PKCS8.php index 4f1db684..e1b62f11 100644 --- a/phpseclib/Crypt/Common/Formats/Keys/PKCS8.php +++ b/phpseclib/Crypt/Common/Formats/Keys/PKCS8.php @@ -275,8 +275,7 @@ abstract class PKCS8 extends PKCS if (!static::$childOIDsLoaded) { ASN1::loadOIDs(is_array(static::OID_NAME) ? array_combine(static::OID_NAME, static::OID_VALUE) : - [static::OID_NAME => static::OID_VALUE] - ); + [static::OID_NAME => static::OID_VALUE]); static::$childOIDsLoaded = true; } if (!self::$oidsLoaded) { @@ -287,8 +286,8 @@ abstract class PKCS8 extends PKCS 'pbeWithMD2AndRC2-CBC' => '1.2.840.113549.1.5.4', 'pbeWithMD5AndDES-CBC' => '1.2.840.113549.1.5.3', 'pbeWithMD5AndRC2-CBC' => '1.2.840.113549.1.5.6', - 'pbeWithSHA1AndDES-CBC'=> '1.2.840.113549.1.5.10', - 'pbeWithSHA1AndRC2-CBC'=> '1.2.840.113549.1.5.11', + 'pbeWithSHA1AndDES-CBC' => '1.2.840.113549.1.5.10', + 'pbeWithSHA1AndRC2-CBC' => '1.2.840.113549.1.5.11', // from PKCS#12: // https://tools.ietf.org/html/rfc7292 @@ -308,10 +307,10 @@ abstract class PKCS8 extends PKCS 'id-hmacWithSHA1' => '1.2.840.113549.2.7', 'id-hmacWithSHA224' => '1.2.840.113549.2.8', 'id-hmacWithSHA256' => '1.2.840.113549.2.9', - 'id-hmacWithSHA384'=> '1.2.840.113549.2.10', - 'id-hmacWithSHA512'=> '1.2.840.113549.2.11', - 'id-hmacWithSHA512-224'=> '1.2.840.113549.2.12', - 'id-hmacWithSHA512-256'=> '1.2.840.113549.2.13', + 'id-hmacWithSHA384' => '1.2.840.113549.2.10', + 'id-hmacWithSHA512' => '1.2.840.113549.2.11', + 'id-hmacWithSHA512-224' => '1.2.840.113549.2.12', + 'id-hmacWithSHA512-256' => '1.2.840.113549.2.13', 'desCBC' => '1.3.14.3.2.7', 'des-EDE3-CBC' => '1.2.840.113549.3.7', @@ -319,8 +318,8 @@ abstract class PKCS8 extends PKCS 'rc5-CBC-PAD' => '1.2.840.113549.3.9', 'aes128-CBC-PAD' => '2.16.840.1.101.3.4.1.2', - 'aes192-CBC-PAD'=> '2.16.840.1.101.3.4.1.22', - 'aes256-CBC-PAD'=> '2.16.840.1.101.3.4.1.42' + 'aes192-CBC-PAD' => '2.16.840.1.101.3.4.1.22', + 'aes256-CBC-PAD' => '2.16.840.1.101.3.4.1.42' ]); self::$oidsLoaded = true; } diff --git a/phpseclib/Crypt/Common/Formats/Keys/PuTTY.php b/phpseclib/Crypt/Common/Formats/Keys/PuTTY.php index e80a28f2..c4d59daf 100644 --- a/phpseclib/Crypt/Common/Formats/Keys/PuTTY.php +++ b/phpseclib/Crypt/Common/Formats/Keys/PuTTY.php @@ -89,7 +89,7 @@ abstract class PuTTY $sequence = 0; while (strlen($symkey) < $length) { $temp = pack('Na*', $sequence++, $password); - $symkey.= Hex::decode(sha1($temp)); + $symkey .= Hex::decode(sha1($temp)); } return substr($symkey, 0, $length); } @@ -170,10 +170,10 @@ abstract class PuTTY break; case $in_value: $in_value = $line[strlen($line) - 1] == '\\'; - $values[$current].= $in_value ? substr($line, 0, -1) : $line; + $values[$current] .= $in_value ? substr($line, 0, -1) : $line; break; default: - $data.= $line; + $data .= $line; } } @@ -246,7 +246,7 @@ abstract class PuTTY case 2: $symkey = self::generateV2Key($password, 32); $symiv = str_repeat("\0", $crypto->getBlockLength() >> 3); - $hashkey.= $password; + $hashkey .= $password; } } @@ -270,7 +270,7 @@ abstract class PuTTY $private = $crypto->decrypt($private); } - $source.= Strings::packSSH2('s', $private); + $source .= Strings::packSSH2('s', $private); $hmac = trim(preg_replace('#Private-MAC: (.+)#', '$1', $key[$offset + $privateLength])); $hmac = Hex::decode($hmac); @@ -302,19 +302,19 @@ abstract class PuTTY $version = isset($options['version']) ? $options['version'] : self::$version; $key = "PuTTY-User-Key-File-$version: $type\r\n"; - $key.= "Encryption: $encryption\r\n"; - $key.= "Comment: $comment\r\n"; + $key .= "Encryption: $encryption\r\n"; + $key .= "Comment: $comment\r\n"; $public = Strings::packSSH2('s', $type) . $public; $source = Strings::packSSH2('ssss', $type, $encryption, $comment, $public); $public = Base64::encode($public); - $key.= "Public-Lines: " . ((strlen($public) + 63) >> 6) . "\r\n"; - $key.= chunk_split($public, 64); + $key .= "Public-Lines: " . ((strlen($public) + 63) >> 6) . "\r\n"; + $key .= chunk_split($public, 64); if (empty($password) && !is_string($password)) { - $source.= Strings::packSSH2('s', $private); + $source .= Strings::packSSH2('s', $private); switch ($version) { case 3: $hash = new Hash('sha256'); @@ -325,18 +325,18 @@ abstract class PuTTY $hash->setKey(sha1('putty-private-key-file-mac-key', true)); } } else { - $private.= Random::string(16 - (strlen($private) & 15)); - $source.= Strings::packSSH2('s', $private); + $private .= Random::string(16 - (strlen($private) & 15)); + $source .= Strings::packSSH2('s', $private); $crypto = new AES('cbc'); switch ($version) { case 3: $salt = Random::string(16); - $key.= "Key-Derivation: Argon2id\r\n"; - $key.= "Argon2-Memory: 8192\r\n"; - $key.= "Argon2-Passes: 13\r\n"; - $key.= "Argon2-Parallelism: 1\r\n"; - $key.= "Argon2-Salt: " . Hex::encode($salt) . "\r\n"; + $key .= "Key-Derivation: Argon2id\r\n"; + $key .= "Argon2-Memory: 8192\r\n"; + $key .= "Argon2-Passes: 13\r\n"; + $key .= "Argon2-Parallelism: 1\r\n"; + $key .= "Argon2-Salt: " . Hex::encode($salt) . "\r\n"; extract(self::generateV3Key($password, 'Argon2id', 8192, 13, $salt)); $hash = new Hash('sha256'); @@ -360,9 +360,9 @@ abstract class PuTTY } $private = Base64::encode($private); - $key.= 'Private-Lines: ' . ((strlen($private) + 63) >> 6) . "\r\n"; - $key.= chunk_split($private, 64); - $key.= 'Private-MAC: ' . Hex::encode($hash->hash($source)) . "\r\n"; + $key .= 'Private-Lines: ' . ((strlen($private) + 63) >> 6) . "\r\n"; + $key .= chunk_split($private, 64); + $key .= 'Private-MAC: ' . Hex::encode($hash->hash($source)) . "\r\n"; return $key; } diff --git a/phpseclib/Crypt/Common/SymmetricKey.php b/phpseclib/Crypt/Common/SymmetricKey.php index 519a284e..400a7d5c 100644 --- a/phpseclib/Crypt/Common/SymmetricKey.php +++ b/phpseclib/Crypt/Common/SymmetricKey.php @@ -887,7 +887,7 @@ abstract class SymmetricKey if (is_string($this->key) && strlen($this->key) != $this->explicit_key_length) { $this->key = false; - throw new InconsistentSetupException('Key has already been set and is not ' .$this->explicit_key_length . ' bytes long'); + throw new InconsistentSetupException('Key has already been set and is not ' . $this->explicit_key_length . ' bytes long'); } } @@ -980,7 +980,7 @@ abstract class SymmetricKey -- https://tools.ietf.org/html/rfc7292#appendix-B.1 */ - $password = "\0". chunk_split($password, 1, "\0") . "\0"; + $password = "\0" . chunk_split($password, 1, "\0") . "\0"; /* This standard specifies 3 different values for the ID byte mentioned @@ -1003,7 +1003,7 @@ abstract class SymmetricKey $s = ''; if (strlen($salt)) { while (strlen($s) < $blockLength) { - $s.= $salt; + $s .= $salt; } } $s = substr($s, 0, $blockLength); @@ -1011,7 +1011,7 @@ abstract class SymmetricKey $p = ''; if (strlen($password)) { while (strlen($p) < $blockLength) { - $p.= $password; + $p .= $password; } } $p = substr($p, 0, $blockLength); @@ -1047,9 +1047,9 @@ abstract class SymmetricKey $f = $u = $hashObj->hash($salt . pack('N', $i++)); for ($j = 2; $j <= $count; ++$j) { $u = $hashObj->hash($u); - $f^= $u; + $f ^= $u; } - $key.= $f; + $key .= $f; } $key = substr($key, 0, $dkLen); break; @@ -1100,21 +1100,21 @@ abstract class SymmetricKey } $b = ''; while (strlen($b) < $blockLength) { - $b.= $ai; + $b .= $ai; } $b = substr($b, 0, $blockLength); $b = new BigInteger($b, 256); $newi = ''; - for ($k = 0; $k < strlen($i); $k+= $blockLength) { + for ($k = 0; $k < strlen($i); $k += $blockLength) { $temp = substr($i, $k, $blockLength); $temp = new BigInteger($temp, 256); $temp->setPrecision($blockLength << 3); $temp = $temp->add($b); $temp = $temp->add($one); - $newi.= $temp->toBytes(false); + $newi .= $temp->toBytes(false); } $i = $newi; - $a.= $ai; + $a .= $ai; } return substr($a, 0, $n); @@ -1209,11 +1209,11 @@ abstract class SymmetricKey $max = $this->block_size - $pos; if ($len >= $max) { $i = $max; - $len-= $max; + $len -= $max; $pos = 0; } else { $i = $len; - $pos+= $len; + $pos += $len; $len = 0; } // ie. $i = min($max, $len), $len-= $i, $pos+= $i, $pos%= $blocksize @@ -1225,13 +1225,13 @@ abstract class SymmetricKey $overflow = $len % $this->block_size; if ($overflow) { - $ciphertext.= openssl_encrypt(substr($plaintext, 0, -$overflow) . str_repeat("\0", $this->block_size), $this->cipher_name_openssl, $this->key, OPENSSL_RAW_DATA | OPENSSL_ZERO_PADDING, $iv); + $ciphertext .= openssl_encrypt(substr($plaintext, 0, -$overflow) . str_repeat("\0", $this->block_size), $this->cipher_name_openssl, $this->key, OPENSSL_RAW_DATA | OPENSSL_ZERO_PADDING, $iv); $iv = Strings::pop($ciphertext, $this->block_size); $size = $len - $overflow; $block = $iv ^ substr($plaintext, -$overflow); $iv = substr_replace($iv, $block, 0, $overflow); - $ciphertext.= $block; + $ciphertext .= $block; $pos = $overflow; } elseif ($len) { $ciphertext = openssl_encrypt($plaintext, $this->cipher_name_openssl, $this->key, OPENSSL_RAW_DATA | OPENSSL_ZERO_PADDING, $iv); @@ -1256,7 +1256,7 @@ abstract class SymmetricKey for ($i = 0; $i < $len; ++$i) { $xor = openssl_encrypt($iv, $this->cipher_name_openssl_ecb, $this->key, $this->openssl_options, $this->decryptIV); - $ciphertext.= $plaintext[$i] ^ $xor; + $ciphertext .= $plaintext[$i] ^ $xor; $iv = substr($iv, 1) . $xor[0]; } @@ -1270,7 +1270,8 @@ abstract class SymmetricKey } if ($this->engine === self::ENGINE_MCRYPT) { - set_error_handler(function() {}); + set_error_handler(function () { + }); if ($this->enchanged) { mcrypt_generic_init($this->enmcrypt, $this->key, $this->getIV($this->encryptIV)); $this->enchanged = false; @@ -1291,11 +1292,11 @@ abstract class SymmetricKey $max = $block_size - $pos; if ($len >= $max) { $i = $max; - $len-= $max; + $len -= $max; $pos = 0; } else { $i = $len; - $pos+= $len; + $pos += $len; $len = 0; } $ciphertext = substr($iv, $orig_pos) ^ $plaintext; @@ -1308,15 +1309,15 @@ abstract class SymmetricKey mcrypt_generic_init($this->enmcrypt, $this->key, $iv); $this->enbuffer['enmcrypt_init'] = false; } - $ciphertext.= mcrypt_generic($this->enmcrypt, substr($plaintext, $i, $len - $len % $block_size)); + $ciphertext .= mcrypt_generic($this->enmcrypt, substr($plaintext, $i, $len - $len % $block_size)); $iv = substr($ciphertext, -$block_size); - $len%= $block_size; + $len %= $block_size; } else { while ($len >= $block_size) { $iv = mcrypt_generic($this->ecb, $iv) ^ substr($plaintext, $i, $block_size); - $ciphertext.= $iv; - $len-= $block_size; - $i+= $block_size; + $ciphertext .= $iv; + $len -= $block_size; + $i += $block_size; } } } @@ -1325,7 +1326,7 @@ abstract class SymmetricKey $iv = mcrypt_generic($this->ecb, $iv); $block = $iv ^ substr($plaintext, -$len); $iv = substr_replace($iv, $block, 0, $len); - $ciphertext.= $block; + $ciphertext .= $block; $pos = $len; } @@ -1355,17 +1356,17 @@ abstract class SymmetricKey $ciphertext = ''; switch ($this->mode) { case self::MODE_ECB: - for ($i = 0; $i < strlen($plaintext); $i+=$block_size) { - $ciphertext.= $this->encryptBlock(substr($plaintext, $i, $block_size)); + for ($i = 0; $i < strlen($plaintext); $i += $block_size) { + $ciphertext .= $this->encryptBlock(substr($plaintext, $i, $block_size)); } break; case self::MODE_CBC: $xor = $this->encryptIV; - for ($i = 0; $i < strlen($plaintext); $i+=$block_size) { + for ($i = 0; $i < strlen($plaintext); $i += $block_size) { $block = substr($plaintext, $i, $block_size); $block = $this->encryptBlock($block ^ $xor); $xor = $block; - $ciphertext.= $block; + $ciphertext .= $block; } if ($this->continuousBuffer) { $this->encryptIV = $xor; @@ -1374,21 +1375,21 @@ abstract class SymmetricKey case self::MODE_CTR: $xor = $this->encryptIV; if (strlen($buffer['ciphertext'])) { - for ($i = 0; $i < strlen($plaintext); $i+=$block_size) { + for ($i = 0; $i < strlen($plaintext); $i += $block_size) { $block = substr($plaintext, $i, $block_size); if (strlen($block) > strlen($buffer['ciphertext'])) { - $buffer['ciphertext'].= $this->encryptBlock($xor); + $buffer['ciphertext'] .= $this->encryptBlock($xor); Strings::increment_str($xor); } $key = Strings::shift($buffer['ciphertext'], $block_size); - $ciphertext.= $block ^ $key; + $ciphertext .= $block ^ $key; } } else { - for ($i = 0; $i < strlen($plaintext); $i+=$block_size) { + for ($i = 0; $i < strlen($plaintext); $i += $block_size) { $block = substr($plaintext, $i, $block_size); $key = $this->encryptBlock($xor); Strings::increment_str($xor); - $ciphertext.= $block ^ $key; + $ciphertext .= $block ^ $key; } } if ($this->continuousBuffer) { @@ -1415,11 +1416,11 @@ abstract class SymmetricKey $max = $block_size - $pos; if ($len >= $max) { $i = $max; - $len-= $max; + $len -= $max; $pos = 0; } else { $i = $len; - $pos+= $len; + $pos += $len; $len = 0; } // ie. $i = min($max, $len), $len-= $i, $pos+= $i, $pos%= $blocksize @@ -1428,15 +1429,15 @@ abstract class SymmetricKey } while ($len >= $block_size) { $iv = $this->encryptBlock($iv) ^ substr($plaintext, $i, $block_size); - $ciphertext.= $iv; - $len-= $block_size; - $i+= $block_size; + $ciphertext .= $iv; + $len -= $block_size; + $i += $block_size; } if ($len) { $iv = $this->encryptBlock($iv); $block = $iv ^ substr($plaintext, $i); $iv = substr_replace($iv, $block, 0, $len); - $ciphertext.= $block; + $ciphertext .= $block; $pos = $len; } break; @@ -1465,7 +1466,7 @@ abstract class SymmetricKey for ($i = 0; $i < $len; ++$i) { $xor = $this->encryptBlock($iv); - $ciphertext.= $plaintext[$i] ^ $xor; + $ciphertext .= $plaintext[$i] ^ $xor; $iv = substr($iv, 1) . $xor[0]; } @@ -1476,19 +1477,19 @@ abstract class SymmetricKey case self::MODE_OFB: $xor = $this->encryptIV; if (strlen($buffer['xor'])) { - for ($i = 0; $i < strlen($plaintext); $i+=$block_size) { + for ($i = 0; $i < strlen($plaintext); $i += $block_size) { $block = substr($plaintext, $i, $block_size); if (strlen($block) > strlen($buffer['xor'])) { $xor = $this->encryptBlock($xor); - $buffer['xor'].= $xor; + $buffer['xor'] .= $xor; } $key = Strings::shift($buffer['xor'], $block_size); - $ciphertext.= $block ^ $key; + $ciphertext .= $block ^ $key; } } else { - for ($i = 0; $i < strlen($plaintext); $i+=$block_size) { + for ($i = 0; $i < strlen($plaintext); $i += $block_size) { $xor = $this->encryptBlock($xor); - $ciphertext.= substr($plaintext, $i, $block_size) ^ $xor; + $ciphertext .= substr($plaintext, $i, $block_size) ^ $xor; } $key = $xor; } @@ -1600,11 +1601,11 @@ abstract class SymmetricKey $max = $this->block_size - $pos; if ($len >= $max) { $i = $max; - $len-= $max; + $len -= $max; $pos = 0; } else { $i = $len; - $pos+= $len; + $pos += $len; $len = 0; } // ie. $i = min($max, $len), $len-= $i, $pos+= $i, $pos%= $this->blocksize @@ -1614,16 +1615,16 @@ abstract class SymmetricKey } $overflow = $len % $this->block_size; if ($overflow) { - $plaintext.= openssl_decrypt(substr($ciphertext, 0, -$overflow), $this->cipher_name_openssl, $this->key, OPENSSL_RAW_DATA | OPENSSL_ZERO_PADDING, $iv); + $plaintext .= openssl_decrypt(substr($ciphertext, 0, -$overflow), $this->cipher_name_openssl, $this->key, OPENSSL_RAW_DATA | OPENSSL_ZERO_PADDING, $iv); if ($len - $overflow) { $iv = substr($ciphertext, -$overflow - $this->block_size, -$overflow); } $iv = openssl_encrypt(str_repeat("\0", $this->block_size), $this->cipher_name_openssl, $this->key, OPENSSL_RAW_DATA | OPENSSL_ZERO_PADDING, $iv); - $plaintext.= $iv ^ substr($ciphertext, -$overflow); + $plaintext .= $iv ^ substr($ciphertext, -$overflow); $iv = substr_replace($iv, substr($ciphertext, -$overflow), 0, $overflow); $pos = $overflow; } elseif ($len) { - $plaintext.= openssl_decrypt($ciphertext, $this->cipher_name_openssl, $this->key, OPENSSL_RAW_DATA | OPENSSL_ZERO_PADDING, $iv); + $plaintext .= openssl_decrypt($ciphertext, $this->cipher_name_openssl, $this->key, OPENSSL_RAW_DATA | OPENSSL_ZERO_PADDING, $iv); $iv = substr($ciphertext, -$this->block_size); } break; @@ -1644,7 +1645,7 @@ abstract class SymmetricKey for ($i = 0; $i < $len; ++$i) { $xor = openssl_encrypt($iv, $this->cipher_name_openssl_ecb, $this->key, $this->openssl_options, $this->decryptIV); - $plaintext.= $ciphertext[$i] ^ $xor; + $plaintext .= $ciphertext[$i] ^ $xor; $iv = substr($iv, 1) . $xor[0]; } @@ -1660,7 +1661,8 @@ abstract class SymmetricKey } if ($this->engine === self::ENGINE_MCRYPT) { - set_error_handler(function() {}); + set_error_handler(function () { + }); $block_size = $this->block_size; if ($this->dechanged) { mcrypt_generic_init($this->demcrypt, $this->key, $this->getIV($this->decryptIV)); @@ -1678,11 +1680,11 @@ abstract class SymmetricKey $max = $block_size - $pos; if ($len >= $max) { $i = $max; - $len-= $max; + $len -= $max; $pos = 0; } else { $i = $len; - $pos+= $len; + $pos += $len; $len = 0; } // ie. $i = min($max, $len), $len-= $i, $pos+= $i, $pos%= $blocksize @@ -1691,13 +1693,13 @@ abstract class SymmetricKey } if ($len >= $block_size) { $cb = substr($ciphertext, $i, $len - $len % $block_size); - $plaintext.= mcrypt_generic($this->ecb, $iv . $cb) ^ $cb; + $plaintext .= mcrypt_generic($this->ecb, $iv . $cb) ^ $cb; $iv = substr($cb, -$block_size); - $len%= $block_size; + $len %= $block_size; } if ($len) { $iv = mcrypt_generic($this->ecb, $iv); - $plaintext.= $iv ^ substr($ciphertext, -$len); + $plaintext .= $iv ^ substr($ciphertext, -$len); $iv = substr_replace($iv, substr($ciphertext, -$len), 0, $len); $pos = $len; } @@ -1729,15 +1731,15 @@ abstract class SymmetricKey $plaintext = ''; switch ($this->mode) { case self::MODE_ECB: - for ($i = 0; $i < strlen($ciphertext); $i+=$block_size) { - $plaintext.= $this->decryptBlock(substr($ciphertext, $i, $block_size)); + for ($i = 0; $i < strlen($ciphertext); $i += $block_size) { + $plaintext .= $this->decryptBlock(substr($ciphertext, $i, $block_size)); } break; case self::MODE_CBC: $xor = $this->decryptIV; - for ($i = 0; $i < strlen($ciphertext); $i+=$block_size) { + for ($i = 0; $i < strlen($ciphertext); $i += $block_size) { $block = substr($ciphertext, $i, $block_size); - $plaintext.= $this->decryptBlock($block) ^ $xor; + $plaintext .= $this->decryptBlock($block) ^ $xor; $xor = $block; } if ($this->continuousBuffer) { @@ -1747,21 +1749,21 @@ abstract class SymmetricKey case self::MODE_CTR: $xor = $this->decryptIV; if (strlen($buffer['ciphertext'])) { - for ($i = 0; $i < strlen($ciphertext); $i+=$block_size) { + for ($i = 0; $i < strlen($ciphertext); $i += $block_size) { $block = substr($ciphertext, $i, $block_size); if (strlen($block) > strlen($buffer['ciphertext'])) { - $buffer['ciphertext'].= $this->encryptBlock($xor); + $buffer['ciphertext'] .= $this->encryptBlock($xor); Strings::increment_str($xor); } $key = Strings::shift($buffer['ciphertext'], $block_size); - $plaintext.= $block ^ $key; + $plaintext .= $block ^ $key; } } else { - for ($i = 0; $i < strlen($ciphertext); $i+=$block_size) { + for ($i = 0; $i < strlen($ciphertext); $i += $block_size) { $block = substr($ciphertext, $i, $block_size); $key = $this->encryptBlock($xor); Strings::increment_str($xor); - $plaintext.= $block ^ $key; + $plaintext .= $block ^ $key; } } if ($this->continuousBuffer) { @@ -1786,11 +1788,11 @@ abstract class SymmetricKey $max = $block_size - $pos; if ($len >= $max) { $i = $max; - $len-= $max; + $len -= $max; $pos = 0; } else { $i = $len; - $pos+= $len; + $pos += $len; $len = 0; } // ie. $i = min($max, $len), $len-= $i, $pos+= $i, $pos%= $blocksize @@ -1800,14 +1802,14 @@ abstract class SymmetricKey while ($len >= $block_size) { $iv = $this->encryptBlock($iv); $cb = substr($ciphertext, $i, $block_size); - $plaintext.= $iv ^ $cb; + $plaintext .= $iv ^ $cb; $iv = $cb; - $len-= $block_size; - $i+= $block_size; + $len -= $block_size; + $i += $block_size; } if ($len) { $iv = $this->encryptBlock($iv); - $plaintext.= $iv ^ substr($ciphertext, $i); + $plaintext .= $iv ^ substr($ciphertext, $i); $iv = substr_replace($iv, substr($ciphertext, $i), 0, $len); $pos = $len; } @@ -1837,7 +1839,7 @@ abstract class SymmetricKey for ($i = 0; $i < $len; ++$i) { $xor = $this->encryptBlock($iv); - $plaintext.= $ciphertext[$i] ^ $xor; + $plaintext .= $ciphertext[$i] ^ $xor; $iv = substr($iv, 1) . $xor[0]; } @@ -1848,19 +1850,19 @@ abstract class SymmetricKey case self::MODE_OFB: $xor = $this->decryptIV; if (strlen($buffer['xor'])) { - for ($i = 0; $i < strlen($ciphertext); $i+=$block_size) { + for ($i = 0; $i < strlen($ciphertext); $i += $block_size) { $block = substr($ciphertext, $i, $block_size); if (strlen($block) > strlen($buffer['xor'])) { $xor = $this->encryptBlock($xor); - $buffer['xor'].= $xor; + $buffer['xor'] .= $xor; } $key = Strings::shift($buffer['xor'], $block_size); - $plaintext.= $block ^ $key; + $plaintext .= $block ^ $key; } } else { - for ($i = 0; $i < strlen($ciphertext); $i+=$block_size) { + for ($i = 0; $i < strlen($ciphertext); $i += $block_size) { $xor = $this->encryptBlock($xor); - $plaintext.= substr($ciphertext, $i, $block_size) ^ $xor; + $plaintext .= substr($ciphertext, $i, $block_size) ^ $xor; } $key = $xor; } @@ -1984,21 +1986,21 @@ abstract class SymmetricKey if ($this->openssl_emulate_ctr) { $xor = $encryptIV; if (strlen($buffer['ciphertext'])) { - for ($i = 0; $i < strlen($plaintext); $i+=$block_size) { + for ($i = 0; $i < strlen($plaintext); $i += $block_size) { $block = substr($plaintext, $i, $block_size); if (strlen($block) > strlen($buffer['ciphertext'])) { - $buffer['ciphertext'].= openssl_encrypt($xor, $this->cipher_name_openssl_ecb, $key, OPENSSL_RAW_DATA | OPENSSL_ZERO_PADDING); + $buffer['ciphertext'] .= openssl_encrypt($xor, $this->cipher_name_openssl_ecb, $key, OPENSSL_RAW_DATA | OPENSSL_ZERO_PADDING); } Strings::increment_str($xor); $otp = Strings::shift($buffer['ciphertext'], $block_size); - $ciphertext.= $block ^ $otp; + $ciphertext .= $block ^ $otp; } } else { - for ($i = 0; $i < strlen($plaintext); $i+=$block_size) { + for ($i = 0; $i < strlen($plaintext); $i += $block_size) { $block = substr($plaintext, $i, $block_size); $otp = openssl_encrypt($xor, $this->cipher_name_openssl_ecb, $key, OPENSSL_RAW_DATA | OPENSSL_ZERO_PADDING); Strings::increment_str($xor); - $ciphertext.= $block ^ $otp; + $ciphertext .= $block ^ $otp; } } if ($this->continuousBuffer) { @@ -2025,13 +2027,13 @@ abstract class SymmetricKey $plaintext2 = Strings::pop($plaintext, $overflow); // ie. trim $plaintext to a multiple of $block_size and put rest of $plaintext in $plaintext2 $encrypted = openssl_encrypt($plaintext . str_repeat("\0", $block_size), $this->cipher_name_openssl, $key, OPENSSL_RAW_DATA | OPENSSL_ZERO_PADDING, $encryptIV); $temp = Strings::pop($encrypted, $block_size); - $ciphertext.= $encrypted . ($plaintext2 ^ $temp); + $ciphertext .= $encrypted . ($plaintext2 ^ $temp); if ($this->continuousBuffer) { $buffer['ciphertext'] = substr($temp, $overflow); $encryptIV = $temp; } } elseif (!strlen($buffer['ciphertext'])) { - $ciphertext.= openssl_encrypt($plaintext . str_repeat("\0", $block_size), $this->cipher_name_openssl, $key, OPENSSL_RAW_DATA | OPENSSL_ZERO_PADDING, $encryptIV); + $ciphertext .= openssl_encrypt($plaintext . str_repeat("\0", $block_size), $this->cipher_name_openssl, $key, OPENSSL_RAW_DATA | OPENSSL_ZERO_PADDING, $encryptIV); $temp = Strings::pop($ciphertext, $block_size); if ($this->continuousBuffer) { $encryptIV = $temp; @@ -2080,12 +2082,12 @@ abstract class SymmetricKey if (strlen($plaintext)) { if ($overflow) { - $ciphertext.= openssl_encrypt(substr($plaintext, 0, -$overflow) . str_repeat("\0", $block_size), $this->cipher_name_openssl, $key, OPENSSL_RAW_DATA | OPENSSL_ZERO_PADDING, $encryptIV); + $ciphertext .= openssl_encrypt(substr($plaintext, 0, -$overflow) . str_repeat("\0", $block_size), $this->cipher_name_openssl, $key, OPENSSL_RAW_DATA | OPENSSL_ZERO_PADDING, $encryptIV); $xor = Strings::pop($ciphertext, $block_size); if ($this->continuousBuffer) { $encryptIV = $xor; } - $ciphertext.= Strings::shift($xor, $overflow) ^ substr($plaintext, -$overflow); + $ciphertext .= Strings::shift($xor, $overflow) ^ substr($plaintext, -$overflow); if ($this->continuousBuffer) { $buffer['xor'] = $xor; } @@ -2270,7 +2272,8 @@ abstract class SymmetricKey } return false; case self::ENGINE_MCRYPT: - set_error_handler(function() {}); + set_error_handler(function () { + }); $result = $this->cipher_name_mcrypt && extension_loaded('mcrypt') && in_array($this->cipher_name_mcrypt, mcrypt_list_algorithms()); @@ -2388,7 +2391,8 @@ abstract class SymmetricKey } if ($this->engine != self::ENGINE_MCRYPT && $this->enmcrypt) { - set_error_handler(function() {}); + set_error_handler(function () { + }); // Closing the current mcrypt resource(s). _mcryptSetup() will, if needed, // (re)open them with the module named in $this->cipher_name_mcrypt mcrypt_module_close($this->enmcrypt); @@ -2508,7 +2512,8 @@ abstract class SymmetricKey case self::ENGINE_MCRYPT: $this->enchanged = $this->dechanged = true; - set_error_handler(function() {}); + set_error_handler(function () { + }); if (!isset($this->enmcrypt)) { static $mcrypt_modes = [ @@ -2531,7 +2536,6 @@ abstract class SymmetricKey if ($this->mode == self::MODE_CFB) { $this->ecb = mcrypt_module_open($this->cipher_name_mcrypt, '', MCRYPT_MODE_ECB, ''); } - } // else should mcrypt_generic_deinit be called? if ($this->mode == self::MODE_CFB) { @@ -2806,9 +2810,9 @@ abstract class SymmetricKey $_ciphertext = ""; $_plaintext_len = strlen($_text); - for ($_i = 0; $_i < $_plaintext_len; $_i+= '.$block_size.') { - $in = substr($_text, $_i, '.$block_size.'); - '.$encrypt_block.' + for ($_i = 0; $_i < $_plaintext_len; $_i+= ' . $block_size . ') { + $in = substr($_text, $_i, ' . $block_size . '); + ' . $encrypt_block . ' $_ciphertext.= $in; } @@ -2817,12 +2821,12 @@ abstract class SymmetricKey $decrypt = $init_decrypt . ' $_plaintext = ""; - $_text = str_pad($_text, strlen($_text) + ('.$block_size.' - strlen($_text) % '.$block_size.') % '.$block_size.', chr(0)); + $_text = str_pad($_text, strlen($_text) + (' . $block_size . ' - strlen($_text) % ' . $block_size . ') % ' . $block_size . ', chr(0)); $_ciphertext_len = strlen($_text); - for ($_i = 0; $_i < $_ciphertext_len; $_i+= '.$block_size.') { - $in = substr($_text, $_i, '.$block_size.'); - '.$decrypt_block.' + for ($_i = 0; $_i < $_ciphertext_len; $_i+= ' . $block_size . ') { + $in = substr($_text, $_i, ' . $block_size . '); + ' . $decrypt_block . ' $_plaintext.= $in; } @@ -2836,22 +2840,22 @@ abstract class SymmetricKey $_xor = $this->encryptIV; $_buffer = &$this->enbuffer; if (strlen($_buffer["ciphertext"])) { - for ($_i = 0; $_i < $_plaintext_len; $_i+= '.$block_size.') { - $_block = substr($_text, $_i, '.$block_size.'); + for ($_i = 0; $_i < $_plaintext_len; $_i+= ' . $block_size . ') { + $_block = substr($_text, $_i, ' . $block_size . '); if (strlen($_block) > strlen($_buffer["ciphertext"])) { $in = $_xor; - '.$encrypt_block.' + ' . $encrypt_block . ' \phpseclib3\Common\Functions\Strings::increment_str($_xor); $_buffer["ciphertext"].= $in; } - $_key = \phpseclib3\Common\Functions\Strings::shift($_buffer["ciphertext"], '.$block_size.'); + $_key = \phpseclib3\Common\Functions\Strings::shift($_buffer["ciphertext"], ' . $block_size . '); $_ciphertext.= $_block ^ $_key; } } else { - for ($_i = 0; $_i < $_plaintext_len; $_i+= '.$block_size.') { - $_block = substr($_text, $_i, '.$block_size.'); + for ($_i = 0; $_i < $_plaintext_len; $_i+= ' . $block_size . ') { + $_block = substr($_text, $_i, ' . $block_size . '); $in = $_xor; - '.$encrypt_block.' + ' . $encrypt_block . ' \phpseclib3\Common\Functions\Strings::increment_str($_xor); $_key = $in; $_ciphertext.= $_block ^ $_key; @@ -2859,7 +2863,7 @@ abstract class SymmetricKey } if ($this->continuousBuffer) { $this->encryptIV = $_xor; - if ($_start = $_plaintext_len % '.$block_size.') { + if ($_start = $_plaintext_len % ' . $block_size . ') { $_buffer["ciphertext"] = substr($_key, $_start) . $_buffer["ciphertext"]; } } @@ -2874,22 +2878,22 @@ abstract class SymmetricKey $_buffer = &$this->debuffer; if (strlen($_buffer["ciphertext"])) { - for ($_i = 0; $_i < $_ciphertext_len; $_i+= '.$block_size.') { - $_block = substr($_text, $_i, '.$block_size.'); + for ($_i = 0; $_i < $_ciphertext_len; $_i+= ' . $block_size . ') { + $_block = substr($_text, $_i, ' . $block_size . '); if (strlen($_block) > strlen($_buffer["ciphertext"])) { $in = $_xor; - '.$encrypt_block.' + ' . $encrypt_block . ' \phpseclib3\Common\Functions\Strings::increment_str($_xor); $_buffer["ciphertext"].= $in; } - $_key = \phpseclib3\Common\Functions\Strings::shift($_buffer["ciphertext"], '.$block_size.'); + $_key = \phpseclib3\Common\Functions\Strings::shift($_buffer["ciphertext"], ' . $block_size . '); $_plaintext.= $_block ^ $_key; } } else { - for ($_i = 0; $_i < $_ciphertext_len; $_i+= '.$block_size.') { - $_block = substr($_text, $_i, '.$block_size.'); + for ($_i = 0; $_i < $_ciphertext_len; $_i+= ' . $block_size . ') { + $_block = substr($_text, $_i, ' . $block_size . '); $in = $_xor; - '.$encrypt_block.' + ' . $encrypt_block . ' \phpseclib3\Common\Functions\Strings::increment_str($_xor); $_key = $in; $_plaintext.= $_block ^ $_key; @@ -2897,7 +2901,7 @@ abstract class SymmetricKey } if ($this->continuousBuffer) { $this->decryptIV = $_xor; - if ($_start = $_ciphertext_len % '.$block_size.') { + if ($_start = $_ciphertext_len % ' . $block_size . ') { $_buffer["ciphertext"] = substr($_key, $_start) . $_buffer["ciphertext"]; } } @@ -2921,7 +2925,7 @@ abstract class SymmetricKey $_i = 0; if ($_pos) { $_orig_pos = $_pos; - $_max = '.$block_size.' - $_pos; + $_max = ' . $block_size . ' - $_pos; if ($_len >= $_max) { $_i = $_max; $_len-= $_max; @@ -2934,17 +2938,17 @@ abstract class SymmetricKey $_ciphertext = substr($_iv, $_orig_pos) ^ $_text; $_iv = substr_replace($_iv, $_ciphertext, $_orig_pos, $_i); } - while ($_len >= '.$block_size.') { + while ($_len >= ' . $block_size . ') { $in = $_iv; - '.$encrypt_block.'; - $_iv = $in ^ substr($_text, $_i, '.$block_size.'); + ' . $encrypt_block . '; + $_iv = $in ^ substr($_text, $_i, ' . $block_size . '); $_ciphertext.= $_iv; - $_len-= '.$block_size.'; - $_i+= '.$block_size.'; + $_len-= ' . $block_size . '; + $_i+= ' . $block_size . '; } if ($_len) { $in = $_iv; - '.$encrypt_block.' + ' . $encrypt_block . ' $_iv = $in; $_block = $_iv ^ substr($_text, $_i); $_iv = substr_replace($_iv, $_block, 0, $_len); @@ -2969,7 +2973,7 @@ abstract class SymmetricKey $_i = 0; if ($_pos) { $_orig_pos = $_pos; - $_max = '.$block_size.' - $_pos; + $_max = ' . $block_size . ' - $_pos; if ($_len >= $_max) { $_i = $_max; $_len-= $_max; @@ -2982,19 +2986,19 @@ abstract class SymmetricKey $_plaintext = substr($_iv, $_orig_pos) ^ $_text; $_iv = substr_replace($_iv, substr($_text, 0, $_i), $_orig_pos, $_i); } - while ($_len >= '.$block_size.') { + while ($_len >= ' . $block_size . ') { $in = $_iv; - '.$encrypt_block.' + ' . $encrypt_block . ' $_iv = $in; - $cb = substr($_text, $_i, '.$block_size.'); + $cb = substr($_text, $_i, ' . $block_size . '); $_plaintext.= $_iv ^ $cb; $_iv = $cb; - $_len-= '.$block_size.'; - $_i+= '.$block_size.'; + $_len-= ' . $block_size . '; + $_i+= ' . $block_size . '; } if ($_len) { $in = $_iv; - '.$encrypt_block.' + ' . $encrypt_block . ' $_iv = $in; $_plaintext.= $_iv ^ substr($_text, $_i); $_iv = substr_replace($_iv, substr($_text, $_i), 0, $_len); @@ -3012,16 +3016,16 @@ abstract class SymmetricKey for ($_i = 0; $_i < $_len; ++$_i) { $in = $_iv; - '.$encrypt_block.' + ' . $encrypt_block . ' $_ciphertext .= ($_c = $_text[$_i] ^ $in); $_iv = substr($_iv, 1) . $_c; } if ($this->continuousBuffer) { - if ($_len >= '.$block_size.') { - $this->encryptIV = substr($_ciphertext, -'.$block_size.'); + if ($_len >= ' . $block_size . ') { + $this->encryptIV = substr($_ciphertext, -' . $block_size . '); } else { - $this->encryptIV = substr($this->encryptIV, $_len - '.$block_size.') . substr($_ciphertext, -$_len); + $this->encryptIV = substr($this->encryptIV, $_len - ' . $block_size . ') . substr($_ciphertext, -$_len); } } @@ -3034,16 +3038,16 @@ abstract class SymmetricKey for ($_i = 0; $_i < $_len; ++$_i) { $in = $_iv; - '.$encrypt_block.' + ' . $encrypt_block . ' $_plaintext .= $_text[$_i] ^ $in; $_iv = substr($_iv, 1) . $_text[$_i]; } if ($this->continuousBuffer) { - if ($_len >= '.$block_size.') { - $this->decryptIV = substr($_text, -'.$block_size.'); + if ($_len >= ' . $block_size . ') { + $this->decryptIV = substr($_text, -' . $block_size . '); } else { - $this->decryptIV = substr($this->decryptIV, $_len - '.$block_size.') . substr($_text, -$_len); + $this->decryptIV = substr($this->decryptIV, $_len - ' . $block_size . ') . substr($_text, -$_len); } } @@ -3058,7 +3062,7 @@ abstract class SymmetricKey for ($_i = 0; $_i < $_len; ++$_i) { $in = $_iv; - '.$encrypt_block.' + ' . $encrypt_block . ' $_ciphertext.= $_text[$_i] ^ $in; $_iv = substr($_iv, 1) . $in[0]; } @@ -3076,7 +3080,7 @@ abstract class SymmetricKey for ($_i = 0; $_i < $_len; ++$_i) { $in = $_iv; - '.$encrypt_block.' + ' . $encrypt_block . ' $_plaintext.= $_text[$_i] ^ $in; $_iv = substr($_iv, 1) . $in[0]; } @@ -3096,29 +3100,29 @@ abstract class SymmetricKey $_buffer = &$this->enbuffer; if (strlen($_buffer["xor"])) { - for ($_i = 0; $_i < $_plaintext_len; $_i+= '.$block_size.') { - $_block = substr($_text, $_i, '.$block_size.'); + for ($_i = 0; $_i < $_plaintext_len; $_i+= ' . $block_size . ') { + $_block = substr($_text, $_i, ' . $block_size . '); if (strlen($_block) > strlen($_buffer["xor"])) { $in = $_xor; - '.$encrypt_block.' + ' . $encrypt_block . ' $_xor = $in; $_buffer["xor"].= $_xor; } - $_key = \phpseclib3\Common\Functions\Strings::shift($_buffer["xor"], '.$block_size.'); + $_key = \phpseclib3\Common\Functions\Strings::shift($_buffer["xor"], ' . $block_size . '); $_ciphertext.= $_block ^ $_key; } } else { - for ($_i = 0; $_i < $_plaintext_len; $_i+= '.$block_size.') { + for ($_i = 0; $_i < $_plaintext_len; $_i+= ' . $block_size . ') { $in = $_xor; - '.$encrypt_block.' + ' . $encrypt_block . ' $_xor = $in; - $_ciphertext.= substr($_text, $_i, '.$block_size.') ^ $_xor; + $_ciphertext.= substr($_text, $_i, ' . $block_size . ') ^ $_xor; } $_key = $_xor; } if ($this->continuousBuffer) { $this->encryptIV = $_xor; - if ($_start = $_plaintext_len % '.$block_size.') { + if ($_start = $_plaintext_len % ' . $block_size . ') { $_buffer["xor"] = substr($_key, $_start) . $_buffer["xor"]; } } @@ -3132,29 +3136,29 @@ abstract class SymmetricKey $_buffer = &$this->debuffer; if (strlen($_buffer["xor"])) { - for ($_i = 0; $_i < $_ciphertext_len; $_i+= '.$block_size.') { - $_block = substr($_text, $_i, '.$block_size.'); + for ($_i = 0; $_i < $_ciphertext_len; $_i+= ' . $block_size . ') { + $_block = substr($_text, $_i, ' . $block_size . '); if (strlen($_block) > strlen($_buffer["xor"])) { $in = $_xor; - '.$encrypt_block.' + ' . $encrypt_block . ' $_xor = $in; $_buffer["xor"].= $_xor; } - $_key = \phpseclib3\Common\Functions\Strings::shift($_buffer["xor"], '.$block_size.'); + $_key = \phpseclib3\Common\Functions\Strings::shift($_buffer["xor"], ' . $block_size . '); $_plaintext.= $_block ^ $_key; } } else { - for ($_i = 0; $_i < $_ciphertext_len; $_i+= '.$block_size.') { + for ($_i = 0; $_i < $_ciphertext_len; $_i+= ' . $block_size . ') { $in = $_xor; - '.$encrypt_block.' + ' . $encrypt_block . ' $_xor = $in; - $_plaintext.= substr($_text, $_i, '.$block_size.') ^ $_xor; + $_plaintext.= substr($_text, $_i, ' . $block_size . ') ^ $_xor; } $_key = $_xor; } if ($this->continuousBuffer) { $this->decryptIV = $_xor; - if ($_start = $_ciphertext_len % '.$block_size.') { + if ($_start = $_ciphertext_len % ' . $block_size . ') { $_buffer["xor"] = substr($_key, $_start) . $_buffer["xor"]; } } @@ -3164,12 +3168,12 @@ abstract class SymmetricKey case self::MODE_STREAM: $encrypt = $init_encrypt . ' $_ciphertext = ""; - '.$encrypt_block.' + ' . $encrypt_block . ' return $_ciphertext; '; $decrypt = $init_decrypt . ' $_plaintext = ""; - '.$decrypt_block.' + ' . $decrypt_block . ' return $_plaintext; '; break; @@ -3181,9 +3185,9 @@ abstract class SymmetricKey $in = $this->encryptIV; - for ($_i = 0; $_i < $_plaintext_len; $_i+= '.$block_size.') { - $in = substr($_text, $_i, '.$block_size.') ^ $in; - '.$encrypt_block.' + for ($_i = 0; $_i < $_plaintext_len; $_i+= ' . $block_size . ') { + $in = substr($_text, $_i, ' . $block_size . ') ^ $in; + ' . $encrypt_block . ' $_ciphertext.= $in; } @@ -3196,14 +3200,14 @@ abstract class SymmetricKey $decrypt = $init_decrypt . ' $_plaintext = ""; - $_text = str_pad($_text, strlen($_text) + ('.$block_size.' - strlen($_text) % '.$block_size.') % '.$block_size.', chr(0)); + $_text = str_pad($_text, strlen($_text) + (' . $block_size . ' - strlen($_text) % ' . $block_size . ') % ' . $block_size . ', chr(0)); $_ciphertext_len = strlen($_text); $_iv = $this->decryptIV; - for ($_i = 0; $_i < $_ciphertext_len; $_i+= '.$block_size.') { - $in = $_block = substr($_text, $_i, '.$block_size.'); - '.$decrypt_block.' + for ($_i = 0; $_i < $_ciphertext_len; $_i+= ' . $block_size . ') { + $in = $_block = substr($_text, $_i, ' . $block_size . '); + ' . $decrypt_block . ' $_plaintext.= $in ^ $_iv; $_iv = $_block; } @@ -3381,7 +3385,7 @@ abstract class SymmetricKey $s = $this->poly1305Key; // strlen($this->poly1305Key) == 32 $r = Strings::shift($s, 16); $r = strrev($r); - $r&= "\x0f\xff\xff\xfc\x0f\xff\xff\xfc\x0f\xff\xff\xfc\x0f\xff\xff\xff"; + $r &= "\x0f\xff\xff\xfc\x0f\xff\xff\xfc\x0f\xff\xff\xfc\x0f\xff\xff\xff"; $s = strrev($s); $r = self::$poly1305Field->newInteger(new BigInteger($r, 256)); diff --git a/phpseclib/Crypt/Common/Traits/Fingerprint.php b/phpseclib/Crypt/Common/Traits/Fingerprint.php index 0db9c84a..12a43b4d 100644 --- a/phpseclib/Crypt/Common/Traits/Fingerprint.php +++ b/phpseclib/Crypt/Common/Traits/Fingerprint.php @@ -59,4 +59,4 @@ trait Fingerprint return false; } } -} \ No newline at end of file +} diff --git a/phpseclib/Crypt/DES.php b/phpseclib/Crypt/DES.php index 8a277973..cdcb394f 100644 --- a/phpseclib/Crypt/DES.php +++ b/phpseclib/Crypt/DES.php @@ -87,7 +87,7 @@ class DES extends BlockCipher * @var int * @access private */ - protected $key_length = 8; + protected $key_length = 8; /** * The mcrypt specific name of the cipher @@ -1248,7 +1248,7 @@ class DES extends BlockCipher self::ENCRYPT => [], self::DECRYPT => array_fill(0, 32, 0) ]; - for ($i = 0, $ki = 31; $i < 16; ++$i, $ki-= 2) { + for ($i = 0, $ki = 31; $i < 16; ++$i, $ki -= 2) { $c <<= $shifts[$i]; $c = ($c | ($c >> 28)) & 0x0FFFFFFF; $d <<= $shifts[$i]; @@ -1367,7 +1367,7 @@ class DES extends BlockCipher // start of "the Feistel (F) function" - see the following URL: // http://en.wikipedia.org/wiki/Image:Data_Encryption_Standard_InfoBox_Diagram.png // Merge key schedule. - $crypt_block[$c].= ' + $crypt_block[$c] .= ' $b1 = ((' . $r . ' >> 3) & 0x1FFFFFFF) ^ (' . $r . ' << 29) ^ ' . $k[$c][++$ki] . '; $b2 = ((' . $r . ' >> 31) & 0x00000001) ^ (' . $r . ' << 1) ^ ' . $k[$c][++$ki] . ';' . /* S-box indexing. */ @@ -1385,7 +1385,7 @@ class DES extends BlockCipher } // Perform the inverse IP permutation. - $crypt_block[$c].= '$in = + $crypt_block[$c] .= '$in = ($shuffleinvip[($l >> 24) & 0xFF] & "\x80\x80\x80\x80\x80\x80\x80\x80") | ($shuffleinvip[($r >> 24) & 0xFF] & "\x40\x40\x40\x40\x40\x40\x40\x40") | ($shuffleinvip[($l >> 16) & 0xFF] & "\x20\x20\x20\x20\x20\x20\x20\x20") | diff --git a/phpseclib/Crypt/DH.php b/phpseclib/Crypt/DH.php index 01eb460e..99ddd60a 100644 --- a/phpseclib/Crypt/DH.php +++ b/phpseclib/Crypt/DH.php @@ -82,7 +82,7 @@ abstract class DH extends AsymmetricKey */ public static function createParameters(...$args) { - $params = new Parameters; + $params = new Parameters(); if (count($args) == 2 && $args[0] instanceof BigInteger && $args[1] instanceof BigInteger) { //if (!$args[0]->isPrime()) { // throw new \InvalidArgumentException('The first parameter should be a prime number'); @@ -252,7 +252,7 @@ abstract class DH extends AsymmetricKey $max = $params->prime->subtract($one); } - $key = new PrivateKey; + $key = new PrivateKey(); $key->prime = $params->prime; $key->base = $params->base; $key->privateKey = BigInteger::randomRange($one, $max); @@ -324,7 +324,8 @@ abstract class DH extends AsymmetricKey { try { return EC::load($key, $password); - } catch (NoKeyLoadedException $e) {} + } catch (NoKeyLoadedException $e) { + } return parent::load($key, $password); } @@ -339,11 +340,11 @@ abstract class DH extends AsymmetricKey protected static function onLoad($components) { if (!isset($components['privateKey']) && !isset($components['publicKey'])) { - $new = new Parameters; + $new = new Parameters(); } else { $new = isset($components['privateKey']) ? - new PrivateKey : - new PublicKey; + new PrivateKey() : + new PublicKey(); } $new->prime = $components['prime']; diff --git a/phpseclib/Crypt/DH/Formats/Keys/PKCS8.php b/phpseclib/Crypt/DH/Formats/Keys/PKCS8.php index b06aba34..7dfa8108 100644 --- a/phpseclib/Crypt/DH/Formats/Keys/PKCS8.php +++ b/phpseclib/Crypt/DH/Formats/Keys/PKCS8.php @@ -154,4 +154,4 @@ abstract class PKCS8 extends Progenitor $key = ASN1::encodeDER($publicKey, ['type' => ASN1::TYPE_INTEGER]); return self::wrapPublicKey($key, $params); } -} \ No newline at end of file +} diff --git a/phpseclib/Crypt/DSA.php b/phpseclib/Crypt/DSA.php index 4abd4695..1d38ed27 100644 --- a/phpseclib/Crypt/DSA.php +++ b/phpseclib/Crypt/DSA.php @@ -169,7 +169,7 @@ abstract class DSA extends AsymmetricKey $h = $h->add(self::$one); } - $dsa = new Parameters; + $dsa = new Parameters(); $dsa->p = $p; $dsa->q = $q; $dsa->g = $g; @@ -199,15 +199,15 @@ abstract class DSA extends AsymmetricKey if (count($args) == 2 && is_int($args[0]) && is_int($args[1])) { $params = self::createParameters($args[0], $args[1]); - } else if (count($args) == 1 && $args[0] instanceof Parameters) { + } elseif (count($args) == 1 && $args[0] instanceof Parameters) { $params = $args[0]; - } else if (!count($args)) { + } elseif (!count($args)) { $params = self::createParameters(); } else { throw new InsufficientSetupException('Valid parameters are either two integers (L and N), a single DSA object or no parameters at all.'); } - $private = new PrivateKey; + $private = new PrivateKey(); $private->p = $params->p; $private->q = $params->q; $private->g = $params->g; @@ -237,12 +237,12 @@ abstract class DSA extends AsymmetricKey } if (!isset($components['x']) && !isset($components['y'])) { - $new = new Parameters; - } else if (isset($components['x'])) { - $new = new PrivateKey; + $new = new Parameters(); + } elseif (isset($components['x'])) { + $new = new PrivateKey(); $new->x = $components['x']; } else { - $new = new PublicKey; + $new = new PublicKey(); } $new->p = $components['p']; @@ -339,6 +339,6 @@ abstract class DSA extends AsymmetricKey */ public function getSignatureFormat() { - return $this->shortFormat; + return $this->shortFormat; } } diff --git a/phpseclib/Crypt/DSA/Formats/Signature/SSH2.php b/phpseclib/Crypt/DSA/Formats/Signature/SSH2.php index 41426055..f378b772 100644 --- a/phpseclib/Crypt/DSA/Formats/Signature/SSH2.php +++ b/phpseclib/Crypt/DSA/Formats/Signature/SSH2.php @@ -70,7 +70,9 @@ abstract class SSH2 if ($r->getLength() > 160 || $s->getLength() > 160) { return false; } - return Strings::packSSH2('ss', 'ssh-dss', + return Strings::packSSH2( + 'ss', + 'ssh-dss', str_pad($r->toBytes(), 20, "\0", STR_PAD_LEFT) . str_pad($s->toBytes(), 20, "\0", STR_PAD_LEFT) ); diff --git a/phpseclib/Crypt/EC.php b/phpseclib/Crypt/EC.php index 86b3412a..6709d54c 100644 --- a/phpseclib/Crypt/EC.php +++ b/phpseclib/Crypt/EC.php @@ -158,7 +158,7 @@ abstract class EC extends AsymmetricKey return $privatekey; } - $privatekey = new PrivateKey; + $privatekey = new PrivateKey(); $curveName = $curve; if (preg_match('#(?:^curve|^ed)\d+$#', $curveName)) { @@ -217,14 +217,14 @@ abstract class EC extends AsymmetricKey } if (!isset($components['dA']) && !isset($components['QA'])) { - $new = new Parameters; + $new = new Parameters(); $new->curve = $components['curve']; return $new; } $new = isset($components['dA']) ? - new PrivateKey : - new PublicKey; + new PrivateKey() : + new PublicKey(); $new->curve = $components['curve']; $new->QA = $components['QA']; @@ -396,7 +396,7 @@ abstract class EC extends AsymmetricKey */ public function getSignatureFormat() { - return $this->shortFormat; + return $this->shortFormat; } /** @@ -437,7 +437,7 @@ abstract class EC extends AsymmetricKey */ public function getContext() { - return $this->context; + return $this->context; } /** @@ -474,4 +474,4 @@ abstract class EC extends AsymmetricKey return parent::__toString(); } -} \ No newline at end of file +} diff --git a/phpseclib/Crypt/EC/BaseCurves/KoblitzPrime.php b/phpseclib/Crypt/EC/BaseCurves/KoblitzPrime.php index fe885e72..7e641ec5 100644 --- a/phpseclib/Crypt/EC/BaseCurves/KoblitzPrime.php +++ b/phpseclib/Crypt/EC/BaseCurves/KoblitzPrime.php @@ -139,7 +139,7 @@ class KoblitzPrime extends Prime ]; if (isset($p['naf'])) { - $beta['naf'] = array_map(function($p) { + $beta['naf'] = array_map(function ($p) { return [ $p[0]->multiply($this->beta), $p[1], @@ -202,7 +202,8 @@ class KoblitzPrime extends Prime $f = $e->multiply($e); $x3 = $f->subtract($this->two->multiply($d)); $y3 = $e->multiply($d->subtract($x3))->subtract( - $this->eight->multiply($c)); + $this->eight->multiply($c) + ); $z3 = $this->two->multiply($y1)->multiply($z1); return [$x3, $y3, $z3]; } @@ -320,4 +321,4 @@ class KoblitzPrime extends Prime ['a' => $a2, 'b' => $b2] ]; } -} \ No newline at end of file +} diff --git a/phpseclib/Crypt/EC/BaseCurves/Montgomery.php b/phpseclib/Crypt/EC/BaseCurves/Montgomery.php index bfa2926e..10066953 100644 --- a/phpseclib/Crypt/EC/BaseCurves/Montgomery.php +++ b/phpseclib/Crypt/EC/BaseCurves/Montgomery.php @@ -280,4 +280,4 @@ class Montgomery extends Base list($x, $z) = $p; return [$x->divide($z)]; } -} \ No newline at end of file +} diff --git a/phpseclib/Crypt/EC/BaseCurves/Prime.php b/phpseclib/Crypt/EC/BaseCurves/Prime.php index 696960f7..ccf56439 100644 --- a/phpseclib/Crypt/EC/BaseCurves/Prime.php +++ b/phpseclib/Crypt/EC/BaseCurves/Prime.php @@ -207,8 +207,10 @@ class Prime extends Base $v = $u1->multiply($h2); $x3 = $r->multiply($r)->subtract($h3)->subtract($v->multiply($this->two)); $y3 = $r->multiply( - $v->subtract($x3))->subtract( - $s1->multiply($h3)); + $v->subtract($x3) + )->subtract( + $s1->multiply($h3) + ); return [$x3, $y3, $h]; } @@ -242,8 +244,10 @@ class Prime extends Base $v = $u1->multiply($h2); $x3 = $r->multiply($r)->subtract($h3)->subtract($v->multiply($this->two)); $y3 = $r->multiply( - $v->subtract($x3))->subtract( - $s1->multiply($h3)); + $v->subtract($x3) + )->subtract( + $s1->multiply($h3) + ); $z3 = $h->multiply($z1); return [$x3, $y3, $z3]; } @@ -279,8 +283,10 @@ class Prime extends Base $v = $u1->multiply($h2); $x3 = $r->multiply($r)->subtract($h3)->subtract($v->multiply($this->two)); $y3 = $r->multiply( - $v->subtract($x3))->subtract( - $s1->multiply($h3)); + $v->subtract($x3) + )->subtract( + $s1->multiply($h3) + ); $z3 = $h->multiply($z1)->multiply($z2); return [$x3, $y3, $z3]; } @@ -370,7 +376,8 @@ class Prime extends Base $m = $m1->add($m2); $x1 = $m->multiply($m)->subtract($this->two->multiply($s)); $y1 = $m->multiply($s->subtract($x1))->subtract( - $this->eight->multiply($y2->multiply($y2))); + $this->eight->multiply($y2->multiply($y2)) + ); $z1 = $this->two->multiply($y)->multiply($z); return [$x1, $y1, $z1]; } @@ -390,7 +397,8 @@ class Prime extends Base $m = $m1->add($this->a); $x1 = $m->multiply($m)->subtract($this->two->multiply($s)); $y1 = $m->multiply($s->subtract($x1))->subtract( - $this->eight->multiply($y2->multiply($y2))); + $this->eight->multiply($y2->multiply($y2)) + ); $z1 = $this->two->multiply($y); return [$x1, $y1, $z1]; } @@ -439,8 +447,12 @@ class Prime extends Base $x = new BigInteger($m, 256); $xp = $this->convertInteger($x); switch ($y) { - case 2: $ypn = false; break; - case 3: $ypn = true; break; + case 2: + $ypn = false; + break; + case 3: + $ypn = true; + break; default: throw new \RuntimeException('Coordinate not in recognized format'); } @@ -529,7 +541,7 @@ class Prime extends Base // comb all window NAFs $max = 0; - for ($i = $length - 1; $i >= 1; $i-= 2) { + for ($i = $length - 1; $i >= 1; $i -= 2) { $a = $i - 1; $b = $i; if ($wndWidth[$a] != 1 || $wndWidth[$b] != 1) { @@ -687,12 +699,12 @@ class Prime extends Base while ($k1->compare(new BigInteger(-$d1)) > 0 || $k2->compare(new BigInteger(-$d2)) > 0) { // first phase $m14 = $k1->testBit(0) + 2 * $k1->testBit(1); - $m14+= $d1; - $m14&= 3; + $m14 += $d1; + $m14 &= 3; $m24 = $k2->testBit(0) + 2 * $k2->testBit(1); - $m24+= $d2; - $m24&= 3; + $m24 += $d2; + $m24 &= 3; if ($m14 == 3) { $m14 = -1; @@ -704,8 +716,8 @@ class Prime extends Base $u1 = 0; if ($m14 & 1) { // if $m14 is odd $m8 = $k1->testBit(0) + 2 * $k1->testBit(1) + 4 * $k1->testBit(2); - $m8+= $d1; - $m8&= 7; + $m8 += $d1; + $m8 &= 7; $u1 = ($m8 == 3 || $m8 == 5) && $m24 == 2 ? -$m14 : $m14; } $jsf[0][] = $u1; @@ -713,8 +725,8 @@ class Prime extends Base $u2 = 0; if ($m24 & 1) { // if $m24 is odd $m8 = $k2->testBit(0) + 2 * $k2->testBit(1) + 4 * $k2->testBit(2); - $m8+= $d2; - $m8&= 7; + $m8 += $d2; + $m8 &= 7; $u2 = ($m8 == 3 || $m8 == 5) && $m14 == 2 ? -$m24 : $m24; } $jsf[1][] = $u2; @@ -771,4 +783,4 @@ class Prime extends Base $p['fresh'] = true; return $p; } -} \ No newline at end of file +} diff --git a/phpseclib/Crypt/EC/BaseCurves/TwistedEdwards.php b/phpseclib/Crypt/EC/BaseCurves/TwistedEdwards.php index 2bf61950..6fb04c77 100644 --- a/phpseclib/Crypt/EC/BaseCurves/TwistedEdwards.php +++ b/phpseclib/Crypt/EC/BaseCurves/TwistedEdwards.php @@ -216,4 +216,4 @@ class TwistedEdwards extends Base return $lhs->equals($rhs); } -} \ No newline at end of file +} diff --git a/phpseclib/Crypt/EC/Curves/Curve25519.php b/phpseclib/Crypt/EC/Curves/Curve25519.php index 7a71fbf3..3d158263 100644 --- a/phpseclib/Crypt/EC/Curves/Curve25519.php +++ b/phpseclib/Crypt/EC/Curves/Curve25519.php @@ -53,9 +53,9 @@ class Curve25519 extends Montgomery //return [$this->factory->newInteger(new BigInteger($r, 256))]; $d = $d->toBytes(); - $d&= "\xF8" . str_repeat("\xFF", 30) . "\x7F"; + $d &= "\xF8" . str_repeat("\xFF", 30) . "\x7F"; $d = strrev($d); - $d|= "\x40"; + $d |= "\x40"; $d = new BigInteger($d, -256); return parent::multiplyPoint($p, $d); @@ -80,4 +80,4 @@ class Curve25519 extends Montgomery throw new \RangeException('x must be a positive integer less than 256 bytes in length'); } } -} \ No newline at end of file +} diff --git a/phpseclib/Crypt/EC/Curves/Curve448.php b/phpseclib/Crypt/EC/Curves/Curve448.php index f3508ace..d0ce3265 100644 --- a/phpseclib/Crypt/EC/Curves/Curve448.php +++ b/phpseclib/Crypt/EC/Curves/Curve448.php @@ -25,13 +25,17 @@ class Curve448 extends Montgomery // 2^448 - 2^224 - 1 $this->setModulo(new BigInteger( 'FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFE' . - 'FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF', 16)); + 'FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF', + 16 + )); $this->a24 = $this->factory->newInteger(new BigInteger('39081')); $this->p = [$this->factory->newInteger(new BigInteger(5))]; // 2^446 - 0x8335dc163bb124b65129c96fde933d8d723a70aadc873d6d54a7bb0d $this->setOrder(new BigInteger( '3FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF' . - '7CCA23E9C44EDB49AED63690216CC2728DC58F552378C292AB5844F3', 16)); + '7CCA23E9C44EDB49AED63690216CC2728DC58F552378C292AB5844F3', + 16 + )); /* $this->setCoefficients( @@ -62,7 +66,7 @@ class Curve448 extends Montgomery $d = $d->toBytes(); $d[0] = $d[0] & "\xFC"; $d = strrev($d); - $d|= "\x80"; + $d |= "\x80"; $d = new BigInteger($d, 256); return parent::multiplyPoint($p, $d); @@ -87,4 +91,4 @@ class Curve448 extends Montgomery throw new \RangeException('x must be a positive integer less than 446 bytes in length'); } } -} \ No newline at end of file +} diff --git a/phpseclib/Crypt/EC/Curves/Ed448.php b/phpseclib/Crypt/EC/Curves/Ed448.php index 5979e28c..3a7313a8 100644 --- a/phpseclib/Crypt/EC/Curves/Ed448.php +++ b/phpseclib/Crypt/EC/Curves/Ed448.php @@ -29,11 +29,13 @@ class Ed448 extends TwistedEdwards // 2^448 - 2^224 - 1 $this->setModulo(new BigInteger( 'FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFE' . - 'FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF', 16)); + 'FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF', + 16 + )); $this->setCoefficients( new BigInteger(1), // -39081 - new BigInteger('FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFE' . + new BigInteger('FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFE' . 'FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF6756', 16) ); $this->setBasePoint( @@ -44,7 +46,9 @@ class Ed448 extends TwistedEdwards ); $this->setOrder(new BigInteger( '3FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF' . - '7CCA23E9C44EDB49AED63690216CC2728DC58F552378C292AB5844F3', 16)); + '7CCA23E9C44EDB49AED63690216CC2728DC58F552378C292AB5844F3', + 16 + )); } /** @@ -263,4 +267,4 @@ class Ed448 extends TwistedEdwards return [$x3, $y3, $z3]; } -} \ No newline at end of file +} diff --git a/phpseclib/Crypt/EC/Curves/brainpoolP160r1.php b/phpseclib/Crypt/EC/Curves/brainpoolP160r1.php index 23a4e6d2..4792926d 100644 --- a/phpseclib/Crypt/EC/Curves/brainpoolP160r1.php +++ b/phpseclib/Crypt/EC/Curves/brainpoolP160r1.php @@ -33,4 +33,4 @@ class brainpoolP160r1 extends Prime ); $this->setOrder(new BigInteger('E95E4A5F737059DC60DF5991D45029409E60FC09', 16)); } -} \ No newline at end of file +} diff --git a/phpseclib/Crypt/EC/Curves/brainpoolP160t1.php b/phpseclib/Crypt/EC/Curves/brainpoolP160t1.php index beafc34b..f0b5bc20 100644 --- a/phpseclib/Crypt/EC/Curves/brainpoolP160t1.php +++ b/phpseclib/Crypt/EC/Curves/brainpoolP160t1.php @@ -46,4 +46,4 @@ class brainpoolP160t1 extends Prime ); $this->setOrder(new BigInteger('E95E4A5F737059DC60DF5991D45029409E60FC09', 16)); } -} \ No newline at end of file +} diff --git a/phpseclib/Crypt/EC/Curves/brainpoolP192r1.php b/phpseclib/Crypt/EC/Curves/brainpoolP192r1.php index 11afdadb..03ccc3a2 100644 --- a/phpseclib/Crypt/EC/Curves/brainpoolP192r1.php +++ b/phpseclib/Crypt/EC/Curves/brainpoolP192r1.php @@ -33,4 +33,4 @@ class brainpoolP192r1 extends Prime ); $this->setOrder(new BigInteger('C302F41D932A36CDA7A3462F9E9E916B5BE8F1029AC4ACC1', 16)); } -} \ No newline at end of file +} diff --git a/phpseclib/Crypt/EC/Curves/brainpoolP192t1.php b/phpseclib/Crypt/EC/Curves/brainpoolP192t1.php index 71f956f2..ce39535b 100644 --- a/phpseclib/Crypt/EC/Curves/brainpoolP192t1.php +++ b/phpseclib/Crypt/EC/Curves/brainpoolP192t1.php @@ -33,4 +33,4 @@ class brainpoolP192t1 extends Prime ); $this->setOrder(new BigInteger('C302F41D932A36CDA7A3462F9E9E916B5BE8F1029AC4ACC1', 16)); } -} \ No newline at end of file +} diff --git a/phpseclib/Crypt/EC/Curves/brainpoolP224r1.php b/phpseclib/Crypt/EC/Curves/brainpoolP224r1.php index 83e49b02..1d17f1c5 100644 --- a/phpseclib/Crypt/EC/Curves/brainpoolP224r1.php +++ b/phpseclib/Crypt/EC/Curves/brainpoolP224r1.php @@ -33,4 +33,4 @@ class brainpoolP224r1 extends Prime ); $this->setOrder(new BigInteger('D7C134AA264366862A18302575D0FB98D116BC4B6DDEBCA3A5A7939F', 16)); } -} \ No newline at end of file +} diff --git a/phpseclib/Crypt/EC/Curves/brainpoolP224t1.php b/phpseclib/Crypt/EC/Curves/brainpoolP224t1.php index 97032a48..ec3558c1 100644 --- a/phpseclib/Crypt/EC/Curves/brainpoolP224t1.php +++ b/phpseclib/Crypt/EC/Curves/brainpoolP224t1.php @@ -33,4 +33,4 @@ class brainpoolP224t1 extends Prime ); $this->setOrder(new BigInteger('D7C134AA264366862A18302575D0FB98D116BC4B6DDEBCA3A5A7939F', 16)); } -} \ No newline at end of file +} diff --git a/phpseclib/Crypt/EC/Curves/brainpoolP256r1.php b/phpseclib/Crypt/EC/Curves/brainpoolP256r1.php index 0d386004..d97dafb1 100644 --- a/phpseclib/Crypt/EC/Curves/brainpoolP256r1.php +++ b/phpseclib/Crypt/EC/Curves/brainpoolP256r1.php @@ -33,4 +33,4 @@ class brainpoolP256r1 extends Prime ); $this->setOrder(new BigInteger('A9FB57DBA1EEA9BC3E660A909D838D718C397AA3B561A6F7901E0E82974856A7', 16)); } -} \ No newline at end of file +} diff --git a/phpseclib/Crypt/EC/Curves/brainpoolP320r1.php b/phpseclib/Crypt/EC/Curves/brainpoolP320r1.php index a6253a71..21672531 100644 --- a/phpseclib/Crypt/EC/Curves/brainpoolP320r1.php +++ b/phpseclib/Crypt/EC/Curves/brainpoolP320r1.php @@ -39,4 +39,4 @@ class brainpoolP320r1 extends Prime $this->setOrder(new BigInteger('D35E472036BC4FB7E13C785ED201E065F98FCFA5B68F12A32D4' . '82EC7EE8658E98691555B44C59311', 16)); } -} \ No newline at end of file +} diff --git a/phpseclib/Crypt/EC/Curves/brainpoolP320t1.php b/phpseclib/Crypt/EC/Curves/brainpoolP320t1.php index e6277185..1c76b856 100644 --- a/phpseclib/Crypt/EC/Curves/brainpoolP320t1.php +++ b/phpseclib/Crypt/EC/Curves/brainpoolP320t1.php @@ -39,4 +39,4 @@ class brainpoolP320t1 extends Prime $this->setOrder(new BigInteger('D35E472036BC4FB7E13C785ED201E065F98FCFA5B68F12A32D4' . '82EC7EE8658E98691555B44C59311', 16)); } -} \ No newline at end of file +} diff --git a/phpseclib/Crypt/EC/Curves/brainpoolP384r1.php b/phpseclib/Crypt/EC/Curves/brainpoolP384r1.php index 5bc8a6d5..a911b6c6 100644 --- a/phpseclib/Crypt/EC/Curves/brainpoolP384r1.php +++ b/phpseclib/Crypt/EC/Curves/brainpoolP384r1.php @@ -24,25 +24,37 @@ class brainpoolP384r1 extends Prime { $this->setModulo(new BigInteger( '8CB91E82A3386D280F5D6F7E50E641DF152F7109ED5456B412B1DA197FB71123ACD3A729901D1A7' . - '1874700133107EC53', 16)); + '1874700133107EC53', + 16 + )); $this->setCoefficients( new BigInteger( '7BC382C63D8C150C3C72080ACE05AFA0C2BEA28E4FB22787139165EFBA91F90F8AA5814A503' . - 'AD4EB04A8C7DD22CE2826', 16), + 'AD4EB04A8C7DD22CE2826', + 16 + ), new BigInteger( '4A8C7DD22CE28268B39B55416F0447C2FB77DE107DCD2A62E880EA53EEB62D57CB4390295DB' . - 'C9943AB78696FA504C11', 16) + 'C9943AB78696FA504C11', + 16 + ) ); $this->setBasePoint( new BigInteger( '1D1C64F068CF45FFA2A63A81B7C13F6B8847A3E77EF14FE3DB7FCAFE0CBD10E8E826E03436D' . - '646AAEF87B2E247D4AF1E', 16), + '646AAEF87B2E247D4AF1E', + 16 + ), new BigInteger( '8ABE1D7520F9C2A45CB1EB8E95CFD55262B70B29FEEC5864E19C054FF99129280E464621779' . - '1811142820341263C5315', 16) + '1811142820341263C5315', + 16 + ) ); $this->setOrder(new BigInteger( '8CB91E82A3386D280F5D6F7E50E641DF152F7109ED5456B31F166E6CAC0425A7CF3AB6AF6B7FC31' . - '03B883202E9046565', 16)); + '03B883202E9046565', + 16 + )); } -} \ No newline at end of file +} diff --git a/phpseclib/Crypt/EC/Curves/brainpoolP384t1.php b/phpseclib/Crypt/EC/Curves/brainpoolP384t1.php index 8bd4a790..12bc5882 100644 --- a/phpseclib/Crypt/EC/Curves/brainpoolP384t1.php +++ b/phpseclib/Crypt/EC/Curves/brainpoolP384t1.php @@ -24,25 +24,37 @@ class brainpoolP384t1 extends Prime { $this->setModulo(new BigInteger( '8CB91E82A3386D280F5D6F7E50E641DF152F7109ED5456B412B1DA197FB71123ACD3A729901D1A7' . - '1874700133107EC53', 16)); + '1874700133107EC53', + 16 + )); $this->setCoefficients( new BigInteger( '8CB91E82A3386D280F5D6F7E50E641DF152F7109ED5456B412B1DA197FB71123ACD3A729901' . - 'D1A71874700133107EC50', 16), // eg. -3 + 'D1A71874700133107EC50', + 16 + ), // eg. -3 new BigInteger( '7F519EADA7BDA81BD826DBA647910F8C4B9346ED8CCDC64E4B1ABD11756DCE1D2074AA263B8' . - '8805CED70355A33B471EE', 16) + '8805CED70355A33B471EE', + 16 + ) ); $this->setBasePoint( new BigInteger( '18DE98B02DB9A306F2AFCD7235F72A819B80AB12EBD653172476FECD462AABFFC4FF191B946' . - 'A5F54D8D0AA2F418808CC', 16), + 'A5F54D8D0AA2F418808CC', + 16 + ), new BigInteger( '25AB056962D30651A114AFD2755AD336747F93475B7A1FCA3B88F2B6A208CCFE469408584DC' . - '2B2912675BF5B9E582928', 16) + '2B2912675BF5B9E582928', + 16 + ) ); $this->setOrder(new BigInteger( '8CB91E82A3386D280F5D6F7E50E641DF152F7109ED5456B31F166E6CAC0425A7CF3AB6AF6B7FC31' . - '03B883202E9046565', 16)); + '03B883202E9046565', + 16 + )); } -} \ No newline at end of file +} diff --git a/phpseclib/Crypt/EC/Curves/brainpoolP512r1.php b/phpseclib/Crypt/EC/Curves/brainpoolP512r1.php index 8d22120f..9931f3b2 100644 --- a/phpseclib/Crypt/EC/Curves/brainpoolP512r1.php +++ b/phpseclib/Crypt/EC/Curves/brainpoolP512r1.php @@ -24,25 +24,37 @@ class brainpoolP512r1 extends Prime { $this->setModulo(new BigInteger( 'AADD9DB8DBE9C48B3FD4E6AE33C9FC07CB308DB3B3C9D20ED6639CCA703308717D4D9B009BC' . - '66842AECDA12AE6A380E62881FF2F2D82C68528AA6056583A48F3', 16)); + '66842AECDA12AE6A380E62881FF2F2D82C68528AA6056583A48F3', + 16 + )); $this->setCoefficients( new BigInteger( '7830A3318B603B89E2327145AC234CC594CBDD8D3DF91610A83441CAEA9863BC2DED5D5AA82' . - '53AA10A2EF1C98B9AC8B57F1117A72BF2C7B9E7C1AC4D77FC94CA', 16), + '53AA10A2EF1C98B9AC8B57F1117A72BF2C7B9E7C1AC4D77FC94CA', + 16 + ), new BigInteger( '3DF91610A83441CAEA9863BC2DED5D5AA8253AA10A2EF1C98B9AC8B57F1117A72BF2C7B9E7C' . - '1AC4D77FC94CADC083E67984050B75EBAE5DD2809BD638016F723', 16) + '1AC4D77FC94CADC083E67984050B75EBAE5DD2809BD638016F723', + 16 + ) ); $this->setBasePoint( new BigInteger( '81AEE4BDD82ED9645A21322E9C4C6A9385ED9F70B5D916C1B43B62EEF4D0098EFF3B1F78E2D' . - '0D48D50D1687B93B97D5F7C6D5047406A5E688B352209BCB9F822', 16), + '0D48D50D1687B93B97D5F7C6D5047406A5E688B352209BCB9F822', + 16 + ), new BigInteger( '7DDE385D566332ECC0EABFA9CF7822FDF209F70024A57B1AA000C55B881F8111B2DCDE494A5' . - 'F485E5BCA4BD88A2763AED1CA2B2FA8F0540678CD1E0F3AD80892', 16) + 'F485E5BCA4BD88A2763AED1CA2B2FA8F0540678CD1E0F3AD80892', + 16 + ) ); $this->setOrder(new BigInteger( 'AADD9DB8DBE9C48B3FD4E6AE33C9FC07CB308DB3B3C9D20ED6639CCA70330870553E5C414CA' . - '92619418661197FAC10471DB1D381085DDADDB58796829CA90069', 16)); + '92619418661197FAC10471DB1D381085DDADDB58796829CA90069', + 16 + )); } -} \ No newline at end of file +} diff --git a/phpseclib/Crypt/EC/Curves/brainpoolP512t1.php b/phpseclib/Crypt/EC/Curves/brainpoolP512t1.php index 8566182e..d4027d10 100644 --- a/phpseclib/Crypt/EC/Curves/brainpoolP512t1.php +++ b/phpseclib/Crypt/EC/Curves/brainpoolP512t1.php @@ -24,25 +24,37 @@ class brainpoolP512t1 extends Prime { $this->setModulo(new BigInteger( 'AADD9DB8DBE9C48B3FD4E6AE33C9FC07CB308DB3B3C9D20ED6639CCA703308717D4D9B009BC' . - '66842AECDA12AE6A380E62881FF2F2D82C68528AA6056583A48F3', 16)); + '66842AECDA12AE6A380E62881FF2F2D82C68528AA6056583A48F3', + 16 + )); $this->setCoefficients( new BigInteger( 'AADD9DB8DBE9C48B3FD4E6AE33C9FC07CB308DB3B3C9D20ED6639CCA703308717D4D9B009BC' . - '66842AECDA12AE6A380E62881FF2F2D82C68528AA6056583A48F0', 16), // eg. -3 + '66842AECDA12AE6A380E62881FF2F2D82C68528AA6056583A48F0', + 16 + ), // eg. -3 new BigInteger( '7CBBBCF9441CFAB76E1890E46884EAE321F70C0BCB4981527897504BEC3E36A62BCDFA23049' . - '76540F6450085F2DAE145C22553B465763689180EA2571867423E', 16) + '76540F6450085F2DAE145C22553B465763689180EA2571867423E', + 16 + ) ); $this->setBasePoint( new BigInteger( '640ECE5C12788717B9C1BA06CBC2A6FEBA85842458C56DDE9DB1758D39C0313D82BA51735CD' . - 'B3EA499AA77A7D6943A64F7A3F25FE26F06B51BAA2696FA9035DA', 16), + 'B3EA499AA77A7D6943A64F7A3F25FE26F06B51BAA2696FA9035DA', + 16 + ), new BigInteger( '5B534BD595F5AF0FA2C892376C84ACE1BB4E3019B71634C01131159CAE03CEE9D9932184BEE' . - 'F216BD71DF2DADF86A627306ECFF96DBB8BACE198B61E00F8B332', 16) + 'F216BD71DF2DADF86A627306ECFF96DBB8BACE198B61E00F8B332', + 16 + ) ); $this->setOrder(new BigInteger( 'AADD9DB8DBE9C48B3FD4E6AE33C9FC07CB308DB3B3C9D20ED6639CCA70330870553E5C414CA' . - '92619418661197FAC10471DB1D381085DDADDB58796829CA90069', 16)); + '92619418661197FAC10471DB1D381085DDADDB58796829CA90069', + 16 + )); } -} \ No newline at end of file +} diff --git a/phpseclib/Crypt/EC/Curves/nistb233.php b/phpseclib/Crypt/EC/Curves/nistb233.php index a2e974ac..f9998cff 100644 --- a/phpseclib/Crypt/EC/Curves/nistb233.php +++ b/phpseclib/Crypt/EC/Curves/nistb233.php @@ -17,4 +17,4 @@ namespace phpseclib3\Crypt\EC\Curves; final class nistb233 extends sect233r1 { -} \ No newline at end of file +} diff --git a/phpseclib/Crypt/EC/Curves/nistb409.php b/phpseclib/Crypt/EC/Curves/nistb409.php index c3f25829..20cb29d9 100644 --- a/phpseclib/Crypt/EC/Curves/nistb409.php +++ b/phpseclib/Crypt/EC/Curves/nistb409.php @@ -17,4 +17,4 @@ namespace phpseclib3\Crypt\EC\Curves; final class nistb409 extends sect409r1 { -} \ No newline at end of file +} diff --git a/phpseclib/Crypt/EC/Curves/nistk163.php b/phpseclib/Crypt/EC/Curves/nistk163.php index 2d3add6e..9bb8e482 100644 --- a/phpseclib/Crypt/EC/Curves/nistk163.php +++ b/phpseclib/Crypt/EC/Curves/nistk163.php @@ -17,4 +17,4 @@ namespace phpseclib3\Crypt\EC\Curves; final class nistk163 extends sect163k1 { -} \ No newline at end of file +} diff --git a/phpseclib/Crypt/EC/Curves/nistk233.php b/phpseclib/Crypt/EC/Curves/nistk233.php index 05efea40..c9c7e187 100644 --- a/phpseclib/Crypt/EC/Curves/nistk233.php +++ b/phpseclib/Crypt/EC/Curves/nistk233.php @@ -17,4 +17,4 @@ namespace phpseclib3\Crypt\EC\Curves; final class nistk233 extends sect233k1 { -} \ No newline at end of file +} diff --git a/phpseclib/Crypt/EC/Curves/nistk283.php b/phpseclib/Crypt/EC/Curves/nistk283.php index 95420587..673d8387 100644 --- a/phpseclib/Crypt/EC/Curves/nistk283.php +++ b/phpseclib/Crypt/EC/Curves/nistk283.php @@ -17,4 +17,4 @@ namespace phpseclib3\Crypt\EC\Curves; final class nistk283 extends sect283k1 { -} \ No newline at end of file +} diff --git a/phpseclib/Crypt/EC/Curves/nistk409.php b/phpseclib/Crypt/EC/Curves/nistk409.php index eb55ce7b..5e6f6a84 100644 --- a/phpseclib/Crypt/EC/Curves/nistk409.php +++ b/phpseclib/Crypt/EC/Curves/nistk409.php @@ -17,4 +17,4 @@ namespace phpseclib3\Crypt\EC\Curves; final class nistk409 extends sect409k1 { -} \ No newline at end of file +} diff --git a/phpseclib/Crypt/EC/Curves/nistp192.php b/phpseclib/Crypt/EC/Curves/nistp192.php index c600d79f..a9a8edb5 100644 --- a/phpseclib/Crypt/EC/Curves/nistp192.php +++ b/phpseclib/Crypt/EC/Curves/nistp192.php @@ -17,4 +17,4 @@ namespace phpseclib3\Crypt\EC\Curves; final class nistp192 extends secp192r1 { -} \ No newline at end of file +} diff --git a/phpseclib/Crypt/EC/Curves/nistp224.php b/phpseclib/Crypt/EC/Curves/nistp224.php index 5c4320ec..fcccb795 100644 --- a/phpseclib/Crypt/EC/Curves/nistp224.php +++ b/phpseclib/Crypt/EC/Curves/nistp224.php @@ -17,4 +17,4 @@ namespace phpseclib3\Crypt\EC\Curves; final class nistp224 extends secp224r1 { -} \ No newline at end of file +} diff --git a/phpseclib/Crypt/EC/Curves/nistp256.php b/phpseclib/Crypt/EC/Curves/nistp256.php index 56d0b5ad..4853cdf9 100644 --- a/phpseclib/Crypt/EC/Curves/nistp256.php +++ b/phpseclib/Crypt/EC/Curves/nistp256.php @@ -17,4 +17,4 @@ namespace phpseclib3\Crypt\EC\Curves; final class nistp256 extends secp256r1 { -} \ No newline at end of file +} diff --git a/phpseclib/Crypt/EC/Curves/nistp384.php b/phpseclib/Crypt/EC/Curves/nistp384.php index 7a45babf..04e6c716 100644 --- a/phpseclib/Crypt/EC/Curves/nistp384.php +++ b/phpseclib/Crypt/EC/Curves/nistp384.php @@ -17,4 +17,4 @@ namespace phpseclib3\Crypt\EC\Curves; final class nistp384 extends secp384r1 { -} \ No newline at end of file +} diff --git a/phpseclib/Crypt/EC/Curves/nistp521.php b/phpseclib/Crypt/EC/Curves/nistp521.php index 167b058f..21a96d78 100644 --- a/phpseclib/Crypt/EC/Curves/nistp521.php +++ b/phpseclib/Crypt/EC/Curves/nistp521.php @@ -17,4 +17,4 @@ namespace phpseclib3\Crypt\EC\Curves; final class nistp521 extends secp521r1 { -} \ No newline at end of file +} diff --git a/phpseclib/Crypt/EC/Curves/nistt571.php b/phpseclib/Crypt/EC/Curves/nistt571.php index df92a395..bd1696af 100644 --- a/phpseclib/Crypt/EC/Curves/nistt571.php +++ b/phpseclib/Crypt/EC/Curves/nistt571.php @@ -17,4 +17,4 @@ namespace phpseclib3\Crypt\EC\Curves; final class nistt571 extends sect571k1 { -} \ No newline at end of file +} diff --git a/phpseclib/Crypt/EC/Curves/prime192v1.php b/phpseclib/Crypt/EC/Curves/prime192v1.php index d329122a..d4f01e84 100644 --- a/phpseclib/Crypt/EC/Curves/prime192v1.php +++ b/phpseclib/Crypt/EC/Curves/prime192v1.php @@ -17,4 +17,4 @@ namespace phpseclib3\Crypt\EC\Curves; final class prime192v1 extends secp192r1 { -} \ No newline at end of file +} diff --git a/phpseclib/Crypt/EC/Curves/prime192v2.php b/phpseclib/Crypt/EC/Curves/prime192v2.php index f5dbfa6b..05e95fdf 100644 --- a/phpseclib/Crypt/EC/Curves/prime192v2.php +++ b/phpseclib/Crypt/EC/Curves/prime192v2.php @@ -33,4 +33,4 @@ class prime192v2 extends Prime ); $this->setOrder(new BigInteger('FFFFFFFFFFFFFFFFFFFFFFFE5FB1A724DC80418648D8DD31', 16)); } -} \ No newline at end of file +} diff --git a/phpseclib/Crypt/EC/Curves/prime192v3.php b/phpseclib/Crypt/EC/Curves/prime192v3.php index 0bd83d37..216f81a6 100644 --- a/phpseclib/Crypt/EC/Curves/prime192v3.php +++ b/phpseclib/Crypt/EC/Curves/prime192v3.php @@ -33,4 +33,4 @@ class prime192v3 extends Prime ); $this->setOrder(new BigInteger('FFFFFFFFFFFFFFFFFFFFFFFF7A62D031C83F4294F640EC13', 16)); } -} \ No newline at end of file +} diff --git a/phpseclib/Crypt/EC/Curves/prime239v1.php b/phpseclib/Crypt/EC/Curves/prime239v1.php index e42e6925..eb938312 100644 --- a/phpseclib/Crypt/EC/Curves/prime239v1.php +++ b/phpseclib/Crypt/EC/Curves/prime239v1.php @@ -33,4 +33,4 @@ class prime239v1 extends Prime ); $this->setOrder(new BigInteger('7FFFFFFFFFFFFFFFFFFFFFFF7FFFFF9E5E9A9F5D9071FBD1522688909D0B', 16)); } -} \ No newline at end of file +} diff --git a/phpseclib/Crypt/EC/Curves/prime239v2.php b/phpseclib/Crypt/EC/Curves/prime239v2.php index ad6a3a86..f89970e9 100644 --- a/phpseclib/Crypt/EC/Curves/prime239v2.php +++ b/phpseclib/Crypt/EC/Curves/prime239v2.php @@ -33,4 +33,4 @@ class prime239v2 extends Prime ); $this->setOrder(new BigInteger('7FFFFFFFFFFFFFFFFFFFFFFF800000CFA7E8594377D414C03821BC582063', 16)); } -} \ No newline at end of file +} diff --git a/phpseclib/Crypt/EC/Curves/prime239v3.php b/phpseclib/Crypt/EC/Curves/prime239v3.php index ad41cfe0..7ee6f271 100644 --- a/phpseclib/Crypt/EC/Curves/prime239v3.php +++ b/phpseclib/Crypt/EC/Curves/prime239v3.php @@ -33,4 +33,4 @@ class prime239v3 extends Prime ); $this->setOrder(new BigInteger('7FFFFFFFFFFFFFFFFFFFFFFF7FFFFF975DEB41B3A6057C3C432146526551', 16)); } -} \ No newline at end of file +} diff --git a/phpseclib/Crypt/EC/Curves/prime256v1.php b/phpseclib/Crypt/EC/Curves/prime256v1.php index 8440514a..5c90586a 100644 --- a/phpseclib/Crypt/EC/Curves/prime256v1.php +++ b/phpseclib/Crypt/EC/Curves/prime256v1.php @@ -17,4 +17,4 @@ namespace phpseclib3\Crypt\EC\Curves; final class prime256v1 extends secp256r1 { -} \ No newline at end of file +} diff --git a/phpseclib/Crypt/EC/Curves/secp112r1.php b/phpseclib/Crypt/EC/Curves/secp112r1.php index 4f060018..e54f25c3 100644 --- a/phpseclib/Crypt/EC/Curves/secp112r1.php +++ b/phpseclib/Crypt/EC/Curves/secp112r1.php @@ -33,4 +33,4 @@ class secp112r1 extends Prime ); $this->setOrder(new BigInteger('DB7C2ABF62E35E7628DFAC6561C5', 16)); } -} \ No newline at end of file +} diff --git a/phpseclib/Crypt/EC/Curves/secp112r2.php b/phpseclib/Crypt/EC/Curves/secp112r2.php index e23e6b54..83454430 100644 --- a/phpseclib/Crypt/EC/Curves/secp112r2.php +++ b/phpseclib/Crypt/EC/Curves/secp112r2.php @@ -34,4 +34,4 @@ class secp112r2 extends Prime ); $this->setOrder(new BigInteger('36DF0AAFD8B8D7597CA10520D04B', 16)); } -} \ No newline at end of file +} diff --git a/phpseclib/Crypt/EC/Curves/secp128r1.php b/phpseclib/Crypt/EC/Curves/secp128r1.php index afe1336b..ee0b8afe 100644 --- a/phpseclib/Crypt/EC/Curves/secp128r1.php +++ b/phpseclib/Crypt/EC/Curves/secp128r1.php @@ -33,4 +33,4 @@ class secp128r1 extends Prime ); $this->setOrder(new BigInteger('FFFFFFFE0000000075A30D1B9038A115', 16)); } -} \ No newline at end of file +} diff --git a/phpseclib/Crypt/EC/Curves/secp128r2.php b/phpseclib/Crypt/EC/Curves/secp128r2.php index 4e2719b1..3b137dd7 100644 --- a/phpseclib/Crypt/EC/Curves/secp128r2.php +++ b/phpseclib/Crypt/EC/Curves/secp128r2.php @@ -34,4 +34,4 @@ class secp128r2 extends Prime ); $this->setOrder(new BigInteger('3FFFFFFF7FFFFFFFBE0024720613B5A3', 16)); } -} \ No newline at end of file +} diff --git a/phpseclib/Crypt/EC/Curves/secp160k1.php b/phpseclib/Crypt/EC/Curves/secp160k1.php index 80ff73e3..fbc73a9f 100644 --- a/phpseclib/Crypt/EC/Curves/secp160k1.php +++ b/phpseclib/Crypt/EC/Curves/secp160k1.php @@ -45,4 +45,4 @@ class secp160k1 extends KoblitzPrime ]; $this->beta = $this->factory->newInteger(new BigInteger('645B7345A143464942CC46D7CF4D5D1E1E6CBB68', -16)); } -} \ No newline at end of file +} diff --git a/phpseclib/Crypt/EC/Curves/secp160r1.php b/phpseclib/Crypt/EC/Curves/secp160r1.php index 5d7739c4..9bbfbfe2 100644 --- a/phpseclib/Crypt/EC/Curves/secp160r1.php +++ b/phpseclib/Crypt/EC/Curves/secp160r1.php @@ -33,4 +33,4 @@ class secp160r1 extends Prime ); $this->setOrder(new BigInteger('0100000000000000000001F4C8F927AED3CA752257', 16)); } -} \ No newline at end of file +} diff --git a/phpseclib/Crypt/EC/Curves/secp160r2.php b/phpseclib/Crypt/EC/Curves/secp160r2.php index 9b2789b4..e326c736 100644 --- a/phpseclib/Crypt/EC/Curves/secp160r2.php +++ b/phpseclib/Crypt/EC/Curves/secp160r2.php @@ -34,4 +34,4 @@ class secp160r2 extends Prime ); $this->setOrder(new BigInteger('0100000000000000000000351EE786A818F3A1A16B', 16)); } -} \ No newline at end of file +} diff --git a/phpseclib/Crypt/EC/Curves/secp192k1.php b/phpseclib/Crypt/EC/Curves/secp192k1.php index 79ff610c..31a13176 100644 --- a/phpseclib/Crypt/EC/Curves/secp192k1.php +++ b/phpseclib/Crypt/EC/Curves/secp192k1.php @@ -44,4 +44,4 @@ class secp192k1 extends KoblitzPrime ]; $this->beta = $this->factory->newInteger(new BigInteger('447A96E6C647963E2F7809FEAAB46947F34B0AA3CA0BBA74', -16)); } -} \ No newline at end of file +} diff --git a/phpseclib/Crypt/EC/Curves/secp192r1.php b/phpseclib/Crypt/EC/Curves/secp192r1.php index be7d3898..fb5ecf7c 100644 --- a/phpseclib/Crypt/EC/Curves/secp192r1.php +++ b/phpseclib/Crypt/EC/Curves/secp192r1.php @@ -36,7 +36,7 @@ class secp192r1 extends Prime now, if PHP supported unsigned integers things might be different. no bit-shifting would be required for the PHP engine and it'd be a lot faster. but as is, BigInteger uses base-2**31 or base-2**26 depending on whether or not the system is has a 32-bit - or a 64-bit OS. + or a 64-bit OS. */ /* $m_length = $this->getLengthInBytes(); @@ -77,4 +77,4 @@ class secp192r1 extends Prime ); $this->setOrder(new BigInteger('FFFFFFFFFFFFFFFFFFFFFFFF99DEF836146BC9B1B4D22831', 16)); } -} \ No newline at end of file +} diff --git a/phpseclib/Crypt/EC/Curves/secp224k1.php b/phpseclib/Crypt/EC/Curves/secp224k1.php index 6a2b9a82..ca85b981 100644 --- a/phpseclib/Crypt/EC/Curves/secp224k1.php +++ b/phpseclib/Crypt/EC/Curves/secp224k1.php @@ -44,4 +44,4 @@ class secp224k1 extends KoblitzPrime ]; $this->beta = $this->factory->newInteger(new BigInteger('01F178FFA4B17C89E6F73AECE2AAD57AF4C0A748B63C830947B27E04', -16)); } -} \ No newline at end of file +} diff --git a/phpseclib/Crypt/EC/Curves/secp256k1.php b/phpseclib/Crypt/EC/Curves/secp256k1.php index 958a4847..69461210 100644 --- a/phpseclib/Crypt/EC/Curves/secp256k1.php +++ b/phpseclib/Crypt/EC/Curves/secp256k1.php @@ -48,4 +48,4 @@ class secp256k1 extends KoblitzPrime ]; $this->beta = $this->factory->newInteger(new BigInteger('7AE96A2B657C07106E64479EAC3434E99CF0497512F58995C1396C28719501EE', -16)); } -} \ No newline at end of file +} diff --git a/phpseclib/Crypt/EC/Curves/secp384r1.php b/phpseclib/Crypt/EC/Curves/secp384r1.php index 8c01a761..6d180fe9 100644 --- a/phpseclib/Crypt/EC/Curves/secp384r1.php +++ b/phpseclib/Crypt/EC/Curves/secp384r1.php @@ -51,4 +51,4 @@ class secp384r1 extends Prime 16 )); } -} \ No newline at end of file +} diff --git a/phpseclib/Crypt/EC/Curves/secp521r1.php b/phpseclib/Crypt/EC/Curves/secp521r1.php index 8c2b9bbd..6e9164cb 100644 --- a/phpseclib/Crypt/EC/Curves/secp521r1.php +++ b/phpseclib/Crypt/EC/Curves/secp521r1.php @@ -45,4 +45,4 @@ class secp521r1 extends Prime 'FFFA51868783BF2F966B7FCC0148F709A5D03BB5C9B8899C47AEBB6FB71E9138' . '6409', 16)); } -} \ No newline at end of file +} diff --git a/phpseclib/Crypt/EC/Curves/sect113r1.php b/phpseclib/Crypt/EC/Curves/sect113r1.php index 958082a3..dfbf094b 100644 --- a/phpseclib/Crypt/EC/Curves/sect113r1.php +++ b/phpseclib/Crypt/EC/Curves/sect113r1.php @@ -33,4 +33,4 @@ class sect113r1 extends Binary ); $this->setOrder(new BigInteger('0100000000000000D9CCEC8A39E56F', 16)); } -} \ No newline at end of file +} diff --git a/phpseclib/Crypt/EC/Curves/sect113r2.php b/phpseclib/Crypt/EC/Curves/sect113r2.php index 9683c28f..e5a62a37 100644 --- a/phpseclib/Crypt/EC/Curves/sect113r2.php +++ b/phpseclib/Crypt/EC/Curves/sect113r2.php @@ -33,4 +33,4 @@ class sect113r2 extends Binary ); $this->setOrder(new BigInteger('010000000000000108789B2496AF93', 16)); } -} \ No newline at end of file +} diff --git a/phpseclib/Crypt/EC/Curves/sect131r1.php b/phpseclib/Crypt/EC/Curves/sect131r1.php index f1585b7f..9bd4f9a8 100644 --- a/phpseclib/Crypt/EC/Curves/sect131r1.php +++ b/phpseclib/Crypt/EC/Curves/sect131r1.php @@ -33,4 +33,4 @@ class sect131r1 extends Binary ); $this->setOrder(new BigInteger('0400000000000000023123953A9464B54D', 16)); } -} \ No newline at end of file +} diff --git a/phpseclib/Crypt/EC/Curves/sect131r2.php b/phpseclib/Crypt/EC/Curves/sect131r2.php index ecf7f99e..8351797e 100644 --- a/phpseclib/Crypt/EC/Curves/sect131r2.php +++ b/phpseclib/Crypt/EC/Curves/sect131r2.php @@ -33,4 +33,4 @@ class sect131r2 extends Binary ); $this->setOrder(new BigInteger('0400000000000000016954A233049BA98F', 16)); } -} \ No newline at end of file +} diff --git a/phpseclib/Crypt/EC/Curves/sect163k1.php b/phpseclib/Crypt/EC/Curves/sect163k1.php index cf51933b..a25e7d6b 100644 --- a/phpseclib/Crypt/EC/Curves/sect163k1.php +++ b/phpseclib/Crypt/EC/Curves/sect163k1.php @@ -33,4 +33,4 @@ class sect163k1 extends Binary ); $this->setOrder(new BigInteger('04000000000000000000020108A2E0CC0D99F8A5EF', 16)); } -} \ No newline at end of file +} diff --git a/phpseclib/Crypt/EC/Curves/sect163r1.php b/phpseclib/Crypt/EC/Curves/sect163r1.php index ca1c00ff..5061bf1e 100644 --- a/phpseclib/Crypt/EC/Curves/sect163r1.php +++ b/phpseclib/Crypt/EC/Curves/sect163r1.php @@ -33,4 +33,4 @@ class sect163r1 extends Binary ); $this->setOrder(new BigInteger('03FFFFFFFFFFFFFFFFFFFF48AAB689C29CA710279B', 16)); } -} \ No newline at end of file +} diff --git a/phpseclib/Crypt/EC/Curves/sect409k1.php b/phpseclib/Crypt/EC/Curves/sect409k1.php index d9c798a2..3fbefd08 100644 --- a/phpseclib/Crypt/EC/Curves/sect409k1.php +++ b/phpseclib/Crypt/EC/Curves/sect409k1.php @@ -33,7 +33,8 @@ class sect409k1 extends Binary ); $this->setOrder(new BigInteger( '7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFE5F' . - '83B2D4EA20400EC4557D5ED3E3E7CA5B4B5C83B8E01E5FCF', 16 + '83B2D4EA20400EC4557D5ED3E3E7CA5B4B5C83B8E01E5FCF', + 16 )); } } diff --git a/phpseclib/Crypt/EC/Curves/sect409r1.php b/phpseclib/Crypt/EC/Curves/sect409r1.php index c441180c..683a0d77 100644 --- a/phpseclib/Crypt/EC/Curves/sect409r1.php +++ b/phpseclib/Crypt/EC/Curves/sect409r1.php @@ -33,7 +33,8 @@ class sect409r1 extends Binary ); $this->setOrder(new BigInteger( '010000000000000000000000000000000000000000000000000001E2' . - 'AAD6A612F33307BE5FA47C3C9E052F838164CD37D9A21173', 16 + 'AAD6A612F33307BE5FA47C3C9E052F838164CD37D9A21173', + 16 )); } } diff --git a/phpseclib/Crypt/EC/Curves/sect571k1.php b/phpseclib/Crypt/EC/Curves/sect571k1.php index c1dd4f11..c17e8722 100644 --- a/phpseclib/Crypt/EC/Curves/sect571k1.php +++ b/phpseclib/Crypt/EC/Curves/sect571k1.php @@ -37,7 +37,8 @@ class sect571k1 extends Binary ); $this->setOrder(new BigInteger( '020000000000000000000000000000000000000000000000000000000000000000000000' . - '131850E1F19A63E4B391A8DB917F4138B630D84BE5D639381E91DEB45CFE778F637C1001', 16 + '131850E1F19A63E4B391A8DB917F4138B630D84BE5D639381E91DEB45CFE778F637C1001', + 16 )); } } diff --git a/phpseclib/Crypt/EC/Curves/sect571r1.php b/phpseclib/Crypt/EC/Curves/sect571r1.php index 95239342..cd025ac2 100644 --- a/phpseclib/Crypt/EC/Curves/sect571r1.php +++ b/phpseclib/Crypt/EC/Curves/sect571r1.php @@ -37,7 +37,8 @@ class sect571r1 extends Binary ); $this->setOrder(new BigInteger( '03FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF' . - 'E661CE18FF55987308059B186823851EC7DD9CA1161DE93D5174D66E8382E9BB2FE84E47', 16 + 'E661CE18FF55987308059B186823851EC7DD9CA1161DE93D5174D66E8382E9BB2FE84E47', + 16 )); } } diff --git a/phpseclib/Crypt/EC/Formats/Keys/Common.php b/phpseclib/Crypt/EC/Formats/Keys/Common.php index bf7e9aca..c1fe4e86 100644 --- a/phpseclib/Crypt/EC/Formats/Keys/Common.php +++ b/phpseclib/Crypt/EC/Formats/Keys/Common.php @@ -97,8 +97,8 @@ trait Common 'sect163k1' => '1.3.132.0.1', 'sect163r2' => '1.3.132.0.15', 'secp224r1' => '1.3.132.0.33', - 'sect233k1'=> '1.3.132.0.26', - 'sect233r1'=> '1.3.132.0.27', + 'sect233k1' => '1.3.132.0.26', + 'sect233r1' => '1.3.132.0.27', 'secp256r1' => '1.2.840.10045.3.1.7', // aka prime256v1 'sect283k1' => '1.3.132.0.16', 'sect283r1' => '1.3.132.0.17', diff --git a/phpseclib/Crypt/EC/Formats/Keys/MontgomeryPrivate.php b/phpseclib/Crypt/EC/Formats/Keys/MontgomeryPrivate.php index 01fb8515..4658fbd6 100644 --- a/phpseclib/Crypt/EC/Formats/Keys/MontgomeryPrivate.php +++ b/phpseclib/Crypt/EC/Formats/Keys/MontgomeryPrivate.php @@ -56,10 +56,10 @@ abstract class MontgomeryPrivate { switch (strlen($key)) { case 32: - $curve = new Curve25519; + $curve = new Curve25519(); break; case 56: - $curve = new Curve448; + $curve = new Curve448(); break; default: throw new \LengthException('The only supported lengths are 32 and 56'); diff --git a/phpseclib/Crypt/EC/Formats/Keys/MontgomeryPublic.php b/phpseclib/Crypt/EC/Formats/Keys/MontgomeryPublic.php index 91a88bd4..03f465e6 100644 --- a/phpseclib/Crypt/EC/Formats/Keys/MontgomeryPublic.php +++ b/phpseclib/Crypt/EC/Formats/Keys/MontgomeryPublic.php @@ -48,10 +48,10 @@ abstract class MontgomeryPublic { switch (strlen($key)) { case 32: - $curve = new Curve25519; + $curve = new Curve25519(); break; case 56: - $curve = new Curve448; + $curve = new Curve448(); break; default: throw new \LengthException('The only supported lengths are 32 and 56'); diff --git a/phpseclib/Crypt/EC/Formats/Keys/OpenSSH.php b/phpseclib/Crypt/EC/Formats/Keys/OpenSSH.php index 269ec0f8..de20446c 100644 --- a/phpseclib/Crypt/EC/Formats/Keys/OpenSSH.php +++ b/phpseclib/Crypt/EC/Formats/Keys/OpenSSH.php @@ -65,7 +65,7 @@ abstract class OpenSSH extends Progenitor if ($type != $parsed['type']) { throw new \RuntimeException("The public and private keys are not of the same type ($type vs $parsed[type])"); } - if ($type == 'ssh-ed25519' ) { + if ($type == 'ssh-ed25519') { list(, $key, $comment) = Strings::unpackSSH2('sss', $paddedKey); $key = libsodium::load($key); $key['comment'] = $comment; @@ -117,7 +117,7 @@ abstract class OpenSSH extends Progenitor $name = $reflect->getShortName(); $oid = self::$curveOIDs[$name]; - $aliases = array_filter(self::$curveOIDs, function($v) use ($oid) { + $aliases = array_filter(self::$curveOIDs, function ($v) use ($oid) { return $v == $oid; }); $aliases = array_keys($aliases); diff --git a/phpseclib/Crypt/EC/Formats/Keys/PuTTY.php b/phpseclib/Crypt/EC/Formats/Keys/PuTTY.php index 60ac545d..87082570 100644 --- a/phpseclib/Crypt/EC/Formats/Keys/PuTTY.php +++ b/phpseclib/Crypt/EC/Formats/Keys/PuTTY.php @@ -113,7 +113,7 @@ abstract class PuTTY extends Progenitor if (!$curve instanceof TwistedEdwardsCurve) { $private = $privateKey->toBytes(); if (!(strlen($privateKey->toBits()) & 7)) { - $private ="\0$private"; + $private = "\0$private"; } } diff --git a/phpseclib/Crypt/EC/Formats/Keys/XML.php b/phpseclib/Crypt/EC/Formats/Keys/XML.php index 7d7528fd..598922b5 100644 --- a/phpseclib/Crypt/EC/Formats/Keys/XML.php +++ b/phpseclib/Crypt/EC/Formats/Keys/XML.php @@ -125,7 +125,7 @@ abstract class XML $query = '/'; $names = explode('/', $name); foreach ($names as $name) { - $query.= "/*[translate(local-name(), 'ABCDEFGHIJKLMNOPQRSTUVWXYZ','abcdefghijklmnopqrstuvwxyz')='$name']"; + $query .= "/*[translate(local-name(), 'ABCDEFGHIJKLMNOPQRSTUVWXYZ','abcdefghijklmnopqrstuvwxyz')='$name']"; } $result = $xpath->query($query); if (!isset($error)) { @@ -435,7 +435,7 @@ abstract class XML $temp = $result['specifiedCurve']; switch ($temp['fieldID']['fieldType']) { case 'prime-field': - $xml.= '<' . $pre . 'PrimeFieldParamsType>' . "\r\n" . + $xml .= '<' . $pre . 'PrimeFieldParamsType>' . "\r\n" . '<' . $pre . 'P>' . $temp['fieldID']['parameters'] . '' . "\r\n" . '' . "\r\n"; $a = $curve->getA(); @@ -445,7 +445,7 @@ abstract class XML default: throw new UnsupportedCurveException('Field Type of ' . $temp['fieldID']['fieldType'] . ' is not supported'); } - $xml.= '' . "\r\n" . + $xml .= '' . "\r\n" . '<' . $pre . 'CurveParamsType>' . "\r\n" . '<' . $pre . 'A>' . $a . '' . "\r\n" . '<' . $pre . 'B>' . $b . '' . "\r\n" . @@ -470,14 +470,14 @@ abstract class XML $temp = $result['specifiedCurve']; switch ($temp['fieldID']['fieldType']) { case 'prime-field': - $xml.= '<' . $pre . 'Prime>' . "\r\n" . + $xml .= '<' . $pre . 'Prime>' . "\r\n" . '<' . $pre . 'P>' . Base64::encode($temp['fieldID']['parameters']->toBytes()) . '' . "\r\n" . '' . "\r\n" ; break; default: throw new UnsupportedCurveException('Field Type of ' . $temp['fieldID']['fieldType'] . ' is not supported'); } - $xml.= '' . "\r\n" . + $xml .= '' . "\r\n" . '<' . $pre . 'Curve>' . "\r\n" . '<' . $pre . 'A>' . Base64::encode($temp['curve']['a']) . '' . "\r\n" . '<' . $pre . 'B>' . Base64::encode($temp['curve']['b']) . '' . "\r\n" . diff --git a/phpseclib/Crypt/Hash.php b/phpseclib/Crypt/Hash.php index ab0f488e..5827ced8 100644 --- a/phpseclib/Crypt/Hash.php +++ b/phpseclib/Crypt/Hash.php @@ -404,7 +404,7 @@ class Hash if (in_array(substr($hash, 0, 5), ['sha3-', 'shake', 'kecca'])) { // PHP 7.1.0 introduced support for "SHA3 fixed mode algorithms": // http://php.net/ChangeLog-7.php#7.1.0 - if (version_compare(PHP_VERSION, '7.1.0') < 0 || substr($hash, 0,5) != 'sha3-') { + if (version_compare(PHP_VERSION, '7.1.0') < 0 || substr($hash, 0, 5) != 'sha3-') { //preg_match('#(\d+)$#', $hash, $matches); //$this->parameters['capacity'] = 2 * $matches[1]; // 1600 - $this->blockSize //$this->parameters['rate'] = 1600 - $this->parameters['capacity']; // == $this->blockSize @@ -546,15 +546,15 @@ class Hash // $y = ''; for ($i = 0; $i < $iters; $i++) { - $L1Key_i = substr($L1Key, $i * 16, 1024); - $L2Key_i = substr($L2Key, $i * 24, 24); + $L1Key_i = substr($L1Key, $i * 16, 1024); + $L2Key_i = substr($L2Key, $i * 24, 24); $L3Key1_i = substr($L3Key1, $i * 64, 64); $L3Key2_i = substr($L3Key2, $i * 4, 4); $a = self::L1Hash($L1Key_i, $m); $b = strlen($m) <= 1024 ? "\0\0\0\0\0\0\0\0$a" : self::L2Hash($L2Key_i, $a); $c = self::L3Hash($L3Key1_i, $L3Key2_i, $b); - $y.= $c; + $y .= $c; } return $y; @@ -586,7 +586,7 @@ class Hash $y = ''; for ($i = 0; $i < count($m) - 1; $i++) { $m[$i] = pack('N*', ...unpack('V*', $m[$i])); // ENDIAN-SWAP - $y.= static::nh($k, $m[$i], $length); + $y .= static::nh($k, $m[$i], $length); } // @@ -599,7 +599,7 @@ class Hash $m[$i] = str_pad($m[$i], $pad, "\0"); // zeropad $m[$i] = pack('N*', ...unpack('V*', $m[$i])); // ENDIAN-SWAP - $y.= static::nh($k, $m[$i], new BigInteger($length * 8)); + $y .= static::nh($k, $m[$i], new BigInteger($length * 8)); return $y; } @@ -613,7 +613,7 @@ class Hash */ private static function nh($k, $m, $length) { - $toUInt32 = function($x) { + $toUInt32 = function ($x) { $x = new BigInteger($x, 256); $x->setPrecision(32); return $x; @@ -635,7 +635,7 @@ class Hash // Perform NH hash on the chunks, pairing words for multiplication // which are 4 apart to accommodate vector-parallelism. // - $y = new BigInteger; + $y = new BigInteger(); $y->setPrecision(64); $i = 0; while ($i < $t) { @@ -659,7 +659,7 @@ class Hash $temp = $temp->multiply($m[$i + 7]->add($k[$i + 7])); $y = $y->add($temp); - $i+= 8; + $i += 8; } return $y->add($length)->toBytes(); @@ -702,7 +702,7 @@ class Hash $m_2 = substr($m, 0x20000) . "\x80"; $length = strlen($m_2); $pad = 16 - ($length % 16); - $pad%= 16; + $pad %= 16; $m_2 = str_pad($m_2, $length + $pad, "\0"); // zeropad $y = self::poly(64, self::$maxwordrange64, $k64, $m_1); $y = str_pad($y, 16, "\0", STR_PAD_LEFT); @@ -863,7 +863,7 @@ class Hash $temp .= $text; $temp = substr($algo($temp, ...array_values($this->parameters)), 0, $this->length); $output = $this->opad ^ $key; - $output.= $temp; + $output .= $temp; $output = $algo($output, ...array_values($this->parameters)); return substr($output, 0, $this->length); @@ -981,7 +981,7 @@ class Hash $padLength = $block_size - (strlen($p) % $block_size); $num_ints = $block_size >> 2; - $p.= static::sha3_pad($padLength, $padType); + $p .= static::sha3_pad($padLength, $padType); $n = strlen($p) / $r; // number of blocks @@ -998,9 +998,9 @@ class Hash foreach ($p as $pi) { $pi = unpack('V*', $pi); $x = $y = 0; - for ($i = 1; $i <= $num_ints; $i+=2) { - $s[$x][$y][0]^= $pi[$i + 1]; - $s[$x][$y][1]^= $pi[$i]; + for ($i = 1; $i <= $num_ints; $i += 2) { + $s[$x][$y][0] ^= $pi[$i + 1]; + $s[$x][$y][1] ^= $pi[$i]; if (++$y == 5) { $y = 0; $x++; @@ -1012,7 +1012,7 @@ class Hash $z = ''; $i = $j = 0; while (strlen($z) < $d) { - $z.= pack('V2', $s[$i][$j][1], $s[$i][$j++][0]); + $z .= pack('V2', $s[$i][$j][1], $s[$i][$j++][0]); if ($j == 5) { $j = 0; $i++; @@ -1092,8 +1092,8 @@ class Hash ]; for ($i = 0; $i < 5; $i++) { for ($j = 0; $j < 5; $j++) { - $s[$i][$j][0]^= $temp[$j][0]; - $s[$i][$j][1]^= $temp[$j][1]; + $s[$i][$j][0] ^= $temp[$j][0]; + $s[$i][$j][1] ^= $temp[$j][1]; } } @@ -1131,8 +1131,8 @@ class Hash } // iota step - $s[0][0][0]^= $roundConstants[$round][0]; - $s[0][0][1]^= $roundConstants[$round][1]; + $s[0][0][0] ^= $roundConstants[$round][0]; + $s[0][0][1] ^= $roundConstants[$round][1]; } } @@ -1148,7 +1148,7 @@ class Hash if ($shift < 32) { list($hi, $lo) = $x; } else { - $shift-= 32; + $shift -= 32; list($lo, $hi) = $x; } @@ -1174,7 +1174,7 @@ class Hash $padLength = $block_size - (strlen($p) % $block_size); $num_ints = $block_size >> 2; - $p.= static::sha3_pad($padLength, $padType); + $p .= static::sha3_pad($padLength, $padType); $n = strlen($p) / $r; // number of blocks @@ -1192,7 +1192,7 @@ class Hash $pi = unpack('P*', $pi); $x = $y = 0; foreach ($pi as $subpi) { - $s[$x][$y++]^= $subpi; + $s[$x][$y++] ^= $subpi; if ($y == 5) { $y = 0; $x++; @@ -1204,7 +1204,7 @@ class Hash $z = ''; $i = $j = 0; while (strlen($z) < $d) { - $z.= pack('P', $s[$i][$j++]); + $z .= pack('P', $s[$i][$j++]); if ($j == 5) { $j = 0; $i++; @@ -1276,7 +1276,7 @@ class Hash ]; for ($i = 0; $i < 5; $i++) { for ($j = 0; $j < 5; $j++) { - $s[$i][$j]^= $temp[$j]; + $s[$i][$j] ^= $temp[$j]; } } @@ -1301,7 +1301,7 @@ class Hash } // iota step - $s[0][0]^= $roundConstants[$round]; + $s[0][0] ^= $roundConstants[$round]; } } @@ -1363,10 +1363,10 @@ class Hash // Pre-processing $length = strlen($m); // to round to nearest 112 mod 128, we'll add 128 - (length + (128 - 112)) % 128 - $m.= str_repeat(chr(0), 128 - (($length + 16) & 0x7F)); + $m .= str_repeat(chr(0), 128 - (($length + 16) & 0x7F)); $m[$length] = chr(0x80); // we don't support hashing strings 512MB long - $m.= pack('N4', 0, 0, 0, $length << 3); + $m .= pack('N4', 0, 0, 0, $length << 3); // Process the message in successive 1024-bit chunks $chunks = str_split($m, 128); diff --git a/phpseclib/Crypt/PublicKeyLoader.php b/phpseclib/Crypt/PublicKeyLoader.php index ccb8556c..e1393c59 100644 --- a/phpseclib/Crypt/PublicKeyLoader.php +++ b/phpseclib/Crypt/PublicKeyLoader.php @@ -42,15 +42,18 @@ abstract class PublicKeyLoader { try { return EC::load($key, $password); - } catch (NoKeyLoadedException $e) {} + } catch (NoKeyLoadedException $e) { + } try { return RSA::load($key, $password); - } catch (NoKeyLoadedException $e) {} + } catch (NoKeyLoadedException $e) { + } try { return DSA::load($key, $password); - } catch (NoKeyLoadedException $e) {} + } catch (NoKeyLoadedException $e) { + } try { $x509 = new X509(); @@ -59,7 +62,8 @@ abstract class PublicKeyLoader if ($key) { return $key; } - } catch (\Exception $e) {} + } catch (\Exception $e) { + } throw new NoKeyLoadedException('Unable to read key'); } diff --git a/phpseclib/Crypt/RC2.php b/phpseclib/Crypt/RC2.php index 210337a4..0db9a74a 100644 --- a/phpseclib/Crypt/RC2.php +++ b/phpseclib/Crypt/RC2.php @@ -615,7 +615,7 @@ class RC2 extends BlockCipher $r3 += $keys[$r2 & 0x3F];'; $limit = $actions[$limit]; } - } + } $encrypt_block .= '$in = pack("v4", $r0, $r1, $r2, $r3);'; diff --git a/phpseclib/Crypt/RSA.php b/phpseclib/Crypt/RSA.php index 54248a17..c102efde 100644 --- a/phpseclib/Crypt/RSA.php +++ b/phpseclib/Crypt/RSA.php @@ -425,7 +425,7 @@ abstract class RSA extends AsymmetricKey // coefficient INTEGER, -- (inverse of q) mod p // otherPrimeInfos OtherPrimeInfos OPTIONAL // } - $privatekey = new PrivateKey; + $privatekey = new PrivateKey(); $privatekey->modulus = $n; $privatekey->k = $bits >> 3; $privatekey->publicExponent = $e; @@ -456,8 +456,8 @@ abstract class RSA extends AsymmetricKey protected static function onLoad($components) { $key = $components['isPublicKey'] ? - new PublicKey : - new PrivateKey; + new PublicKey() : + new PrivateKey(); $key->modulus = $components['modulus']; $key->publicExponent = $components['publicExponent']; @@ -603,7 +603,7 @@ abstract class RSA extends AsymmetricKey case 'sha512/256': $t = "\x30\x31\x30\x0d\x06\x09\x60\x86\x48\x01\x65\x03\x04\x02\x06\x05\x00\x04\x20"; } - $t.= $h; + $t .= $h; $tLen = strlen($t); if ($emLen < $tLen + 11) { @@ -663,7 +663,7 @@ abstract class RSA extends AsymmetricKey default: throw new UnsupportedAlgorithmException('md2 and md5 require NULLs'); } - $t.= $h; + $t .= $h; $tLen = strlen($t); if ($emLen < $tLen + 11) { @@ -695,7 +695,7 @@ abstract class RSA extends AsymmetricKey $count = ceil($maskLen / $this->mgfHLen); for ($i = 0; $i < $count; $i++) { $c = pack('N', $i); - $t.= $this->mgfHash->hash($mgfSeed . $c); + $t .= $this->mgfHash->hash($mgfSeed . $c); } return substr($t, 0, $maskLen); @@ -793,7 +793,7 @@ abstract class RSA extends AsymmetricKey */ public function getMGFHash() { - return clone $this->mgfHash; + return clone $this->mgfHash; } /** @@ -823,7 +823,7 @@ abstract class RSA extends AsymmetricKey */ public function getSaltLength() { - return $this->sLen !== null ? $this->sLen : $this->hLen; + return $this->sLen !== null ? $this->sLen : $this->hLen; } /** @@ -855,7 +855,7 @@ abstract class RSA extends AsymmetricKey */ public function getLabel() { - return $this->label; + return $this->label; } /** @@ -917,7 +917,7 @@ abstract class RSA extends AsymmetricKey */ public function getPadding() { - return $this->signaturePadding | $this->encryptionPadding; + return $this->signaturePadding | $this->encryptionPadding; } /** @@ -959,4 +959,4 @@ abstract class RSA extends AsymmetricKey { static::$enableBlinding = false; } -} \ No newline at end of file +} diff --git a/phpseclib/Crypt/RSA/Formats/Keys/MSBLOB.php b/phpseclib/Crypt/RSA/Formats/Keys/MSBLOB.php index 0077bdb8..7328bd2f 100644 --- a/phpseclib/Crypt/RSA/Formats/Keys/MSBLOB.php +++ b/phpseclib/Crypt/RSA/Formats/Keys/MSBLOB.php @@ -209,14 +209,14 @@ abstract class MSBLOB $n = strrev($n->toBytes()); $e = str_pad(strrev($e->toBytes()), 4, "\0"); $key = pack('aavV', chr(self::PRIVATEKEYBLOB), chr(2), 0, self::CALG_RSA_KEYX); - $key.= pack('VVa*', self::RSA2, 8 * strlen($n), $e); - $key.= $n; - $key.= strrev($primes[1]->toBytes()); - $key.= strrev($primes[2]->toBytes()); - $key.= strrev($exponents[1]->toBytes()); - $key.= strrev($exponents[2]->toBytes()); - $key.= strrev($coefficients[2]->toBytes()); - $key.= strrev($d->toBytes()); + $key .= pack('VVa*', self::RSA2, 8 * strlen($n), $e); + $key .= $n; + $key .= strrev($primes[1]->toBytes()); + $key .= strrev($primes[2]->toBytes()); + $key .= strrev($exponents[1]->toBytes()); + $key .= strrev($exponents[2]->toBytes()); + $key .= strrev($coefficients[2]->toBytes()); + $key .= strrev($d->toBytes()); return Base64::encode($key); } @@ -234,8 +234,8 @@ abstract class MSBLOB $n = strrev($n->toBytes()); $e = str_pad(strrev($e->toBytes()), 4, "\0"); $key = pack('aavV', chr(self::PUBLICKEYBLOB), chr(2), 0, self::CALG_RSA_KEYX); - $key.= pack('VVa*', self::RSA1, 8 * strlen($n), $e); - $key.= $n; + $key .= pack('VVa*', self::RSA1, 8 * strlen($n), $e); + $key .= $n; return Base64::encode($key); } diff --git a/phpseclib/Crypt/RSA/Formats/Keys/PKCS1.php b/phpseclib/Crypt/RSA/Formats/Keys/PKCS1.php index 8562ba2f..b7dda78f 100644 --- a/phpseclib/Crypt/RSA/Formats/Keys/PKCS1.php +++ b/phpseclib/Crypt/RSA/Formats/Keys/PKCS1.php @@ -70,7 +70,7 @@ abstract class PKCS1 extends Progenitor $key = ASN1::asn1map($decoded[0], Maps\RSAPrivateKey::MAP); if (is_array($key)) { - $components+= [ + $components += [ 'modulus' => $key['modulus'], 'publicExponent' => $key['publicExponent'], 'privateExponent' => $key['privateExponent'], diff --git a/phpseclib/Crypt/RSA/Formats/Keys/Raw.php b/phpseclib/Crypt/RSA/Formats/Keys/Raw.php index aa7fd04e..5ccef230 100644 --- a/phpseclib/Crypt/RSA/Formats/Keys/Raw.php +++ b/phpseclib/Crypt/RSA/Formats/Keys/Raw.php @@ -74,7 +74,7 @@ abstract class Raw if (isset($key['primes'])) { $components['primes'] = $key['primes']; - } else if (isset($key['p']) && isset($key['q'])) { + } elseif (isset($key['p']) && isset($key['q'])) { $indices = [ ['p', 'q'], ['prime1', 'prime2'] @@ -164,9 +164,15 @@ abstract class Raw 'e' => clone $e, 'n' => clone $n, 'd' => clone $d, - 'primes' => array_map(function($var) { return clone $var; }, $primes), - 'exponents' => array_map(function($var) { return clone $var; }, $exponents), - 'coefficients' => array_map(function($var) { return clone $var; }, $coefficients) + 'primes' => array_map(function ($var) { + return clone $var; + }, $primes), + 'exponents' => array_map(function ($var) { + return clone $var; + }, $exponents), + 'coefficients' => array_map(function ($var) { + return clone $var; + }, $coefficients) ]; } diff --git a/phpseclib/Crypt/RSA/PrivateKey.php b/phpseclib/Crypt/RSA/PrivateKey.php index 52abfb82..a4390deb 100644 --- a/phpseclib/Crypt/RSA/PrivateKey.php +++ b/phpseclib/Crypt/RSA/PrivateKey.php @@ -408,9 +408,9 @@ class PrivateKey extends RSA implements Common\PrivateKey $patternMatch = 0; $offset = 0; for ($i = 0; $i < strlen($m); $i++) { - $patternMatch|= $leadingZeros & ($m[$i] === "\1"); - $leadingZeros&= $m[$i] === "\0"; - $offset+= $patternMatch ? 0 : 1; + $patternMatch |= $leadingZeros & ($m[$i] === "\1"); + $leadingZeros &= $m[$i] === "\0"; + $offset += $patternMatch ? 0 : 1; } // we do | instead of || to avoid https://en.wikipedia.org/wiki/Short-circuit_evaluation @@ -505,7 +505,7 @@ class PrivateKey extends RSA implements Common\PrivateKey if ($type == PSS::class) { if ($this->signaturePadding == self::SIGNATURE_PSS) { - $options+= [ + $options += [ 'hash' => $this->hash->getHash(), 'MGFHash' => $this->mgfHash->getHash(), 'saltLength' => $this->getSaltLength() diff --git a/phpseclib/Crypt/RSA/PublicKey.php b/phpseclib/Crypt/RSA/PublicKey.php index aa56292d..5a8c8f1f 100644 --- a/phpseclib/Crypt/RSA/PublicKey.php +++ b/phpseclib/Crypt/RSA/PublicKey.php @@ -349,7 +349,7 @@ class PublicKey extends RSA implements Common\PublicKey while (strlen($ps) != $psLen) { $temp = Random::string($psLen - strlen($ps)); $temp = str_replace("\x00", '', $temp); - $ps.= $temp; + $ps .= $temp; } $type = 2; $em = chr(0) . chr($type) . $ps . chr(0) . $m; @@ -492,7 +492,7 @@ class PublicKey extends RSA implements Common\PublicKey if ($type == PSS::class) { if ($this->signaturePadding == self::SIGNATURE_PSS) { - $options+= [ + $options += [ 'hash' => $this->hash->getHash(), 'MGFHash' => $this->mgfHash->getHash(), 'saltLength' => $this->getSaltLength() @@ -512,7 +512,7 @@ class PublicKey extends RSA implements Common\PublicKey */ public function asPrivateKey() { - $new = new PrivateKey; + $new = new PrivateKey(); $new->exponent = $this->exponent; $new->modulus = $this->modulus; $new->k = $this->k; diff --git a/phpseclib/Crypt/Random.php b/phpseclib/Crypt/Random.php index 1c943933..8bcaa8da 100644 --- a/phpseclib/Crypt/Random.php +++ b/phpseclib/Crypt/Random.php @@ -184,7 +184,7 @@ abstract class Random $i = $crypto->encrypt(microtime()); // strlen(microtime()) == 21 $r = $crypto->encrypt($i ^ $v); // strlen($v) == 20 $v = $crypto->encrypt($r ^ $i); // strlen($r) == 20 - $result.= $r; + $result .= $r; } return substr($result, 0, $length); diff --git a/phpseclib/Crypt/Rijndael.php b/phpseclib/Crypt/Rijndael.php index d5f1e007..90994869 100644 --- a/phpseclib/Crypt/Rijndael.php +++ b/phpseclib/Crypt/Rijndael.php @@ -55,7 +55,6 @@ namespace phpseclib3\Crypt; use phpseclib3\Common\Functions\Strings; - use phpseclib3\Crypt\Common\BlockCipher; use phpseclib3\Exception\BadDecryptionException; use phpseclib3\Exception\BadModeException; @@ -854,7 +853,7 @@ class Rijndael extends BlockCipher $c = $this->c; // Generating encrypt code: - $init_encrypt.= ' + $init_encrypt .= ' static $tables; if (empty($tables)) { $tables = &$this->getTables(); @@ -871,47 +870,47 @@ class Rijndael extends BlockCipher $wc = $Nb - 1; // Preround: addRoundKey - $encrypt_block = '$in = unpack("N*", $in);'."\n"; + $encrypt_block = '$in = unpack("N*", $in);' . "\n"; for ($i = 0; $i < $Nb; ++$i) { - $encrypt_block .= '$s'.$i.' = $in['.($i + 1).'] ^ '.$w[++$wc].";\n"; + $encrypt_block .= '$s' . $i . ' = $in[' . ($i + 1) . '] ^ ' . $w[++$wc] . ";\n"; } // Mainrounds: shiftRows + subWord + mixColumns + addRoundKey for ($round = 1; $round < $Nr; ++$round) { list($s, $e) = [$e, $s]; for ($i = 0; $i < $Nb; ++$i) { - $encrypt_block.= - '$'.$e.$i.' = - $t0[($'.$s.$i .' >> 24) & 0xff] ^ - $t1[($'.$s.(($i + $c[1]) % $Nb).' >> 16) & 0xff] ^ - $t2[($'.$s.(($i + $c[2]) % $Nb).' >> 8) & 0xff] ^ - $t3[ $'.$s.(($i + $c[3]) % $Nb).' & 0xff] ^ - '.$w[++$wc].";\n"; + $encrypt_block .= + '$' . $e . $i . ' = + $t0[($' . $s . $i . ' >> 24) & 0xff] ^ + $t1[($' . $s . (($i + $c[1]) % $Nb) . ' >> 16) & 0xff] ^ + $t2[($' . $s . (($i + $c[2]) % $Nb) . ' >> 8) & 0xff] ^ + $t3[ $' . $s . (($i + $c[3]) % $Nb) . ' & 0xff] ^ + ' . $w[++$wc] . ";\n"; } } // Finalround: subWord + shiftRows + addRoundKey for ($i = 0; $i < $Nb; ++$i) { - $encrypt_block.= - '$'.$e.$i.' = - $sbox[ $'.$e.$i.' & 0xff] | - ($sbox[($'.$e.$i.' >> 8) & 0xff] << 8) | - ($sbox[($'.$e.$i.' >> 16) & 0xff] << 16) | - ($sbox[($'.$e.$i.' >> 24) & 0xff] << 24);'."\n"; + $encrypt_block .= + '$' . $e . $i . ' = + $sbox[ $' . $e . $i . ' & 0xff] | + ($sbox[($' . $e . $i . ' >> 8) & 0xff] << 8) | + ($sbox[($' . $e . $i . ' >> 16) & 0xff] << 16) | + ($sbox[($' . $e . $i . ' >> 24) & 0xff] << 24);' . "\n"; } - $encrypt_block .= '$in = pack("N*"'."\n"; + $encrypt_block .= '$in = pack("N*"' . "\n"; for ($i = 0; $i < $Nb; ++$i) { - $encrypt_block.= ', - ($'.$e.$i .' & '.((int)0xFF000000).') ^ - ($'.$e.(($i + $c[1]) % $Nb).' & 0x00FF0000 ) ^ - ($'.$e.(($i + $c[2]) % $Nb).' & 0x0000FF00 ) ^ - ($'.$e.(($i + $c[3]) % $Nb).' & 0x000000FF ) ^ - '.$w[$i]."\n"; + $encrypt_block .= ', + ($' . $e . $i . ' & ' . ((int)0xFF000000) . ') ^ + ($' . $e . (($i + $c[1]) % $Nb) . ' & 0x00FF0000 ) ^ + ($' . $e . (($i + $c[2]) % $Nb) . ' & 0x0000FF00 ) ^ + ($' . $e . (($i + $c[3]) % $Nb) . ' & 0x000000FF ) ^ + ' . $w[$i] . "\n"; } $encrypt_block .= ');'; // Generating decrypt code: - $init_decrypt.= ' + $init_decrypt .= ' static $invtables; if (empty($invtables)) { $invtables = &$this->getInvTables(); @@ -928,42 +927,42 @@ class Rijndael extends BlockCipher $wc = $Nb - 1; // Preround: addRoundKey - $decrypt_block = '$in = unpack("N*", $in);'."\n"; + $decrypt_block = '$in = unpack("N*", $in);' . "\n"; for ($i = 0; $i < $Nb; ++$i) { - $decrypt_block .= '$s'.$i.' = $in['.($i + 1).'] ^ '.$dw[++$wc].';'."\n"; + $decrypt_block .= '$s' . $i . ' = $in[' . ($i + 1) . '] ^ ' . $dw[++$wc] . ';' . "\n"; } // Mainrounds: shiftRows + subWord + mixColumns + addRoundKey for ($round = 1; $round < $Nr; ++$round) { list($s, $e) = [$e, $s]; for ($i = 0; $i < $Nb; ++$i) { - $decrypt_block.= - '$'.$e.$i.' = - $dt0[($'.$s.$i .' >> 24) & 0xff] ^ - $dt1[($'.$s.(($Nb + $i - $c[1]) % $Nb).' >> 16) & 0xff] ^ - $dt2[($'.$s.(($Nb + $i - $c[2]) % $Nb).' >> 8) & 0xff] ^ - $dt3[ $'.$s.(($Nb + $i - $c[3]) % $Nb).' & 0xff] ^ - '.$dw[++$wc].";\n"; + $decrypt_block .= + '$' . $e . $i . ' = + $dt0[($' . $s . $i . ' >> 24) & 0xff] ^ + $dt1[($' . $s . (($Nb + $i - $c[1]) % $Nb) . ' >> 16) & 0xff] ^ + $dt2[($' . $s . (($Nb + $i - $c[2]) % $Nb) . ' >> 8) & 0xff] ^ + $dt3[ $' . $s . (($Nb + $i - $c[3]) % $Nb) . ' & 0xff] ^ + ' . $dw[++$wc] . ";\n"; } } // Finalround: subWord + shiftRows + addRoundKey for ($i = 0; $i < $Nb; ++$i) { - $decrypt_block.= - '$'.$e.$i.' = - $isbox[ $'.$e.$i.' & 0xff] | - ($isbox[($'.$e.$i.' >> 8) & 0xff] << 8) | - ($isbox[($'.$e.$i.' >> 16) & 0xff] << 16) | - ($isbox[($'.$e.$i.' >> 24) & 0xff] << 24);'."\n"; + $decrypt_block .= + '$' . $e . $i . ' = + $isbox[ $' . $e . $i . ' & 0xff] | + ($isbox[($' . $e . $i . ' >> 8) & 0xff] << 8) | + ($isbox[($' . $e . $i . ' >> 16) & 0xff] << 16) | + ($isbox[($' . $e . $i . ' >> 24) & 0xff] << 24);' . "\n"; } - $decrypt_block .= '$in = pack("N*"'."\n"; + $decrypt_block .= '$in = pack("N*"' . "\n"; for ($i = 0; $i < $Nb; ++$i) { - $decrypt_block.= ', - ($'.$e.$i. ' & '.((int)0xFF000000).') ^ - ($'.$e.(($Nb + $i - $c[1]) % $Nb).' & 0x00FF0000 ) ^ - ($'.$e.(($Nb + $i - $c[2]) % $Nb).' & 0x0000FF00 ) ^ - ($'.$e.(($Nb + $i - $c[3]) % $Nb).' & 0x000000FF ) ^ - '.$dw[$i]."\n"; + $decrypt_block .= ', + ($' . $e . $i . ' & ' . ((int)0xFF000000) . ') ^ + ($' . $e . (($Nb + $i - $c[1]) % $Nb) . ' & 0x00FF0000 ) ^ + ($' . $e . (($Nb + $i - $c[2]) % $Nb) . ' & 0x0000FF00 ) ^ + ($' . $e . (($Nb + $i - $c[3]) % $Nb) . ' & 0x000000FF ) ^ + ' . $dw[$i] . "\n"; } $decrypt_block .= ');'; diff --git a/phpseclib/Crypt/Salsa20.php b/phpseclib/Crypt/Salsa20.php index a6b4c3f2..98a6e4c2 100644 --- a/phpseclib/Crypt/Salsa20.php +++ b/phpseclib/Crypt/Salsa20.php @@ -216,7 +216,7 @@ class Salsa20 extends StreamCipher $key = $this->key; if (strlen($key) == 16) { $constant = 'expand 16-byte k'; - $key.= $key; + $key .= $key; } else { $constant = 'expand 32-byte k'; } @@ -330,7 +330,7 @@ class Salsa20 extends StreamCipher $i = $this->counter; $blocks = str_split($text, 64); foreach ($blocks as &$block) { - $block^= static::salsa20($this->p1 . pack('V', $i++) . $this->p2); + $block ^= static::salsa20($this->p1 . pack('V', $i++) . $this->p2); } return implode('', $blocks); @@ -357,7 +357,7 @@ class Salsa20 extends StreamCipher if ($this->engine == self::ENGINE_OPENSSL) { $iv = pack('V', $buffer['counter']) . $this->p2; // at this point $text should be a multiple of 64 - $buffer['counter']+= (strlen($text) >> 6) + 1; // ie. divide by 64 + $buffer['counter'] += (strlen($text) >> 6) + 1; // ie. divide by 64 $encrypted = openssl_encrypt( $text . str_repeat("\0", 64), $this->cipher_name_openssl, @@ -370,19 +370,19 @@ class Salsa20 extends StreamCipher $blocks = str_split($text, 64); if (strlen($text)) { foreach ($blocks as &$block) { - $block^= static::salsa20($this->p1 . pack('V', $buffer['counter']++) . $this->p2); + $block ^= static::salsa20($this->p1 . pack('V', $buffer['counter']++) . $this->p2); } } $encrypted = implode('', $blocks); $temp = static::salsa20($this->p1 . pack('V', $buffer['counter']++) . $this->p2); } - $ciphertext.= $encrypted . ($text2 ^ $temp); + $ciphertext .= $encrypted . ($text2 ^ $temp); $buffer['ciphertext'] = substr($temp, $overflow); } elseif (!strlen($buffer['ciphertext'])) { if ($this->engine == self::ENGINE_OPENSSL) { $iv = pack('V', $buffer['counter']) . $this->p2; - $buffer['counter']+= (strlen($text) >> 6); - $ciphertext.= openssl_encrypt( + $buffer['counter'] += (strlen($text) >> 6); + $ciphertext .= openssl_encrypt( $text, $this->cipher_name_openssl, $this->key, @@ -392,9 +392,9 @@ class Salsa20 extends StreamCipher } else { $blocks = str_split($text, 64); foreach ($blocks as &$block) { - $block^= static::salsa20($this->p1 . pack('V', $buffer['counter']++) . $this->p2); + $block ^= static::salsa20($this->p1 . pack('V', $buffer['counter']++) . $this->p2); } - $ciphertext.= implode('', $blocks); + $ciphertext .= implode('', $blocks); } } @@ -412,11 +412,11 @@ class Salsa20 extends StreamCipher { $r1 = $x << $n; if (PHP_INT_SIZE == 8) { - $r1&= 0xFFFFFFFF; + $r1 &= 0xFFFFFFFF; $r2 = ($x & 0xFFFFFFFF) >> (32 - $n); } else { $r2 = $x >> (32 - $n); - $r2&= (1 << $n) - 1; + $r2 &= (1 << $n) - 1; } return $r1 | $r2; } @@ -431,10 +431,10 @@ class Salsa20 extends StreamCipher */ protected static function quarterRound(&$a, &$b, &$c, &$d) { - $b^= self::leftRotate($a + $d, 7); - $c^= self::leftRotate($b + $a, 9); - $d^= self::leftRotate($c + $b, 13); - $a^= self::leftRotate($d + $c, 18); + $b ^= self::leftRotate($a + $d, 7); + $c ^= self::leftRotate($b + $a, 9); + $d ^= self::leftRotate($c + $b, 13); + $a ^= self::leftRotate($d + $c, 18); } /** @@ -460,14 +460,14 @@ class Salsa20 extends StreamCipher protected static function doubleRound(&$x0, &$x1, &$x2, &$x3, &$x4, &$x5, &$x6, &$x7, &$x8, &$x9, &$x10, &$x11, &$x12, &$x13, &$x14, &$x15) { // columnRound - static::quarterRound( $x0, $x4, $x8, $x12); - static::quarterRound( $x5, $x9, $x13, $x1); - static::quarterRound($x10, $x14, $x2, $x6); - static::quarterRound($x15, $x3, $x7, $x11); + static::quarterRound($x0, $x4, $x8, $x12); + static::quarterRound($x5, $x9, $x13, $x1); + static::quarterRound($x10, $x14, $x2, $x6); + static::quarterRound($x15, $x3, $x7, $x11); // rowRound - static::quarterRound( $x0, $x1, $x2, $x3); - static::quarterRound( $x5, $x6, $x7, $x4); - static::quarterRound($x10, $x11, $x8, $x9); + static::quarterRound($x0, $x1, $x2, $x3); + static::quarterRound($x5, $x6, $x7, $x4); + static::quarterRound($x10, $x11, $x8, $x9); static::quarterRound($x15, $x12, $x13, $x14); } @@ -484,7 +484,7 @@ class Salsa20 extends StreamCipher } for ($i = 1; $i <= 16; $i++) { - $x[$i]+= $z[$i]; + $x[$i] += $z[$i]; } return pack('V*', ...$x); diff --git a/phpseclib/Crypt/TripleDES.php b/phpseclib/Crypt/TripleDES.php index 3c57d52b..1185bab7 100644 --- a/phpseclib/Crypt/TripleDES.php +++ b/phpseclib/Crypt/TripleDES.php @@ -260,7 +260,7 @@ class TripleDES extends DES switch (strlen($key)) { case 16: - $key.= substr($key, 0, 8); + $key .= substr($key, 0, 8); break; case 24: break; @@ -275,8 +275,8 @@ class TripleDES extends DES $this->setEngine(); if ($this->mode_3cbc) { - $this->des[0]->setKey(substr($key, 0, 8)); - $this->des[1]->setKey(substr($key, 8, 8)); + $this->des[0]->setKey(substr($key, 0, 8)); + $this->des[1]->setKey(substr($key, 8, 8)); $this->des[2]->setKey(substr($key, 16, 8)); } } diff --git a/phpseclib/Crypt/Twofish.php b/phpseclib/Crypt/Twofish.php index 136708e3..1673ce96 100644 --- a/phpseclib/Crypt/Twofish.php +++ b/phpseclib/Crypt/Twofish.php @@ -463,7 +463,7 @@ class Twofish extends BlockCipher case 16: list($s7, $s6, $s5, $s4) = $this->mdsrem($le_longs[1], $le_longs[2]); list($s3, $s2, $s1, $s0) = $this->mdsrem($le_longs[3], $le_longs[4]); - for ($i = 0, $j = 1; $i < 40; $i+= 2, $j+= 2) { + for ($i = 0, $j = 1; $i < 40; $i += 2, $j += 2) { $A = $m0[$q0[$q0[$i] ^ $key[ 9]] ^ $key[1]] ^ $m1[$q0[$q1[$i] ^ $key[10]] ^ $key[2]] ^ $m2[$q1[$q0[$i] ^ $key[11]] ^ $key[3]] ^ @@ -489,7 +489,7 @@ class Twofish extends BlockCipher list($sb, $sa, $s9, $s8) = $this->mdsrem($le_longs[1], $le_longs[2]); list($s7, $s6, $s5, $s4) = $this->mdsrem($le_longs[3], $le_longs[4]); list($s3, $s2, $s1, $s0) = $this->mdsrem($le_longs[5], $le_longs[6]); - for ($i = 0, $j = 1; $i < 40; $i+= 2, $j+= 2) { + for ($i = 0, $j = 1; $i < 40; $i += 2, $j += 2) { $A = $m0[$q0[$q0[$q1[$i] ^ $key[17]] ^ $key[ 9]] ^ $key[1]] ^ $m1[$q0[$q1[$q1[$i] ^ $key[18]] ^ $key[10]] ^ $key[2]] ^ $m2[$q1[$q0[$q0[$i] ^ $key[19]] ^ $key[11]] ^ $key[3]] ^ @@ -516,7 +516,7 @@ class Twofish extends BlockCipher list($sb, $sa, $s9, $s8) = $this->mdsrem($le_longs[3], $le_longs[4]); list($s7, $s6, $s5, $s4) = $this->mdsrem($le_longs[5], $le_longs[6]); list($s3, $s2, $s1, $s0) = $this->mdsrem($le_longs[7], $le_longs[8]); - for ($i = 0, $j = 1; $i < 40; $i+= 2, $j+= 2) { + for ($i = 0, $j = 1; $i < 40; $i += 2, $j += 2) { $A = $m0[$q0[$q0[$q1[$q1[$i] ^ $key[25]] ^ $key[17]] ^ $key[ 9]] ^ $key[1]] ^ $m1[$q0[$q1[$q1[$q0[$i] ^ $key[26]] ^ $key[18]] ^ $key[10]] ^ $key[2]] ^ $m2[$q1[$q0[$q0[$q0[$i] ^ $key[27]] ^ $key[19]] ^ $key[11]] ^ $key[3]] ^ @@ -563,28 +563,28 @@ class Twofish extends BlockCipher // Shift the others up. $B = ($B << 8) | (0xff & ($A >> 24)); - $A<<= 8; + $A <<= 8; $u = $t << 1; // Subtract the modular polynomial on overflow. if ($t & 0x80) { - $u^= 0x14d; + $u ^= 0x14d; } // Remove t * (a * x^2 + 1). $B ^= $t ^ ($u << 16); // Form u = a*t + t/a = t*(a + 1/a). - $u^= 0x7fffffff & ($t >> 1); + $u ^= 0x7fffffff & ($t >> 1); // Add the modular polynomial on underflow. if ($t & 0x01) { - $u^= 0xa6 ; + $u ^= 0xa6 ; } // Remove t * (a + 1/a) * (x^3 + x). - $B^= ($u << 24) | ($u << 8); + $B ^= ($u << 24) | ($u << 8); } return [ @@ -625,7 +625,7 @@ class Twofish extends BlockCipher $S1[ $R1 & 0xff] ^ $S2[($R1 >> 8) & 0xff] ^ $S3[($R1 >> 16) & 0xff]; - $R2^= self::safe_intval($t0 + $t1 + $K[++$ki]); + $R2 ^= self::safe_intval($t0 + $t1 + $K[++$ki]); $R2 = ($R2 >> 1 & 0x7fffffff) | ($R2 << 31); $R3 = ((($R3 >> 31) & 1) | ($R3 << 1)) ^ self::safe_intval($t0 + ($t1 << 1) + $K[++$ki]); @@ -637,7 +637,7 @@ class Twofish extends BlockCipher $S1[ $R3 & 0xff] ^ $S2[($R3 >> 8) & 0xff] ^ $S3[($R3 >> 16) & 0xff]; - $R0^= self::safe_intval($t0 + $t1 + $K[++$ki]); + $R0 ^= self::safe_intval($t0 + $t1 + $K[++$ki]); $R0 = ($R0 >> 1 & 0x7fffffff) | ($R0 << 31); $R1 = ((($R1 >> 31) & 1) | ($R1 << 1)) ^ self::safe_intval($t0 + ($t1 << 1) + $K[++$ki]); } @@ -681,7 +681,7 @@ class Twofish extends BlockCipher $S1[$R1 & 0xff] ^ $S2[$R1 >> 8 & 0xff] ^ $S3[$R1 >> 16 & 0xff]; - $R3^= self::safe_intval($t0 + ($t1 << 1) + $K[--$ki]); + $R3 ^= self::safe_intval($t0 + ($t1 << 1) + $K[--$ki]); $R3 = $R3 >> 1 & 0x7fffffff | $R3 << 31; $R2 = ($R2 >> 31 & 0x1 | $R2 << 1) ^ self::safe_intval($t0 + $t1 + $K[--$ki]); @@ -693,7 +693,7 @@ class Twofish extends BlockCipher $S1[$R3 & 0xff] ^ $S2[$R3 >> 8 & 0xff] ^ $S3[$R3 >> 16 & 0xff]; - $R1^= self::safe_intval($t0 + ($t1 << 1) + $K[--$ki]); + $R1 ^= self::safe_intval($t0 + ($t1 << 1) + $K[--$ki]); $R1 = $R1 >> 1 & 0x7fffffff | $R1 << 31; $R0 = ($R0 >> 31 & 0x1 | $R0 << 1) ^ self::safe_intval($t0 + $t1 + $K[--$ki]); } @@ -732,13 +732,13 @@ class Twofish extends BlockCipher // Generating encrypt code: $encrypt_block = ' $in = unpack("V4", $in); - $R0 = '.$K[0].' ^ $in[1]; - $R1 = '.$K[1].' ^ $in[2]; - $R2 = '.$K[2].' ^ $in[3]; - $R3 = '.$K[3].' ^ $in[4]; + $R0 = ' . $K[0] . ' ^ $in[1]; + $R1 = ' . $K[1] . ' ^ $in[2]; + $R2 = ' . $K[2] . ' ^ $in[3]; + $R3 = ' . $K[3] . ' ^ $in[4]; '; for ($ki = 7, $i = 0; $i < 8; ++$i) { - $encrypt_block.= ' + $encrypt_block .= ' $t0 = $S0[ $R0 & 0xff] ^ $S1[($R0 >> 8) & 0xff] ^ $S2[($R0 >> 16) & 0xff] ^ @@ -764,23 +764,23 @@ class Twofish extends BlockCipher $R1 = ((($R1 >> 31) & 1) | ($R1 << 1)) ^ ' . sprintf($safeint, '($t0 + ($t1 << 1) + ' . $K[++$ki] . ')') . '; '; } - $encrypt_block.= ' - $in = pack("V4", '.$K[4].' ^ $R2, - '.$K[5].' ^ $R3, - '.$K[6].' ^ $R0, - '.$K[7].' ^ $R1); + $encrypt_block .= ' + $in = pack("V4", ' . $K[4] . ' ^ $R2, + ' . $K[5] . ' ^ $R3, + ' . $K[6] . ' ^ $R0, + ' . $K[7] . ' ^ $R1); '; // Generating decrypt code: $decrypt_block = ' $in = unpack("V4", $in); - $R0 = '.$K[4].' ^ $in[1]; - $R1 = '.$K[5].' ^ $in[2]; - $R2 = '.$K[6].' ^ $in[3]; - $R3 = '.$K[7].' ^ $in[4]; + $R0 = ' . $K[4] . ' ^ $in[1]; + $R1 = ' . $K[5] . ' ^ $in[2]; + $R2 = ' . $K[6] . ' ^ $in[3]; + $R3 = ' . $K[7] . ' ^ $in[4]; '; for ($ki = 40, $i = 0; $i < 8; ++$i) { - $decrypt_block.= ' + $decrypt_block .= ' $t0 = $S0[$R0 & 0xff] ^ $S1[$R0 >> 8 & 0xff] ^ $S2[$R0 >> 16 & 0xff] ^ @@ -791,7 +791,7 @@ class Twofish extends BlockCipher $S3[$R1 >> 16 & 0xff]; $R3^= ' . sprintf($safeint, '$t0 + ($t1 << 1) + ' . $K[--$ki]) . '; $R3 = $R3 >> 1 & 0x7fffffff | $R3 << 31; - $R2 = ($R2 >> 31 & 0x1 | $R2 << 1) ^ ' . sprintf($safeint, '($t0 + $t1 + '.$K[--$ki] . ')') . '; + $R2 = ($R2 >> 31 & 0x1 | $R2 << 1) ^ ' . sprintf($safeint, '($t0 + $t1 + ' . $K[--$ki] . ')') . '; $t0 = $S0[$R2 & 0xff] ^ $S1[$R2 >> 8 & 0xff] ^ @@ -803,14 +803,14 @@ class Twofish extends BlockCipher $S3[$R3 >> 16 & 0xff]; $R1^= ' . sprintf($safeint, '$t0 + ($t1 << 1) + ' . $K[--$ki]) . '; $R1 = $R1 >> 1 & 0x7fffffff | $R1 << 31; - $R0 = ($R0 >> 31 & 0x1 | $R0 << 1) ^ ' . sprintf($safeint, '($t0 + $t1 + '.$K[--$ki] . ')') . '; + $R0 = ($R0 >> 31 & 0x1 | $R0 << 1) ^ ' . sprintf($safeint, '($t0 + $t1 + ' . $K[--$ki] . ')') . '; '; } - $decrypt_block.= ' - $in = pack("V4", '.$K[0].' ^ $R2, - '.$K[1].' ^ $R3, - '.$K[2].' ^ $R0, - '.$K[3].' ^ $R1); + $decrypt_block .= ' + $in = pack("V4", ' . $K[0] . ' ^ $R2, + ' . $K[1] . ' ^ $R3, + ' . $K[2] . ' ^ $R0, + ' . $K[3] . ' ^ $R1); '; $this->inline_crypt = $this->createInlineCryptFunction( diff --git a/phpseclib/File/ANSI.php b/phpseclib/File/ANSI.php index 8f459839..fb724577 100644 --- a/phpseclib/File/ANSI.php +++ b/phpseclib/File/ANSI.php @@ -234,7 +234,7 @@ class ANSI $this->tokenization = ['']; for ($i = 0; $i < strlen($source); $i++) { if (strlen($this->ansi)) { - $this->ansi.= $source[$i]; + $this->ansi .= $source[$i]; $chr = ord($source[$i]); // http://en.wikipedia.org/wiki/ANSI_escape_code#Sequence_elements // single character CSI's not currently supported @@ -299,11 +299,11 @@ class ANSI break; case preg_match('#\x1B\[(\d+)C#', $this->ansi, $match): // Move cursor right n lines $this->old_x = $this->x; - $this->x+= $match[1]; + $this->x += $match[1]; break; case preg_match('#\x1B\[(\d+)D#', $this->ansi, $match): // Move cursor left n lines $this->old_x = $this->x; - $this->x-= $match[1]; + $this->x -= $match[1]; if ($this->x < 0) { $this->x = 0; } @@ -376,7 +376,7 @@ class ANSI continue; } - $this->tokenization[count($this->tokenization) - 1].= $source[$i]; + $this->tokenization[count($this->tokenization) - 1] .= $source[$i]; switch ($source[$i]) { case "\r": $this->x = 0; @@ -403,7 +403,7 @@ class ANSI //if (!strlen($this->tokenization[count($this->tokenization) - 1])) { // array_pop($this->tokenization); //} - $this->ansi.= "\x1B"; + $this->ansi .= "\x1B"; break; default: $this->attrs[$this->y][$this->x] = clone $this->attr_cell; @@ -474,7 +474,7 @@ class ANSI $close = $open = ''; if ($last_attr->foreground != $cur_attr->foreground) { if ($cur_attr->foreground != 'white') { - $open.= ''; + $open .= ''; } if ($last_attr->foreground != 'white') { $close = '' . $close; @@ -482,7 +482,7 @@ class ANSI } if ($last_attr->background != $cur_attr->background) { if ($cur_attr->background != 'black') { - $open.= ''; + $open .= ''; } if ($last_attr->background != 'black') { $close = '' . $close; @@ -490,29 +490,29 @@ class ANSI } if ($last_attr->bold != $cur_attr->bold) { if ($cur_attr->bold) { - $open.= ''; + $open .= ''; } else { $close = '' . $close; } } if ($last_attr->underline != $cur_attr->underline) { if ($cur_attr->underline) { - $open.= ''; + $open .= ''; } else { $close = '' . $close; } } if ($last_attr->blink != $cur_attr->blink) { if ($cur_attr->blink) { - $open.= ''; + $open .= ''; } else { $close = '' . $close; } } - $output.= $close . $open; + $output .= $close . $open; } - $output.= htmlspecialchars($char); + $output .= htmlspecialchars($char); return $output; } @@ -530,14 +530,14 @@ class ANSI for ($i = 0; $i <= $this->max_y; $i++) { for ($j = 0; $j <= $this->max_x; $j++) { $cur_attr = $this->attrs[$i][$j]; - $output.= $this->processCoordinate($last_attr, $cur_attr, isset($this->screen[$i][$j]) ? $this->screen[$i][$j] : ''); + $output .= $this->processCoordinate($last_attr, $cur_attr, isset($this->screen[$i][$j]) ? $this->screen[$i][$j] : ''); $last_attr = $this->attrs[$i][$j]; } - $output.= "\r\n"; + $output .= "\r\n"; } $output = substr($output, 0, -2); // close any remaining open tags - $output.= $this->processCoordinate($last_attr, $this->base_attr_cell, ''); + $output .= $this->processCoordinate($last_attr, $this->base_attr_cell, ''); return rtrim($output); } @@ -565,14 +565,14 @@ class ANSI for ($i = 0; $i < count($this->history); $i++) { for ($j = 0; $j <= $this->max_x + 1; $j++) { $cur_attr = $this->history_attrs[$i][$j]; - $scrollback.= $this->processCoordinate($last_attr, $cur_attr, isset($this->history[$i][$j]) ? $this->history[$i][$j] : ''); + $scrollback .= $this->processCoordinate($last_attr, $cur_attr, isset($this->history[$i][$j]) ? $this->history[$i][$j] : ''); $last_attr = $this->history_attrs[$i][$j]; } - $scrollback.= "\r\n"; + $scrollback .= "\r\n"; } $base_attr_cell = $this->base_attr_cell; $this->base_attr_cell = $last_attr; - $scrollback.= $this->getScreen(); + $scrollback .= $this->getScreen(); $this->base_attr_cell = $base_attr_cell; return '
' . $scrollback . '
'; diff --git a/phpseclib/File/ASN1.php b/phpseclib/File/ASN1.php index 426f7780..92e498be 100644 --- a/phpseclib/File/ASN1.php +++ b/phpseclib/File/ASN1.php @@ -187,7 +187,7 @@ abstract class ASN1 * @var array * @access public */ - const STRING_TYPE_SIZE = [ + const STRING_TYPE_SIZE = [ self::TYPE_UTF8_STRING => 0, self::TYPE_BMP_STRING => 2, self::TYPE_UNIVERSAL_STRING => 4, @@ -266,7 +266,7 @@ abstract class ASN1 } while ($loop); } - $start+= $startOffset; + $start += $startOffset; // Length, as discussed in paragraph 8.1.3 of X.690-0207.pdf#page=13 if (!isset($encoded[$encoded_pos])) { @@ -281,16 +281,16 @@ abstract class ASN1 } elseif ($length & 0x80) { // definite length, long form // technically, the long form of the length can be represented by up to 126 octets (bytes), but we'll only // support it up to four. - $length&= 0x7F; + $length &= 0x7F; $temp = substr($encoded, $encoded_pos, $length); $encoded_pos += $length; // tags of indefinte length don't really have a header length; this length includes the tag - $current+= ['headerlength' => $length + 2]; - $start+= $length; + $current += ['headerlength' => $length + 2]; + $start += $length; extract(unpack('Nlength', substr(str_pad($temp, 4, chr(0), STR_PAD_LEFT), -4))); /** @var integer $length */ } else { - $current+= ['headerlength' => 2]; + $current += ['headerlength' => 2]; } if ($length > (strlen($encoded) - $encoded_pos)) { @@ -335,13 +335,13 @@ abstract class ASN1 $length = $temp['length']; // end-of-content octets - see paragraph 8.1.5 if (substr($content, $content_pos + $length, 2) == "\0\0") { - $length+= 2; - $start+= $length; + $length += 2; + $start += $length; $newcontent[] = $temp; break; } - $start+= $length; - $remainingLength-= $length; + $start += $length; + $remainingLength -= $length; $newcontent[] = $temp; $content_pos += $length; } @@ -358,7 +358,7 @@ abstract class ASN1 ] + $current; } - $current+= ['type' => $tag]; + $current += ['type' => $tag]; // decode UNIVERSAL tags switch ($tag) { @@ -389,14 +389,14 @@ abstract class ASN1 if ($temp === false) { return false; } - $length-= (strlen($content) - $content_pos); + $length -= (strlen($content) - $content_pos); $last = count($temp) - 1; for ($i = 0; $i < $last; $i++) { // all subtags should be bit strings if ($temp[$i]['type'] != self::TYPE_BIT_STRING) { return false; } - $current['content'].= substr($temp[$i]['content'], 1); + $current['content'] .= substr($temp[$i]['content'], 1); } // all subtags should be bit strings if ($temp[$last]['type'] != self::TYPE_BIT_STRING) { @@ -421,11 +421,11 @@ abstract class ASN1 if ($temp['type'] != self::TYPE_OCTET_STRING) { return false; } - $current['content'].= $temp['content']; - $length+= $temp['length']; + $current['content'] .= $temp['content']; + $length += $temp['length']; } if (substr($content, $content_pos, 2) == "\0\0") { - $length+= 2; // +2 for the EOC + $length += 2; // +2 for the EOC } } break; @@ -456,7 +456,7 @@ abstract class ASN1 } $content_pos += $temp['length']; $current['content'][] = $temp; - $offset+= $temp['length']; + $offset += $temp['length']; } break; case self::TYPE_OBJECT_IDENTIFIER: @@ -512,7 +512,7 @@ abstract class ASN1 return false; } - $start+= $length; + $start += $length; // ie. length is the length of the full TLV encoding - it's not just the length of the value return $current + ['length' => $start - $current['start']]; @@ -664,7 +664,7 @@ abstract class ASN1 } // Fail mapping if all input items have not been consumed. - return $i < $n ? null: $map; + return $i < $n ? null : $map; // the main diff between sets and sequences is the encapsulation of the foreach in another for loop case self::TYPE_SET: @@ -834,7 +834,7 @@ abstract class ASN1 { $length = ord(Strings::shift($string)); if ($length & 0x80) { // definite length, long form - $length&= 0x7F; + $length &= 0x7F; $temp = Strings::shift($string, $length); list(, $length) = unpack('N', substr(str_pad($temp, 4, chr(0), STR_PAD_LEFT), -4)); } @@ -894,7 +894,7 @@ abstract class ASN1 switch ($tag) { case self::TYPE_SET: // Children order is not important, thus process in sequence. case self::TYPE_SEQUENCE: - $tag|= 0x20; // set the constructed bit + $tag |= 0x20; // set the constructed bit // ignore the min and max if (isset($mapping['min']) && isset($mapping['max'])) { @@ -906,7 +906,7 @@ abstract class ASN1 if ($temp === false) { return false; } - $value[]= $temp; + $value[] = $temp; } /* "The encodings of the component values of a set-of value shall appear in ascending order, the encodings being compared as octet strings with the shorter components being padded at their trailing end with 0-octets. @@ -959,7 +959,7 @@ abstract class ASN1 $temp = $subtag . substr($temp, 1); } } - $value.= $temp; + $value .= $temp; } break; case self::TYPE_CHOICE: @@ -1026,7 +1026,7 @@ abstract class ASN1 case self::TYPE_UTC_TIME: case self::TYPE_GENERALIZED_TIME: $format = $mapping['type'] == self::TYPE_UTC_TIME ? 'y' : 'Y'; - $format.= 'mdHis'; + $format .= 'mdHis'; // if $source does _not_ include timezone information within it then assume that the timezone is GMT $date = new \DateTime($source, new \DateTimeZone('GMT')); // if $source _does_ include timezone information within it then convert the time to GMT @@ -1060,7 +1060,7 @@ abstract class ASN1 $bits = implode('', array_pad($bits, $size + $offset + 1, 0)); $bytes = explode(' ', rtrim(chunk_split($bits, 8, ' '))); foreach ($bytes as $byte) { - $value.= chr(bindec($byte)); + $value .= chr(bindec($byte)); } break; @@ -1255,7 +1255,7 @@ abstract class ASN1 } $temp[strlen($temp) - 1] = $temp[strlen($temp) - 1] & chr(0x7F); } - $value.= $temp; + $value .= $temp; } return $value; @@ -1293,7 +1293,7 @@ abstract class ASN1 $prefix = substr($content, 0, 2) >= 50 ? '19' : '20'; $content = $prefix . $content; } elseif (strpos($content, '.') !== false) { - $format.= '.u'; + $format .= '.u'; } if ($content[strlen($content) - 1] == 'Z') { @@ -1301,7 +1301,7 @@ abstract class ASN1 } if (strpos($content, '-') !== false || strpos($content, '+') !== false) { - $format.= 'O'; + $format .= 'O'; } // error supression isn't necessary as of PHP 7.0: @@ -1333,7 +1333,7 @@ abstract class ASN1 */ public static function loadOIDs($oids) { - self::$reverseOIDs+= $oids; + self::$reverseOIDs += $oids; self::$oids = array_flip(self::$reverseOIDs); } diff --git a/phpseclib/File/ASN1/Maps/Attribute.php b/phpseclib/File/ASN1/Maps/Attribute.php index a80dad31..5e8f2614 100644 --- a/phpseclib/File/ASN1/Maps/Attribute.php +++ b/phpseclib/File/ASN1/Maps/Attribute.php @@ -30,7 +30,7 @@ abstract class Attribute 'type' => ASN1::TYPE_SEQUENCE, 'children' => [ 'type' => AttributeType::MAP, - 'value'=> [ + 'value' => [ 'type' => ASN1::TYPE_SET, 'min' => 1, 'max' => -1, diff --git a/phpseclib/File/ASN1/Maps/AttributeTypeAndValue.php b/phpseclib/File/ASN1/Maps/AttributeTypeAndValue.php index ff4faa07..da825d0b 100644 --- a/phpseclib/File/ASN1/Maps/AttributeTypeAndValue.php +++ b/phpseclib/File/ASN1/Maps/AttributeTypeAndValue.php @@ -30,7 +30,7 @@ abstract class AttributeTypeAndValue 'type' => ASN1::TYPE_SEQUENCE, 'children' => [ 'type' => AttributeType::MAP, - 'value'=> AttributeValue::MAP + 'value' => AttributeValue::MAP ] ]; } diff --git a/phpseclib/File/ASN1/Maps/Characteristic_two.php b/phpseclib/File/ASN1/Maps/Characteristic_two.php index b73e0ba2..2645077b 100644 --- a/phpseclib/File/ASN1/Maps/Characteristic_two.php +++ b/phpseclib/File/ASN1/Maps/Characteristic_two.php @@ -37,4 +37,4 @@ abstract class Characteristic_two ] ] ]; -} \ No newline at end of file +} diff --git a/phpseclib/File/ASN1/Maps/DSAPrivateKey.php b/phpseclib/File/ASN1/Maps/DSAPrivateKey.php index eaec347d..7e61aecf 100644 --- a/phpseclib/File/ASN1/Maps/DSAPrivateKey.php +++ b/phpseclib/File/ASN1/Maps/DSAPrivateKey.php @@ -37,4 +37,4 @@ abstract class DSAPrivateKey 'x' => ['type' => ASN1::TYPE_INTEGER] ] ]; -} \ No newline at end of file +} diff --git a/phpseclib/File/ASN1/Maps/FieldID.php b/phpseclib/File/ASN1/Maps/FieldID.php index 13c6ac49..fe3a6716 100644 --- a/phpseclib/File/ASN1/Maps/FieldID.php +++ b/phpseclib/File/ASN1/Maps/FieldID.php @@ -36,4 +36,4 @@ abstract class FieldID ] ] ]; -} \ No newline at end of file +} diff --git a/phpseclib/File/ASN1/Maps/HashAlgorithm.php b/phpseclib/File/ASN1/Maps/HashAlgorithm.php index 02f587d1..d74ad593 100644 --- a/phpseclib/File/ASN1/Maps/HashAlgorithm.php +++ b/phpseclib/File/ASN1/Maps/HashAlgorithm.php @@ -27,4 +27,4 @@ use phpseclib3\File\ASN1; abstract class HashAlgorithm { const MAP = AlgorithmIdentifier::MAP; -} \ No newline at end of file +} diff --git a/phpseclib/File/ASN1/Maps/IssuingDistributionPoint.php b/phpseclib/File/ASN1/Maps/IssuingDistributionPoint.php index f4b35b38..a3a9c63c 100644 --- a/phpseclib/File/ASN1/Maps/IssuingDistributionPoint.php +++ b/phpseclib/File/ASN1/Maps/IssuingDistributionPoint.php @@ -60,7 +60,7 @@ abstract class IssuingDistributionPoint 'default' => false, 'implicit' => true ], - 'onlyContainsAttributeCerts' =>[ + 'onlyContainsAttributeCerts' => [ 'type' => ASN1::TYPE_BOOLEAN, 'constant' => 5, 'optional' => true, diff --git a/phpseclib/File/ASN1/Maps/MaskGenAlgorithm.php b/phpseclib/File/ASN1/Maps/MaskGenAlgorithm.php index 5e0e26f0..115f1c53 100644 --- a/phpseclib/File/ASN1/Maps/MaskGenAlgorithm.php +++ b/phpseclib/File/ASN1/Maps/MaskGenAlgorithm.php @@ -27,4 +27,4 @@ use phpseclib3\File\ASN1; abstract class MaskGenAlgorithm { const MAP = AlgorithmIdentifier::MAP; -} \ No newline at end of file +} diff --git a/phpseclib/File/ASN1/Maps/OneAsymmetricKey.php b/phpseclib/File/ASN1/Maps/OneAsymmetricKey.php index 9a5c1687..dbc7f839 100644 --- a/phpseclib/File/ASN1/Maps/OneAsymmetricKey.php +++ b/phpseclib/File/ASN1/Maps/OneAsymmetricKey.php @@ -35,7 +35,7 @@ abstract class OneAsymmetricKey 'type' => ASN1::TYPE_INTEGER, 'mapping' => ['v1', 'v2'] ], - 'privateKeyAlgorithm'=> AlgorithmIdentifier::MAP, + 'privateKeyAlgorithm' => AlgorithmIdentifier::MAP, 'privateKey' => PrivateKey::MAP, 'attributes' => [ 'constant' => 0, diff --git a/phpseclib/File/ASN1/Maps/PBES2params.php b/phpseclib/File/ASN1/Maps/PBES2params.php index 1d807db7..13befe91 100644 --- a/phpseclib/File/ASN1/Maps/PBES2params.php +++ b/phpseclib/File/ASN1/Maps/PBES2params.php @@ -31,7 +31,7 @@ abstract class PBES2params const MAP = [ 'type' => ASN1::TYPE_SEQUENCE, 'children' => [ - 'keyDerivationFunc'=> AlgorithmIdentifier::MAP, + 'keyDerivationFunc' => AlgorithmIdentifier::MAP, 'encryptionScheme' => AlgorithmIdentifier::MAP ] ]; diff --git a/phpseclib/File/ASN1/Maps/PBKDF2params.php b/phpseclib/File/ASN1/Maps/PBKDF2params.php index 16d37a95..b6fbbdd3 100644 --- a/phpseclib/File/ASN1/Maps/PBKDF2params.php +++ b/phpseclib/File/ASN1/Maps/PBKDF2params.php @@ -33,8 +33,8 @@ abstract class PBKDF2params 'children' => [ // technically, this is a CHOICE in RFC2898 but the other "choice" is, currently, more of a placeholder // in the RFC - 'salt'=> ['type' => ASN1::TYPE_OCTET_STRING], - 'iterationCount'=> ['type' => ASN1::TYPE_INTEGER], + 'salt' => ['type' => ASN1::TYPE_OCTET_STRING], + 'iterationCount' => ['type' => ASN1::TYPE_INTEGER], 'keyLength' => [ 'type' => ASN1::TYPE_INTEGER, 'optional' => true diff --git a/phpseclib/File/ASN1/Maps/PBMAC1params.php b/phpseclib/File/ASN1/Maps/PBMAC1params.php index f375aa16..2b259671 100644 --- a/phpseclib/File/ASN1/Maps/PBMAC1params.php +++ b/phpseclib/File/ASN1/Maps/PBMAC1params.php @@ -31,8 +31,8 @@ abstract class PBMAC1params const MAP = [ 'type' => ASN1::TYPE_SEQUENCE, 'children' => [ - 'keyDerivationFunc'=> AlgorithmIdentifier::MAP, - 'messageAuthScheme'=> AlgorithmIdentifier::MAP + 'keyDerivationFunc' => AlgorithmIdentifier::MAP, + 'messageAuthScheme' => AlgorithmIdentifier::MAP ] ]; } diff --git a/phpseclib/File/ASN1/Maps/PKCS9String.php b/phpseclib/File/ASN1/Maps/PKCS9String.php index 11c638bd..95d68c4b 100644 --- a/phpseclib/File/ASN1/Maps/PKCS9String.php +++ b/phpseclib/File/ASN1/Maps/PKCS9String.php @@ -1,7 +1,7 @@ * @access public */ -abstract class PKCS9String +abstract class PKCS9String { const MAP = [ 'type' => ASN1::TYPE_CHOICE, diff --git a/phpseclib/File/ASN1/Maps/Pentanomial.php b/phpseclib/File/ASN1/Maps/Pentanomial.php index 493cd299..1af566b8 100644 --- a/phpseclib/File/ASN1/Maps/Pentanomial.php +++ b/phpseclib/File/ASN1/Maps/Pentanomial.php @@ -34,4 +34,4 @@ abstract class Pentanomial 'k3' => ['type' => ASN1::TYPE_INTEGER], // k3 > h2 ] ]; -} \ No newline at end of file +} diff --git a/phpseclib/File/ASN1/Maps/Prime_p.php b/phpseclib/File/ASN1/Maps/Prime_p.php index 09c8006b..4a57c463 100644 --- a/phpseclib/File/ASN1/Maps/Prime_p.php +++ b/phpseclib/File/ASN1/Maps/Prime_p.php @@ -27,4 +27,4 @@ use phpseclib3\File\ASN1; abstract class Prime_p { const MAP = ['type' => ASN1::TYPE_INTEGER]; -} \ No newline at end of file +} diff --git a/phpseclib/File/ASN1/Maps/PrivateKeyInfo.php b/phpseclib/File/ASN1/Maps/PrivateKeyInfo.php index 170f6f27..3b5c8c60 100644 --- a/phpseclib/File/ASN1/Maps/PrivateKeyInfo.php +++ b/phpseclib/File/ASN1/Maps/PrivateKeyInfo.php @@ -33,7 +33,7 @@ abstract class PrivateKeyInfo 'type' => ASN1::TYPE_INTEGER, 'mapping' => ['v1'] ], - 'privateKeyAlgorithm'=> AlgorithmIdentifier::MAP, + 'privateKeyAlgorithm' => AlgorithmIdentifier::MAP, 'privateKey' => PrivateKey::MAP, 'attributes' => [ 'constant' => 0, diff --git a/phpseclib/File/ASN1/Maps/PublicKeyInfo.php b/phpseclib/File/ASN1/Maps/PublicKeyInfo.php index 587230bc..81aea29e 100644 --- a/phpseclib/File/ASN1/Maps/PublicKeyInfo.php +++ b/phpseclib/File/ASN1/Maps/PublicKeyInfo.php @@ -32,7 +32,7 @@ abstract class PublicKeyInfo const MAP = [ 'type' => ASN1::TYPE_SEQUENCE, 'children' => [ - 'publicKeyAlgorithm'=> AlgorithmIdentifier::MAP, + 'publicKeyAlgorithm' => AlgorithmIdentifier::MAP, 'publicKey' => ['type' => ASN1::TYPE_BIT_STRING] ] ]; diff --git a/phpseclib/File/ASN1/Maps/RC2CBCParameter.php b/phpseclib/File/ASN1/Maps/RC2CBCParameter.php index 3697f103..597f02df 100644 --- a/phpseclib/File/ASN1/Maps/RC2CBCParameter.php +++ b/phpseclib/File/ASN1/Maps/RC2CBCParameter.php @@ -31,11 +31,11 @@ abstract class RC2CBCParameter const MAP = [ 'type' => ASN1::TYPE_SEQUENCE, 'children' => [ - 'rc2ParametersVersion'=> [ + 'rc2ParametersVersion' => [ 'type' => ASN1::TYPE_INTEGER, 'optional' => true ], - 'iv'=> ['type' => ASN1::TYPE_OCTET_STRING] + 'iv' => ['type' => ASN1::TYPE_OCTET_STRING] ] ]; } diff --git a/phpseclib/File/ASN1/Maps/Trinomial.php b/phpseclib/File/ASN1/Maps/Trinomial.php index 7cd4ba27..55e7be81 100644 --- a/phpseclib/File/ASN1/Maps/Trinomial.php +++ b/phpseclib/File/ASN1/Maps/Trinomial.php @@ -27,4 +27,4 @@ use phpseclib3\File\ASN1; abstract class Trinomial { const MAP = ['type' => ASN1::TYPE_INTEGER]; -} \ No newline at end of file +} diff --git a/phpseclib/File/X509.php b/phpseclib/File/X509.php index 5423407f..092bc720 100644 --- a/phpseclib/File/X509.php +++ b/phpseclib/File/X509.php @@ -334,7 +334,7 @@ class X509 //'id-ad' => '1.3.6.1.5.5.7.48', 'id-qt-cps' => '1.3.6.1.5.5.7.2.1', 'id-qt-unotice' => '1.3.6.1.5.5.7.2.2', - 'id-ad-ocsp' =>'1.3.6.1.5.5.7.48.1', + 'id-ad-ocsp' => '1.3.6.1.5.5.7.48.1', 'id-ad-caIssuers' => '1.3.6.1.5.5.7.48.2', 'id-ad-timeStamping' => '1.3.6.1.5.5.7.48.3', 'id-ad-caRepository' => '1.3.6.1.5.5.7.48.5', @@ -681,7 +681,7 @@ class X509 if ($value['extnId'] == $id) { $extensions[$key] = $newext; continue 2; - } + } } } $extensions[] = $newext; @@ -1148,7 +1148,7 @@ class X509 $notBefore = new \DateTimeImmutable($notBefore, new \DateTimeZone(@date_default_timezone_get())); $notAfter = new \DateTimeImmutable($notAfter, new \DateTimeZone(@date_default_timezone_get())); - return $date >= $notBefore && $date<= $notAfter; + return $date >= $notBefore && $date <= $notAfter; } /** @@ -1192,7 +1192,7 @@ class X509 if ($temp === false) { return false; } - $data.= $temp; + $data .= $temp; } break; @@ -1694,7 +1694,7 @@ class X509 $this->dn['rdnSequence'][] = [ [ 'type' => $propName, - 'value'=> $v + 'value' => $v ] ]; } @@ -1827,7 +1827,7 @@ class X509 // handles everything else $results = preg_split('#((?:^|, *|/)(?:C=|O=|OU=|CN=|L=|ST=|SN=|postalCode=|streetAddress=|emailAddress=|serialNumber=|organizationalUnitName=|title=|description=|role=|x500UniqueIdentifier=|postalAddress=))#', $dn, -1, PREG_SPLIT_DELIM_CAPTURE); - for ($i = 1; $i < count($results); $i+=2) { + for ($i = 1; $i < count($results); $i += 2) { $prop = trim($results[$i], ', =/'); $value = $results[$i + 1]; if (!$this->setDNProp($prop, $value, $type)) { @@ -1949,7 +1949,7 @@ class X509 } if (!$start) { - $output.= $delim; + $output .= $delim; } if (is_array($value)) { foreach ($value as $type => $v) { @@ -1966,10 +1966,12 @@ class X509 $value = array_pop($value); // Always strip data type. } } elseif (is_object($value) && $value instanceof Element) { - $callback = function($x) { return '\x' . bin2hex($x[0]); }; + $callback = function ($x) { + return '\x' . bin2hex($x[0]); + }; $value = strtoupper(preg_replace_callback('#[^\x20-\x7E]#', $callback, $value->element)); } - $output.= $desc . '=' . $value; + $output .= $desc . '=' . $value; $result[$desc] = isset($result[$desc]) ? array_merge((array) $result[$desc], [$value]) : $value; @@ -3457,7 +3459,7 @@ class X509 * @access public * @return mixed */ - public function getExtension($id, $cert = null, $path=null) + public function getExtension($id, $cert = null, $path = null) { return $this->getExtensionHelper($id, $cert, $path); } @@ -3656,7 +3658,7 @@ class X509 $attributes[$last]['value'][] = $value; break; default: - $attributes[] = ['type' => $id, 'value' => $disposition == self::ATTR_ALL ? $value: [$value]]; + $attributes[] = ['type' => $id, 'value' => $disposition == self::ATTR_ALL ? $value : [$value]]; break; } @@ -4004,7 +4006,7 @@ class X509 if (is_array($rclist = $this->subArray($crl, 'tbsCertList/revokedCertificates'))) { if (($i = $this->revokedCertificate($rclist, $serial)) !== false) { - return $this->getExtension($id, $crl, "tbsCertList/revokedCertificates/$i/crlEntryExtensions"); + return $this->getExtension($id, $crl, "tbsCertList/revokedCertificates/$i/crlEntryExtensions"); } } diff --git a/phpseclib/Math/BigInteger.php b/phpseclib/Math/BigInteger.php index 6bc11261..68cdec6b 100644 --- a/phpseclib/Math/BigInteger.php +++ b/phpseclib/Math/BigInteger.php @@ -204,7 +204,7 @@ class BigInteger */ public function __toString() { - return (string) $this->value; + return (string)$this->value; } /** @@ -248,7 +248,7 @@ class BigInteger * @param bool $twos_compliment * @return string */ - function toBits($twos_compliment = false) + public function toBits($twos_compliment = false) { return $this->value->toBits($twos_compliment); } @@ -270,7 +270,7 @@ class BigInteger * @param BigInteger $y * @return BigInteger */ - function subtract(BigInteger $y) + public function subtract(BigInteger $y) { return new static($this->value->subtract($y->value)); } @@ -324,8 +324,9 @@ class BigInteger * Calculates modular inverses. * * Say you have (30 mod 17 * x mod 17) mod 17 == 1. x can be found using modular inverses. - * @return BigInteger + * * @param BigInteger $n + * @return BigInteger */ public function modInverse(BigInteger $n) { @@ -336,8 +337,9 @@ class BigInteger * Calculates modular inverses. * * Say you have (30 mod 17 * x mod 17) mod 17 == 1. x can be found using modular inverses. - * @return BigInteger[] + * * @param BigInteger $n + * @return BigInteger[] */ public function extendedGCD(BigInteger $n) { @@ -375,7 +377,7 @@ class BigInteger */ public function abs() { - return new static($this->value->abs()); + return new static($this->value->abs()); } /** @@ -470,8 +472,8 @@ class BigInteger /** * Compares two numbers. * - * Although one might think !$x->compare($y) means $x != $y, it, in fact, means the opposite. The reason for this is - * demonstrated thusly: + * Although one might think !$x->compare($y) means $x != $y, it, in fact, means the opposite. The reason for this + * is demonstrated thusly: * * $x > $y: $x->compare($y) > 0 * $x < $y: $x->compare($y) < 0 @@ -612,7 +614,7 @@ class BigInteger $class = self::$mainEngine; extract($class::minMaxBits($bits)); /** @var BigInteger $min - * @var BigInteger $max + * @var BigInteger $max */ return [ 'min' => new static($min), @@ -754,7 +756,9 @@ class BigInteger public static function min(BigInteger ...$nums) { $class = self::$mainEngine; - $nums = array_map(function($num) { return $num->value; }, $nums); + $nums = array_map(function ($num) { + return $num->value; + }, $nums); return new static($class::min(...$nums)); } @@ -767,7 +771,9 @@ class BigInteger public static function max(BigInteger ...$nums) { $class = self::$mainEngine; - $nums = array_map(function($num) { return $num->value; }, $nums); + $nums = array_map(function ($num) { + return $num->value; + }, $nums); return new static($class::max(...$nums)); } @@ -859,7 +865,7 @@ class BigInteger public function createRecurringModuloFunction() { $func = $this->value->createRecurringModuloFunction(); - return function(BigInteger $x) use ($func) { + return function (BigInteger $x) use ($func) { return new static($func($x->value)); }; } @@ -874,7 +880,7 @@ class BigInteger */ public function bitwise_split($split) { - return array_map(function($val) { + return array_map(function ($val) { return new static($val); }, $this->value->bitwise_split($split)); } diff --git a/phpseclib/Math/BigInteger/Engines/BCMath.php b/phpseclib/Math/BigInteger/Engines/BCMath.php index 0c592b3d..01e1c1c0 100644 --- a/phpseclib/Math/BigInteger/Engines/BCMath.php +++ b/phpseclib/Math/BigInteger/Engines/BCMath.php @@ -89,8 +89,8 @@ class BCMath extends Engine /** * Test for engine validity * - * @see parent::__construct() * @return bool + * @see parent::__construct() */ public static function isValidEngine() { @@ -102,8 +102,8 @@ class BCMath extends Engine * * @param mixed $x integer Base-10 number or base-$base number if $base set. * @param int $base - * @see parent::__construct() * @return \phpseclib3\Math\BigInteger\Engines\BCMath + * @see parent::__construct() */ public function __construct($x = 0, $base = 10) { @@ -135,9 +135,15 @@ class BCMath extends Engine $x = str_pad($this->value, $len, chr(0), STR_PAD_LEFT); $this->value = '0'; - for ($i = 0; $i < $len; $i+= 4) { + for ($i = 0; $i < $len; $i += 4) { $this->value = bcmul($this->value, '4294967296', 0); // 4294967296 == 2**32 - $this->value = bcadd($this->value, 0x1000000 * ord($x[$i]) + ((ord($x[$i + 1]) << 16) | (ord($x[$i + 2]) << 8) | ord($x[$i + 3])), 0); + $this->value = bcadd( + $this->value, + 0x1000000 * ord($x[$i]) + ((ord($x[$i + 1]) << 16) | (ord( + $x[$i + 2] + ) << 8) | ord($x[$i + 3])), + 0 + ); } if ($this->is_negative) { @@ -153,7 +159,7 @@ class BCMath extends Engine case 10: // explicitly casting $x to a string is necessary, here, since doing $x[0] on -1 yields different // results then doing it on '-1' does (modInverse does $x[0]) - $this->value = $this->value === '-' ? '0' : (string) $this->value; + $this->value = $this->value === '-' ? '0' : (string)$this->value; } } @@ -177,7 +183,7 @@ class BCMath extends Engine * @param bool $twos_compliment * @return string */ - function toBytes($twos_compliment = false) + public function toBytes($twos_compliment = false) { if ($twos_compliment) { return $this->toBytesHelper(); @@ -274,8 +280,8 @@ class BCMath extends Engine * * Say you have (30 mod 17 * x mod 17) mod 17 == 1. x can be found using modular inverses. * - * @return false|BCMath * @param \phpseclib3\Math\BigInteger\Engines\BCMath $n + * @return false|BCMath */ public function modInverse(BCMath $n) { @@ -325,8 +331,8 @@ class BCMath extends Engine return [ 'gcd' => $this->normalize(new static($u)), - 'x' => $this->normalize(new static($a)), - 'y' => $this->normalize(new static($b)) + 'x' => $this->normalize(new static($a)), + 'y' => $this->normalize(new static($b)) ]; } @@ -428,8 +434,8 @@ class BCMath extends Engine /** * Compares two numbers. * - * Although one might think !$x->compare($y) means $x != $y, it, in fact, means the opposite. The reason for this is - * demonstrated thusly: + * Although one might think !$x->compare($y) means $x != $y, it, in fact, means the opposite. The reason for this + * is demonstrated thusly: * * $x > $y: $x->compare($y) > 0 * $x < $y: $x->compare($y) < 0 @@ -604,9 +610,9 @@ class BCMath extends Engine * * ie. $s = gmp_scan1($n, 0) and $r = gmp_div_q($n, gmp_pow(gmp_init('2'), $s)); * - * @see self::isPrime() * @param BCMath $r * @return int + * @see self::isPrime() */ public static function scan1divide(BCMath $r) { @@ -672,8 +678,8 @@ class BCMath extends Engine /** * Set Bitmask * - * @return Engine * @param int $bits + * @return Engine * @see self::setPrecision() */ protected static function setBitmask($bits) diff --git a/phpseclib/Math/BigInteger/Engines/BCMath/Base.php b/phpseclib/Math/BigInteger/Engines/BCMath/Base.php index 0e189b70..1f7cdf53 100644 --- a/phpseclib/Math/BigInteger/Engines/BCMath/Base.php +++ b/phpseclib/Math/BigInteger/Engines/BCMath/Base.php @@ -113,4 +113,4 @@ abstract class Base extends BCMath { return static::reduce(bcmul($x, $x), $n); } -} \ No newline at end of file +} diff --git a/phpseclib/Math/BigInteger/Engines/BCMath/BuiltIn.php b/phpseclib/Math/BigInteger/Engines/BCMath/BuiltIn.php index f312be15..cda5e934 100644 --- a/phpseclib/Math/BigInteger/Engines/BCMath/BuiltIn.php +++ b/phpseclib/Math/BigInteger/Engines/BCMath/BuiltIn.php @@ -41,4 +41,4 @@ abstract class BuiltIn extends BCMath return $x->normalize($temp); } -} \ No newline at end of file +} diff --git a/phpseclib/Math/BigInteger/Engines/BCMath/DefaultEngine.php b/phpseclib/Math/BigInteger/Engines/BCMath/DefaultEngine.php index a6d175f5..0872da76 100644 --- a/phpseclib/Math/BigInteger/Engines/BCMath/DefaultEngine.php +++ b/phpseclib/Math/BigInteger/Engines/BCMath/DefaultEngine.php @@ -26,4 +26,4 @@ use phpseclib3\Math\BigInteger\Engines\BCMath\Reductions\Barrett; */ abstract class DefaultEngine extends Barrett { -} \ No newline at end of file +} diff --git a/phpseclib/Math/BigInteger/Engines/BCMath/OpenSSL.php b/phpseclib/Math/BigInteger/Engines/BCMath/OpenSSL.php index df7c965d..093a605d 100644 --- a/phpseclib/Math/BigInteger/Engines/BCMath/OpenSSL.php +++ b/phpseclib/Math/BigInteger/Engines/BCMath/OpenSSL.php @@ -26,4 +26,4 @@ use phpseclib3\Math\BigInteger\Engines\OpenSSL as Progenitor; */ abstract class OpenSSL extends Progenitor { -} \ No newline at end of file +} diff --git a/phpseclib/Math/BigInteger/Engines/BCMath/Reductions/Barrett.php b/phpseclib/Math/BigInteger/Engines/BCMath/Reductions/Barrett.php index 2d8f6783..31d8272c 100644 --- a/phpseclib/Math/BigInteger/Engines/BCMath/Reductions/Barrett.php +++ b/phpseclib/Math/BigInteger/Engines/BCMath/Reductions/Barrett.php @@ -92,7 +92,7 @@ abstract class Barrett extends Base $cache[self::DATA][] = [ 'u' => $u, // m.length >> 1 (technically (m.length >> 1) + 1) - 'm1'=> $m1 // m.length + 'm1' => $m1 // m.length ]; } else { extract($cache[self::DATA][$key]); diff --git a/phpseclib/Math/BigInteger/Engines/BCMath/Reductions/EvalBarrett.php b/phpseclib/Math/BigInteger/Engines/BCMath/Reductions/EvalBarrett.php index 80acbdb5..d65e6d94 100644 --- a/phpseclib/Math/BigInteger/Engines/BCMath/Reductions/EvalBarrett.php +++ b/phpseclib/Math/BigInteger/Engines/BCMath/Reductions/EvalBarrett.php @@ -76,9 +76,9 @@ abstract class EvalBarrett extends Base $m = "'$m'"; $u = "'$u'"; - $m1= "'$m1'"; + $m1 = "'$m1'"; - $code.= ' + $code .= ' $lsd = substr($n, -' . $cutoff . '); $msd = substr($n, 0, -' . $cutoff . '); @@ -109,4 +109,4 @@ abstract class EvalBarrett extends Base return $func; } -} \ No newline at end of file +} diff --git a/phpseclib/Math/BigInteger/Engines/Engine.php b/phpseclib/Math/BigInteger/Engines/Engine.php index 717a48cc..edcc5ecb 100644 --- a/phpseclib/Math/BigInteger/Engines/Engine.php +++ b/phpseclib/Math/BigInteger/Engines/Engine.php @@ -109,7 +109,7 @@ abstract class Engine switch ($base) { case -256: - case 256: + case 256: if ($base == -256 && (ord($x[0]) & 0x80)) { $this->value = ~$x; $this->is_negative = true; @@ -126,7 +126,7 @@ abstract class Engine } break; case -16: - case 16: + case 16: if ($base > 0 && $x[0] == '-') { $this->is_negative = true; $x = substr($x, 1); @@ -149,7 +149,7 @@ abstract class Engine } break; case -10: - case 10: + case 10: // (? 0 && $x[0] == '-') { $this->is_negative = true; $x = substr($x, 1); @@ -494,9 +494,9 @@ abstract class Engine } if ($shift < 0) { - $shift+= $precision; + $shift += $precision; } - $shift%= $precision; + $shift %= $precision; if (!$shift) { return clone $this; @@ -1132,7 +1132,7 @@ abstract class Engine } return [ - 'gcd'=> $u, + 'gcd' => $u, 'x' => $a, 'y' => $b ]; diff --git a/phpseclib/Math/BigInteger/Engines/GMP.php b/phpseclib/Math/BigInteger/Engines/GMP.php index cf848305..0e4f37f4 100644 --- a/phpseclib/Math/BigInteger/Engines/GMP.php +++ b/phpseclib/Math/BigInteger/Engines/GMP.php @@ -90,8 +90,8 @@ class GMP extends Engine /** * Test for engine validity * - * @see parent::__construct() * @return bool + * @see parent::__construct() */ public static function isValidEngine() { @@ -103,8 +103,8 @@ class GMP extends Engine * * @param mixed $x integer Base-10 number or base-$base number if $base set. * @param int $base - * @see parent::__construct() * @return \phpseclib3\Math\BigInteger\Engines\GMP + * @see parent::__construct() */ public function __construct($x = 0, $base = 10) { @@ -156,7 +156,7 @@ class GMP extends Engine */ public function toString() { - return (string) $this->value; + return (string)$this->value; } /** @@ -191,7 +191,7 @@ class GMP extends Engine * @param bool $twos_compliment * @return string */ - function toBytes($twos_compliment = false) + public function toBytes($twos_compliment = false) { if ($twos_compliment) { return $this->toBytesHelper(); @@ -278,8 +278,8 @@ class GMP extends Engine /** * Compares two numbers. * - * Although one might think !$x->compare($y) means $x != $y, it, in fact, means the opposite. The reason for this is - * demonstrated thusly: + * Although one might think !$x->compare($y) means $x != $y, it, in fact, means the opposite. The reason for this + * is demonstrated thusly: * * $x > $y: $x->compare($y) > 0 * $x < $y: $x->compare($y) < 0 @@ -352,8 +352,8 @@ class GMP extends Engine return [ 'gcd' => $this->normalize(new self($g)), - 'x' => $this->normalize(new self($s)), - 'y' => $this->normalize(new self($t)) + 'x' => $this->normalize(new self($s)), + 'y' => $this->normalize(new self($t)) ]; } @@ -680,7 +680,7 @@ class GMP extends Engine public function createRecurringModuloFunction() { $temp = $this->value; - return function(GMP $x) use ($temp) { + return function (GMP $x) use ($temp) { return new GMP($x->value % $temp); }; } @@ -744,4 +744,4 @@ class GMP extends Engine return $temp; } -} \ No newline at end of file +} diff --git a/phpseclib/Math/BigInteger/Engines/GMP/DefaultEngine.php b/phpseclib/Math/BigInteger/Engines/GMP/DefaultEngine.php index 9889271e..860a1837 100644 --- a/phpseclib/Math/BigInteger/Engines/GMP/DefaultEngine.php +++ b/phpseclib/Math/BigInteger/Engines/GMP/DefaultEngine.php @@ -41,4 +41,4 @@ abstract class DefaultEngine extends GMP return $x->normalize($temp); } -} \ No newline at end of file +} diff --git a/phpseclib/Math/BigInteger/Engines/OpenSSL.php b/phpseclib/Math/BigInteger/Engines/OpenSSL.php index 6109def7..25468e54 100644 --- a/phpseclib/Math/BigInteger/Engines/OpenSSL.php +++ b/phpseclib/Math/BigInteger/Engines/OpenSSL.php @@ -69,4 +69,4 @@ abstract class OpenSSL $class = get_class($x); return new $class($result, 256); } -} \ No newline at end of file +} diff --git a/phpseclib/Math/BigInteger/Engines/PHP.php b/phpseclib/Math/BigInteger/Engines/PHP.php index 599f967a..09560d1b 100644 --- a/phpseclib/Math/BigInteger/Engines/PHP.php +++ b/phpseclib/Math/BigInteger/Engines/PHP.php @@ -34,7 +34,7 @@ abstract class PHP extends Engine * multiply() or whatever, we'll just work directly on arrays, taking them in as parameters and returning them. * * @access protected - */ + */ /** * $result[self::VALUE] contains the value. */ @@ -76,8 +76,8 @@ abstract class PHP extends Engine * * @param mixed $x integer Base-10 number or base-$base number if $base set. * @param int $base - * @see parent::__construct() * @return \phpseclib3\Math\BigInteger\Engines\PHP + * @see parent::__construct() */ public function __construct($x = 0, $base = 10) { @@ -119,7 +119,12 @@ abstract class PHP extends Engine $x = substr($x, 1); } - $x = str_pad($x, strlen($x) + ((static::MAX10LEN - 1) * strlen($x)) % static::MAX10LEN, 0, STR_PAD_LEFT); + $x = str_pad( + $x, + strlen($x) + ((static::MAX10LEN - 1) * strlen($x)) % static::MAX10LEN, + 0, + STR_PAD_LEFT + ); while (strlen($x)) { $temp = $temp->multiply($multiplier); $temp = $temp->add(new static($this->int2bytes(substr($x, 0, static::MAX10LEN)), 256)); @@ -165,7 +170,12 @@ abstract class PHP extends Engine $result = ''; while (count($temp->value)) { list($temp, $mod) = $temp->divide($divisor); - $result = str_pad(isset($mod->value[0]) ? $mod->value[0] : '', static::MAX10LEN, '0', STR_PAD_LEFT) . $result; + $result = str_pad( + isset($mod->value[0]) ? $mod->value[0] : '', + static::MAX10LEN, + '0', + STR_PAD_LEFT + ) . $result; } $result = ltrim($result, '0'); if (empty($result)) { @@ -199,7 +209,12 @@ abstract class PHP extends Engine $result = implode('', array_map('chr', $result)); return $this->precision > 0 ? - str_pad(substr($result, -(($this->precision + 7) >> 3)), ($this->precision + 7) >> 3, chr(0), STR_PAD_LEFT) : + str_pad( + substr($result, -(($this->precision + 7) >> 3)), + ($this->precision + 7) >> 3, + chr(0), + STR_PAD_LEFT + ) : $result; } @@ -240,7 +255,7 @@ abstract class PHP extends Engine $temp = self::subtractHelper($x_value, false, $y_value, false); $temp[self::SIGN] = self::compareHelper($x_value, false, $y_value, false) > 0 ? - $x_negative : $y_negative; + $x_negative : $y_negative; return $temp; } @@ -256,7 +271,7 @@ abstract class PHP extends Engine $value[count($value)] = 0; // just in case the carry adds an extra digit $carry = 0; - for ($i = 0, $j = 1; $j < $size; $i+=2, $j+=2) { + for ($i = 0, $j = 1; $j < $size; $i += 2, $j += 2) { //$sum = $x_value[$j] * static::BASE_FULL + $x_value[$i] + $y_value[$j] * static::BASE_FULL + $y_value[$i] + $carry; $sum = ($x_value[$j] + $y_value[$j]) * static::BASE_FULL + $x_value[$i] + $y_value[$i] + $carry; $carry = $sum >= static::MAX_DIGIT2; // eg. floor($sum / 2**52); only possible values (in any base) are 0 and 1 @@ -264,7 +279,7 @@ abstract class PHP extends Engine $temp = static::BASE === 26 ? intval($sum / 0x4000000) : ($sum >> 31); - $value[$i] = (int) ($sum - static::BASE_FULL * $temp); // eg. a faster alternative to fmod($sum, 0x4000000) + $value[$i] = (int)($sum - static::BASE_FULL * $temp); // eg. a faster alternative to fmod($sum, 0x4000000) $value[$j] = $temp; } @@ -297,7 +312,7 @@ abstract class PHP extends Engine * @param bool $y_negative * @return array */ - static function subtractHelper(array $x_value, $x_negative, array $y_value, $y_negative) + public static function subtractHelper(array $x_value, $x_negative, array $y_value, $y_negative) { $x_size = count($x_value); $y_size = count($y_value); @@ -346,7 +361,7 @@ abstract class PHP extends Engine // at this point, $x_value should be at least as big as - if not bigger than - $y_value $carry = 0; - for ($i = 0, $j = 1; $j < $y_size; $i+=2, $j+=2) { + for ($i = 0, $j = 1; $j < $y_size; $i += 2, $j += 2) { $sum = ($x_value[$j] - $y_value[$j]) * static::BASE_FULL + $x_value[$i] - $y_value[$i] - $carry; $carry = $sum < 0; // eg. floor($sum / 2**52); only possible values (in any base) are 0 and 1 @@ -354,7 +369,7 @@ abstract class PHP extends Engine $temp = static::BASE === 26 ? intval($sum / 0x4000000) : ($sum >> 31); - $x_value[$i] = (int) ($sum - static::BASE_FULL * $temp); + $x_value[$i] = (int)($sum - static::BASE_FULL * $temp); $x_value[$j] = $temp; } @@ -485,7 +500,7 @@ abstract class PHP extends Engine for ($j = 0; $j < $x_length; ++$j) { // ie. $i = 0 $temp = $x_value[$j] * $y_value[0] + $carry; // $product_value[$k] == 0 $carry = static::BASE === 26 ? intval($temp / 0x4000000) : ($temp >> 31); - $product_value[$j] = (int) ($temp - static::BASE_FULL * $carry); + $product_value[$j] = (int)($temp - static::BASE_FULL * $carry); } $product_value[$j] = $carry; @@ -498,7 +513,7 @@ abstract class PHP extends Engine for ($j = 0, $k = $i; $j < $x_length; ++$j, ++$k) { $temp = $product_value[$k] + $x_value[$j] * $y_value[$i] + $carry; $carry = static::BASE === 26 ? intval($temp / 0x4000000) : ($temp >> 31); - $product_value[$k] = (int) ($temp - static::BASE_FULL * $carry); + $product_value[$k] = (int)($temp - static::BASE_FULL * $carry); } $product_value[$k] = $carry; @@ -517,7 +532,8 @@ abstract class PHP extends Engine * * @param \phpseclib3\Math\BigInteger\engines\PHP $y * @return array - * @internal This function is based off of {@link http://www.cacr.math.uwaterloo.ca/hac/about/chap14.pdf#page=9 HAC 14.20}. + * @internal This function is based off of + * {@link http://www.cacr.math.uwaterloo.ca/hac/about/chap14.pdf#page=9 HAC 14.20}. */ protected function divideHelper(PHP $y) { @@ -575,13 +591,13 @@ abstract class PHP extends Engine static $temp, $lhs, $rhs; if (!isset($temp)) { $temp = new static(); - $lhs = new static(); - $rhs = new static(); + $lhs = new static(); + $rhs = new static(); } - if (static::class != get_class($temp)) { + if (static::class != get_class($temp)) { $temp = new static(); - $lhs = new static(); - $rhs = new static(); + $lhs = new static(); + $rhs = new static(); } $temp_value = &$temp->value; $rhs_value = &$rhs->value; @@ -683,7 +699,7 @@ abstract class PHP extends Engine for ($i = count($dividend) - 1; $i >= 0; --$i) { $temp = static::BASE_FULL * $carry + $dividend[$i]; $result[$i] = self::safe_divide($temp, $divisor); - $carry = (int) ($temp - $divisor * $result[$i]); + $carry = (int)($temp - $divisor * $result[$i]); } return [$result, $carry]; @@ -704,7 +720,7 @@ abstract class PHP extends Engine private static function safe_divide($x, $y) { if (static::BASE === 26) { - return (int) ($x / $y); + return (int)($x / $y); } // static::BASE === 31 @@ -886,7 +902,7 @@ abstract class PHP extends Engine * @return array */ protected static function array_repeat($input, $multiplier) - { + { return $multiplier ? array_fill(0, $multiplier, $input) : []; } @@ -903,7 +919,7 @@ abstract class PHP extends Engine return; } - $num_digits = (int) ($shift / static::BASE); + $num_digits = (int)($shift / static::BASE); $shift %= static::BASE; $shift = 1 << $shift; @@ -912,7 +928,7 @@ abstract class PHP extends Engine for ($i = 0; $i < count($this->value); ++$i) { $temp = $this->value[$i] * $shift + $carry; $carry = static::BASE === 26 ? intval($temp / 0x4000000) : ($temp >> 31); - $this->value[$i] = (int) ($temp - $carry * static::BASE_FULL); + $this->value[$i] = (int)($temp - $carry * static::BASE_FULL); } if ($carry) { @@ -937,7 +953,7 @@ abstract class PHP extends Engine return; } - $num_digits = (int) ($shift / static::BASE); + $num_digits = (int)($shift / static::BASE); $shift %= static::BASE; $carry_shift = static::BASE - $shift; $carry_mask = (1 << $shift) - 1; @@ -1009,13 +1025,13 @@ abstract class PHP extends Engine $temp = $square_value[$i2] + $value[$i] * $value[$i]; $carry = static::BASE === 26 ? intval($temp / 0x4000000) : ($temp >> 31); - $square_value[$i2] = (int) ($temp - static::BASE_FULL * $carry); + $square_value[$i2] = (int)($temp - static::BASE_FULL * $carry); // note how we start from $i+1 instead of 0 as we do in multiplication. for ($j = $i + 1, $k = $i2 + 1; $j <= $max_index; ++$j, ++$k) { $temp = $square_value[$k] + 2 * $value[$j] * $value[$i] + $carry; $carry = static::BASE === 26 ? intval($temp / 0x4000000) : ($temp >> 31); - $square_value[$k] = (int) ($temp - static::BASE_FULL * $carry); + $square_value[$k] = (int)($temp - static::BASE_FULL * $carry); } // the following line can yield values larger 2**15. at this point, PHP should switch @@ -1108,9 +1124,9 @@ abstract class PHP extends Engine * * ie. $s = gmp_scan1($n, 0) and $r = gmp_div_q($n, gmp_pow(gmp_init('2'), $s)); * - * @see self::isPrime() * @param PHP $r * @return int + * @see self::isPrime() */ public static function scan1divide(PHP $r) { @@ -1156,7 +1172,7 @@ abstract class PHP extends Engine */ public function isOdd() { - return (bool) ($this->value[0] & 1); + return (bool)($this->value[0] & 1); } /** @@ -1173,7 +1189,7 @@ abstract class PHP extends Engine return false; } - return (bool) ($this->value[$digit] & (1 << $bit)); + return (bool)($this->value[$digit] & (1 << $bit)); } /** @@ -1215,7 +1231,7 @@ abstract class PHP extends Engine throw new \RuntimeException('Offset must be greater than 1'); } - $width = (int) ($split / static::BASE); + $width = (int)($split / static::BASE); if (!$width) { $arr = $this->bitwise_small_split($split); return array_map(function ($digit) { @@ -1234,7 +1250,7 @@ abstract class PHP extends Engine $digit = []; if (!$overflow) { $digit = array_slice($val, $i, $width); - $i+= $width; + $i += $width; $overflow = $split % static::BASE; if ($overflow) { $mask = (1 << $overflow) - 1; @@ -1244,9 +1260,9 @@ abstract class PHP extends Engine } else { $remaining = static::BASE - $overflow; $tempsplit = $split - $remaining; - $tempwidth = (int) ($tempsplit / static::BASE + 1); + $tempwidth = (int)($tempsplit / static::BASE + 1); $digit = array_slice($val, $i, $tempwidth); - $i+= $tempwidth; + $i += $tempwidth; $tempoverflow = $tempsplit % static::BASE; if ($tempoverflow) { $tempmask = (1 << $tempoverflow) - 1; @@ -1289,9 +1305,9 @@ abstract class PHP extends Engine $remaining = static::BASE; while ($i != $len) { $digit = $val[$i] & $mask; - $val[$i]>>= $split; + $val[$i] >>= $split; if (!$overflow) { - $remaining-= $split; + $remaining -= $split; $overflow = $split <= $remaining ? 0 : $split - $remaining; if (!$remaining) { @@ -1299,10 +1315,10 @@ abstract class PHP extends Engine $remaining = static::BASE; $overflow = 0; } - } else if (++$i != $len) { + } elseif (++$i != $len) { $tempmask = (1 << $overflow) - 1; - $digit|= ($val[$i] & $tempmask) << $remaining; - $val[$i]>>= $overflow; + $digit |= ($val[$i] & $tempmask) << $remaining; + $val[$i] >>= $overflow; $remaining = static::BASE - $overflow; $overflow = $split <= $remaining ? 0 : $split - $remaining; } @@ -1316,4 +1332,4 @@ abstract class PHP extends Engine return array_reverse($vals); } -} \ No newline at end of file +} diff --git a/phpseclib/Math/BigInteger/Engines/PHP/Base.php b/phpseclib/Math/BigInteger/Engines/PHP/Base.php index fb781c94..cec7337b 100644 --- a/phpseclib/Math/BigInteger/Engines/PHP/Base.php +++ b/phpseclib/Math/BigInteger/Engines/PHP/Base.php @@ -94,7 +94,7 @@ abstract class Base extends PHP } if ($e->value == [2]) { - $temp = new $class; + $temp = new $class(); $temp->value = $class::square($x->value); list(, $temp) = $temp->divide($n); return $x->normalize($temp); @@ -146,4 +146,4 @@ abstract class Base extends PHP { return static::reduce($class::square($x), $n, $class); } -} \ No newline at end of file +} diff --git a/phpseclib/Math/BigInteger/Engines/PHP/DefaultEngine.php b/phpseclib/Math/BigInteger/Engines/PHP/DefaultEngine.php index 138deb1f..bf5934a7 100644 --- a/phpseclib/Math/BigInteger/Engines/PHP/DefaultEngine.php +++ b/phpseclib/Math/BigInteger/Engines/PHP/DefaultEngine.php @@ -26,4 +26,4 @@ use phpseclib3\Math\BigInteger\Engines\PHP\Reductions\EvalBarrett; */ abstract class DefaultEngine extends EvalBarrett { -} \ No newline at end of file +} diff --git a/phpseclib/Math/BigInteger/Engines/PHP/Montgomery.php b/phpseclib/Math/BigInteger/Engines/PHP/Montgomery.php index 5bee6d02..58334cc8 100644 --- a/phpseclib/Math/BigInteger/Engines/PHP/Montgomery.php +++ b/phpseclib/Math/BigInteger/Engines/PHP/Montgomery.php @@ -60,7 +60,7 @@ abstract class Montgomery extends Base if ($n->value[$i]) { $temp = decbin($n->value[$i]); $j = strlen($temp) - strrpos($temp, '1') - 1; - $j+= $class::BASE * $i; + $j += $class::BASE * $i; break; } } @@ -89,4 +89,4 @@ abstract class Montgomery extends Base return $result; } -} \ No newline at end of file +} diff --git a/phpseclib/Math/BigInteger/Engines/PHP/OpenSSL.php b/phpseclib/Math/BigInteger/Engines/PHP/OpenSSL.php index 1b7b5b40..4e0315eb 100644 --- a/phpseclib/Math/BigInteger/Engines/PHP/OpenSSL.php +++ b/phpseclib/Math/BigInteger/Engines/PHP/OpenSSL.php @@ -26,4 +26,4 @@ use phpseclib3\Math\BigInteger\Engines\OpenSSL as Progenitor; */ abstract class OpenSSL extends Progenitor { -} \ No newline at end of file +} diff --git a/phpseclib/Math/BigInteger/Engines/PHP/Reductions/Barrett.php b/phpseclib/Math/BigInteger/Engines/PHP/Reductions/Barrett.php index 03e0f8aa..e262adb2 100644 --- a/phpseclib/Math/BigInteger/Engines/PHP/Reductions/Barrett.php +++ b/phpseclib/Math/BigInteger/Engines/PHP/Reductions/Barrett.php @@ -91,7 +91,7 @@ abstract class Barrett extends Base $cache[self::DATA][] = [ 'u' => $u, // m.length >> 1 (technically (m.length >> 1) + 1) - 'm1'=> $m1 // m.length + 'm1' => $m1 // m.length ]; } else { extract($cache[self::DATA][$key]); @@ -281,4 +281,4 @@ abstract class Barrett extends Base self::SIGN => $x_negative != $y_negative ]; } -} \ No newline at end of file +} diff --git a/phpseclib/Math/BigInteger/Engines/PHP/Reductions/Classic.php b/phpseclib/Math/BigInteger/Engines/PHP/Reductions/Classic.php index aef167de..95309fca 100644 --- a/phpseclib/Math/BigInteger/Engines/PHP/Reductions/Classic.php +++ b/phpseclib/Math/BigInteger/Engines/PHP/Reductions/Classic.php @@ -43,4 +43,4 @@ abstract class Classic extends Base list(, $temp) = $lhs->divide($rhs); return $temp->value; } -} \ No newline at end of file +} diff --git a/phpseclib/Math/BigInteger/Engines/PHP/Reductions/EvalBarrett.php b/phpseclib/Math/BigInteger/Engines/PHP/Reductions/EvalBarrett.php index 84f21708..e45a261e 100644 --- a/phpseclib/Math/BigInteger/Engines/PHP/Reductions/EvalBarrett.php +++ b/phpseclib/Math/BigInteger/Engines/PHP/Reductions/EvalBarrett.php @@ -117,19 +117,19 @@ abstract class EvalBarrett extends Base $lsd = array_slice($n, 0, ' . $cutoff . '); $msd = array_slice($n, ' . $cutoff . ');'; - $code.= self::generateInlineTrim('msd'); - $code.= self::generateInlineMultiply('msd', $m1, 'temp', $class); - $code.= self::generateInlineAdd('lsd', 'temp', 'n', $class); + $code .= self::generateInlineTrim('msd'); + $code .= self::generateInlineMultiply('msd', $m1, 'temp', $class); + $code .= self::generateInlineAdd('lsd', 'temp', 'n', $class); - $code.= '$temp = array_slice($n, ' . (count($m) - 1) . ');'; - $code.= self::generateInlineMultiply('temp', $u, 'temp2', $class); - $code.= self::generateInlineTrim('temp2'); + $code .= '$temp = array_slice($n, ' . (count($m) - 1) . ');'; + $code .= self::generateInlineMultiply('temp', $u, 'temp2', $class); + $code .= self::generateInlineTrim('temp2'); - $code.= $class::BASE == 26 ? + $code .= $class::BASE == 26 ? '$temp = array_slice($temp2, ' . (count($m) + 1) . ');' : '$temp = array_slice($temp2, ' . ((count($m) >> 1) + 1) . ');'; - $code.= self::generateInlineMultiply('temp', $m, 'temp2', $class); - $code.= self::generateInlineTrim('temp2'); + $code .= self::generateInlineMultiply('temp', $m, 'temp2', $class); + $code .= self::generateInlineTrim('temp2'); /* if ($class::BASE == 26) { @@ -138,14 +138,14 @@ abstract class EvalBarrett extends Base } */ - $code.= self::generateInlineSubtract2('n', 'temp2', 'temp', $class); + $code .= self::generateInlineSubtract2('n', 'temp2', 'temp', $class); $subcode = self::generateInlineSubtract1('temp', $m, 'temp2', $class); - $subcode.= '$temp = $temp2;'; + $subcode .= '$temp = $temp2;'; - $code.= self::generateInlineCompare($m, 'temp', $subcode); + $code .= self::generateInlineCompare($m, 'temp', $subcode); - $code.= 'return $temp;'; + $code .= 'return $temp;'; eval('$func = function ($n) { ' . $code . '};'); @@ -198,51 +198,51 @@ abstract class EvalBarrett extends Base $' . $output . ' = array_fill(0, $length + ' . count($arr) . ', 0); $carry = 0;'; - for ($i = 0; $i < count($arr); $i++) { - $regular.= ' + for ($i = 0; $i < count($arr); $i++) { + $regular .= ' $subtemp = $' . $input . '[0] * ' . $arr[$i]; - $regular.= $i ? ' + $carry;' : ';'; + $regular .= $i ? ' + $carry;' : ';'; - $regular.= '$carry = '; - $regular.= $class::BASE === 26 ? - 'intval($subtemp / 0x4000000);' : - '$subtemp >> 31;'; - $regular.= - '$' . $output . '[' . $i . '] = '; + $regular .= '$carry = '; + $regular .= $class::BASE === 26 ? + 'intval($subtemp / 0x4000000);' : + '$subtemp >> 31;'; + $regular .= + '$' . $output . '[' . $i . '] = '; if ($class::BASE === 26) { - $regular.= '(int) ('; + $regular .= '(int) ('; } - $regular.= '$subtemp - ' . $class::BASE_FULL . ' * $carry'; - $regular.= $class::BASE === 26 ? ');' : ';'; + $regular .= '$subtemp - ' . $class::BASE_FULL . ' * $carry'; + $regular .= $class::BASE === 26 ? ');' : ';'; } - $regular.= '$' . $output . '[' . count($arr) . '] = $carry;'; + $regular .= '$' . $output . '[' . count($arr) . '] = $carry;'; - $regular.= ' + $regular .= ' for ($i = 1; $i < $length; ++$i) {'; for ($j = 0; $j < count($arr); $j++) { - $regular.= $j ? '$k++;' : '$k = $i;'; - $regular.= ' + $regular .= $j ? '$k++;' : '$k = $i;'; + $regular .= ' $subtemp = $' . $output . '[$k] + $' . $input . '[$i] * ' . $arr[$j]; - $regular.= $j ? ' + $carry;' : ';'; + $regular .= $j ? ' + $carry;' : ';'; - $regular.= '$carry = '; - $regular.= $class::BASE === 26 ? + $regular .= '$carry = '; + $regular .= $class::BASE === 26 ? 'intval($subtemp / 0x4000000);' : '$subtemp >> 31;'; - $regular.= + $regular .= '$' . $output . '[$k] = '; if ($class::BASE === 26) { - $regular.= '(int) ('; + $regular .= '(int) ('; } - $regular.= '$subtemp - ' . $class::BASE_FULL . ' * $carry'; - $regular.= $class::BASE === 26 ? ');' : ';'; + $regular .= '$subtemp - ' . $class::BASE_FULL . ' * $carry'; + $regular .= $class::BASE === 26 ? ');' : ';'; } - $regular.= '$' . $output. '[++$k] = $carry; $carry = 0;'; + $regular .= '$' . $output . '[++$k] = $carry; $carry = 0;'; - $regular.= '}}'; + $regular .= '}}'; //if (count($arr) < 2 * self::KARATSUBA_CUTOFF) { //} @@ -273,10 +273,10 @@ abstract class EvalBarrett extends Base $carry = $sum >= ' . self::float2string($class::MAX_DIGIT2) . '; $sum = $carry ? $sum - ' . self::float2string($class::MAX_DIGIT2) . ' : $sum;'; - $code.= $class::BASE === 26 ? + $code .= $class::BASE === 26 ? '$upper = intval($sum / 0x4000000); $' . $result . '[$i] = (int) ($sum - ' . $class::BASE_FULL . ' * $upper);' : '$upper = $sum >> 31; $' . $result . '[$i] = $sum - ' . $class::BASE_FULL . ' * $upper;'; - $code.= ' + $code .= ' $' . $result . '[$j] = $upper; } if ($j == $length) { @@ -290,7 +290,7 @@ abstract class EvalBarrett extends Base } ++$' . $result . '[$i]; }'; - $code.= self::generateInlineTrim($result); + $code .= self::generateInlineTrim($result); return $code; } @@ -309,7 +309,7 @@ abstract class EvalBarrett extends Base private static function generateInlineSubtract2($known, $unknown, $result, $class) { $code = ' - $' . $result .' = $' . $known . '; + $' . $result . ' = $' . $known . '; $carry = 0; $size = count($' . $unknown . '); for ($i = 0, $j = 1; $j < $size; $i+= 2, $j+= 2) { @@ -321,18 +321,18 @@ abstract class EvalBarrett extends Base $sum+= ' . self::float2string($class::MAX_DIGIT2) . '; } $subtemp = '; - $code.= $class::BASE === 26 ? + $code .= $class::BASE === 26 ? 'intval($sum / 0x4000000);' : '$sum >> 31;'; - $code.= '$' . $result . '[$i] = '; + $code .= '$' . $result . '[$i] = '; if ($class::BASE === 26) { - $code.= '(int) ('; + $code .= '(int) ('; } - $code.= '$sum - ' . $class::BASE_FULL . ' * $subtemp'; + $code .= '$sum - ' . $class::BASE_FULL . ' * $subtemp'; if ($class::BASE === 26) { - $code.= ')'; + $code .= ')'; } - $code.= '; + $code .= '; $' . $result . '[$j] = $subtemp; } if ($j == $size) { @@ -349,7 +349,7 @@ abstract class EvalBarrett extends Base --$' . $result . '[$i]; }'; - $code.= self::generateInlineTrim($result); + $code .= self::generateInlineTrim($result); return $code; } @@ -368,52 +368,52 @@ abstract class EvalBarrett extends Base private static function generateInlineSubtract1($unknown, array $known, $result, $class) { $code = '$' . $result . ' = $' . $unknown . ';'; - for ($i = 0, $j = 1; $j < count($known); $i+=2, $j+=2) { - $code.= '$sum = $' . $unknown . '[' . $j . '] * ' . $class::BASE_FULL . ' + $' . $unknown . '[' . $i . '] - '; - $code.= self::float2string($known[$j] * $class::BASE_FULL + $known[$i]); + for ($i = 0, $j = 1; $j < count($known); $i += 2, $j += 2) { + $code .= '$sum = $' . $unknown . '[' . $j . '] * ' . $class::BASE_FULL . ' + $' . $unknown . '[' . $i . '] - '; + $code .= self::float2string($known[$j] * $class::BASE_FULL + $known[$i]); if ($i != 0) { - $code.= ' - $carry'; + $code .= ' - $carry'; } - $code.= '; + $code .= '; if ($carry = $sum < 0) { $sum+= ' . self::float2string($class::MAX_DIGIT2) . '; } $subtemp = '; - $code.= $class::BASE === 26 ? + $code .= $class::BASE === 26 ? 'intval($sum / 0x4000000);' : '$sum >> 31;'; - $code.= ' + $code .= ' $' . $result . '[' . $i . '] = '; if ($class::BASE === 26) { - $code.= ' (int) ('; + $code .= ' (int) ('; } - $code.= '$sum - ' . $class::BASE_FULL . ' * $subtemp'; + $code .= '$sum - ' . $class::BASE_FULL . ' * $subtemp'; if ($class::BASE === 26) { - $code.= ')'; + $code .= ')'; } - $code.= '; + $code .= '; $' . $result . '[' . $j . '] = $subtemp;'; } - $code.= '$i = ' . $i . ';'; + $code .= '$i = ' . $i . ';'; if ($j == count($known)) { - $code.= ' + $code .= ' $sum = $' . $unknown . '[' . $i . '] - ' . $known[$i] . ' - $carry; $carry = $sum < 0; $' . $result . '[' . $i . '] = $carry ? $sum + ' . $class::BASE_FULL . ' : $sum; ++$i;'; } - $code.= ' + $code .= ' if ($carry) { for (; !$' . $result . '[$i]; ++$i) { $' . $result . '[$i] = ' . $class::MAX_DIGIT . '; } --$' . $result . '[$i]; }'; - $code.= self::generateInlineTrim($result); + $code .= self::generateInlineTrim($result); return $code; } @@ -438,13 +438,13 @@ abstract class EvalBarrett extends Base goto end_' . $uniqid . '; case $clength > ' . count($known) . ':'; for ($i = count($known) - 1; $i >= 0; $i--) { - $code.= ' + $code .= ' case $' . $unknown . '[' . $i . '] > ' . $known[$i] . ': goto subcode_' . $uniqid . '; case $' . $unknown . '[' . $i . '] < ' . $known[$i] . ': goto end_' . $uniqid . ';'; } - $code.= ' + $code .= ' default: // do subcode } @@ -484,4 +484,4 @@ abstract class EvalBarrett extends Base return $temp; } -} \ No newline at end of file +} diff --git a/phpseclib/Math/BigInteger/Engines/PHP/Reductions/Montgomery.php b/phpseclib/Math/BigInteger/Engines/PHP/Reductions/Montgomery.php index 79db314d..e7364722 100644 --- a/phpseclib/Math/BigInteger/Engines/PHP/Reductions/Montgomery.php +++ b/phpseclib/Math/BigInteger/Engines/PHP/Reductions/Montgomery.php @@ -127,4 +127,4 @@ abstract class Montgomery extends Progenitor ($result * (2 - ($x * $result) % $class::BASE_FULL)) % $class::BASE_FULL; return $result & $class::MAX_DIGIT; } -} \ No newline at end of file +} diff --git a/phpseclib/Math/BigInteger/Engines/PHP/Reductions/MontgomeryMult.php b/phpseclib/Math/BigInteger/Engines/PHP/Reductions/MontgomeryMult.php index 0c21d034..54fd2bba 100644 --- a/phpseclib/Math/BigInteger/Engines/PHP/Reductions/MontgomeryMult.php +++ b/phpseclib/Math/BigInteger/Engines/PHP/Reductions/MontgomeryMult.php @@ -15,7 +15,6 @@ namespace phpseclib3\Math\BigInteger\Engines\PHP\Reductions; - /** * PHP Montgomery Modular Exponentiation Engine with interleaved multiplication * @@ -77,4 +76,4 @@ abstract class MontgomeryMult extends Montgomery } return $a[self::VALUE]; } -} \ No newline at end of file +} diff --git a/phpseclib/Math/BigInteger/Engines/PHP/Reductions/PowerOfTwo.php b/phpseclib/Math/BigInteger/Engines/PHP/Reductions/PowerOfTwo.php index 73f133d0..c6ec026d 100644 --- a/phpseclib/Math/BigInteger/Engines/PHP/Reductions/PowerOfTwo.php +++ b/phpseclib/Math/BigInteger/Engines/PHP/Reductions/PowerOfTwo.php @@ -60,4 +60,4 @@ abstract class PowerOfTwo extends Base $result = $lhs->bitwise_and($rhs->subtract($temp)); return $result->value; } -} \ No newline at end of file +} diff --git a/phpseclib/Math/BigInteger/Engines/PHP32.php b/phpseclib/Math/BigInteger/Engines/PHP32.php index e1d15554..169bd6d0 100644 --- a/phpseclib/Math/BigInteger/Engines/PHP32.php +++ b/phpseclib/Math/BigInteger/Engines/PHP32.php @@ -15,7 +15,6 @@ namespace phpseclib3\Math\BigInteger\Engines; - /** * Pure-PHP 32-bit Engine. * @@ -110,7 +109,7 @@ class PHP32 extends PHP } while (true) { - $i-= 4; + $i -= 4; if ($i < 0) { if ($i == -4) { break; @@ -125,10 +124,10 @@ class PHP32 extends PHP list(, $digit) = unpack('N', substr($val, $i, 4)); $step = count($vals) & 3; if ($step) { - $digit>>= 2 * $step; + $digit >>= 2 * $step; } if ($step != 3) { - $digit&= static::MAX_DIGIT; + $digit &= static::MAX_DIGIT; $i++; } $vals[] = $digit; @@ -414,4 +413,4 @@ class PHP32 extends PHP { return $this->compare($min) >= 0 && $this->compare($max) <= 0; } -} \ No newline at end of file +} diff --git a/phpseclib/Math/BigInteger/Engines/PHP64.php b/phpseclib/Math/BigInteger/Engines/PHP64.php index 08754d51..35b07fb7 100644 --- a/phpseclib/Math/BigInteger/Engines/PHP64.php +++ b/phpseclib/Math/BigInteger/Engines/PHP64.php @@ -15,7 +15,6 @@ namespace phpseclib3\Math\BigInteger\Engines; - /** * Pure-PHP 64-bit Engine. * @@ -110,7 +109,7 @@ class PHP64 extends PHP } while (true) { - $i-= 4; + $i -= 4; if ($i < 0) { if ($i == -4) { break; @@ -125,15 +124,15 @@ class PHP64 extends PHP list(, $digit) = unpack('N', substr($val, $i, 4)); $step = count($vals) & 7; if (!$step) { - $digit&= static::MAX_DIGIT; + $digit &= static::MAX_DIGIT; $i++; } else { $shift = 8 - $step; - $digit>>= $shift; + $digit >>= $shift; $shift = 32 - $shift; - $digit&= (1 << $shift) - 1; + $digit &= (1 << $shift) - 1; $temp = $i > 0 ? ord($val[$i - 1]) : 0; - $digit|= ($temp << $shift) & 0x7F000000; + $digit |= ($temp << $shift) & 0x7F000000; } $vals[] = $digit; } @@ -418,4 +417,4 @@ class PHP64 extends PHP { return $this->compare($min) >= 0 && $this->compare($max) <= 0; } -} \ No newline at end of file +} diff --git a/phpseclib/Math/BinaryField.php b/phpseclib/Math/BinaryField.php index 096b482b..5c9d57d1 100644 --- a/phpseclib/Math/BinaryField.php +++ b/phpseclib/Math/BinaryField.php @@ -74,7 +74,7 @@ class BinaryField extends FiniteField // implements algorithm 2.40 (in section 2.3.5) in "Guide to Elliptic Curve Cryptography" // with W = 8 - $reduce = function($c) use ($u, $mStart, $m, $t, $finalMask, $pad, $h) { + $reduce = function ($c) use ($u, $mStart, $m, $t, $finalMask, $pad, $h) { $c = str_pad($c, $pad, "\0", STR_PAD_LEFT); for ($i = $mStart; $i >= $m;) { $g = $h >> 3; @@ -159,7 +159,7 @@ class BinaryField extends FiniteField * Converts a base-2 string to a base-256 string * * @param string $x - * @param integer $size + * @param integer $size * @return string */ public static function base2ToBase256($x, $size = null) @@ -192,4 +192,4 @@ class BinaryField extends FiniteField return Strings::bin2bits($x); } -} \ No newline at end of file +} diff --git a/phpseclib/Math/BinaryField/Integer.php b/phpseclib/Math/BinaryField/Integer.php index 8d176a93..0df47a57 100644 --- a/phpseclib/Math/BinaryField/Integer.php +++ b/phpseclib/Math/BinaryField/Integer.php @@ -216,7 +216,7 @@ class Integer extends Base for ($i = 0; $i < strlen($y); $i++) { if ($y[$i] == '1') { $temp = $precomputed[$i & 7] . str_repeat("\0", $i >> 3); - $result^= str_pad($temp, $size, "\0", STR_PAD_LEFT); + $result ^= str_pad($temp, $size, "\0", STR_PAD_LEFT); } } @@ -304,10 +304,10 @@ class Integer extends Base $z2 = ($x0 * $y2) ^ ($x1 * $y1) ^ ($x2 * $y0) ^ ($x3 * $y3); $z3 = ($x0 * $y3) ^ ($x1 * $y2) ^ ($x2 * $y1) ^ ($x3 * $y0); - $z0&= 0x1111111111111111; - $z1&= 0x2222222222222222; - $z2&= 0x4444444444444444; - $z3&= -8608480567731124088; // 0x8888888888888888 gets interpreted as a float + $z0 &= 0x1111111111111111; + $z1 &= 0x2222222222222222; + $z2 &= 0x4444444444444444; + $z3 &= -8608480567731124088; // 0x8888888888888888 gets interpreted as a float $z = $z0 | $z1 | $z2 | $z3; @@ -517,4 +517,4 @@ class Integer extends Base { return ['value' => $this->toHex()]; } -} \ No newline at end of file +} diff --git a/phpseclib/Math/Common/FiniteField.php b/phpseclib/Math/Common/FiniteField.php index c2294a04..599959ff 100644 --- a/phpseclib/Math/Common/FiniteField.php +++ b/phpseclib/Math/Common/FiniteField.php @@ -23,4 +23,4 @@ namespace phpseclib3\Math\Common; */ abstract class FiniteField { -} \ No newline at end of file +} diff --git a/phpseclib/Math/Common/FiniteField/Integer.php b/phpseclib/Math/Common/FiniteField/Integer.php index d163f552..ab968e26 100644 --- a/phpseclib/Math/Common/FiniteField/Integer.php +++ b/phpseclib/Math/Common/FiniteField/Integer.php @@ -23,4 +23,4 @@ namespace phpseclib3\Math\Common\FiniteField; */ abstract class Integer { -} \ No newline at end of file +} diff --git a/phpseclib/Math/PrimeField.php b/phpseclib/Math/PrimeField.php index 7e15f906..d38991e0 100644 --- a/phpseclib/Math/PrimeField.php +++ b/phpseclib/Math/PrimeField.php @@ -119,4 +119,4 @@ class PrimeField extends FiniteField { Integer::cleanupCache($this->instanceID); } -} \ No newline at end of file +} diff --git a/phpseclib/Math/PrimeField/Integer.php b/phpseclib/Math/PrimeField/Integer.php index 825aaf8e..71024882 100644 --- a/phpseclib/Math/PrimeField/Integer.php +++ b/phpseclib/Math/PrimeField/Integer.php @@ -405,4 +405,4 @@ class Integer extends Base { return ['value' => $this->toHex()]; } -} \ No newline at end of file +} diff --git a/phpseclib/Net/SFTP.php b/phpseclib/Net/SFTP.php index eaa403fa..b70073bd 100644 --- a/phpseclib/Net/SFTP.php +++ b/phpseclib/Net/SFTP.php @@ -600,7 +600,7 @@ class SFTP extends SSH2 if ($response === false) { return false; } - } else if ($response === true && $this->isTimeout()) { + } elseif ($response === true && $this->isTimeout()) { return false; } @@ -914,7 +914,7 @@ class SFTP extends SSH2 $dir = './'; // suffix a slash if needed } elseif ($dir[strlen($dir) - 1] != '/') { - $dir.= '/'; + $dir .= '/'; } $dir = $this->realpath($dir); @@ -1207,8 +1207,8 @@ class SFTP extends SSH2 } break; case 'mode': - $a[$sort]&= 07777; - $b[$sort]&= 07777; + $a[$sort] &= 07777; + $b[$sort] &= 07777; default: if ($a[$sort] === $b[$sort]) { break; @@ -1246,7 +1246,7 @@ class SFTP extends SSH2 return; } $len = count($args) & 0x7FFFFFFE; - for ($i = 0; $i < $len; $i+=2) { + for ($i = 0; $i < $len; $i += 2) { $this->sortOptions[$args[$i]] = $args[$i + 1]; } if (!count($this->sortOptions)) { @@ -1389,7 +1389,7 @@ class SFTP extends SSH2 } if (isset($stat['type'])) { if ($stat['type'] == NET_SFTP_TYPE_DIRECTORY) { - $filename.= '/.'; + $filename .= '/.'; } $this->update_stat_cache($filename, (object) ['stat' => $stat]); return $stat; @@ -1402,7 +1402,7 @@ class SFTP extends SSH2 $this->pwd = $pwd; if ($stat['type'] == NET_SFTP_TYPE_DIRECTORY) { - $filename.= '/.'; + $filename .= '/.'; } $this->update_stat_cache($filename, (object) ['stat' => $stat]); @@ -1446,7 +1446,7 @@ class SFTP extends SSH2 } if (isset($lstat['type'])) { if ($lstat['type'] == NET_SFTP_TYPE_DIRECTORY) { - $filename.= '/.'; + $filename .= '/.'; } $this->update_stat_cache($filename, (object) ['lstat' => $lstat]); return $lstat; @@ -1467,7 +1467,7 @@ class SFTP extends SSH2 $this->pwd = $pwd; if ($lstat['type'] == NET_SFTP_TYPE_DIRECTORY) { - $filename.= '/.'; + $filename .= '/.'; } $this->update_stat_cache($filename, (object) ['lstat' => $lstat]); @@ -1555,10 +1555,10 @@ class SFTP extends SSH2 Strings::packSSH2('NQ2', NET_SFTP_ATTR_ACCESSTIME | NET_SFTP_ATTR_MODIFYTIME, $atime, $time); $packet = Strings::packSSH2('s', $filename); - $packet.= $this->version >= 5 ? + $packet .= $this->version >= 5 ? pack('N2', 0, NET_SFTP_OPEN_OPEN_EXISTING) : pack('N', NET_SFTP_OPEN_WRITE | NET_SFTP_OPEN_CREATE | NET_SFTP_OPEN_EXCL); - $packet.= $attr; + $packet .= $attr; $this->send_sftp_packet(NET_SFTP_OPEN, $packet); @@ -1731,7 +1731,7 @@ class SFTP extends SSH2 } $packet = Strings::packSSH2('s', $filename); - $packet.= $this->version >= 4 ? + $packet .= $this->version >= 4 ? pack('a*Ca*', substr($attr, 0, 4), NET_SFTP_TYPE_UNKNOWN, substr($attr, 4)) : $attr; $this->send_sftp_packet(NET_SFTP_SETSTAT, $packet); @@ -1800,7 +1800,7 @@ class SFTP extends SSH2 } } else { $packet = Strings::packSSH2('s', $temp); - $packet.= $this->version >= 4 ? + $packet .= $this->version >= 4 ? pack('Ca*', NET_SFTP_TYPE_UNKNOWN, $attr) : $attr; $this->send_sftp_packet(NET_SFTP_SETSTAT, $packet); @@ -1817,7 +1817,7 @@ class SFTP extends SSH2 } $packet = Strings::packSSH2('s', $path); - $packet.= $this->version >= 4 ? + $packet .= $this->version >= 4 ? pack('Ca*', NET_SFTP_TYPE_UNKNOWN, $attr) : $attr; $this->send_sftp_packet(NET_SFTP_SETSTAT, $packet); @@ -2134,14 +2134,14 @@ class SFTP extends SSH2 if ($this->version >= 5) { $flags = NET_SFTP_OPEN_CREATE_TRUNCATE; } else { - $flags|= NET_SFTP_OPEN_TRUNCATE; + $flags |= NET_SFTP_OPEN_TRUNCATE; } } $this->remove_from_stat_cache($remote_file); $packet = Strings::packSSH2('s', $remote_file); - $packet.= $this->version >= 5 ? + $packet .= $this->version >= 5 ? pack('N3', 0, $flags, 0) : pack('N2', $flags, 0); $this->send_sftp_packet(NET_SFTP_OPEN, $packet); @@ -2196,7 +2196,7 @@ class SFTP extends SSH2 if ($local_start >= 0) { fseek($fp, $local_start); - $size-= $local_start; + $size -= $local_start; } } elseif ($dataCallback) { $size = 0; @@ -2209,7 +2209,7 @@ class SFTP extends SSH2 $sftp_packet_size = $this->max_sftp_packet; // make the SFTP packet be exactly the SFTP packet size by including the bytes in the NET_SFTP_WRITE packets "header" - $sftp_packet_size-= strlen($handle) + 25; + $sftp_packet_size -= strlen($handle) + 25; $i = $j = 0; while ($dataCallback || ($size === 0 || $sent < $size)) { if ($dataCallback) { @@ -2234,7 +2234,7 @@ class SFTP extends SSH2 } throw $e; } - $sent+= strlen($temp); + $sent += strlen($temp); if (is_callable($progressCallback)) { $progressCallback($sent); } @@ -2368,7 +2368,7 @@ class SFTP extends SSH2 } $packet = Strings::packSSH2('s', $remote_file); - $packet.= $this->version >= 5 ? + $packet .= $this->version >= 5 ? pack('N3', 0, NET_SFTP_OPEN_OPEN_EXISTING, 0) : pack('N2', NET_SFTP_OPEN_READ, 0); $this->send_sftp_packet(NET_SFTP_OPEN, $packet); @@ -2424,7 +2424,7 @@ class SFTP extends SSH2 throw $e; } $packet = null; - $read+= $packet_size; + $read += $packet_size; $i++; } @@ -2448,9 +2448,9 @@ class SFTP extends SSH2 switch ($this->packet_type) { case NET_SFTP_DATA: $temp = substr($response, 4); - $offset+= strlen($temp); + $offset += strlen($temp); if ($local_file === false) { - $content.= $temp; + $content .= $temp; } elseif (is_callable($local_file)) { $local_file($temp); } else { @@ -2984,7 +2984,7 @@ class SFTP extends SSH2 SSH_FXP_RENAME_NATIVE 0x00000004 (none of these are currently supported) */ - $packet.= "\0\0\0\0"; + $packet .= "\0\0\0\0"; } $this->send_sftp_packet(NET_SFTP_RENAME, $packet); @@ -3096,21 +3096,21 @@ class SFTP extends SSH2 list($attr['mode']) = Strings::unpackSSH2('N', $response); $fileType = $this->parseMode($attr['mode']); if ($this->version < 4 && $fileType !== false) { - $attr+= ['type' => $fileType]; + $attr += ['type' => $fileType]; } break; case NET_SFTP_ATTR_ACCESSTIME: // 0x00000008 if ($this->version >= 4) { - $attr+= $this->parseTime('atime', $flags, $response); + $attr += $this->parseTime('atime', $flags, $response); break; } list($attr['atime'], $attr['mtime']) = Strings::unpackSSH2('NN', $response); break; case NET_SFTP_ATTR_CREATETIME: // 0x00000010 (SFTPv4+) - $attr+= $this->parseTime('createtime', $flags, $response); + $attr += $this->parseTime('createtime', $flags, $response); break; case NET_SFTP_ATTR_MODIFYTIME: // 0x00000020 - $attr+= $this->parseTime('mtime', $flags, $response); + $attr += $this->parseTime('mtime', $flags, $response); break; case NET_SFTP_ATTR_ACL: // 0x00000040 // access control list @@ -3165,7 +3165,7 @@ class SFTP extends SSH2 case NET_SFTP_ATTR_CTIME: // 0x00008000 // 'ctime' contains the last time the file attributes were changed. The // exact meaning of this field depends on the server. - $attr+= $this->parseTime('ctime', $flags, $response); + $attr += $this->parseTime('ctime', $flags, $response); break; case NET_SFTP_ATTR_EXTENDED: // 0x80000000 list($count) = Strings::unpackSSH2('N', $response); @@ -3275,7 +3275,7 @@ class SFTP extends SSH2 $packet = $this->use_request_id ? pack('NCNa*', strlen($data) + 5, $type, $request_id, $data) : - pack('NCa*', strlen($data) + 1, $type, $data); + pack('NCa*', strlen($data) + 1, $type, $data); $start = microtime(true); $result = $this->send_channel_packet(self::CHANNEL, $packet); @@ -3362,7 +3362,7 @@ class SFTP extends SSH2 $this->packet_buffer = ''; return false; } - $this->packet_buffer.= $temp; + $this->packet_buffer .= $temp; } if (strlen($this->packet_buffer) < 4) { throw new \RuntimeException('Packet is too small'); @@ -3371,7 +3371,7 @@ class SFTP extends SSH2 /** @var integer $length */ $tempLength = $length; - $tempLength-= strlen($this->packet_buffer); + $tempLength -= strlen($this->packet_buffer); // 256 * 1024 is what SFTP_MAX_MSG_LENGTH is set to in OpenSSH's sftp-common.h if (!$this->allow_arbitrary_length_packets && !$this->use_request_id && $tempLength > 256 * 1024) { @@ -3386,8 +3386,8 @@ class SFTP extends SSH2 $this->packet_buffer = ''; return false; } - $this->packet_buffer.= $temp; - $tempLength-= strlen($temp); + $this->packet_buffer .= $temp; + $tempLength -= strlen($temp); } $stop = microtime(true); @@ -3396,9 +3396,9 @@ class SFTP extends SSH2 if ($this->use_request_id) { extract(unpack('Npacket_id', Strings::shift($this->packet_buffer, 4))); // remove the request id - $length-= 5; // account for the request id and the packet type + $length -= 5; // account for the request id and the packet type } else { - $length-= 1; // account for the packet type + $length -= 1; // account for the packet type } $packet = Strings::shift($this->packet_buffer, $length); diff --git a/phpseclib/Net/SFTP/Stream.php b/phpseclib/Net/SFTP/Stream.php index 4bf201bc..ccee1593 100644 --- a/phpseclib/Net/SFTP/Stream.php +++ b/phpseclib/Net/SFTP/Stream.php @@ -37,7 +37,7 @@ class Stream * * @var array */ - static $instances; + public static $instances; /** * SFTP instance @@ -157,14 +157,14 @@ class Stream $orig = $path; extract(parse_url($path) + ['port' => 22]); if (isset($query)) { - $path.= '?' . $query; + $path .= '?' . $query; } elseif (preg_match('/(\?|\?#)$/', $orig)) { - $path.= '?'; + $path .= '?'; } if (isset($fragment)) { - $path.= '#' . $fragment; + $path .= '#' . $fragment; } elseif ($orig[strlen($orig) - 1] == '#') { - $path.= '#'; + $path .= '#'; } if (!isset($host)) { @@ -329,7 +329,7 @@ class Stream $this->eof = true; return false; } - $this->pos+= strlen($result); + $this->pos += strlen($result); return $result; } @@ -361,7 +361,7 @@ class Stream if ($result === false) { return false; } - $this->pos+= strlen($data); + $this->pos += strlen($data); if ($this->pos > $this->size) { $this->size = $this->pos; } @@ -415,10 +415,10 @@ class Stream } break; case SEEK_CUR: - $offset+= $this->pos; + $offset += $this->pos; break; case SEEK_END: - $offset+= $this->size; + $offset += $this->size; } $this->pos = $offset; diff --git a/phpseclib/Net/SSH2.php b/phpseclib/Net/SSH2.php index d18bf1e2..d053f507 100644 --- a/phpseclib/Net/SSH2.php +++ b/phpseclib/Net/SSH2.php @@ -1409,7 +1409,7 @@ class SSH2 $elapsed = microtime(true) - $start; if ($this->curTimeout) { - $this->curTimeout-= $elapsed; + $this->curTimeout -= $elapsed; if ($this->curTimeout < 0) { throw new \RuntimeException('Connection timed out whilst attempting to open socket connection'); } @@ -1446,7 +1446,7 @@ class SSH2 throw new \RuntimeException('Connection timed out whilst receiving server identification string'); } $elapsed = microtime(true) - $start; - $this->curTimeout-= $elapsed; + $this->curTimeout -= $elapsed; } $temp = stream_get_line($this->fsock, 255, "\n"); @@ -1457,7 +1457,7 @@ class SSH2 continue; } - $line.= "$temp\n"; + $line .= "$temp\n"; // quoting RFC4253, "Implementers who wish to maintain // compatibility with older, undocumented versions of this protocol may @@ -1472,7 +1472,7 @@ class SSH2 break; } - $data.= $line; + $data .= $line; } if (feof($this->fsock)) { @@ -1516,7 +1516,7 @@ class SSH2 $this->key_exchange(); } - $this->bitmap|= self::MASK_CONNECTED; + $this->bitmap |= self::MASK_CONNECTED; return true; } @@ -1618,7 +1618,7 @@ class SSH2 $client_cookie = Random::string(16); $kexinit_payload_client = pack('Ca*', NET_SSH2_MSG_KEXINIT, $client_cookie); - $kexinit_payload_client.= Strings::packSSH2( + $kexinit_payload_client .= Strings::packSSH2( 'L10bN', $kex_algorithms, $server_host_key_algorithms, @@ -1867,15 +1867,17 @@ class SSH2 $keyBytes = "\0$keyBytes"; } - $this->exchange_hash = Strings::packSSH2('s5', + $this->exchange_hash = Strings::packSSH2( + 's5', $this->identifier, $this->server_identifier, $kexinit_payload_client, $kexinit_payload_server, $this->server_public_host_key ); - $this->exchange_hash.= $exchange_hash_rfc4419; - $this->exchange_hash.= Strings::packSSH2('s3', + $this->exchange_hash .= $exchange_hash_rfc4419; + $this->exchange_hash .= Strings::packSSH2( + 's3', $ourPublicBytes, $theirPublicBytes, $keyBytes @@ -1937,7 +1939,7 @@ class SSH2 if ($this->encrypt->usesIV()) { $iv = $kexHash->hash($keyBytes . $this->exchange_hash . 'A' . $this->session_id); while ($this->encrypt_block_size > strlen($iv)) { - $iv.= $kexHash->hash($keyBytes . $this->exchange_hash . $iv); + $iv .= $kexHash->hash($keyBytes . $this->exchange_hash . $iv); } $this->encrypt->setIV(substr($iv, 0, $this->encrypt_block_size)); } @@ -1956,7 +1958,7 @@ class SSH2 $key = $kexHash->hash($keyBytes . $this->exchange_hash . 'C' . $this->session_id); while ($encryptKeyLength > strlen($key)) { - $key.= $kexHash->hash($keyBytes . $this->exchange_hash . $key); + $key .= $kexHash->hash($keyBytes . $this->exchange_hash . $key); } switch ($encrypt) { case 'chacha20-poly1305@openssh.com': @@ -1981,7 +1983,7 @@ class SSH2 if ($this->decrypt->usesIV()) { $iv = $kexHash->hash($keyBytes . $this->exchange_hash . 'B' . $this->session_id); while ($this->decrypt_block_size > strlen($iv)) { - $iv.= $kexHash->hash($keyBytes . $this->exchange_hash . $iv); + $iv .= $kexHash->hash($keyBytes . $this->exchange_hash . $iv); } $this->decrypt->setIV(substr($iv, 0, $this->decrypt_block_size)); } @@ -2001,7 +2003,7 @@ class SSH2 $key = $kexHash->hash($keyBytes . $this->exchange_hash . 'D' . $this->session_id); while ($decryptKeyLength > strlen($key)) { - $key.= $kexHash->hash($keyBytes . $this->exchange_hash . $key); + $key .= $kexHash->hash($keyBytes . $this->exchange_hash . $key); } switch ($decrypt) { case 'chacha20-poly1305@openssh.com': @@ -2030,7 +2032,7 @@ class SSH2 if (!$this->encrypt->usesNonce()) { list($this->hmac_create, $createKeyLength) = self::mac_algorithm_to_hash_instance($mac_algorithm_out); } else { - $this->hmac_create = new \stdClass; + $this->hmac_create = new \stdClass(); $this->hmac_create_name = $mac_algorithm_out; //$mac_algorithm_out = 'none'; $createKeyLength = 0; @@ -2039,7 +2041,7 @@ class SSH2 if ($this->hmac_create instanceof Hash) { $key = $kexHash->hash($keyBytes . $this->exchange_hash . 'E' . $this->session_id); while ($createKeyLength > strlen($key)) { - $key.= $kexHash->hash($keyBytes . $this->exchange_hash . $key); + $key .= $kexHash->hash($keyBytes . $this->exchange_hash . $key); } $this->hmac_create->setKey(substr($key, 0, $createKeyLength)); $this->hmac_create_name = $mac_algorithm_out; @@ -2050,7 +2052,7 @@ class SSH2 list($this->hmac_check, $checkKeyLength) = self::mac_algorithm_to_hash_instance($mac_algorithm_in); $this->hmac_size = $this->hmac_check->getLengthInBytes(); } else { - $this->hmac_check = new \stdClass; + $this->hmac_check = new \stdClass(); $this->hmac_check_name = $mac_algorithm_in; //$mac_algorithm_in = 'none'; $checkKeyLength = 0; @@ -2060,7 +2062,7 @@ class SSH2 if ($this->hmac_check instanceof Hash) { $key = $kexHash->hash($keyBytes . $this->exchange_hash . 'F' . $this->session_id); while ($checkKeyLength > strlen($key)) { - $key.= $kexHash->hash($keyBytes . $this->exchange_hash . $key); + $key .= $kexHash->hash($keyBytes . $this->exchange_hash . $key); } $this->hmac_check->setKey(substr($key, 0, $checkKeyLength)); $this->hmac_check_name = $mac_algorithm_in; @@ -2409,12 +2411,12 @@ class SSH2 } if (!isset($password)) { - $packet = Strings::packSSH2( - 'Cs3', - NET_SSH2_MSG_USERAUTH_REQUEST, - $username, - 'ssh-connection', - 'none' + $packet = Strings::packSSH2( + 'Cs3', + NET_SSH2_MSG_USERAUTH_REQUEST, + $username, + 'ssh-connection', + 'none' ); $this->send_binary_packet($packet); @@ -2589,8 +2591,8 @@ class SSH2 // see http://tools.ietf.org/html/rfc4256#section-3.4 $packet = $logged = pack('CN', NET_SSH2_MSG_USERAUTH_INFO_RESPONSE, count($responses)); for ($i = 0; $i < count($responses); $i++) { - $packet.= Strings::packSSH2('s', $responses[$i]); - $logged.= Strings::packSSH2('s', 'dummy-answer'); + $packet .= Strings::packSSH2('s', $responses[$i]); + $logged .= Strings::packSSH2('s', 'dummy-answer'); } $this->send_binary_packet($packet, $logged); @@ -2657,7 +2659,7 @@ class SSH2 $privatekey = $privatekey->withPadding(RSA::SIGNATURE_PKCS1); $algos = ['rsa-sha2-256', 'rsa-sha2-512', 'ssh-rsa']; if (isset($this->preferred['hostkey'])) { - $algos = array_intersect($this->preferred['hostkey'] , $algos); + $algos = array_intersect($this->preferred['hostkey'], $algos); } $algo = self::array_intersect_first($algos, $this->server_host_key_algorithms); switch ($algo) { @@ -2674,7 +2676,7 @@ class SSH2 $hash = 'sha1'; $signatureType = 'ssh-rsa'; } - } else if ($publickey instanceof EC) { + } elseif ($publickey instanceof EC) { $privatekey = $privatekey->withSignatureFormat('SSH2'); $curveName = $privatekey->getCurve(); switch ($curveName) { @@ -2700,7 +2702,7 @@ class SSH2 } throw new UnsupportedCurveException('Named Curve of ' . $curveName . ' is not supported by phpseclib3\'s SSH2 implementation'); } - } else if ($publickey instanceof DSA) { + } elseif ($publickey instanceof DSA) { $privatekey = $privatekey->withSignatureFormat('SSH2'); $hash = 'sha1'; $signatureType = 'ssh-dss'; @@ -2750,7 +2752,7 @@ class SSH2 if ($publickey instanceof RSA) { $signature = Strings::packSSH2('ss', $signatureType, $signature); } - $packet.= Strings::packSSH2('s', $signature); + $packet .= Strings::packSSH2('s', $signature); $this->send_binary_packet($packet); @@ -2794,7 +2796,7 @@ class SSH2 * @param int $interval * @access public */ - function setKeepAlive($interval) + public function setKeepAlive($interval) { $this->keepAlive = $interval; } @@ -2931,7 +2933,7 @@ class SSH2 return true; } } else { - $output.= $temp; + $output .= $temp; } } } @@ -3135,7 +3137,7 @@ class SSH2 return Strings::shift($this->interactiveBuffer, strlen($this->interactiveBuffer)); } - $this->interactiveBuffer.= $response; + $this->interactiveBuffer .= $response; } } @@ -3420,11 +3422,11 @@ class SSH2 if (!@stream_select($read, $write, $except, $this->keepAlive)) { $this->send_binary_packet(pack('CN', NET_SSH2_MSG_IGNORE, 0)); $elapsed = microtime(true) - $start; - $this->curTimeout-= $elapsed; + $this->curTimeout -= $elapsed; return $this->get_binary_packet(true); } $elapsed = microtime(true) - $start; - $this->curTimeout-= $elapsed; + $this->curTimeout -= $elapsed; } $sec = (int) floor($this->curTimeout); @@ -3436,7 +3438,7 @@ class SSH2 return true; } $elapsed = microtime(true) - $start; - $this->curTimeout-= $elapsed; + $this->curTimeout -= $elapsed; } } @@ -3468,7 +3470,7 @@ class SSH2 * @var integer $packet_length */ - $raw.= $this->read_remaining_bytes($packet_length - $this->decrypt_block_size + 4); + $raw .= $this->read_remaining_bytes($packet_length - $this->decrypt_block_size + 4); $stop = microtime(true); $tag = stream_get_contents($this->fsock, $this->decrypt_block_size); $this->decrypt->setTag($tag); @@ -3491,7 +3493,7 @@ class SSH2 * @var integer $packet_length */ - $raw.= $this->read_remaining_bytes($packet_length - $this->decrypt_block_size + 4); + $raw .= $this->read_remaining_bytes($packet_length - $this->decrypt_block_size + 4); $stop = microtime(true); $tag = stream_get_contents($this->fsock, 16); @@ -3519,7 +3521,7 @@ class SSH2 /** * @var integer $packet_length */ - $raw.= $this->read_remaining_bytes($packet_length - $this->decrypt_block_size + 4); + $raw .= $this->read_remaining_bytes($packet_length - $this->decrypt_block_size + 4); $stop = microtime(true); $encrypted = $temp . $raw; $raw = $temp . $this->decrypt->decrypt($raw); @@ -3547,7 +3549,7 @@ class SSH2 $stop = microtime(true); } if (strlen($buffer)) { - $raw.= $this->decrypt ? $this->decrypt->decrypt($buffer) : $buffer; + $raw .= $this->decrypt ? $this->decrypt->decrypt($buffer) : $buffer; } $payload = Strings::shift($raw, $packet_length - $padding_length - 1); @@ -3648,7 +3650,7 @@ class SSH2 case $this->decryptName == 'aes256-gcm@openssh.com': case $this->decryptName == 'chacha20-poly1305@openssh.com': case $this->hmac_check instanceof Hash && $this->hmac_check_etm: - $remaining_length+= $this->decrypt_block_size - 4; + $remaining_length += $this->decrypt_block_size - 4; $adjustLength = true; } } @@ -3667,7 +3669,7 @@ class SSH2 } if ($adjustLength) { - $remaining_length-= $this->decrypt_block_size - 4; + $remaining_length -= $this->decrypt_block_size - 4; } $buffer = ''; @@ -3677,8 +3679,8 @@ class SSH2 $this->disconnect_helper(NET_SSH2_DISCONNECT_CONNECTION_LOST); throw new \RuntimeException('Error reading from socket'); } - $buffer.= $temp; - $remaining_length-= strlen($temp); + $buffer .= $temp; + $remaining_length -= strlen($temp); } return $buffer; @@ -3830,7 +3832,7 @@ class SSH2 Strings::shift($payload, 1); list($channel, $window_size) = Strings::unpackSSH2('NN', $payload); - $this->window_size_client_to_server[$channel]+= $window_size; + $this->window_size_client_to_server[$channel] += $window_size; $payload = ($this->bitmap & self::MASK_WINDOW_ADJUST) ? true : $this->get_binary_packet($skip_channel_filter); } @@ -3977,7 +3979,7 @@ class SSH2 // will not be setup yet on incoming channel open request if (isset($channel) && isset($this->channel_status[$channel]) && isset($this->window_size_server_to_client[$channel])) { - $this->window_size_server_to_client[$channel]-= strlen($response); + $this->window_size_server_to_client[$channel] -= strlen($response); // resize the window, if appropriate if ($this->window_size_server_to_client[$channel] < 0) { @@ -3985,7 +3987,7 @@ class SSH2 //if ($this->window_size_server_to_client[$channel] < 0x3FFFFFFF) { $packet = pack('CNN', NET_SSH2_MSG_CHANNEL_WINDOW_ADJUST, $this->server_channels[$channel], $this->window_resize); $this->send_binary_packet($packet); - $this->window_size_server_to_client[$channel]+= $this->window_resize; + $this->window_size_server_to_client[$channel] += $this->window_resize; } switch ($type) { @@ -3997,7 +3999,7 @@ class SSH2 */ // currently, there's only one possible value for $data_type_code: NET_SSH2_EXTENDED_DATA_STDERR list($data_type_code, $data) = Strings::unpackSSH2('Ns', $response); - $this->stdErrorLog.= $data; + $this->stdErrorLog .= $data; if ($skip_extended || $this->quiet_mode) { continue 2; } @@ -4023,7 +4025,7 @@ class SSH2 $this->errors[] = "SSH_MSG_CHANNEL_REQUEST (exit-signal): $signal_name"; if (strlen($error_message)) { - $this->errors[count($this->errors) - 1].= "\r\n$error_message"; + $this->errors[count($this->errors) - 1] .= "\r\n$error_message"; } $this->send_binary_packet(pack('CN', NET_SSH2_MSG_CHANNEL_EOF, $this->server_channels[$client_channel])); @@ -4057,8 +4059,8 @@ class SSH2 ) = Strings::unpackSSH2('NNN', $response); if ($window_size < 0) { - $window_size&= 0x7FFFFFFF; - $window_size+= 0x80000000; + $window_size &= 0x7FFFFFFF; + $window_size += 0x80000000; } $this->window_size_client_to_server[$channel] = $window_size; $result = $client_channel == $channel ? true : $this->get_channel_packet($client_channel, $skip_extended); @@ -4126,7 +4128,7 @@ class SSH2 $this->curTimeout = 5; if ($this->bitmap & self::MASK_SHELL) { - $this->bitmap&= ~self::MASK_SHELL; + $this->bitmap &= ~self::MASK_SHELL; } if ($this->channel_status[$channel] != NET_SSH2_MSG_CHANNEL_EOF) { $this->send_binary_packet(pack('CN', NET_SSH2_MSG_CHANNEL_CLOSE, $this->server_channels[$channel])); @@ -4188,17 +4190,17 @@ class SSH2 // 4 (packet length) + 1 (padding length) + 4 (minimal padding amount) == 9 $packet_length = strlen($data) + 9; if ($this->encrypt && $this->encrypt->usesNonce()) { - $packet_length-= 4; + $packet_length -= 4; } // round up to the nearest $this->encrypt_block_size - $packet_length+= (($this->encrypt_block_size - 1) * $packet_length) % $this->encrypt_block_size; + $packet_length += (($this->encrypt_block_size - 1) * $packet_length) % $this->encrypt_block_size; // subtracting strlen($data) is obvious - subtracting 5 is necessary because of packet_length and padding_length $padding_length = $packet_length - strlen($data) - 5; switch (true) { case $this->encrypt && $this->encrypt->usesNonce(): case $this->hmac_create instanceof Hash && $this->hmac_create_etm: - $padding_length+= 4; - $packet_length+= 4; + $padding_length += 4; + $packet_length += 4; } $padding = Random::string($padding_length); @@ -4270,7 +4272,7 @@ class SSH2 $this->send_seq_no++; - $packet.= $this->encrypt && $this->encrypt->usesNonce() ? $this->encrypt->getTag() : $hmac; + $packet .= $this->encrypt && $this->encrypt->usesNonce() ? $this->encrypt->getTag() : $hmac; $start = microtime(true); $sent = @fputs($this->fsock, $packet); @@ -4315,10 +4317,10 @@ class SSH2 // the most useful log for SSH2 case self::LOG_COMPLEX: $this->message_number_log[] = $message_number; - $this->log_size+= strlen($message); + $this->log_size += strlen($message); $this->message_log[] = $message; while ($this->log_size > self::LOG_MAX_SIZE) { - $this->log_size-= strlen(array_shift($this->message_log)); + $this->log_size -= strlen(array_shift($this->message_log)); array_shift($this->message_number_log); } break; @@ -4355,10 +4357,10 @@ class SSH2 $entry = $this->format_log([$message], [$message_number]); if ($this->realtime_log_wrap) { $temp = "<<< START >>>\r\n"; - $entry.= $temp; + $entry .= $temp; fseek($this->realtime_log_file, ftell($this->realtime_log_file) - strlen($temp)); } - $this->realtime_log_size+= strlen($entry); + $this->realtime_log_size += strlen($entry); if ($this->realtime_log_size > self::LOG_MAX_SIZE) { fseek($this->realtime_log_file, 0); $this->realtime_log_size = strlen($entry); @@ -4382,10 +4384,10 @@ class SSH2 { while (strlen($data)) { if (!$this->window_size_client_to_server[$client_channel]) { - $this->bitmap^= self::MASK_WINDOW_ADJUST; + $this->bitmap ^= self::MASK_WINDOW_ADJUST; // using an invalid channel will let the buffers be built up for the valid channels $this->get_channel_packet(-1); - $this->bitmap^= self::MASK_WINDOW_ADJUST; + $this->bitmap ^= self::MASK_WINDOW_ADJUST; } /* The maximum amount of data allowed is determined by the maximum @@ -4404,7 +4406,7 @@ class SSH2 $this->server_channels[$client_channel], $temp ); - $this->window_size_client_to_server[$client_channel]-= strlen($temp); + $this->window_size_client_to_server[$client_channel] -= strlen($temp); $this->send_binary_packet($packet); } @@ -4449,7 +4451,7 @@ class SSH2 } if ($this->bitmap & self::MASK_SHELL) { - $this->bitmap&= ~self::MASK_SHELL; + $this->bitmap &= ~self::MASK_SHELL; } } @@ -4538,12 +4540,12 @@ class SSH2 { $output = ''; for ($i = 0; $i < count($message_log); $i++) { - $output.= $message_number_log[$i] . "\r\n"; + $output .= $message_number_log[$i] . "\r\n"; $current_log = $message_log[$i]; $j = 0; do { if (strlen($current_log)) { - $output.= str_pad(dechex($j), 7, '0', STR_PAD_LEFT) . '0 '; + $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', function ($matches) { @@ -4553,10 +4555,10 @@ class SSH2 // http://en.wikipedia.org/wiki/ASCII#ASCII_printable_characters // also replace < with a . since < messes up the output on web browsers $raw = preg_replace('#[^\x20-\x7E]|<#', '.', $fragment); - $output.= str_pad($hex, $this->log_long_width - $this->log_short_width, ' ') . $raw . "\r\n"; + $output .= str_pad($hex, $this->log_long_width - $this->log_short_width, ' ') . $raw . "\r\n"; $j++; } while (strlen($current_log)); - $output.= "\r\n"; + $output .= "\r\n"; } return $output; @@ -5232,7 +5234,7 @@ class SSH2 return self::$connections; } $temp = []; - foreach (self::$connections as $key=>$ref) { + foreach (self::$connections as $key => $ref) { $temp[$key] = $ref->get(); } return $temp; diff --git a/phpseclib/System/SSH/Agent.php b/phpseclib/System/SSH/Agent.php index 07666bbb..8b412f0f 100644 --- a/phpseclib/System/SSH/Agent.php +++ b/phpseclib/System/SSH/Agent.php @@ -192,7 +192,7 @@ class Agent case 'ecdsa-sha2-nistp256': case 'ecdsa-sha2-nistp384': case 'ecdsa-sha2-nistp521': - $key = PublicKeyLoader::load($key_type . ' ' . base64_encode($key_blob)); + $key = PublicKeyLoader::load($key_type . ' ' . base64_encode($key_blob)); } // resources are passed by reference by default if (isset($key)) { @@ -267,7 +267,7 @@ class Agent public function forwardData($data) { if ($this->expected_bytes > 0) { - $this->socket_buffer.= $data; + $this->socket_buffer .= $data; $this->expected_bytes -= strlen($data); } else { $agent_data_bytes = current(unpack('N', $data)); diff --git a/phpseclib/bootstrap.php b/phpseclib/bootstrap.php index 5829d328..517106c3 100644 --- a/phpseclib/bootstrap.php +++ b/phpseclib/bootstrap.php @@ -9,6 +9,7 @@ * * @license http://www.opensource.org/licenses/mit-license.html MIT License */ + if (extension_loaded('mbstring')) { // 2 - MB_OVERLOAD_STRING // mbstring.func_overload is deprecated in php 7.2 and removed in php 8.0. diff --git a/tests/Functional/Net/SFTPUserStoryTest.php b/tests/Functional/Net/SFTPUserStoryTest.php index 56b2809a..d1a9f991 100644 --- a/tests/Functional/Net/SFTPUserStoryTest.php +++ b/tests/Functional/Net/SFTPUserStoryTest.php @@ -10,10 +10,10 @@ use phpseclib3\Net\SFTP; class Functional_Net_SFTPUserStoryTest extends PhpseclibFunctionalTestCase { - static protected $scratchDir; - static protected $exampleData; - static protected $exampleDataLength; - static protected $buffer; + protected static $scratchDir; + protected static $exampleData; + protected static $exampleDataLength; + protected static $buffer; public static function setUpBeforeClass() { @@ -135,7 +135,7 @@ class Functional_Net_SFTPUserStoryTest extends PhpseclibFunctionalTestCase return $sftp; } - static function demoCallback($length) + public static function demoCallback($length) { $r = substr(self::$buffer, 0, $length); self::$buffer = substr(self::$buffer, $length); @@ -486,6 +486,7 @@ class Functional_Net_SFTPUserStoryTest extends PhpseclibFunctionalTestCase /** * on older versions this would result in a fatal error + * * @depends testStatOnCWD * @group github402 */ @@ -764,7 +765,14 @@ class Functional_Net_SFTPUserStoryTest extends PhpseclibFunctionalTestCase $list_cache_disabled = $sftp->rawlist('.', true); - $this->assertEquals($list_cache_enabled, $list_cache_disabled, 'The files should be the same regardless of stat cache', 0.0, 10, true); + $this->assertEquals( + $list_cache_enabled, + $list_cache_disabled, + 'The files should be the same regardless of stat cache', + 0.0, + 10, + true + ); return $sftp; } diff --git a/tests/Functional/Net/SFTPWrongServerTest.php b/tests/Functional/Net/SFTPWrongServerTest.php index f1287028..c9fd53e5 100644 --- a/tests/Functional/Net/SFTPWrongServerTest.php +++ b/tests/Functional/Net/SFTPWrongServerTest.php @@ -14,8 +14,8 @@ class SFTPWrongServerTest extends TestCase } catch (UnableToConnectException $e) { // getaddrinfo message seems not to return stable text static::assertSame( - 'Cannot connect to dummy-server:22. Error 0. php_network_getaddresses: getaddrinfo', - substr($e->getMessage(),0,81) + 'Cannot connect to dummy-server:22. Error 0. php_network_getaddresses: getaddrinfo', + substr($e->getMessage(), 0, 81) ); } } diff --git a/tests/Functional/Net/SSH2AgentTest.php b/tests/Functional/Net/SSH2AgentTest.php index 99aaa95a..178d7f8d 100644 --- a/tests/Functional/Net/SSH2AgentTest.php +++ b/tests/Functional/Net/SSH2AgentTest.php @@ -24,7 +24,7 @@ class Functional_Net_SSH2AgentTest extends PhpseclibFunctionalTestCase public function testAgentLogin() { $ssh = new SSH2($this->getEnv('SSH_HOSTNAME')); - $agent = new Agent; + $agent = new Agent(); $this->assertTrue( $ssh->login($this->getEnv('SSH_USERNAME'), $agent), diff --git a/tests/PhpseclibFunctionalTestCase.php b/tests/PhpseclibFunctionalTestCase.php index b49aebdb..f9f18516 100644 --- a/tests/PhpseclibFunctionalTestCase.php +++ b/tests/PhpseclibFunctionalTestCase.php @@ -1,4 +1,5 @@ * @copyright 2014 Andreas Fischer diff --git a/tests/PhpseclibTestCase.php b/tests/PhpseclibTestCase.php index 3eaff1c7..31e8f609 100644 --- a/tests/PhpseclibTestCase.php +++ b/tests/PhpseclibTestCase.php @@ -1,4 +1,5 @@ * @copyright 2013 Andreas Fischer diff --git a/tests/Unit/Crypt/AES/EvalTest.php b/tests/Unit/Crypt/AES/EvalTest.php index 9426a995..dff0ef34 100644 --- a/tests/Unit/Crypt/AES/EvalTest.php +++ b/tests/Unit/Crypt/AES/EvalTest.php @@ -1,4 +1,5 @@ * @copyright 2013 Andreas Fischer diff --git a/tests/Unit/Crypt/AES/McryptTest.php b/tests/Unit/Crypt/AES/McryptTest.php index e1b981ed..b6fa1f14 100644 --- a/tests/Unit/Crypt/AES/McryptTest.php +++ b/tests/Unit/Crypt/AES/McryptTest.php @@ -1,4 +1,5 @@ * @copyright 2013 Andreas Fischer diff --git a/tests/Unit/Crypt/AES/OpenSSLTest.php b/tests/Unit/Crypt/AES/OpenSSLTest.php index fe3a6adf..69e237cb 100644 --- a/tests/Unit/Crypt/AES/OpenSSLTest.php +++ b/tests/Unit/Crypt/AES/OpenSSLTest.php @@ -1,4 +1,5 @@ * @copyright 2013 Andreas Fischer diff --git a/tests/Unit/Crypt/AES/PurePHPTest.php b/tests/Unit/Crypt/AES/PurePHPTest.php index 27e5f5b2..f5433b16 100644 --- a/tests/Unit/Crypt/AES/PurePHPTest.php +++ b/tests/Unit/Crypt/AES/PurePHPTest.php @@ -1,4 +1,5 @@ * @copyright 2013 Andreas Fischer diff --git a/tests/Unit/Crypt/AES/TestCase.php b/tests/Unit/Crypt/AES/TestCase.php index 46164418..ba29648a 100644 --- a/tests/Unit/Crypt/AES/TestCase.php +++ b/tests/Unit/Crypt/AES/TestCase.php @@ -1,4 +1,5 @@ * @copyright 2013 Andreas Fischer @@ -188,7 +189,7 @@ abstract class Unit_Crypt_AES_TestCase extends PhpseclibTestCase $result = ''; foreach ($test as $len) { $temp = str_repeat('d', $len); - $str.= $temp; + $str .= $temp; } $c1 = $aes->$op($str); @@ -204,7 +205,7 @@ abstract class Unit_Crypt_AES_TestCase extends PhpseclibTestCase foreach ($test as $len) { $temp = str_repeat('d', $len); $output = $aes->$op($temp); - $result.= $output; + $result .= $output; } $c2 = $result; @@ -237,7 +238,7 @@ abstract class Unit_Crypt_AES_TestCase extends PhpseclibTestCase $result = ''; foreach ($test as $len) { $temp = str_repeat('d', $len); - $str.= $temp; + $str .= $temp; } $c1 = $aes->$op($str); @@ -252,7 +253,7 @@ abstract class Unit_Crypt_AES_TestCase extends PhpseclibTestCase foreach ($test as $len) { $temp = str_repeat('d', $len); $output = $aes->$op($temp); - $result.= $output; + $result .= $output; } $c2 = $result; diff --git a/tests/Unit/Crypt/BlowfishTest.php b/tests/Unit/Crypt/BlowfishTest.php index 5289c67f..bb496698 100644 --- a/tests/Unit/Crypt/BlowfishTest.php +++ b/tests/Unit/Crypt/BlowfishTest.php @@ -1,4 +1,5 @@ * @copyright MMXIII Andreas Fischer diff --git a/tests/Unit/Crypt/ChaCha20Test.php b/tests/Unit/Crypt/ChaCha20Test.php index ab5c784b..676807c2 100644 --- a/tests/Unit/Crypt/ChaCha20Test.php +++ b/tests/Unit/Crypt/ChaCha20Test.php @@ -1,4 +1,5 @@ * @copyright 2014 Jim Wigginton @@ -92,7 +93,7 @@ class Unit_Crypt_ChaCha20Test extends PhpseclibTestCase $expected = str_replace(':', '', $expected); $expected = pack('H*', $expected); - $c = new ChaCha20; + $c = new ChaCha20(); $c->setPoly1305Key($key); $r = new \ReflectionClass(get_class($c)); // this unit test is testing Poly1305 independent of ChaCha20, which phpseclib doesn't @@ -209,7 +210,7 @@ class Unit_Crypt_ChaCha20Test extends PhpseclibTestCase $p1 = $c->encrypt($plaintext); $p2 = ''; foreach ($partitions as $partition) { - $p2.= $c2->encrypt(str_repeat("\0", $partition)); + $p2 .= $c2->encrypt(str_repeat("\0", $partition)); } $this->assertSame($p1, $p2, "Failed asserting that ciphertext matches expected value with $engine engine"); diff --git a/tests/Unit/Crypt/DHTest.php b/tests/Unit/Crypt/DHTest.php index 71314b74..d3025dcf 100644 --- a/tests/Unit/Crypt/DHTest.php +++ b/tests/Unit/Crypt/DHTest.php @@ -1,4 +1,5 @@ * @copyright 2013 Andreas Fischer @@ -231,11 +232,13 @@ Q3ADAIcv9LEmTBnSAOsCs1K9ExAmSv/T2/4+9dW28UYb+p/uV477d1wf+nCWS6VU { // utilizing test vector from https://tools.ietf.org/html/rfc7748#section-6.2 - $alicePrivate = EC::loadFormat('MontgomeryPrivate', pack('H*', + $alicePrivate = EC::loadFormat('MontgomeryPrivate', pack( + 'H*', '9a8f4925d1519f5775cf46b04b5800d4ee9ee8bae8bc5565d498c28d' . 'd9c9baf574a9419744897391006382a6f127ab1d9ac2d8c0a598726b' )); - $bobPrivate = EC::loadFormat('MontgomeryPrivate', pack('H*', + $bobPrivate = EC::loadFormat('MontgomeryPrivate', pack( + 'H*', '1c306a7ac2a0e2e0990b294470cba339e6453772b075811d8fad0d1d' . '6927c120bb5ee8972b0d3e21374c9c921b09d1b0366f10b65173992d' )); @@ -255,7 +258,8 @@ Q3ADAIcv9LEmTBnSAOsCs1K9ExAmSv/T2/4+9dW28UYb+p/uV477d1wf+nCWS6VU bin2hex($bobPublic->toString('MontgomeryPublic')) ); - $expected = pack('H*', + $expected = pack( + 'H*', '07fff4181ac6cc95ec1c16a94a0f74d12da232ce40a77552281d282b' . 'b60c0b56fd2464c335543936521c24403085d59a449a5037514a879d' ); diff --git a/tests/Unit/Crypt/DSA/LoadDSAKeyTest.php b/tests/Unit/Crypt/DSA/LoadDSAKeyTest.php index 53ecf568..f851775f 100644 --- a/tests/Unit/Crypt/DSA/LoadDSAKeyTest.php +++ b/tests/Unit/Crypt/DSA/LoadDSAKeyTest.php @@ -1,4 +1,5 @@ * @copyright 2013 Jim Wigginton diff --git a/tests/Unit/Crypt/EC/CurveTest.php b/tests/Unit/Crypt/EC/CurveTest.php index e43a4f7a..de89e769 100644 --- a/tests/Unit/Crypt/EC/CurveTest.php +++ b/tests/Unit/Crypt/EC/CurveTest.php @@ -114,7 +114,7 @@ class Unit_Crypt_EC_CurveTest extends PhpseclibTestCase public function testBasePoint($name) { $class = 'phpseclib3\Crypt\EC\Curves\\' . $name; - $curve = new $class; + $curve = new $class(); $this->assertTrue($curve->verifyPoint($curve->getBasePoint()), "Failed to verify basepoint of curve $name"); } @@ -127,7 +127,7 @@ class Unit_Crypt_EC_CurveTest extends PhpseclibTestCase public function testKeyGeneration($name) { $class = 'phpseclib3\Crypt\EC\Curves\\' . $name; - $curve = new $class; + $curve = new $class(); $dA = $curve->createRandomMultiplier(); $QA = $curve->multiplyPoint($curve->getBasePoint(), $dA); $this->assertTrue($curve->verifyPoint($QA), "Failed to verify point multiplication on curve $name with $dA"); diff --git a/tests/Unit/Crypt/EC/KeyTest.php b/tests/Unit/Crypt/EC/KeyTest.php index cbe96a09..3e8c31c8 100644 --- a/tests/Unit/Crypt/EC/KeyTest.php +++ b/tests/Unit/Crypt/EC/KeyTest.php @@ -1,4 +1,5 @@ * @copyright 2013 Jim Wigginton @@ -348,7 +349,6 @@ Private-MAC: 97a990a3d5f6b8f268d4be9c4ab9ebfd8fa79849 OpenSSH::setComment('ecdsa-key-20181105'); $this->assertSameNL($expected, $key->toString('OpenSSH')); - } public function testPuTTYnistp521() diff --git a/tests/Unit/Crypt/GCMTest.php b/tests/Unit/Crypt/GCMTest.php index 090f2152..dc83efcd 100644 --- a/tests/Unit/Crypt/GCMTest.php +++ b/tests/Unit/Crypt/GCMTest.php @@ -1,4 +1,5 @@ * @copyright 2013 Andreas Fischer diff --git a/tests/Unit/Crypt/HashTest.php b/tests/Unit/Crypt/HashTest.php index 84c1b924..f31fef71 100644 --- a/tests/Unit/Crypt/HashTest.php +++ b/tests/Unit/Crypt/HashTest.php @@ -1,4 +1,5 @@ * @copyright 2012 Andreas Fischer diff --git a/tests/Unit/Crypt/RC2Test.php b/tests/Unit/Crypt/RC2Test.php index bd1ed161..0e99ce0f 100644 --- a/tests/Unit/Crypt/RC2Test.php +++ b/tests/Unit/Crypt/RC2Test.php @@ -1,4 +1,5 @@ * @copyright MMXIII Andreas Fischer @@ -9,7 +10,7 @@ use phpseclib3\Crypt\RC2; class Unit_Crypt_RC2Test extends PhpseclibTestCase { - var $engines = [ + public $engines = [ 'PHP', 'Eval', 'mcrypt', @@ -99,7 +100,7 @@ class Unit_Crypt_RC2Test extends PhpseclibTestCase $rc2->setPreferredEngine('OpenSSL'); if ($rc2->getEngine() == 'OpenSSL') { $openssl = $rc2->encrypt('d'); - $this->assertEquals($result, $openssl, 'Failed asserting that the OpenSSL engine produced the correct result'); + $this->assertEquals($result, $openssl, 'Failed asserting that the OpenSSL engine produced the correct result'); } else { self::markTestSkipped('Unable to initialize OpenSSL engine'); } diff --git a/tests/Unit/Crypt/RC4Test.php b/tests/Unit/Crypt/RC4Test.php index e634afcd..5cbc9d88 100644 --- a/tests/Unit/Crypt/RC4Test.php +++ b/tests/Unit/Crypt/RC4Test.php @@ -1,4 +1,5 @@ * @copyright 2014 Jim Wigginton diff --git a/tests/Unit/Crypt/RSA/LoadKeyTest.php b/tests/Unit/Crypt/RSA/LoadKeyTest.php index 756ab090..8f471aed 100644 --- a/tests/Unit/Crypt/RSA/LoadKeyTest.php +++ b/tests/Unit/Crypt/RSA/LoadKeyTest.php @@ -1,4 +1,5 @@ * @copyright 2013 Jim Wigginton @@ -335,11 +336,11 @@ Ao8eayMp6FcvNucIpUndo1X8dKMv3Y26ZQIDAQAB public function testSSHPubKeyFingerprint() { - $key = 'ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQD9K+ebJRMN10kGanhi6kDz6EYFqZttZWZh0'. - 'YoEbIbbere9N2Yvfc7oIoCTHYowhXND9WSJaIs1E4bx0085CZnofWaqf4NbZTzAh18iZup08ec'. - 'COB5gJVS1efpgVSviDF2L7jxMsBVoOBfqsmA8m0RwDDVezyWvw4y+STSuVzu2jI8EfwN7ZFGC6'. - 'Yo8m/Z94qIGzqPYGKJLuCeidB0TnUE0ZtzOJTiOc/WoTm/NOpCdfQZEJggd1MOTi+QUnqRu4Wu'. - 'b6wYtY/q/WtUFr3nK+x0lgOtokhnJfRR/6fnmC1CztPnIT4BWK81VGKWONAxuhMyQ5XChyu6S9'. + $key = 'ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQD9K+ebJRMN10kGanhi6kDz6EYFqZttZWZh0' . + 'YoEbIbbere9N2Yvfc7oIoCTHYowhXND9WSJaIs1E4bx0085CZnofWaqf4NbZTzAh18iZup08ec' . + 'COB5gJVS1efpgVSviDF2L7jxMsBVoOBfqsmA8m0RwDDVezyWvw4y+STSuVzu2jI8EfwN7ZFGC6' . + 'Yo8m/Z94qIGzqPYGKJLuCeidB0TnUE0ZtzOJTiOc/WoTm/NOpCdfQZEJggd1MOTi+QUnqRu4Wu' . + 'b6wYtY/q/WtUFr3nK+x0lgOtokhnJfRR/6fnmC1CztPnIT4BWK81VGKWONAxuhMyQ5XChyu6S9' . 'mWG5tUlUI/5'; $rsa = PublicKeyLoader::load($key, 'password'); @@ -997,8 +998,8 @@ IBgv3a3Lyb+IQtT75LE1yjE= $key = $rsa->toString('PSS'); $r2 = PSS::load($key); - $this->assertSame($r['hash'], $r2['hash']); - $this->assertSame($r['MGFHash'], $r2['MGFHash']); + $this->assertSame($r['hash'], $r2['hash']); + $this->assertSame($r['MGFHash'], $r2['MGFHash']); $this->assertSame($r['saltLength'], $r2['saltLength']); } diff --git a/tests/Unit/Crypt/RSA/ModeTest.php b/tests/Unit/Crypt/RSA/ModeTest.php index c7ec8dcb..e4b6d9e0 100644 --- a/tests/Unit/Crypt/RSA/ModeTest.php +++ b/tests/Unit/Crypt/RSA/ModeTest.php @@ -1,4 +1,5 @@ * @copyright 2013 Jim Wigginton diff --git a/tests/Unit/Crypt/RandomTest.php b/tests/Unit/Crypt/RandomTest.php index 5385826c..daf130f1 100644 --- a/tests/Unit/Crypt/RandomTest.php +++ b/tests/Unit/Crypt/RandomTest.php @@ -1,4 +1,5 @@ * @copyright 2014 Andreas Fischer diff --git a/tests/Unit/Crypt/Salsa20Test.php b/tests/Unit/Crypt/Salsa20Test.php index 81d7570c..debbb143 100644 --- a/tests/Unit/Crypt/Salsa20Test.php +++ b/tests/Unit/Crypt/Salsa20Test.php @@ -1,4 +1,5 @@ * @copyright 2014 Jim Wigginton diff --git a/tests/Unit/Crypt/TripleDESTest.php b/tests/Unit/Crypt/TripleDESTest.php index 252af485..0e5e49e3 100644 --- a/tests/Unit/Crypt/TripleDESTest.php +++ b/tests/Unit/Crypt/TripleDESTest.php @@ -1,4 +1,5 @@ * @copyright 2014 Jim Wigginton @@ -9,7 +10,7 @@ use phpseclib3\Crypt\TripleDES; class Unit_Crypt_TripleDESTest extends PhpseclibTestCase { - var $engines = [ + public $engines = [ 'PHP', 'Eval', 'mcrypt', diff --git a/tests/Unit/Crypt/TwofishTest.php b/tests/Unit/Crypt/TwofishTest.php index e9f3f78d..677fb9d0 100644 --- a/tests/Unit/Crypt/TwofishTest.php +++ b/tests/Unit/Crypt/TwofishTest.php @@ -1,4 +1,5 @@ * @copyright MMXIII Andreas Fischer diff --git a/tests/Unit/File/ANSITest.php b/tests/Unit/File/ANSITest.php index 0cc4a029..0d2eb144 100644 --- a/tests/Unit/File/ANSITest.php +++ b/tests/Unit/File/ANSITest.php @@ -1,4 +1,5 @@ * @copyright 2014 Jim Wigginton @@ -12,19 +13,19 @@ class Unit_File_ANSITest extends PhpseclibTestCase public function testCase1() { $str = "\x1B[07m"; // turn reverse video on - $str.= "aaaaaaaaaaaaaaaaaa"; - $str.= "\x1B[10D"; // move cursor left 10 lines - $str.= "\x1B[m"; // reset everything - $str.= "bbb"; + $str .= "aaaaaaaaaaaaaaaaaa"; + $str .= "\x1B[10D"; // move cursor left 10 lines + $str .= "\x1B[m"; // reset everything + $str .= "bbb"; $ansi = new ANSI(); $ansi->appendString($str); $expected = '
';
-        $expected.= 'aaaaaaaa';
-        $expected.= 'bbb';
-        $expected.= 'aaaaaaa';
-        $expected.= '
'; + $expected .= 'aaaaaaaa'; + $expected .= 'bbb'; + $expected .= 'aaaaaaa'; + $expected .= ''; $this->assertSame($ansi->getScreen(), $expected); } @@ -32,15 +33,15 @@ class Unit_File_ANSITest extends PhpseclibTestCase public function testCaseJ() { $str = "\x1B[H"; // Move cursor to upper left corner - $str.= "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"; - $str.= "\x1B[H"; // Move cursor to upper left corner - $str.= "\x1B[J"; // Clear screen from cursor down + $str .= "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"; + $str .= "\x1B[H"; // Move cursor to upper left corner + $str .= "\x1B[J"; // Clear screen from cursor down $ansi = new ANSI(); $ansi->appendString($str); $expected = '
';
-        $expected.= '
'; + $expected .= ''; $this->assertSame($ansi->getScreen(), $expected); } @@ -49,9 +50,9 @@ class Unit_File_ANSITest extends PhpseclibTestCase { $str = ''; foreach (range('a', 'y') as $char) { - $str.= "$char\r\n"; + $str .= "$char\r\n"; } - $str.= str_repeat('z', 100); + $str .= str_repeat('z', 100); $ansi = new ANSI(); $ansi->appendString($str); diff --git a/tests/Unit/File/ASN1Test.php b/tests/Unit/File/ASN1Test.php index 1d5b6161..7e080a99 100644 --- a/tests/Unit/File/ASN1Test.php +++ b/tests/Unit/File/ASN1Test.php @@ -1,4 +1,5 @@ * @copyright 2014 Jim Wigginton diff --git a/tests/Unit/File/X509/CRLTest.php b/tests/Unit/File/X509/CRLTest.php index 12ff839f..0a7d9e81 100644 --- a/tests/Unit/File/X509/CRLTest.php +++ b/tests/Unit/File/X509/CRLTest.php @@ -1,4 +1,5 @@ * @copyright 2017 Jim Wigginton diff --git a/tests/Unit/File/X509/CSRTest.php b/tests/Unit/File/X509/CSRTest.php index d3a14ab3..8c9a1c99 100644 --- a/tests/Unit/File/X509/CSRTest.php +++ b/tests/Unit/File/X509/CSRTest.php @@ -1,4 +1,5 @@ * @copyright 2014 Jim Wigginton @@ -130,7 +131,7 @@ U9VQQSQzY1oZMVX8i1m5WUTLPz2yLJIBQVdXqhMCQBGoiuSoSjafUhV7i1cEGpb88h5NBYZzWXGZ */ public function testPKCS1CSR() { - $x509 = new X509; + $x509 = new X509(); $x509->loadCSR('-----BEGIN CERTIFICATE REQUEST----- MIICijCCAXICAQAwRTELMAkGA1UEBhMCQVUxEzARBgNVBAgMClNvbWUtU3RhdGUx ITAfBgNVBAoMGEludGVybmV0IFdpZGdpdHMgUHR5IEx0ZDCCASIwDQYJKoZIhvcN @@ -156,7 +157,7 @@ fUQvcGEA9FSQ8Y0nfF9vzzcCjLtOI6xJluYL9XCk8WVEBEawA2zmHWTzzuHFHHEM */ public function testPSSCSR() { - $x509 = new X509; + $x509 = new X509(); $x509->loadCSR('-----BEGIN CERTIFICATE REQUEST----- MIICuTCCAXACAQAwRTELMAkGA1UEBhMCQVUxEzARBgNVBAgMClNvbWUtU3RhdGUx ITAfBgNVBAoMGEludGVybmV0IFdpZGdpdHMgUHR5IEx0ZDCCASAwCwYJKoZIhvcN diff --git a/tests/Unit/File/X509/SPKACTest.php b/tests/Unit/File/X509/SPKACTest.php index bf49fd37..46c09010 100644 --- a/tests/Unit/File/X509/SPKACTest.php +++ b/tests/Unit/File/X509/SPKACTest.php @@ -1,4 +1,5 @@ * @copyright 2014 Jim Wigginton diff --git a/tests/Unit/File/X509/X509ExtensionTest.php b/tests/Unit/File/X509/X509ExtensionTest.php index 74a062db..0c2a00d0 100644 --- a/tests/Unit/File/X509/X509ExtensionTest.php +++ b/tests/Unit/File/X509/X509ExtensionTest.php @@ -1,4 +1,5 @@ * @copyright 2014 Jim Wigginton diff --git a/tests/Unit/File/X509/X509Test.php b/tests/Unit/File/X509/X509Test.php index eb1318b2..95934095 100644 --- a/tests/Unit/File/X509/X509Test.php +++ b/tests/Unit/File/X509/X509Test.php @@ -1,4 +1,5 @@ * @copyright 2014 Jim Wigginton @@ -137,7 +138,7 @@ IOkKcGQRCMha8X2e7GmlpdWC1ycenlbN0nbVeSv3JUMcafC4+Q== $value = ASN1::encodeOID('1.2.3.4'); $ext = chr(ASN1::TYPE_OBJECT_IDENTIFIER) . ASN1::encodeLength(strlen($value)) . $value; $value = 'zzzzzzzzz'; - $ext.= chr(ASN1::TYPE_OCTET_STRING) . ASN1::encodeLength(strlen($value)) . $value; + $ext .= chr(ASN1::TYPE_OCTET_STRING) . ASN1::encodeLength(strlen($value)) . $value; $ext = chr(ASN1::TYPE_SEQUENCE | 0x20) . ASN1::encodeLength(strlen($ext)) . $ext; $cert['tbsCertificate']['extensions'][4] = new Element($ext); @@ -1189,7 +1190,7 @@ qzFkAKWjJj4KjfrbZX4C0Spfxw== $key = ASN1::encodeDER($key, ['type' => ASN1::TYPE_BIT_STRING]); $key = new Element($key); - $x509 = new X509; + $x509 = new X509(); $this->assertIsString($x509->computeKeyIdentifier($key)); } @@ -1241,15 +1242,15 @@ QwinX0cR9Hx84rSMrFndxZi52o9EOLJ7cithncoW1KOAf7lIJIUzP0oIKkskAndQ o2UiZsxgoMYuq02T07DOknc= -----END ENCRYPTED PRIVATE KEY-----', 'demo'); - $subject = new X509; + $subject = new X509(); $subject->setDNProp('id-at-organizationName', 'phpseclib demo cert'); $subject->setPublicKey($private->getPublicKey()); - $issuer = new X509; + $issuer = new X509(); $issuer->setPrivateKey($private); $issuer->setDNProp('id-at-organizationName', 'phpseclib CA cert'); - $x509 = new X509; + $x509 = new X509(); $x509->sign($issuer, $subject); } diff --git a/tests/Unit/Math/BigInteger/BCMathTest.php b/tests/Unit/Math/BigInteger/BCMathTest.php index 5870a3f3..15d2312a 100644 --- a/tests/Unit/Math/BigInteger/BCMathTest.php +++ b/tests/Unit/Math/BigInteger/BCMathTest.php @@ -1,4 +1,5 @@ * @copyright 2013 Andreas Fischer diff --git a/tests/Unit/Math/BigInteger/DefaultTest.php b/tests/Unit/Math/BigInteger/DefaultTest.php index 868e6b2a..627577ad 100644 --- a/tests/Unit/Math/BigInteger/DefaultTest.php +++ b/tests/Unit/Math/BigInteger/DefaultTest.php @@ -1,4 +1,5 @@ * @copyright 2013 Andreas Fischer diff --git a/tests/Unit/Math/BigInteger/GMPTest.php b/tests/Unit/Math/BigInteger/GMPTest.php index a10c6a9f..8668adb0 100644 --- a/tests/Unit/Math/BigInteger/GMPTest.php +++ b/tests/Unit/Math/BigInteger/GMPTest.php @@ -1,4 +1,5 @@ * @copyright 2013 Andreas Fischer diff --git a/tests/Unit/Math/BigInteger/PHP32Test.php b/tests/Unit/Math/BigInteger/PHP32Test.php index 584ef584..d85814cb 100644 --- a/tests/Unit/Math/BigInteger/PHP32Test.php +++ b/tests/Unit/Math/BigInteger/PHP32Test.php @@ -1,4 +1,5 @@ * @copyright 2013 Andreas Fischer diff --git a/tests/Unit/Math/BigInteger/PHP64OpenSSLTest.php b/tests/Unit/Math/BigInteger/PHP64OpenSSLTest.php index f9828f60..1171d0e7 100644 --- a/tests/Unit/Math/BigInteger/PHP64OpenSSLTest.php +++ b/tests/Unit/Math/BigInteger/PHP64OpenSSLTest.php @@ -1,4 +1,5 @@ * @copyright 2013 Andreas Fischer diff --git a/tests/Unit/Math/BigInteger/PHP64Test.php b/tests/Unit/Math/BigInteger/PHP64Test.php index 5caa1588..b0999866 100644 --- a/tests/Unit/Math/BigInteger/PHP64Test.php +++ b/tests/Unit/Math/BigInteger/PHP64Test.php @@ -1,4 +1,5 @@ * @copyright 2013 Andreas Fischer diff --git a/tests/Unit/Math/BigInteger/TestCase.php b/tests/Unit/Math/BigInteger/TestCase.php index bf2db6f4..3de0ce4a 100644 --- a/tests/Unit/Math/BigInteger/TestCase.php +++ b/tests/Unit/Math/BigInteger/TestCase.php @@ -1,4 +1,5 @@ * @copyright 2012 Andreas Fischer @@ -20,15 +21,15 @@ abstract class Unit_Math_BigInteger_TestCase extends PhpseclibTestCase public function testConstructorBase16() { - $this->assertSame('50', (string) $this->getInstance('0x32', 16)); - $this->assertSame('12345678910', (string) $this->getInstance('0x2DFDC1C3E', 16)); - $this->assertSame('18446744073709551615', (string) $this->getInstance('0xFFFFFFFFFFFFFFFF', 16)); - $this->assertSame('18446744073709551616', (string) $this->getInstance('0x10000000000000000', 16)); + $this->assertSame('50', (string) $this->getInstance('0x32', 16)); + $this->assertSame('12345678910', (string) $this->getInstance('0x2DFDC1C3E', 16)); + $this->assertSame('18446744073709551615', (string) $this->getInstance('0xFFFFFFFFFFFFFFFF', 16)); + $this->assertSame('18446744073709551616', (string) $this->getInstance('0x10000000000000000', 16)); } public function testConstructorBase256() { - $this->assertSame('-128', (string) $this->getInstance("\x80", -256)); + $this->assertSame('-128', (string) $this->getInstance("\x80", -256)); } public function testToBytes() diff --git a/tests/Unit/Math/BigIntegerTest.php b/tests/Unit/Math/BigIntegerTest.php index ee84d3a0..a79acaa3 100644 --- a/tests/Unit/Math/BigIntegerTest.php +++ b/tests/Unit/Math/BigIntegerTest.php @@ -8,13 +8,13 @@ use phpseclib3\Math\BigInteger\Engines\PHP64; class Unit_Math_BigIntegerTest extends PhpseclibTestCase { - - /** - * @param string $className - * @param bool $isValid - */ - private static function mockEngine($className, $isValid) { - eval(<<toString()); - } + static::assertSame($expectedEngineClass, $bigint->toString()); + } } diff --git a/tests/Unit/Net/SFTPStreamUnitTest.php b/tests/Unit/Net/SFTPStreamUnitTest.php index 2aa7ab21..eea7a3d3 100644 --- a/tests/Unit/Net/SFTPStreamUnitTest.php +++ b/tests/Unit/Net/SFTPStreamUnitTest.php @@ -1,4 +1,5 @@ * @copyright 2014 Andreas Fischer diff --git a/tests/bootstrap.php b/tests/bootstrap.php index bb137e4d..843a7310 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -1,4 +1,5 @@ Date: Sat, 19 Feb 2022 17:19:08 -0600 Subject: [PATCH 2/3] CS adjustments --- phpseclib/Crypt/Common/Formats/Keys/PuTTY.php | 4 ++-- phpseclib/Net/SFTP.php | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/phpseclib/Crypt/Common/Formats/Keys/PuTTY.php b/phpseclib/Crypt/Common/Formats/Keys/PuTTY.php index c4d59daf..086c0cb2 100644 --- a/phpseclib/Crypt/Common/Formats/Keys/PuTTY.php +++ b/phpseclib/Crypt/Common/Formats/Keys/PuTTY.php @@ -119,7 +119,7 @@ abstract class PuTTY $flavour = SODIUM_CRYPTO_PWHASH_ALG_ARGON2ID13; break; default: - throw new UnsupportedAlgorithmException('Only Argon2i and Argon2id are supported'); + throw new UnsupportedAlgorithmException('Only Argon2i and Argon2id are supported'); } $length = 80; // keylen + ivlen + mac_keylen @@ -181,7 +181,7 @@ abstract class PuTTY if ($components === false) { throw new \UnexpectedValueException('Unable to decode public key'); } - $components+= $values; + $components += $values; $components['comment'] = str_replace(['\\\\', '\"'], ['\\', '"'], $values['comment']); return $components; diff --git a/phpseclib/Net/SFTP.php b/phpseclib/Net/SFTP.php index b70073bd..b7053c65 100644 --- a/phpseclib/Net/SFTP.php +++ b/phpseclib/Net/SFTP.php @@ -381,13 +381,13 @@ class SFTP extends SSH2 20 => 'NET_SFTP_SYMLINK', 21 => 'NET_SFTP_LINK', - 101=> 'NET_SFTP_STATUS', - 102=> 'NET_SFTP_HANDLE', - 103=> 'NET_SFTP_DATA', - 104=> 'NET_SFTP_NAME', - 105=> 'NET_SFTP_ATTRS', + 101 => 'NET_SFTP_STATUS', + 102 => 'NET_SFTP_HANDLE', + 103 => 'NET_SFTP_DATA', + 104 => 'NET_SFTP_NAME', + 105 => 'NET_SFTP_ATTRS', - 200=> 'NET_SFTP_EXTENDED' + 200 => 'NET_SFTP_EXTENDED' ]; $this->status_codes = [ 0 => 'NET_SFTP_STATUS_OK', From f2e9dd993d9131e570f54ba9f6c38a39db11aaba Mon Sep 17 00:00:00 2001 From: terrafrost Date: Sat, 19 Feb 2022 17:33:15 -0600 Subject: [PATCH 3/3] ChaCha20: ignore coding standards --- phpseclib/Crypt/ChaCha20.php | 979 ++++++++++++----------------------- 1 file changed, 331 insertions(+), 648 deletions(-) diff --git a/phpseclib/Crypt/ChaCha20.php b/phpseclib/Crypt/ChaCha20.php index dc77136b..357edf44 100644 --- a/phpseclib/Crypt/ChaCha20.php +++ b/phpseclib/Crypt/ChaCha20.php @@ -280,14 +280,15 @@ class ChaCha20 extends Salsa20 */ protected static function quarterRound(&$a, &$b, &$c, &$d) { - $a += $b; - $d = self::leftRotate($d ^ $a, 16); - $c += $d; - $b = self::leftRotate($b ^ $c, 12); - $a += $b; - $d = self::leftRotate($d ^ $a, 8); - $c += $d; - $b = self::leftRotate($b ^ $c, 7); + // in https://datatracker.ietf.org/doc/html/rfc7539#section-2.1 the addition, + // xor'ing and rotation are all on the same line so i'm keeping it on the same + // line here as well + // @codingStandardsIgnoreStart + $a+= $b; $d = self::leftRotate($d ^ $a, 16); + $c+= $d; $b = self::leftRotate($b ^ $c, 12); + $a+= $b; $d = self::leftRotate($d ^ $a, 8); + $c+= $d; $b = self::leftRotate($b ^ $c, 7); + // @codingStandardsIgnoreEnd } /** @@ -359,745 +360,427 @@ class ChaCha20 extends Salsa20 $z14 = $x14; $z15 = $x15; + // @codingStandardsIgnoreStart // columnRound - $x0 += $x4; - $x12 = self::leftRotate($x12 ^ $x0, 16); - $x8 += $x12; - $x4 = self::leftRotate($x4 ^ $x8, 12); - $x0 += $x4; - $x12 = self::leftRotate($x12 ^ $x0, 8); - $x8 += $x12; - $x4 = self::leftRotate($x4 ^ $x8, 7); + $x0+= $x4; $x12 = self::leftRotate($x12 ^ $x0, 16); + $x8+= $x12; $x4 = self::leftRotate($x4 ^ $x8, 12); + $x0+= $x4; $x12 = self::leftRotate($x12 ^ $x0, 8); + $x8+= $x12; $x4 = self::leftRotate($x4 ^ $x8, 7); - $x1 += $x5; - $x13 = self::leftRotate($x13 ^ $x1, 16); - $x9 += $x13; - $x5 = self::leftRotate($x5 ^ $x9, 12); - $x1 += $x5; - $x13 = self::leftRotate($x13 ^ $x1, 8); - $x9 += $x13; - $x5 = self::leftRotate($x5 ^ $x9, 7); + $x1+= $x5; $x13 = self::leftRotate($x13 ^ $x1, 16); + $x9+= $x13; $x5 = self::leftRotate($x5 ^ $x9, 12); + $x1+= $x5; $x13 = self::leftRotate($x13 ^ $x1, 8); + $x9+= $x13; $x5 = self::leftRotate($x5 ^ $x9, 7); - $x2 += $x6; - $x14 = self::leftRotate($x14 ^ $x2, 16); - $x10 += $x14; - $x6 = self::leftRotate($x6 ^ $x10, 12); - $x2 += $x6; - $x14 = self::leftRotate($x14 ^ $x2, 8); - $x10 += $x14; - $x6 = self::leftRotate($x6 ^ $x10, 7); + $x2+= $x6; $x14 = self::leftRotate($x14 ^ $x2, 16); + $x10+= $x14; $x6 = self::leftRotate($x6 ^ $x10, 12); + $x2+= $x6; $x14 = self::leftRotate($x14 ^ $x2, 8); + $x10+= $x14; $x6 = self::leftRotate($x6 ^ $x10, 7); - $x3 += $x7; - $x15 = self::leftRotate($x15 ^ $x3, 16); - $x11 += $x15; - $x7 = self::leftRotate($x7 ^ $x11, 12); - $x3 += $x7; - $x15 = self::leftRotate($x15 ^ $x3, 8); - $x11 += $x15; - $x7 = self::leftRotate($x7 ^ $x11, 7); + $x3+= $x7; $x15 = self::leftRotate($x15 ^ $x3, 16); + $x11+= $x15; $x7 = self::leftRotate($x7 ^ $x11, 12); + $x3+= $x7; $x15 = self::leftRotate($x15 ^ $x3, 8); + $x11+= $x15; $x7 = self::leftRotate($x7 ^ $x11, 7); // rowRound - $x0 += $x5; - $x15 = self::leftRotate($x15 ^ $x0, 16); - $x10 += $x15; - $x5 = self::leftRotate($x5 ^ $x10, 12); - $x0 += $x5; - $x15 = self::leftRotate($x15 ^ $x0, 8); - $x10 += $x15; - $x5 = self::leftRotate($x5 ^ $x10, 7); + $x0+= $x5; $x15 = self::leftRotate($x15 ^ $x0, 16); + $x10+= $x15; $x5 = self::leftRotate($x5 ^ $x10, 12); + $x0+= $x5; $x15 = self::leftRotate($x15 ^ $x0, 8); + $x10+= $x15; $x5 = self::leftRotate($x5 ^ $x10, 7); - $x1 += $x6; - $x12 = self::leftRotate($x12 ^ $x1, 16); - $x11 += $x12; - $x6 = self::leftRotate($x6 ^ $x11, 12); - $x1 += $x6; - $x12 = self::leftRotate($x12 ^ $x1, 8); - $x11 += $x12; - $x6 = self::leftRotate($x6 ^ $x11, 7); + $x1+= $x6; $x12 = self::leftRotate($x12 ^ $x1, 16); + $x11+= $x12; $x6 = self::leftRotate($x6 ^ $x11, 12); + $x1+= $x6; $x12 = self::leftRotate($x12 ^ $x1, 8); + $x11+= $x12; $x6 = self::leftRotate($x6 ^ $x11, 7); - $x2 += $x7; - $x13 = self::leftRotate($x13 ^ $x2, 16); - $x8 += $x13; - $x7 = self::leftRotate($x7 ^ $x8, 12); - $x2 += $x7; - $x13 = self::leftRotate($x13 ^ $x2, 8); - $x8 += $x13; - $x7 = self::leftRotate($x7 ^ $x8, 7); + $x2+= $x7; $x13 = self::leftRotate($x13 ^ $x2, 16); + $x8+= $x13; $x7 = self::leftRotate($x7 ^ $x8, 12); + $x2+= $x7; $x13 = self::leftRotate($x13 ^ $x2, 8); + $x8+= $x13; $x7 = self::leftRotate($x7 ^ $x8, 7); - $x3 += $x4; - $x14 = self::leftRotate($x14 ^ $x3, 16); - $x9 += $x14; - $x4 = self::leftRotate($x4 ^ $x9, 12); - $x3 += $x4; - $x14 = self::leftRotate($x14 ^ $x3, 8); - $x9 += $x14; - $x4 = self::leftRotate($x4 ^ $x9, 7); + $x3+= $x4; $x14 = self::leftRotate($x14 ^ $x3, 16); + $x9+= $x14; $x4 = self::leftRotate($x4 ^ $x9, 12); + $x3+= $x4; $x14 = self::leftRotate($x14 ^ $x3, 8); + $x9+= $x14; $x4 = self::leftRotate($x4 ^ $x9, 7); // columnRound - $x0 += $x4; - $x12 = self::leftRotate($x12 ^ $x0, 16); - $x8 += $x12; - $x4 = self::leftRotate($x4 ^ $x8, 12); - $x0 += $x4; - $x12 = self::leftRotate($x12 ^ $x0, 8); - $x8 += $x12; - $x4 = self::leftRotate($x4 ^ $x8, 7); + $x0+= $x4; $x12 = self::leftRotate($x12 ^ $x0, 16); + $x8+= $x12; $x4 = self::leftRotate($x4 ^ $x8, 12); + $x0+= $x4; $x12 = self::leftRotate($x12 ^ $x0, 8); + $x8+= $x12; $x4 = self::leftRotate($x4 ^ $x8, 7); - $x1 += $x5; - $x13 = self::leftRotate($x13 ^ $x1, 16); - $x9 += $x13; - $x5 = self::leftRotate($x5 ^ $x9, 12); - $x1 += $x5; - $x13 = self::leftRotate($x13 ^ $x1, 8); - $x9 += $x13; - $x5 = self::leftRotate($x5 ^ $x9, 7); + $x1+= $x5; $x13 = self::leftRotate($x13 ^ $x1, 16); + $x9+= $x13; $x5 = self::leftRotate($x5 ^ $x9, 12); + $x1+= $x5; $x13 = self::leftRotate($x13 ^ $x1, 8); + $x9+= $x13; $x5 = self::leftRotate($x5 ^ $x9, 7); - $x2 += $x6; - $x14 = self::leftRotate($x14 ^ $x2, 16); - $x10 += $x14; - $x6 = self::leftRotate($x6 ^ $x10, 12); - $x2 += $x6; - $x14 = self::leftRotate($x14 ^ $x2, 8); - $x10 += $x14; - $x6 = self::leftRotate($x6 ^ $x10, 7); + $x2+= $x6; $x14 = self::leftRotate($x14 ^ $x2, 16); + $x10+= $x14; $x6 = self::leftRotate($x6 ^ $x10, 12); + $x2+= $x6; $x14 = self::leftRotate($x14 ^ $x2, 8); + $x10+= $x14; $x6 = self::leftRotate($x6 ^ $x10, 7); - $x3 += $x7; - $x15 = self::leftRotate($x15 ^ $x3, 16); - $x11 += $x15; - $x7 = self::leftRotate($x7 ^ $x11, 12); - $x3 += $x7; - $x15 = self::leftRotate($x15 ^ $x3, 8); - $x11 += $x15; - $x7 = self::leftRotate($x7 ^ $x11, 7); + $x3+= $x7; $x15 = self::leftRotate($x15 ^ $x3, 16); + $x11+= $x15; $x7 = self::leftRotate($x7 ^ $x11, 12); + $x3+= $x7; $x15 = self::leftRotate($x15 ^ $x3, 8); + $x11+= $x15; $x7 = self::leftRotate($x7 ^ $x11, 7); // rowRound - $x0 += $x5; - $x15 = self::leftRotate($x15 ^ $x0, 16); - $x10 += $x15; - $x5 = self::leftRotate($x5 ^ $x10, 12); - $x0 += $x5; - $x15 = self::leftRotate($x15 ^ $x0, 8); - $x10 += $x15; - $x5 = self::leftRotate($x5 ^ $x10, 7); + $x0+= $x5; $x15 = self::leftRotate($x15 ^ $x0, 16); + $x10+= $x15; $x5 = self::leftRotate($x5 ^ $x10, 12); + $x0+= $x5; $x15 = self::leftRotate($x15 ^ $x0, 8); + $x10+= $x15; $x5 = self::leftRotate($x5 ^ $x10, 7); - $x1 += $x6; - $x12 = self::leftRotate($x12 ^ $x1, 16); - $x11 += $x12; - $x6 = self::leftRotate($x6 ^ $x11, 12); - $x1 += $x6; - $x12 = self::leftRotate($x12 ^ $x1, 8); - $x11 += $x12; - $x6 = self::leftRotate($x6 ^ $x11, 7); + $x1+= $x6; $x12 = self::leftRotate($x12 ^ $x1, 16); + $x11+= $x12; $x6 = self::leftRotate($x6 ^ $x11, 12); + $x1+= $x6; $x12 = self::leftRotate($x12 ^ $x1, 8); + $x11+= $x12; $x6 = self::leftRotate($x6 ^ $x11, 7); - $x2 += $x7; - $x13 = self::leftRotate($x13 ^ $x2, 16); - $x8 += $x13; - $x7 = self::leftRotate($x7 ^ $x8, 12); - $x2 += $x7; - $x13 = self::leftRotate($x13 ^ $x2, 8); - $x8 += $x13; - $x7 = self::leftRotate($x7 ^ $x8, 7); + $x2+= $x7; $x13 = self::leftRotate($x13 ^ $x2, 16); + $x8+= $x13; $x7 = self::leftRotate($x7 ^ $x8, 12); + $x2+= $x7; $x13 = self::leftRotate($x13 ^ $x2, 8); + $x8+= $x13; $x7 = self::leftRotate($x7 ^ $x8, 7); - $x3 += $x4; - $x14 = self::leftRotate($x14 ^ $x3, 16); - $x9 += $x14; - $x4 = self::leftRotate($x4 ^ $x9, 12); - $x3 += $x4; - $x14 = self::leftRotate($x14 ^ $x3, 8); - $x9 += $x14; - $x4 = self::leftRotate($x4 ^ $x9, 7); + $x3+= $x4; $x14 = self::leftRotate($x14 ^ $x3, 16); + $x9+= $x14; $x4 = self::leftRotate($x4 ^ $x9, 12); + $x3+= $x4; $x14 = self::leftRotate($x14 ^ $x3, 8); + $x9+= $x14; $x4 = self::leftRotate($x4 ^ $x9, 7); // columnRound - $x0 += $x4; - $x12 = self::leftRotate($x12 ^ $x0, 16); - $x8 += $x12; - $x4 = self::leftRotate($x4 ^ $x8, 12); - $x0 += $x4; - $x12 = self::leftRotate($x12 ^ $x0, 8); - $x8 += $x12; - $x4 = self::leftRotate($x4 ^ $x8, 7); + $x0+= $x4; $x12 = self::leftRotate($x12 ^ $x0, 16); + $x8+= $x12; $x4 = self::leftRotate($x4 ^ $x8, 12); + $x0+= $x4; $x12 = self::leftRotate($x12 ^ $x0, 8); + $x8+= $x12; $x4 = self::leftRotate($x4 ^ $x8, 7); - $x1 += $x5; - $x13 = self::leftRotate($x13 ^ $x1, 16); - $x9 += $x13; - $x5 = self::leftRotate($x5 ^ $x9, 12); - $x1 += $x5; - $x13 = self::leftRotate($x13 ^ $x1, 8); - $x9 += $x13; - $x5 = self::leftRotate($x5 ^ $x9, 7); + $x1+= $x5; $x13 = self::leftRotate($x13 ^ $x1, 16); + $x9+= $x13; $x5 = self::leftRotate($x5 ^ $x9, 12); + $x1+= $x5; $x13 = self::leftRotate($x13 ^ $x1, 8); + $x9+= $x13; $x5 = self::leftRotate($x5 ^ $x9, 7); - $x2 += $x6; - $x14 = self::leftRotate($x14 ^ $x2, 16); - $x10 += $x14; - $x6 = self::leftRotate($x6 ^ $x10, 12); - $x2 += $x6; - $x14 = self::leftRotate($x14 ^ $x2, 8); - $x10 += $x14; - $x6 = self::leftRotate($x6 ^ $x10, 7); + $x2+= $x6; $x14 = self::leftRotate($x14 ^ $x2, 16); + $x10+= $x14; $x6 = self::leftRotate($x6 ^ $x10, 12); + $x2+= $x6; $x14 = self::leftRotate($x14 ^ $x2, 8); + $x10+= $x14; $x6 = self::leftRotate($x6 ^ $x10, 7); - $x3 += $x7; - $x15 = self::leftRotate($x15 ^ $x3, 16); - $x11 += $x15; - $x7 = self::leftRotate($x7 ^ $x11, 12); - $x3 += $x7; - $x15 = self::leftRotate($x15 ^ $x3, 8); - $x11 += $x15; - $x7 = self::leftRotate($x7 ^ $x11, 7); + $x3+= $x7; $x15 = self::leftRotate($x15 ^ $x3, 16); + $x11+= $x15; $x7 = self::leftRotate($x7 ^ $x11, 12); + $x3+= $x7; $x15 = self::leftRotate($x15 ^ $x3, 8); + $x11+= $x15; $x7 = self::leftRotate($x7 ^ $x11, 7); // rowRound - $x0 += $x5; - $x15 = self::leftRotate($x15 ^ $x0, 16); - $x10 += $x15; - $x5 = self::leftRotate($x5 ^ $x10, 12); - $x0 += $x5; - $x15 = self::leftRotate($x15 ^ $x0, 8); - $x10 += $x15; - $x5 = self::leftRotate($x5 ^ $x10, 7); + $x0+= $x5; $x15 = self::leftRotate($x15 ^ $x0, 16); + $x10+= $x15; $x5 = self::leftRotate($x5 ^ $x10, 12); + $x0+= $x5; $x15 = self::leftRotate($x15 ^ $x0, 8); + $x10+= $x15; $x5 = self::leftRotate($x5 ^ $x10, 7); - $x1 += $x6; - $x12 = self::leftRotate($x12 ^ $x1, 16); - $x11 += $x12; - $x6 = self::leftRotate($x6 ^ $x11, 12); - $x1 += $x6; - $x12 = self::leftRotate($x12 ^ $x1, 8); - $x11 += $x12; - $x6 = self::leftRotate($x6 ^ $x11, 7); + $x1+= $x6; $x12 = self::leftRotate($x12 ^ $x1, 16); + $x11+= $x12; $x6 = self::leftRotate($x6 ^ $x11, 12); + $x1+= $x6; $x12 = self::leftRotate($x12 ^ $x1, 8); + $x11+= $x12; $x6 = self::leftRotate($x6 ^ $x11, 7); - $x2 += $x7; - $x13 = self::leftRotate($x13 ^ $x2, 16); - $x8 += $x13; - $x7 = self::leftRotate($x7 ^ $x8, 12); - $x2 += $x7; - $x13 = self::leftRotate($x13 ^ $x2, 8); - $x8 += $x13; - $x7 = self::leftRotate($x7 ^ $x8, 7); + $x2+= $x7; $x13 = self::leftRotate($x13 ^ $x2, 16); + $x8+= $x13; $x7 = self::leftRotate($x7 ^ $x8, 12); + $x2+= $x7; $x13 = self::leftRotate($x13 ^ $x2, 8); + $x8+= $x13; $x7 = self::leftRotate($x7 ^ $x8, 7); - $x3 += $x4; - $x14 = self::leftRotate($x14 ^ $x3, 16); - $x9 += $x14; - $x4 = self::leftRotate($x4 ^ $x9, 12); - $x3 += $x4; - $x14 = self::leftRotate($x14 ^ $x3, 8); - $x9 += $x14; - $x4 = self::leftRotate($x4 ^ $x9, 7); + $x3+= $x4; $x14 = self::leftRotate($x14 ^ $x3, 16); + $x9+= $x14; $x4 = self::leftRotate($x4 ^ $x9, 12); + $x3+= $x4; $x14 = self::leftRotate($x14 ^ $x3, 8); + $x9+= $x14; $x4 = self::leftRotate($x4 ^ $x9, 7); // columnRound - $x0 += $x4; - $x12 = self::leftRotate($x12 ^ $x0, 16); - $x8 += $x12; - $x4 = self::leftRotate($x4 ^ $x8, 12); - $x0 += $x4; - $x12 = self::leftRotate($x12 ^ $x0, 8); - $x8 += $x12; - $x4 = self::leftRotate($x4 ^ $x8, 7); + $x0+= $x4; $x12 = self::leftRotate($x12 ^ $x0, 16); + $x8+= $x12; $x4 = self::leftRotate($x4 ^ $x8, 12); + $x0+= $x4; $x12 = self::leftRotate($x12 ^ $x0, 8); + $x8+= $x12; $x4 = self::leftRotate($x4 ^ $x8, 7); - $x1 += $x5; - $x13 = self::leftRotate($x13 ^ $x1, 16); - $x9 += $x13; - $x5 = self::leftRotate($x5 ^ $x9, 12); - $x1 += $x5; - $x13 = self::leftRotate($x13 ^ $x1, 8); - $x9 += $x13; - $x5 = self::leftRotate($x5 ^ $x9, 7); + $x1+= $x5; $x13 = self::leftRotate($x13 ^ $x1, 16); + $x9+= $x13; $x5 = self::leftRotate($x5 ^ $x9, 12); + $x1+= $x5; $x13 = self::leftRotate($x13 ^ $x1, 8); + $x9+= $x13; $x5 = self::leftRotate($x5 ^ $x9, 7); - $x2 += $x6; - $x14 = self::leftRotate($x14 ^ $x2, 16); - $x10 += $x14; - $x6 = self::leftRotate($x6 ^ $x10, 12); - $x2 += $x6; - $x14 = self::leftRotate($x14 ^ $x2, 8); - $x10 += $x14; - $x6 = self::leftRotate($x6 ^ $x10, 7); + $x2+= $x6; $x14 = self::leftRotate($x14 ^ $x2, 16); + $x10+= $x14; $x6 = self::leftRotate($x6 ^ $x10, 12); + $x2+= $x6; $x14 = self::leftRotate($x14 ^ $x2, 8); + $x10+= $x14; $x6 = self::leftRotate($x6 ^ $x10, 7); - $x3 += $x7; - $x15 = self::leftRotate($x15 ^ $x3, 16); - $x11 += $x15; - $x7 = self::leftRotate($x7 ^ $x11, 12); - $x3 += $x7; - $x15 = self::leftRotate($x15 ^ $x3, 8); - $x11 += $x15; - $x7 = self::leftRotate($x7 ^ $x11, 7); + $x3+= $x7; $x15 = self::leftRotate($x15 ^ $x3, 16); + $x11+= $x15; $x7 = self::leftRotate($x7 ^ $x11, 12); + $x3+= $x7; $x15 = self::leftRotate($x15 ^ $x3, 8); + $x11+= $x15; $x7 = self::leftRotate($x7 ^ $x11, 7); // rowRound - $x0 += $x5; - $x15 = self::leftRotate($x15 ^ $x0, 16); - $x10 += $x15; - $x5 = self::leftRotate($x5 ^ $x10, 12); - $x0 += $x5; - $x15 = self::leftRotate($x15 ^ $x0, 8); - $x10 += $x15; - $x5 = self::leftRotate($x5 ^ $x10, 7); + $x0+= $x5; $x15 = self::leftRotate($x15 ^ $x0, 16); + $x10+= $x15; $x5 = self::leftRotate($x5 ^ $x10, 12); + $x0+= $x5; $x15 = self::leftRotate($x15 ^ $x0, 8); + $x10+= $x15; $x5 = self::leftRotate($x5 ^ $x10, 7); - $x1 += $x6; - $x12 = self::leftRotate($x12 ^ $x1, 16); - $x11 += $x12; - $x6 = self::leftRotate($x6 ^ $x11, 12); - $x1 += $x6; - $x12 = self::leftRotate($x12 ^ $x1, 8); - $x11 += $x12; - $x6 = self::leftRotate($x6 ^ $x11, 7); + $x1+= $x6; $x12 = self::leftRotate($x12 ^ $x1, 16); + $x11+= $x12; $x6 = self::leftRotate($x6 ^ $x11, 12); + $x1+= $x6; $x12 = self::leftRotate($x12 ^ $x1, 8); + $x11+= $x12; $x6 = self::leftRotate($x6 ^ $x11, 7); - $x2 += $x7; - $x13 = self::leftRotate($x13 ^ $x2, 16); - $x8 += $x13; - $x7 = self::leftRotate($x7 ^ $x8, 12); - $x2 += $x7; - $x13 = self::leftRotate($x13 ^ $x2, 8); - $x8 += $x13; - $x7 = self::leftRotate($x7 ^ $x8, 7); + $x2+= $x7; $x13 = self::leftRotate($x13 ^ $x2, 16); + $x8+= $x13; $x7 = self::leftRotate($x7 ^ $x8, 12); + $x2+= $x7; $x13 = self::leftRotate($x13 ^ $x2, 8); + $x8+= $x13; $x7 = self::leftRotate($x7 ^ $x8, 7); - $x3 += $x4; - $x14 = self::leftRotate($x14 ^ $x3, 16); - $x9 += $x14; - $x4 = self::leftRotate($x4 ^ $x9, 12); - $x3 += $x4; - $x14 = self::leftRotate($x14 ^ $x3, 8); - $x9 += $x14; - $x4 = self::leftRotate($x4 ^ $x9, 7); + $x3+= $x4; $x14 = self::leftRotate($x14 ^ $x3, 16); + $x9+= $x14; $x4 = self::leftRotate($x4 ^ $x9, 12); + $x3+= $x4; $x14 = self::leftRotate($x14 ^ $x3, 8); + $x9+= $x14; $x4 = self::leftRotate($x4 ^ $x9, 7); // columnRound - $x0 += $x4; - $x12 = self::leftRotate($x12 ^ $x0, 16); - $x8 += $x12; - $x4 = self::leftRotate($x4 ^ $x8, 12); - $x0 += $x4; - $x12 = self::leftRotate($x12 ^ $x0, 8); - $x8 += $x12; - $x4 = self::leftRotate($x4 ^ $x8, 7); + $x0+= $x4; $x12 = self::leftRotate($x12 ^ $x0, 16); + $x8+= $x12; $x4 = self::leftRotate($x4 ^ $x8, 12); + $x0+= $x4; $x12 = self::leftRotate($x12 ^ $x0, 8); + $x8+= $x12; $x4 = self::leftRotate($x4 ^ $x8, 7); - $x1 += $x5; - $x13 = self::leftRotate($x13 ^ $x1, 16); - $x9 += $x13; - $x5 = self::leftRotate($x5 ^ $x9, 12); - $x1 += $x5; - $x13 = self::leftRotate($x13 ^ $x1, 8); - $x9 += $x13; - $x5 = self::leftRotate($x5 ^ $x9, 7); + $x1+= $x5; $x13 = self::leftRotate($x13 ^ $x1, 16); + $x9+= $x13; $x5 = self::leftRotate($x5 ^ $x9, 12); + $x1+= $x5; $x13 = self::leftRotate($x13 ^ $x1, 8); + $x9+= $x13; $x5 = self::leftRotate($x5 ^ $x9, 7); - $x2 += $x6; - $x14 = self::leftRotate($x14 ^ $x2, 16); - $x10 += $x14; - $x6 = self::leftRotate($x6 ^ $x10, 12); - $x2 += $x6; - $x14 = self::leftRotate($x14 ^ $x2, 8); - $x10 += $x14; - $x6 = self::leftRotate($x6 ^ $x10, 7); + $x2+= $x6; $x14 = self::leftRotate($x14 ^ $x2, 16); + $x10+= $x14; $x6 = self::leftRotate($x6 ^ $x10, 12); + $x2+= $x6; $x14 = self::leftRotate($x14 ^ $x2, 8); + $x10+= $x14; $x6 = self::leftRotate($x6 ^ $x10, 7); - $x3 += $x7; - $x15 = self::leftRotate($x15 ^ $x3, 16); - $x11 += $x15; - $x7 = self::leftRotate($x7 ^ $x11, 12); - $x3 += $x7; - $x15 = self::leftRotate($x15 ^ $x3, 8); - $x11 += $x15; - $x7 = self::leftRotate($x7 ^ $x11, 7); + $x3+= $x7; $x15 = self::leftRotate($x15 ^ $x3, 16); + $x11+= $x15; $x7 = self::leftRotate($x7 ^ $x11, 12); + $x3+= $x7; $x15 = self::leftRotate($x15 ^ $x3, 8); + $x11+= $x15; $x7 = self::leftRotate($x7 ^ $x11, 7); // rowRound - $x0 += $x5; - $x15 = self::leftRotate($x15 ^ $x0, 16); - $x10 += $x15; - $x5 = self::leftRotate($x5 ^ $x10, 12); - $x0 += $x5; - $x15 = self::leftRotate($x15 ^ $x0, 8); - $x10 += $x15; - $x5 = self::leftRotate($x5 ^ $x10, 7); + $x0+= $x5; $x15 = self::leftRotate($x15 ^ $x0, 16); + $x10+= $x15; $x5 = self::leftRotate($x5 ^ $x10, 12); + $x0+= $x5; $x15 = self::leftRotate($x15 ^ $x0, 8); + $x10+= $x15; $x5 = self::leftRotate($x5 ^ $x10, 7); - $x1 += $x6; - $x12 = self::leftRotate($x12 ^ $x1, 16); - $x11 += $x12; - $x6 = self::leftRotate($x6 ^ $x11, 12); - $x1 += $x6; - $x12 = self::leftRotate($x12 ^ $x1, 8); - $x11 += $x12; - $x6 = self::leftRotate($x6 ^ $x11, 7); + $x1+= $x6; $x12 = self::leftRotate($x12 ^ $x1, 16); + $x11+= $x12; $x6 = self::leftRotate($x6 ^ $x11, 12); + $x1+= $x6; $x12 = self::leftRotate($x12 ^ $x1, 8); + $x11+= $x12; $x6 = self::leftRotate($x6 ^ $x11, 7); - $x2 += $x7; - $x13 = self::leftRotate($x13 ^ $x2, 16); - $x8 += $x13; - $x7 = self::leftRotate($x7 ^ $x8, 12); - $x2 += $x7; - $x13 = self::leftRotate($x13 ^ $x2, 8); - $x8 += $x13; - $x7 = self::leftRotate($x7 ^ $x8, 7); + $x2+= $x7; $x13 = self::leftRotate($x13 ^ $x2, 16); + $x8+= $x13; $x7 = self::leftRotate($x7 ^ $x8, 12); + $x2+= $x7; $x13 = self::leftRotate($x13 ^ $x2, 8); + $x8+= $x13; $x7 = self::leftRotate($x7 ^ $x8, 7); - $x3 += $x4; - $x14 = self::leftRotate($x14 ^ $x3, 16); - $x9 += $x14; - $x4 = self::leftRotate($x4 ^ $x9, 12); - $x3 += $x4; - $x14 = self::leftRotate($x14 ^ $x3, 8); - $x9 += $x14; - $x4 = self::leftRotate($x4 ^ $x9, 7); + $x3+= $x4; $x14 = self::leftRotate($x14 ^ $x3, 16); + $x9+= $x14; $x4 = self::leftRotate($x4 ^ $x9, 12); + $x3+= $x4; $x14 = self::leftRotate($x14 ^ $x3, 8); + $x9+= $x14; $x4 = self::leftRotate($x4 ^ $x9, 7); // columnRound - $x0 += $x4; - $x12 = self::leftRotate($x12 ^ $x0, 16); - $x8 += $x12; - $x4 = self::leftRotate($x4 ^ $x8, 12); - $x0 += $x4; - $x12 = self::leftRotate($x12 ^ $x0, 8); - $x8 += $x12; - $x4 = self::leftRotate($x4 ^ $x8, 7); + $x0+= $x4; $x12 = self::leftRotate($x12 ^ $x0, 16); + $x8+= $x12; $x4 = self::leftRotate($x4 ^ $x8, 12); + $x0+= $x4; $x12 = self::leftRotate($x12 ^ $x0, 8); + $x8+= $x12; $x4 = self::leftRotate($x4 ^ $x8, 7); - $x1 += $x5; - $x13 = self::leftRotate($x13 ^ $x1, 16); - $x9 += $x13; - $x5 = self::leftRotate($x5 ^ $x9, 12); - $x1 += $x5; - $x13 = self::leftRotate($x13 ^ $x1, 8); - $x9 += $x13; - $x5 = self::leftRotate($x5 ^ $x9, 7); + $x1+= $x5; $x13 = self::leftRotate($x13 ^ $x1, 16); + $x9+= $x13; $x5 = self::leftRotate($x5 ^ $x9, 12); + $x1+= $x5; $x13 = self::leftRotate($x13 ^ $x1, 8); + $x9+= $x13; $x5 = self::leftRotate($x5 ^ $x9, 7); - $x2 += $x6; - $x14 = self::leftRotate($x14 ^ $x2, 16); - $x10 += $x14; - $x6 = self::leftRotate($x6 ^ $x10, 12); - $x2 += $x6; - $x14 = self::leftRotate($x14 ^ $x2, 8); - $x10 += $x14; - $x6 = self::leftRotate($x6 ^ $x10, 7); + $x2+= $x6; $x14 = self::leftRotate($x14 ^ $x2, 16); + $x10+= $x14; $x6 = self::leftRotate($x6 ^ $x10, 12); + $x2+= $x6; $x14 = self::leftRotate($x14 ^ $x2, 8); + $x10+= $x14; $x6 = self::leftRotate($x6 ^ $x10, 7); - $x3 += $x7; - $x15 = self::leftRotate($x15 ^ $x3, 16); - $x11 += $x15; - $x7 = self::leftRotate($x7 ^ $x11, 12); - $x3 += $x7; - $x15 = self::leftRotate($x15 ^ $x3, 8); - $x11 += $x15; - $x7 = self::leftRotate($x7 ^ $x11, 7); + $x3+= $x7; $x15 = self::leftRotate($x15 ^ $x3, 16); + $x11+= $x15; $x7 = self::leftRotate($x7 ^ $x11, 12); + $x3+= $x7; $x15 = self::leftRotate($x15 ^ $x3, 8); + $x11+= $x15; $x7 = self::leftRotate($x7 ^ $x11, 7); // rowRound - $x0 += $x5; - $x15 = self::leftRotate($x15 ^ $x0, 16); - $x10 += $x15; - $x5 = self::leftRotate($x5 ^ $x10, 12); - $x0 += $x5; - $x15 = self::leftRotate($x15 ^ $x0, 8); - $x10 += $x15; - $x5 = self::leftRotate($x5 ^ $x10, 7); + $x0+= $x5; $x15 = self::leftRotate($x15 ^ $x0, 16); + $x10+= $x15; $x5 = self::leftRotate($x5 ^ $x10, 12); + $x0+= $x5; $x15 = self::leftRotate($x15 ^ $x0, 8); + $x10+= $x15; $x5 = self::leftRotate($x5 ^ $x10, 7); - $x1 += $x6; - $x12 = self::leftRotate($x12 ^ $x1, 16); - $x11 += $x12; - $x6 = self::leftRotate($x6 ^ $x11, 12); - $x1 += $x6; - $x12 = self::leftRotate($x12 ^ $x1, 8); - $x11 += $x12; - $x6 = self::leftRotate($x6 ^ $x11, 7); + $x1+= $x6; $x12 = self::leftRotate($x12 ^ $x1, 16); + $x11+= $x12; $x6 = self::leftRotate($x6 ^ $x11, 12); + $x1+= $x6; $x12 = self::leftRotate($x12 ^ $x1, 8); + $x11+= $x12; $x6 = self::leftRotate($x6 ^ $x11, 7); - $x2 += $x7; - $x13 = self::leftRotate($x13 ^ $x2, 16); - $x8 += $x13; - $x7 = self::leftRotate($x7 ^ $x8, 12); - $x2 += $x7; - $x13 = self::leftRotate($x13 ^ $x2, 8); - $x8 += $x13; - $x7 = self::leftRotate($x7 ^ $x8, 7); + $x2+= $x7; $x13 = self::leftRotate($x13 ^ $x2, 16); + $x8+= $x13; $x7 = self::leftRotate($x7 ^ $x8, 12); + $x2+= $x7; $x13 = self::leftRotate($x13 ^ $x2, 8); + $x8+= $x13; $x7 = self::leftRotate($x7 ^ $x8, 7); - $x3 += $x4; - $x14 = self::leftRotate($x14 ^ $x3, 16); - $x9 += $x14; - $x4 = self::leftRotate($x4 ^ $x9, 12); - $x3 += $x4; - $x14 = self::leftRotate($x14 ^ $x3, 8); - $x9 += $x14; - $x4 = self::leftRotate($x4 ^ $x9, 7); + $x3+= $x4; $x14 = self::leftRotate($x14 ^ $x3, 16); + $x9+= $x14; $x4 = self::leftRotate($x4 ^ $x9, 12); + $x3+= $x4; $x14 = self::leftRotate($x14 ^ $x3, 8); + $x9+= $x14; $x4 = self::leftRotate($x4 ^ $x9, 7); // columnRound - $x0 += $x4; - $x12 = self::leftRotate($x12 ^ $x0, 16); - $x8 += $x12; - $x4 = self::leftRotate($x4 ^ $x8, 12); - $x0 += $x4; - $x12 = self::leftRotate($x12 ^ $x0, 8); - $x8 += $x12; - $x4 = self::leftRotate($x4 ^ $x8, 7); + $x0+= $x4; $x12 = self::leftRotate($x12 ^ $x0, 16); + $x8+= $x12; $x4 = self::leftRotate($x4 ^ $x8, 12); + $x0+= $x4; $x12 = self::leftRotate($x12 ^ $x0, 8); + $x8+= $x12; $x4 = self::leftRotate($x4 ^ $x8, 7); - $x1 += $x5; - $x13 = self::leftRotate($x13 ^ $x1, 16); - $x9 += $x13; - $x5 = self::leftRotate($x5 ^ $x9, 12); - $x1 += $x5; - $x13 = self::leftRotate($x13 ^ $x1, 8); - $x9 += $x13; - $x5 = self::leftRotate($x5 ^ $x9, 7); + $x1+= $x5; $x13 = self::leftRotate($x13 ^ $x1, 16); + $x9+= $x13; $x5 = self::leftRotate($x5 ^ $x9, 12); + $x1+= $x5; $x13 = self::leftRotate($x13 ^ $x1, 8); + $x9+= $x13; $x5 = self::leftRotate($x5 ^ $x9, 7); - $x2 += $x6; - $x14 = self::leftRotate($x14 ^ $x2, 16); - $x10 += $x14; - $x6 = self::leftRotate($x6 ^ $x10, 12); - $x2 += $x6; - $x14 = self::leftRotate($x14 ^ $x2, 8); - $x10 += $x14; - $x6 = self::leftRotate($x6 ^ $x10, 7); + $x2+= $x6; $x14 = self::leftRotate($x14 ^ $x2, 16); + $x10+= $x14; $x6 = self::leftRotate($x6 ^ $x10, 12); + $x2+= $x6; $x14 = self::leftRotate($x14 ^ $x2, 8); + $x10+= $x14; $x6 = self::leftRotate($x6 ^ $x10, 7); - $x3 += $x7; - $x15 = self::leftRotate($x15 ^ $x3, 16); - $x11 += $x15; - $x7 = self::leftRotate($x7 ^ $x11, 12); - $x3 += $x7; - $x15 = self::leftRotate($x15 ^ $x3, 8); - $x11 += $x15; - $x7 = self::leftRotate($x7 ^ $x11, 7); + $x3+= $x7; $x15 = self::leftRotate($x15 ^ $x3, 16); + $x11+= $x15; $x7 = self::leftRotate($x7 ^ $x11, 12); + $x3+= $x7; $x15 = self::leftRotate($x15 ^ $x3, 8); + $x11+= $x15; $x7 = self::leftRotate($x7 ^ $x11, 7); // rowRound - $x0 += $x5; - $x15 = self::leftRotate($x15 ^ $x0, 16); - $x10 += $x15; - $x5 = self::leftRotate($x5 ^ $x10, 12); - $x0 += $x5; - $x15 = self::leftRotate($x15 ^ $x0, 8); - $x10 += $x15; - $x5 = self::leftRotate($x5 ^ $x10, 7); + $x0+= $x5; $x15 = self::leftRotate($x15 ^ $x0, 16); + $x10+= $x15; $x5 = self::leftRotate($x5 ^ $x10, 12); + $x0+= $x5; $x15 = self::leftRotate($x15 ^ $x0, 8); + $x10+= $x15; $x5 = self::leftRotate($x5 ^ $x10, 7); - $x1 += $x6; - $x12 = self::leftRotate($x12 ^ $x1, 16); - $x11 += $x12; - $x6 = self::leftRotate($x6 ^ $x11, 12); - $x1 += $x6; - $x12 = self::leftRotate($x12 ^ $x1, 8); - $x11 += $x12; - $x6 = self::leftRotate($x6 ^ $x11, 7); + $x1+= $x6; $x12 = self::leftRotate($x12 ^ $x1, 16); + $x11+= $x12; $x6 = self::leftRotate($x6 ^ $x11, 12); + $x1+= $x6; $x12 = self::leftRotate($x12 ^ $x1, 8); + $x11+= $x12; $x6 = self::leftRotate($x6 ^ $x11, 7); - $x2 += $x7; - $x13 = self::leftRotate($x13 ^ $x2, 16); - $x8 += $x13; - $x7 = self::leftRotate($x7 ^ $x8, 12); - $x2 += $x7; - $x13 = self::leftRotate($x13 ^ $x2, 8); - $x8 += $x13; - $x7 = self::leftRotate($x7 ^ $x8, 7); + $x2+= $x7; $x13 = self::leftRotate($x13 ^ $x2, 16); + $x8+= $x13; $x7 = self::leftRotate($x7 ^ $x8, 12); + $x2+= $x7; $x13 = self::leftRotate($x13 ^ $x2, 8); + $x8+= $x13; $x7 = self::leftRotate($x7 ^ $x8, 7); - $x3 += $x4; - $x14 = self::leftRotate($x14 ^ $x3, 16); - $x9 += $x14; - $x4 = self::leftRotate($x4 ^ $x9, 12); - $x3 += $x4; - $x14 = self::leftRotate($x14 ^ $x3, 8); - $x9 += $x14; - $x4 = self::leftRotate($x4 ^ $x9, 7); + $x3+= $x4; $x14 = self::leftRotate($x14 ^ $x3, 16); + $x9+= $x14; $x4 = self::leftRotate($x4 ^ $x9, 12); + $x3+= $x4; $x14 = self::leftRotate($x14 ^ $x3, 8); + $x9+= $x14; $x4 = self::leftRotate($x4 ^ $x9, 7); // columnRound - $x0 += $x4; - $x12 = self::leftRotate($x12 ^ $x0, 16); - $x8 += $x12; - $x4 = self::leftRotate($x4 ^ $x8, 12); - $x0 += $x4; - $x12 = self::leftRotate($x12 ^ $x0, 8); - $x8 += $x12; - $x4 = self::leftRotate($x4 ^ $x8, 7); + $x0+= $x4; $x12 = self::leftRotate($x12 ^ $x0, 16); + $x8+= $x12; $x4 = self::leftRotate($x4 ^ $x8, 12); + $x0+= $x4; $x12 = self::leftRotate($x12 ^ $x0, 8); + $x8+= $x12; $x4 = self::leftRotate($x4 ^ $x8, 7); - $x1 += $x5; - $x13 = self::leftRotate($x13 ^ $x1, 16); - $x9 += $x13; - $x5 = self::leftRotate($x5 ^ $x9, 12); - $x1 += $x5; - $x13 = self::leftRotate($x13 ^ $x1, 8); - $x9 += $x13; - $x5 = self::leftRotate($x5 ^ $x9, 7); + $x1+= $x5; $x13 = self::leftRotate($x13 ^ $x1, 16); + $x9+= $x13; $x5 = self::leftRotate($x5 ^ $x9, 12); + $x1+= $x5; $x13 = self::leftRotate($x13 ^ $x1, 8); + $x9+= $x13; $x5 = self::leftRotate($x5 ^ $x9, 7); - $x2 += $x6; - $x14 = self::leftRotate($x14 ^ $x2, 16); - $x10 += $x14; - $x6 = self::leftRotate($x6 ^ $x10, 12); - $x2 += $x6; - $x14 = self::leftRotate($x14 ^ $x2, 8); - $x10 += $x14; - $x6 = self::leftRotate($x6 ^ $x10, 7); + $x2+= $x6; $x14 = self::leftRotate($x14 ^ $x2, 16); + $x10+= $x14; $x6 = self::leftRotate($x6 ^ $x10, 12); + $x2+= $x6; $x14 = self::leftRotate($x14 ^ $x2, 8); + $x10+= $x14; $x6 = self::leftRotate($x6 ^ $x10, 7); - $x3 += $x7; - $x15 = self::leftRotate($x15 ^ $x3, 16); - $x11 += $x15; - $x7 = self::leftRotate($x7 ^ $x11, 12); - $x3 += $x7; - $x15 = self::leftRotate($x15 ^ $x3, 8); - $x11 += $x15; - $x7 = self::leftRotate($x7 ^ $x11, 7); + $x3+= $x7; $x15 = self::leftRotate($x15 ^ $x3, 16); + $x11+= $x15; $x7 = self::leftRotate($x7 ^ $x11, 12); + $x3+= $x7; $x15 = self::leftRotate($x15 ^ $x3, 8); + $x11+= $x15; $x7 = self::leftRotate($x7 ^ $x11, 7); // rowRound - $x0 += $x5; - $x15 = self::leftRotate($x15 ^ $x0, 16); - $x10 += $x15; - $x5 = self::leftRotate($x5 ^ $x10, 12); - $x0 += $x5; - $x15 = self::leftRotate($x15 ^ $x0, 8); - $x10 += $x15; - $x5 = self::leftRotate($x5 ^ $x10, 7); + $x0+= $x5; $x15 = self::leftRotate($x15 ^ $x0, 16); + $x10+= $x15; $x5 = self::leftRotate($x5 ^ $x10, 12); + $x0+= $x5; $x15 = self::leftRotate($x15 ^ $x0, 8); + $x10+= $x15; $x5 = self::leftRotate($x5 ^ $x10, 7); - $x1 += $x6; - $x12 = self::leftRotate($x12 ^ $x1, 16); - $x11 += $x12; - $x6 = self::leftRotate($x6 ^ $x11, 12); - $x1 += $x6; - $x12 = self::leftRotate($x12 ^ $x1, 8); - $x11 += $x12; - $x6 = self::leftRotate($x6 ^ $x11, 7); + $x1+= $x6; $x12 = self::leftRotate($x12 ^ $x1, 16); + $x11+= $x12; $x6 = self::leftRotate($x6 ^ $x11, 12); + $x1+= $x6; $x12 = self::leftRotate($x12 ^ $x1, 8); + $x11+= $x12; $x6 = self::leftRotate($x6 ^ $x11, 7); - $x2 += $x7; - $x13 = self::leftRotate($x13 ^ $x2, 16); - $x8 += $x13; - $x7 = self::leftRotate($x7 ^ $x8, 12); - $x2 += $x7; - $x13 = self::leftRotate($x13 ^ $x2, 8); - $x8 += $x13; - $x7 = self::leftRotate($x7 ^ $x8, 7); + $x2+= $x7; $x13 = self::leftRotate($x13 ^ $x2, 16); + $x8+= $x13; $x7 = self::leftRotate($x7 ^ $x8, 12); + $x2+= $x7; $x13 = self::leftRotate($x13 ^ $x2, 8); + $x8+= $x13; $x7 = self::leftRotate($x7 ^ $x8, 7); - $x3 += $x4; - $x14 = self::leftRotate($x14 ^ $x3, 16); - $x9 += $x14; - $x4 = self::leftRotate($x4 ^ $x9, 12); - $x3 += $x4; - $x14 = self::leftRotate($x14 ^ $x3, 8); - $x9 += $x14; - $x4 = self::leftRotate($x4 ^ $x9, 7); + $x3+= $x4; $x14 = self::leftRotate($x14 ^ $x3, 16); + $x9+= $x14; $x4 = self::leftRotate($x4 ^ $x9, 12); + $x3+= $x4; $x14 = self::leftRotate($x14 ^ $x3, 8); + $x9+= $x14; $x4 = self::leftRotate($x4 ^ $x9, 7); // columnRound - $x0 += $x4; - $x12 = self::leftRotate($x12 ^ $x0, 16); - $x8 += $x12; - $x4 = self::leftRotate($x4 ^ $x8, 12); - $x0 += $x4; - $x12 = self::leftRotate($x12 ^ $x0, 8); - $x8 += $x12; - $x4 = self::leftRotate($x4 ^ $x8, 7); + $x0+= $x4; $x12 = self::leftRotate($x12 ^ $x0, 16); + $x8+= $x12; $x4 = self::leftRotate($x4 ^ $x8, 12); + $x0+= $x4; $x12 = self::leftRotate($x12 ^ $x0, 8); + $x8+= $x12; $x4 = self::leftRotate($x4 ^ $x8, 7); - $x1 += $x5; - $x13 = self::leftRotate($x13 ^ $x1, 16); - $x9 += $x13; - $x5 = self::leftRotate($x5 ^ $x9, 12); - $x1 += $x5; - $x13 = self::leftRotate($x13 ^ $x1, 8); - $x9 += $x13; - $x5 = self::leftRotate($x5 ^ $x9, 7); + $x1+= $x5; $x13 = self::leftRotate($x13 ^ $x1, 16); + $x9+= $x13; $x5 = self::leftRotate($x5 ^ $x9, 12); + $x1+= $x5; $x13 = self::leftRotate($x13 ^ $x1, 8); + $x9+= $x13; $x5 = self::leftRotate($x5 ^ $x9, 7); - $x2 += $x6; - $x14 = self::leftRotate($x14 ^ $x2, 16); - $x10 += $x14; - $x6 = self::leftRotate($x6 ^ $x10, 12); - $x2 += $x6; - $x14 = self::leftRotate($x14 ^ $x2, 8); - $x10 += $x14; - $x6 = self::leftRotate($x6 ^ $x10, 7); + $x2+= $x6; $x14 = self::leftRotate($x14 ^ $x2, 16); + $x10+= $x14; $x6 = self::leftRotate($x6 ^ $x10, 12); + $x2+= $x6; $x14 = self::leftRotate($x14 ^ $x2, 8); + $x10+= $x14; $x6 = self::leftRotate($x6 ^ $x10, 7); - $x3 += $x7; - $x15 = self::leftRotate($x15 ^ $x3, 16); - $x11 += $x15; - $x7 = self::leftRotate($x7 ^ $x11, 12); - $x3 += $x7; - $x15 = self::leftRotate($x15 ^ $x3, 8); - $x11 += $x15; - $x7 = self::leftRotate($x7 ^ $x11, 7); + $x3+= $x7; $x15 = self::leftRotate($x15 ^ $x3, 16); + $x11+= $x15; $x7 = self::leftRotate($x7 ^ $x11, 12); + $x3+= $x7; $x15 = self::leftRotate($x15 ^ $x3, 8); + $x11+= $x15; $x7 = self::leftRotate($x7 ^ $x11, 7); // rowRound - $x0 += $x5; - $x15 = self::leftRotate($x15 ^ $x0, 16); - $x10 += $x15; - $x5 = self::leftRotate($x5 ^ $x10, 12); - $x0 += $x5; - $x15 = self::leftRotate($x15 ^ $x0, 8); - $x10 += $x15; - $x5 = self::leftRotate($x5 ^ $x10, 7); + $x0+= $x5; $x15 = self::leftRotate($x15 ^ $x0, 16); + $x10+= $x15; $x5 = self::leftRotate($x5 ^ $x10, 12); + $x0+= $x5; $x15 = self::leftRotate($x15 ^ $x0, 8); + $x10+= $x15; $x5 = self::leftRotate($x5 ^ $x10, 7); - $x1 += $x6; - $x12 = self::leftRotate($x12 ^ $x1, 16); - $x11 += $x12; - $x6 = self::leftRotate($x6 ^ $x11, 12); - $x1 += $x6; - $x12 = self::leftRotate($x12 ^ $x1, 8); - $x11 += $x12; - $x6 = self::leftRotate($x6 ^ $x11, 7); + $x1+= $x6; $x12 = self::leftRotate($x12 ^ $x1, 16); + $x11+= $x12; $x6 = self::leftRotate($x6 ^ $x11, 12); + $x1+= $x6; $x12 = self::leftRotate($x12 ^ $x1, 8); + $x11+= $x12; $x6 = self::leftRotate($x6 ^ $x11, 7); - $x2 += $x7; - $x13 = self::leftRotate($x13 ^ $x2, 16); - $x8 += $x13; - $x7 = self::leftRotate($x7 ^ $x8, 12); - $x2 += $x7; - $x13 = self::leftRotate($x13 ^ $x2, 8); - $x8 += $x13; - $x7 = self::leftRotate($x7 ^ $x8, 7); + $x2+= $x7; $x13 = self::leftRotate($x13 ^ $x2, 16); + $x8+= $x13; $x7 = self::leftRotate($x7 ^ $x8, 12); + $x2+= $x7; $x13 = self::leftRotate($x13 ^ $x2, 8); + $x8+= $x13; $x7 = self::leftRotate($x7 ^ $x8, 7); - $x3 += $x4; - $x14 = self::leftRotate($x14 ^ $x3, 16); - $x9 += $x14; - $x4 = self::leftRotate($x4 ^ $x9, 12); - $x3 += $x4; - $x14 = self::leftRotate($x14 ^ $x3, 8); - $x9 += $x14; - $x4 = self::leftRotate($x4 ^ $x9, 7); + $x3+= $x4; $x14 = self::leftRotate($x14 ^ $x3, 16); + $x9+= $x14; $x4 = self::leftRotate($x4 ^ $x9, 12); + $x3+= $x4; $x14 = self::leftRotate($x14 ^ $x3, 8); + $x9+= $x14; $x4 = self::leftRotate($x4 ^ $x9, 7); // columnRound - $x0 += $x4; - $x12 = self::leftRotate($x12 ^ $x0, 16); - $x8 += $x12; - $x4 = self::leftRotate($x4 ^ $x8, 12); - $x0 += $x4; - $x12 = self::leftRotate($x12 ^ $x0, 8); - $x8 += $x12; - $x4 = self::leftRotate($x4 ^ $x8, 7); + $x0+= $x4; $x12 = self::leftRotate($x12 ^ $x0, 16); + $x8+= $x12; $x4 = self::leftRotate($x4 ^ $x8, 12); + $x0+= $x4; $x12 = self::leftRotate($x12 ^ $x0, 8); + $x8+= $x12; $x4 = self::leftRotate($x4 ^ $x8, 7); - $x1 += $x5; - $x13 = self::leftRotate($x13 ^ $x1, 16); - $x9 += $x13; - $x5 = self::leftRotate($x5 ^ $x9, 12); - $x1 += $x5; - $x13 = self::leftRotate($x13 ^ $x1, 8); - $x9 += $x13; - $x5 = self::leftRotate($x5 ^ $x9, 7); + $x1+= $x5; $x13 = self::leftRotate($x13 ^ $x1, 16); + $x9+= $x13; $x5 = self::leftRotate($x5 ^ $x9, 12); + $x1+= $x5; $x13 = self::leftRotate($x13 ^ $x1, 8); + $x9+= $x13; $x5 = self::leftRotate($x5 ^ $x9, 7); - $x2 += $x6; - $x14 = self::leftRotate($x14 ^ $x2, 16); - $x10 += $x14; - $x6 = self::leftRotate($x6 ^ $x10, 12); - $x2 += $x6; - $x14 = self::leftRotate($x14 ^ $x2, 8); - $x10 += $x14; - $x6 = self::leftRotate($x6 ^ $x10, 7); + $x2+= $x6; $x14 = self::leftRotate($x14 ^ $x2, 16); + $x10+= $x14; $x6 = self::leftRotate($x6 ^ $x10, 12); + $x2+= $x6; $x14 = self::leftRotate($x14 ^ $x2, 8); + $x10+= $x14; $x6 = self::leftRotate($x6 ^ $x10, 7); - $x3 += $x7; - $x15 = self::leftRotate($x15 ^ $x3, 16); - $x11 += $x15; - $x7 = self::leftRotate($x7 ^ $x11, 12); - $x3 += $x7; - $x15 = self::leftRotate($x15 ^ $x3, 8); - $x11 += $x15; - $x7 = self::leftRotate($x7 ^ $x11, 7); + $x3+= $x7; $x15 = self::leftRotate($x15 ^ $x3, 16); + $x11+= $x15; $x7 = self::leftRotate($x7 ^ $x11, 12); + $x3+= $x7; $x15 = self::leftRotate($x15 ^ $x3, 8); + $x11+= $x15; $x7 = self::leftRotate($x7 ^ $x11, 7); // rowRound - $x0 += $x5; - $x15 = self::leftRotate($x15 ^ $x0, 16); - $x10 += $x15; - $x5 = self::leftRotate($x5 ^ $x10, 12); - $x0 += $x5; - $x15 = self::leftRotate($x15 ^ $x0, 8); - $x10 += $x15; - $x5 = self::leftRotate($x5 ^ $x10, 7); + $x0+= $x5; $x15 = self::leftRotate($x15 ^ $x0, 16); + $x10+= $x15; $x5 = self::leftRotate($x5 ^ $x10, 12); + $x0+= $x5; $x15 = self::leftRotate($x15 ^ $x0, 8); + $x10+= $x15; $x5 = self::leftRotate($x5 ^ $x10, 7); - $x1 += $x6; - $x12 = self::leftRotate($x12 ^ $x1, 16); - $x11 += $x12; - $x6 = self::leftRotate($x6 ^ $x11, 12); - $x1 += $x6; - $x12 = self::leftRotate($x12 ^ $x1, 8); - $x11 += $x12; - $x6 = self::leftRotate($x6 ^ $x11, 7); + $x1+= $x6; $x12 = self::leftRotate($x12 ^ $x1, 16); + $x11+= $x12; $x6 = self::leftRotate($x6 ^ $x11, 12); + $x1+= $x6; $x12 = self::leftRotate($x12 ^ $x1, 8); + $x11+= $x12; $x6 = self::leftRotate($x6 ^ $x11, 7); - $x2 += $x7; - $x13 = self::leftRotate($x13 ^ $x2, 16); - $x8 += $x13; - $x7 = self::leftRotate($x7 ^ $x8, 12); - $x2 += $x7; - $x13 = self::leftRotate($x13 ^ $x2, 8); - $x8 += $x13; - $x7 = self::leftRotate($x7 ^ $x8, 7); + $x2+= $x7; $x13 = self::leftRotate($x13 ^ $x2, 16); + $x8+= $x13; $x7 = self::leftRotate($x7 ^ $x8, 12); + $x2+= $x7; $x13 = self::leftRotate($x13 ^ $x2, 8); + $x8+= $x13; $x7 = self::leftRotate($x7 ^ $x8, 7); - $x3 += $x4; - $x14 = self::leftRotate($x14 ^ $x3, 16); - $x9 += $x14; - $x4 = self::leftRotate($x4 ^ $x9, 12); - $x3 += $x4; - $x14 = self::leftRotate($x14 ^ $x3, 8); - $x9 += $x14; - $x4 = self::leftRotate($x4 ^ $x9, 7); + $x3+= $x4; $x14 = self::leftRotate($x14 ^ $x3, 16); + $x9+= $x14; $x4 = self::leftRotate($x4 ^ $x9, 12); + $x3+= $x4; $x14 = self::leftRotate($x14 ^ $x3, 8); + $x9+= $x14; $x4 = self::leftRotate($x4 ^ $x9, 7); + // @codingStandardsIgnoreEnd $x0 += $z0; $x1 += $z1;