From ef66d9f7ddd23a6ba2a591104dd9ac8a9518f378 Mon Sep 17 00:00:00 2001 From: Jack Worman Date: Sun, 30 Jan 2022 09:34:42 -0600 Subject: [PATCH 1/4] php-cs-fixer ci php-cs-fixer ci --- .gitignore | 9 +++-- .travis.yml | 1 + build/composer.json | 14 +++++++ build/php-cs-fixer.php | 23 ++++++++++++ phpseclib/Crypt/ChaCha20.php | 2 +- phpseclib/Crypt/Common/AsymmetricKey.php | 9 ++--- phpseclib/Crypt/Common/Formats/Keys/PKCS1.php | 6 +-- phpseclib/Crypt/Common/Formats/Keys/PKCS8.php | 9 ++--- phpseclib/Crypt/Common/Formats/Keys/PuTTY.php | 2 +- phpseclib/Crypt/Common/SymmetricKey.php | 8 ++-- phpseclib/Crypt/DH.php | 6 +-- phpseclib/Crypt/DH/Formats/Keys/PKCS1.php | 2 +- phpseclib/Crypt/DH/Formats/Keys/PKCS8.php | 4 +- phpseclib/Crypt/DH/PrivateKey.php | 2 +- phpseclib/Crypt/DH/PublicKey.php | 2 +- phpseclib/Crypt/DSA.php | 4 +- phpseclib/Crypt/DSA/Formats/Keys/OpenSSH.php | 3 +- phpseclib/Crypt/DSA/Formats/Keys/PKCS1.php | 4 +- phpseclib/Crypt/DSA/Formats/Keys/PKCS8.php | 4 +- phpseclib/Crypt/DSA/Formats/Keys/PuTTY.php | 2 +- phpseclib/Crypt/DSA/Formats/Keys/XML.php | 2 +- .../Crypt/DSA/Formats/Signature/ASN1.php | 2 +- .../Crypt/DSA/Formats/Signature/SSH2.php | 2 +- phpseclib/Crypt/DSA/PrivateKey.php | 2 +- phpseclib/Crypt/DSA/PublicKey.php | 2 +- phpseclib/Crypt/EC.php | 16 ++++---- phpseclib/Crypt/EC/BaseCurves/Binary.php | 3 +- .../Crypt/EC/BaseCurves/KoblitzPrime.php | 4 +- phpseclib/Crypt/EC/BaseCurves/Montgomery.php | 5 +-- phpseclib/Crypt/EC/BaseCurves/Prime.php | 4 +- .../Crypt/EC/BaseCurves/TwistedEdwards.php | 2 +- phpseclib/Crypt/EC/Curves/Ed25519.php | 2 +- phpseclib/Crypt/EC/Curves/Ed448.php | 2 +- phpseclib/Crypt/EC/Formats/Keys/Common.php | 13 +++---- .../EC/Formats/Keys/MontgomeryPrivate.php | 4 +- .../EC/Formats/Keys/MontgomeryPublic.php | 3 +- phpseclib/Crypt/EC/Formats/Keys/OpenSSH.php | 5 +-- phpseclib/Crypt/EC/Formats/Keys/PKCS1.php | 12 +++--- phpseclib/Crypt/EC/Formats/Keys/PKCS8.php | 10 ++--- phpseclib/Crypt/EC/Formats/Keys/PuTTY.php | 2 +- phpseclib/Crypt/EC/Formats/Keys/XML.php | 6 +-- phpseclib/Crypt/EC/Formats/Keys/libsodium.php | 2 +- phpseclib/Crypt/EC/Formats/Signature/ASN1.php | 2 +- phpseclib/Crypt/EC/Formats/Signature/SSH2.php | 2 +- phpseclib/Crypt/EC/PrivateKey.php | 22 +++++------ phpseclib/Crypt/EC/PublicKey.php | 12 +++--- phpseclib/Crypt/Hash.php | 7 ++-- phpseclib/Crypt/PublicKeyLoader.php | 2 +- phpseclib/Crypt/RSA.php | 6 +-- phpseclib/Crypt/RSA/Formats/Keys/MSBLOB.php | 2 +- phpseclib/Crypt/RSA/Formats/Keys/OpenSSH.php | 3 +- phpseclib/Crypt/RSA/Formats/Keys/PKCS1.php | 4 +- phpseclib/Crypt/RSA/Formats/Keys/PKCS8.php | 4 +- phpseclib/Crypt/RSA/Formats/Keys/PSS.php | 4 +- phpseclib/Crypt/RSA/Formats/Keys/PuTTY.php | 2 +- phpseclib/Crypt/RSA/Formats/Keys/XML.php | 2 +- phpseclib/Crypt/RSA/PrivateKey.php | 12 ++---- phpseclib/Crypt/RSA/PublicKey.php | 17 ++++----- phpseclib/Crypt/Rijndael.php | 10 ++--- phpseclib/Crypt/Salsa20.php | 6 +-- phpseclib/File/ASN1.php | 11 +++--- phpseclib/File/X509.php | 37 +++++++++---------- .../Engines/BCMath/Reductions/EvalBarrett.php | 2 +- phpseclib/Math/BigInteger/Engines/Engine.php | 6 +-- phpseclib/Math/BigInteger/Engines/GMP.php | 1 - phpseclib/Math/BigInteger/Engines/OpenSSL.php | 1 - .../BigInteger/Engines/PHP/Montgomery.php | 5 +-- .../Engines/PHP/Reductions/EvalBarrett.php | 2 +- .../Engines/PHP/Reductions/MontgomeryMult.php | 1 - phpseclib/Math/BigInteger/Engines/PHP32.php | 1 - phpseclib/Math/BigInteger/Engines/PHP64.php | 1 - phpseclib/Math/BinaryField.php | 5 +-- phpseclib/Math/BinaryField/Integer.php | 4 +- phpseclib/Math/PrimeField/Integer.php | 4 +- phpseclib/Net/SFTP.php | 4 +- phpseclib/Net/SSH2.php | 29 +++++++-------- phpseclib/System/SSH/Agent.php | 4 +- phpseclib/System/SSH/Agent/Identity.php | 10 ++--- tests/Functional/Net/SFTPLargeFileTest.php | 1 - tests/Functional/Net/SFTPWrongServerTest.php | 2 +- tests/Functional/Net/SSH2Test.php | 2 +- tests/PhpseclibFunctionalTestCase.php | 2 - 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 | 1 - tests/Unit/Crypt/DHTest.php | 6 +-- tests/Unit/Crypt/DSA/CreateKeyTest.php | 2 +- tests/Unit/Crypt/DSA/LoadDSAKeyTest.php | 8 +--- tests/Unit/Crypt/EC/CurveTest.php | 9 ++--- tests/Unit/Crypt/EC/KeyTest.php | 4 +- tests/Unit/Crypt/RC4Test.php | 2 +- tests/Unit/Crypt/RSA/LoadKeyTest.php | 14 +++---- tests/Unit/Crypt/RSA/ModeTest.php | 4 +- tests/Unit/File/ASN1Test.php | 32 ++++++++-------- tests/Unit/File/X509/CSRTest.php | 4 +- tests/Unit/File/X509/SPKACTest.php | 2 +- tests/Unit/File/X509/X509Test.php | 6 +-- tests/Unit/Math/BigInteger/BCMathTest.php | 2 +- tests/Unit/Math/BigInteger/DefaultTest.php | 2 +- tests/Unit/Math/BigInteger/GMPTest.php | 2 +- tests/Unit/Math/BigInteger/PHP32Test.php | 2 +- .../Unit/Math/BigInteger/PHP64OpenSSLTest.php | 2 +- tests/Unit/Math/BigInteger/PHP64Test.php | 2 +- tests/Unit/Math/BigInteger/TestCase.php | 4 +- travis/setup-composer.sh | 3 ++ 107 files changed, 296 insertions(+), 296 deletions(-) create mode 100644 build/composer.json create mode 100644 build/php-cs-fixer.php diff --git a/.gitignore b/.gitignore index a40184b6..bb8002f5 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,8 @@ -/vendor -/composer.phar /.idea/ +/build/vendor/ +/build/php-cs-fixer.cache +/build/composer.lock +/composer.lock +/composer.phar +/vendor/ .gitignore -composer.lock diff --git a/.travis.yml b/.travis.yml index 0fba2129..924c6d27 100644 --- a/.travis.yml +++ b/.travis.yml @@ -34,4 +34,5 @@ install: 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/php-cs-fixer fix --config=build/php-cs-fixer.php --diff --dry-run; fi" - travis/run-phpunit.sh diff --git a/build/composer.json b/build/composer.json new file mode 100644 index 00000000..fd870b48 --- /dev/null +++ b/build/composer.json @@ -0,0 +1,14 @@ +{ + "name": "phpseclib/tools", + "description": "", + "minimum-stability": "stable", + "license": "proprietary", + "authors": [{"name": "Jack Worman", "email": "jworman@healthcall.com"}], + "require": { + "php": "^8.1.0", + "friendsofphp/php-cs-fixer": "^3.5" + }, + "config": { + "sort-packages": true + } +} diff --git a/build/php-cs-fixer.php b/build/php-cs-fixer.php new file mode 100644 index 00000000..e66ad577 --- /dev/null +++ b/build/php-cs-fixer.php @@ -0,0 +1,23 @@ +setFinder(PhpCsFixer\Finder::create()->in(__DIR__ . '/..')) + ->setCacheFile(__DIR__ . '/php-cs-fixer.cache') + ->setRiskyAllowed(true) + // https://github.com/FriendsOfPHP/PHP-CS-Fixer/blob/master/doc/rules/index.rst + ->setRules( + [ + // Array + 'array_syntax' => ['syntax' => 'short'], + // Function Notation + 'native_function_invocation' => ['exclude' => [], 'include' => [], 'scope' => 'all', 'strict' => true], + // Import + 'fully_qualified_strict_types' => true, + 'global_namespace_import' => ['import_constants' => false, 'import_functions' => false, 'import_classes' => false], + 'no_leading_import_slash' => true, + 'no_unused_imports' => true, + 'ordered_imports' => ['sort_algorithm' => 'alpha', 'imports_order' => ['class', 'const', 'function']], + 'single_import_per_statement' => true, + 'single_line_after_imports' => true, + ] + ); diff --git a/phpseclib/Crypt/ChaCha20.php b/phpseclib/Crypt/ChaCha20.php index 0bf1c2eb..83686f19 100644 --- a/phpseclib/Crypt/ChaCha20.php +++ b/phpseclib/Crypt/ChaCha20.php @@ -15,8 +15,8 @@ namespace phpseclib3\Crypt; -use phpseclib3\Exception\InsufficientSetupException; use phpseclib3\Exception\BadDecryptionException; +use phpseclib3\Exception\InsufficientSetupException; /** * Pure-PHP implementation of ChaCha20. diff --git a/phpseclib/Crypt/Common/AsymmetricKey.php b/phpseclib/Crypt/Common/AsymmetricKey.php index e94aa976..d5fa46dc 100644 --- a/phpseclib/Crypt/Common/AsymmetricKey.php +++ b/phpseclib/Crypt/Common/AsymmetricKey.php @@ -15,13 +15,12 @@ namespace phpseclib3\Crypt\Common; -use phpseclib3\Exception\UnsupportedFormatException; -use phpseclib3\Exception\NoKeyLoadedException; -use phpseclib3\Math\BigInteger; +use phpseclib3\Crypt\DSA; use phpseclib3\Crypt\Hash; use phpseclib3\Crypt\RSA; -use phpseclib3\Crypt\DSA; -use phpseclib3\Crypt\ECDSA; +use phpseclib3\Exception\NoKeyLoadedException; +use phpseclib3\Exception\UnsupportedFormatException; +use phpseclib3\Math\BigInteger; /** * Base Class for all asymmetric cipher classes diff --git a/phpseclib/Crypt/Common/Formats/Keys/PKCS1.php b/phpseclib/Crypt/Common/Formats/Keys/PKCS1.php index a362d938..ee0d2c7e 100644 --- a/phpseclib/Crypt/Common/Formats/Keys/PKCS1.php +++ b/phpseclib/Crypt/Common/Formats/Keys/PKCS1.php @@ -17,13 +17,13 @@ namespace phpseclib3\Crypt\Common\Formats\Keys; use ParagonIE\ConstantTime\Base64; use ParagonIE\ConstantTime\Hex; -use phpseclib3\Crypt\Random; +use phpseclib3\Common\Functions\Strings; use phpseclib3\Crypt\AES; use phpseclib3\Crypt\DES; +use phpseclib3\Crypt\Random; use phpseclib3\Crypt\TripleDES; -use phpseclib3\File\ASN1; -use phpseclib3\Common\Functions\Strings; use phpseclib3\Exception\UnsupportedAlgorithmException; +use phpseclib3\File\ASN1; /** * PKCS1 Formatted Key Handler diff --git a/phpseclib/Crypt/Common/Formats/Keys/PKCS8.php b/phpseclib/Crypt/Common/Formats/Keys/PKCS8.php index cb6d83ce..789e95cf 100644 --- a/phpseclib/Crypt/Common/Formats/Keys/PKCS8.php +++ b/phpseclib/Crypt/Common/Formats/Keys/PKCS8.php @@ -28,17 +28,16 @@ namespace phpseclib3\Crypt\Common\Formats\Keys; use ParagonIE\ConstantTime\Base64; +use phpseclib3\Common\Functions\Strings; +use phpseclib3\Crypt\AES; use phpseclib3\Crypt\DES; +use phpseclib3\Crypt\Random; use phpseclib3\Crypt\RC2; use phpseclib3\Crypt\RC4; -use phpseclib3\Crypt\AES; use phpseclib3\Crypt\TripleDES; -use phpseclib3\Crypt\Random; -use phpseclib3\Math\BigInteger; +use phpseclib3\Exception\UnsupportedAlgorithmException; use phpseclib3\File\ASN1; use phpseclib3\File\ASN1\Maps; -use phpseclib3\Common\Functions\Strings; -use phpseclib3\Exception\UnsupportedAlgorithmException; /** * PKCS#8 Formatted Key Handler diff --git a/phpseclib/Crypt/Common/Formats/Keys/PuTTY.php b/phpseclib/Crypt/Common/Formats/Keys/PuTTY.php index ccd06f75..3bfc682e 100644 --- a/phpseclib/Crypt/Common/Formats/Keys/PuTTY.php +++ b/phpseclib/Crypt/Common/Formats/Keys/PuTTY.php @@ -17,10 +17,10 @@ namespace phpseclib3\Crypt\Common\Formats\Keys; use ParagonIE\ConstantTime\Base64; use ParagonIE\ConstantTime\Hex; +use phpseclib3\Common\Functions\Strings; use phpseclib3\Crypt\AES; use phpseclib3\Crypt\Hash; use phpseclib3\Crypt\Random; -use phpseclib3\Common\Functions\Strings; use phpseclib3\Exception\UnsupportedAlgorithmException; /** diff --git a/phpseclib/Crypt/Common/SymmetricKey.php b/phpseclib/Crypt/Common/SymmetricKey.php index 7075f205..519a284e 100644 --- a/phpseclib/Crypt/Common/SymmetricKey.php +++ b/phpseclib/Crypt/Common/SymmetricKey.php @@ -36,16 +36,16 @@ namespace phpseclib3\Crypt\Common; -use phpseclib3\Crypt\Hash; use phpseclib3\Common\Functions\Strings; -use phpseclib3\Math\BigInteger; -use phpseclib3\Math\BinaryField; -use phpseclib3\Math\PrimeField; +use phpseclib3\Crypt\Hash; use phpseclib3\Exception\BadDecryptionException; use phpseclib3\Exception\BadModeException; use phpseclib3\Exception\InconsistentSetupException; use phpseclib3\Exception\InsufficientSetupException; use phpseclib3\Exception\UnsupportedAlgorithmException; +use phpseclib3\Math\BigInteger; +use phpseclib3\Math\BinaryField; +use phpseclib3\Math\PrimeField; /** * Base Class for all \phpseclib3\Crypt\* cipher classes diff --git a/phpseclib/Crypt/DH.php b/phpseclib/Crypt/DH.php index c7e6e57a..01eb460e 100644 --- a/phpseclib/Crypt/DH.php +++ b/phpseclib/Crypt/DH.php @@ -26,12 +26,12 @@ namespace phpseclib3\Crypt; -use phpseclib3\Exception\NoKeyLoadedException; -use phpseclib3\Exception\UnsupportedOperationException; use phpseclib3\Crypt\Common\AsymmetricKey; +use phpseclib3\Crypt\DH\Parameters; use phpseclib3\Crypt\DH\PrivateKey; use phpseclib3\Crypt\DH\PublicKey; -use phpseclib3\Crypt\DH\Parameters; +use phpseclib3\Exception\NoKeyLoadedException; +use phpseclib3\Exception\UnsupportedOperationException; use phpseclib3\Math\BigInteger; /** diff --git a/phpseclib/Crypt/DH/Formats/Keys/PKCS1.php b/phpseclib/Crypt/DH/Formats/Keys/PKCS1.php index 368b187f..094332a4 100644 --- a/phpseclib/Crypt/DH/Formats/Keys/PKCS1.php +++ b/phpseclib/Crypt/DH/Formats/Keys/PKCS1.php @@ -23,10 +23,10 @@ namespace phpseclib3\Crypt\DH\Formats\Keys; -use phpseclib3\Math\BigInteger; use phpseclib3\Crypt\Common\Formats\Keys\PKCS1 as Progenitor; use phpseclib3\File\ASN1; use phpseclib3\File\ASN1\Maps; +use phpseclib3\Math\BigInteger; /** * "PKCS1" Formatted DH Key Handler diff --git a/phpseclib/Crypt/DH/Formats/Keys/PKCS8.php b/phpseclib/Crypt/DH/Formats/Keys/PKCS8.php index e69fcee6..5120a8ba 100644 --- a/phpseclib/Crypt/DH/Formats/Keys/PKCS8.php +++ b/phpseclib/Crypt/DH/Formats/Keys/PKCS8.php @@ -21,11 +21,11 @@ namespace phpseclib3\Crypt\DH\Formats\Keys; -use phpseclib3\Math\BigInteger; +use phpseclib3\Common\Functions\Strings; use phpseclib3\Crypt\Common\Formats\Keys\PKCS8 as Progenitor; use phpseclib3\File\ASN1; use phpseclib3\File\ASN1\Maps; -use phpseclib3\Common\Functions\Strings; +use phpseclib3\Math\BigInteger; /** * PKCS#8 Formatted DH Key Handler diff --git a/phpseclib/Crypt/DH/PrivateKey.php b/phpseclib/Crypt/DH/PrivateKey.php index fd92165a..a382630f 100644 --- a/phpseclib/Crypt/DH/PrivateKey.php +++ b/phpseclib/Crypt/DH/PrivateKey.php @@ -13,8 +13,8 @@ namespace phpseclib3\Crypt\DH; -use phpseclib3\Crypt\DH; use phpseclib3\Crypt\Common; +use phpseclib3\Crypt\DH; /** * DH Private Key diff --git a/phpseclib/Crypt/DH/PublicKey.php b/phpseclib/Crypt/DH/PublicKey.php index 9670e28a..f4c6eb62 100644 --- a/phpseclib/Crypt/DH/PublicKey.php +++ b/phpseclib/Crypt/DH/PublicKey.php @@ -13,8 +13,8 @@ namespace phpseclib3\Crypt\DH; -use phpseclib3\Crypt\DH; use phpseclib3\Crypt\Common; +use phpseclib3\Crypt\DH; /** * DH Public Key diff --git a/phpseclib/Crypt/DSA.php b/phpseclib/Crypt/DSA.php index 110e7767..4abd4695 100644 --- a/phpseclib/Crypt/DSA.php +++ b/phpseclib/Crypt/DSA.php @@ -32,11 +32,11 @@ namespace phpseclib3\Crypt; use phpseclib3\Crypt\Common\AsymmetricKey; +use phpseclib3\Crypt\DSA\Parameters; use phpseclib3\Crypt\DSA\PrivateKey; use phpseclib3\Crypt\DSA\PublicKey; -use phpseclib3\Crypt\DSA\Parameters; -use phpseclib3\Math\BigInteger; use phpseclib3\Exception\InsufficientSetupException; +use phpseclib3\Math\BigInteger; /** * Pure-PHP FIPS 186-4 compliant implementation of DSA. diff --git a/phpseclib/Crypt/DSA/Formats/Keys/OpenSSH.php b/phpseclib/Crypt/DSA/Formats/Keys/OpenSSH.php index bf2d9860..922cc24a 100644 --- a/phpseclib/Crypt/DSA/Formats/Keys/OpenSSH.php +++ b/phpseclib/Crypt/DSA/Formats/Keys/OpenSSH.php @@ -17,10 +17,9 @@ namespace phpseclib3\Crypt\DSA\Formats\Keys; -use ParagonIE\ConstantTime\Base64; -use phpseclib3\Math\BigInteger; use phpseclib3\Common\Functions\Strings; use phpseclib3\Crypt\Common\Formats\Keys\OpenSSH as Progenitor; +use phpseclib3\Math\BigInteger; /** * OpenSSH Formatted DSA Key Handler diff --git a/phpseclib/Crypt/DSA/Formats/Keys/PKCS1.php b/phpseclib/Crypt/DSA/Formats/Keys/PKCS1.php index 75748737..ff464b2f 100644 --- a/phpseclib/Crypt/DSA/Formats/Keys/PKCS1.php +++ b/phpseclib/Crypt/DSA/Formats/Keys/PKCS1.php @@ -29,11 +29,11 @@ namespace phpseclib3\Crypt\DSA\Formats\Keys; -use phpseclib3\Math\BigInteger; +use ParagonIE\ConstantTime\Base64; use phpseclib3\Crypt\Common\Formats\Keys\PKCS1 as Progenitor; use phpseclib3\File\ASN1; use phpseclib3\File\ASN1\Maps; -use ParagonIE\ConstantTime\Base64; +use phpseclib3\Math\BigInteger; /** * PKCS#1 Formatted DSA Key Handler diff --git a/phpseclib/Crypt/DSA/Formats/Keys/PKCS8.php b/phpseclib/Crypt/DSA/Formats/Keys/PKCS8.php index 71f66eb0..ab58c698 100644 --- a/phpseclib/Crypt/DSA/Formats/Keys/PKCS8.php +++ b/phpseclib/Crypt/DSA/Formats/Keys/PKCS8.php @@ -25,11 +25,11 @@ namespace phpseclib3\Crypt\DSA\Formats\Keys; -use phpseclib3\Math\BigInteger; +use phpseclib3\Common\Functions\Strings; use phpseclib3\Crypt\Common\Formats\Keys\PKCS8 as Progenitor; use phpseclib3\File\ASN1; use phpseclib3\File\ASN1\Maps; -use phpseclib3\Common\Functions\Strings; +use phpseclib3\Math\BigInteger; /** * PKCS#8 Formatted DSA Key Handler diff --git a/phpseclib/Crypt/DSA/Formats/Keys/PuTTY.php b/phpseclib/Crypt/DSA/Formats/Keys/PuTTY.php index 5f71e684..af50e451 100644 --- a/phpseclib/Crypt/DSA/Formats/Keys/PuTTY.php +++ b/phpseclib/Crypt/DSA/Formats/Keys/PuTTY.php @@ -20,9 +20,9 @@ namespace phpseclib3\Crypt\DSA\Formats\Keys; -use phpseclib3\Math\BigInteger; use phpseclib3\Common\Functions\Strings; use phpseclib3\Crypt\Common\Formats\Keys\PuTTY as Progenitor; +use phpseclib3\Math\BigInteger; /** * PuTTY Formatted DSA Key Handler diff --git a/phpseclib/Crypt/DSA/Formats/Keys/XML.php b/phpseclib/Crypt/DSA/Formats/Keys/XML.php index 42b3bbb9..bdb3b159 100644 --- a/phpseclib/Crypt/DSA/Formats/Keys/XML.php +++ b/phpseclib/Crypt/DSA/Formats/Keys/XML.php @@ -22,8 +22,8 @@ namespace phpseclib3\Crypt\DSA\Formats\Keys; use ParagonIE\ConstantTime\Base64; -use phpseclib3\Math\BigInteger; use phpseclib3\Common\Functions\Strings; +use phpseclib3\Math\BigInteger; /** * XML Formatted DSA Key Handler diff --git a/phpseclib/Crypt/DSA/Formats/Signature/ASN1.php b/phpseclib/Crypt/DSA/Formats/Signature/ASN1.php index a9c29a34..7ee2d8d1 100644 --- a/phpseclib/Crypt/DSA/Formats/Signature/ASN1.php +++ b/phpseclib/Crypt/DSA/Formats/Signature/ASN1.php @@ -18,9 +18,9 @@ namespace phpseclib3\Crypt\DSA\Formats\Signature; -use phpseclib3\Math\BigInteger; use phpseclib3\File\ASN1 as Encoder; use phpseclib3\File\ASN1\Maps; +use phpseclib3\Math\BigInteger; /** * ASN1 Signature Handler diff --git a/phpseclib/Crypt/DSA/Formats/Signature/SSH2.php b/phpseclib/Crypt/DSA/Formats/Signature/SSH2.php index 39f1f6ce..41426055 100644 --- a/phpseclib/Crypt/DSA/Formats/Signature/SSH2.php +++ b/phpseclib/Crypt/DSA/Formats/Signature/SSH2.php @@ -17,8 +17,8 @@ namespace phpseclib3\Crypt\DSA\Formats\Signature; -use phpseclib3\Math\BigInteger; use phpseclib3\Common\Functions\Strings; +use phpseclib3\Math\BigInteger; /** * SSH2 Signature Handler diff --git a/phpseclib/Crypt/DSA/PrivateKey.php b/phpseclib/Crypt/DSA/PrivateKey.php index c976f2cf..5d639079 100644 --- a/phpseclib/Crypt/DSA/PrivateKey.php +++ b/phpseclib/Crypt/DSA/PrivateKey.php @@ -13,10 +13,10 @@ namespace phpseclib3\Crypt\DSA; +use phpseclib3\Crypt\Common; use phpseclib3\Crypt\DSA; use phpseclib3\Crypt\DSA\Formats\Signature\ASN1 as ASN1Signature; use phpseclib3\Math\BigInteger; -use phpseclib3\Crypt\Common; /** * DSA Private Key diff --git a/phpseclib/Crypt/DSA/PublicKey.php b/phpseclib/Crypt/DSA/PublicKey.php index 156476f0..cd4cdc5c 100644 --- a/phpseclib/Crypt/DSA/PublicKey.php +++ b/phpseclib/Crypt/DSA/PublicKey.php @@ -13,9 +13,9 @@ namespace phpseclib3\Crypt\DSA; +use phpseclib3\Crypt\Common; use phpseclib3\Crypt\DSA; use phpseclib3\Crypt\DSA\Formats\Signature\ASN1 as ASN1Signature; -use phpseclib3\Crypt\Common; /** * DSA Public Key diff --git a/phpseclib/Crypt/EC.php b/phpseclib/Crypt/EC.php index 2c0ab197..86b3412a 100644 --- a/phpseclib/Crypt/EC.php +++ b/phpseclib/Crypt/EC.php @@ -32,21 +32,21 @@ namespace phpseclib3\Crypt; use phpseclib3\Crypt\Common\AsymmetricKey; -use phpseclib3\Crypt\EC\PrivateKey; -use phpseclib3\Crypt\EC\PublicKey; -use phpseclib3\Crypt\EC\Parameters; -use phpseclib3\Crypt\EC\BaseCurves\TwistedEdwards as TwistedEdwardsCurve; use phpseclib3\Crypt\EC\BaseCurves\Montgomery as MontgomeryCurve; +use phpseclib3\Crypt\EC\BaseCurves\TwistedEdwards as TwistedEdwardsCurve; use phpseclib3\Crypt\EC\Curves\Curve25519; use phpseclib3\Crypt\EC\Curves\Ed25519; use phpseclib3\Crypt\EC\Curves\Ed448; use phpseclib3\Crypt\EC\Formats\Keys\PKCS1; -use phpseclib3\File\ASN1\Maps\ECParameters; -use phpseclib3\File\ASN1; -use phpseclib3\Math\BigInteger; -use phpseclib3\Exception\UnsupportedCurveException; +use phpseclib3\Crypt\EC\Parameters; +use phpseclib3\Crypt\EC\PrivateKey; +use phpseclib3\Crypt\EC\PublicKey; use phpseclib3\Exception\UnsupportedAlgorithmException; +use phpseclib3\Exception\UnsupportedCurveException; use phpseclib3\Exception\UnsupportedOperationException; +use phpseclib3\File\ASN1; +use phpseclib3\File\ASN1\Maps\ECParameters; +use phpseclib3\Math\BigInteger; /** * Pure-PHP implementation of EC. diff --git a/phpseclib/Crypt/EC/BaseCurves/Binary.php b/phpseclib/Crypt/EC/BaseCurves/Binary.php index 1b2e18e2..0c9d9826 100644 --- a/phpseclib/Crypt/EC/BaseCurves/Binary.php +++ b/phpseclib/Crypt/EC/BaseCurves/Binary.php @@ -23,9 +23,8 @@ namespace phpseclib3\Crypt\EC\BaseCurves; -use phpseclib3\Common\Functions\Strings; -use phpseclib3\Math\BinaryField; use phpseclib3\Math\BigInteger; +use phpseclib3\Math\BinaryField; use phpseclib3\Math\BinaryField\Integer as BinaryInteger; /** diff --git a/phpseclib/Crypt/EC/BaseCurves/KoblitzPrime.php b/phpseclib/Crypt/EC/BaseCurves/KoblitzPrime.php index 0a93f512..fe885e72 100644 --- a/phpseclib/Crypt/EC/BaseCurves/KoblitzPrime.php +++ b/phpseclib/Crypt/EC/BaseCurves/KoblitzPrime.php @@ -30,10 +30,8 @@ namespace phpseclib3\Crypt\EC\BaseCurves; -use phpseclib3\Common\Functions\Strings; -use phpseclib3\Math\PrimeField; use phpseclib3\Math\BigInteger; -use phpseclib3\Math\PrimeField\Integer as PrimeInteger; +use phpseclib3\Math\PrimeField; /** * Curves over y^2 = x^3 + b diff --git a/phpseclib/Crypt/EC/BaseCurves/Montgomery.php b/phpseclib/Crypt/EC/BaseCurves/Montgomery.php index 49693745..bfa2926e 100644 --- a/phpseclib/Crypt/EC/BaseCurves/Montgomery.php +++ b/phpseclib/Crypt/EC/BaseCurves/Montgomery.php @@ -26,10 +26,9 @@ namespace phpseclib3\Crypt\EC\BaseCurves; -use phpseclib3\Common\Functions\Strings; -use phpseclib3\Math\PrimeField; -use phpseclib3\Math\BigInteger; use phpseclib3\Crypt\EC\Curves\Curve25519; +use phpseclib3\Math\BigInteger; +use phpseclib3\Math\PrimeField; use phpseclib3\Math\PrimeField\Integer as PrimeInteger; /** diff --git a/phpseclib/Crypt/EC/BaseCurves/Prime.php b/phpseclib/Crypt/EC/BaseCurves/Prime.php index 07606cfa..696960f7 100644 --- a/phpseclib/Crypt/EC/BaseCurves/Prime.php +++ b/phpseclib/Crypt/EC/BaseCurves/Prime.php @@ -23,10 +23,10 @@ namespace phpseclib3\Crypt\EC\BaseCurves; -use phpseclib3\Math\Common\FiniteField\Integer; use phpseclib3\Common\Functions\Strings; -use phpseclib3\Math\PrimeField; use phpseclib3\Math\BigInteger; +use phpseclib3\Math\Common\FiniteField\Integer; +use phpseclib3\Math\PrimeField; use phpseclib3\Math\PrimeField\Integer as PrimeInteger; /** diff --git a/phpseclib/Crypt/EC/BaseCurves/TwistedEdwards.php b/phpseclib/Crypt/EC/BaseCurves/TwistedEdwards.php index ff4ff2d4..2bf61950 100644 --- a/phpseclib/Crypt/EC/BaseCurves/TwistedEdwards.php +++ b/phpseclib/Crypt/EC/BaseCurves/TwistedEdwards.php @@ -28,8 +28,8 @@ namespace phpseclib3\Crypt\EC\BaseCurves; -use phpseclib3\Math\PrimeField; use phpseclib3\Math\BigInteger; +use phpseclib3\Math\PrimeField; use phpseclib3\Math\PrimeField\Integer as PrimeInteger; /** diff --git a/phpseclib/Crypt/EC/Curves/Ed25519.php b/phpseclib/Crypt/EC/Curves/Ed25519.php index ebbc8648..4f64cff1 100644 --- a/phpseclib/Crypt/EC/Curves/Ed25519.php +++ b/phpseclib/Crypt/EC/Curves/Ed25519.php @@ -15,9 +15,9 @@ namespace phpseclib3\Crypt\EC\Curves; use phpseclib3\Crypt\EC\BaseCurves\TwistedEdwards; -use phpseclib3\Math\BigInteger; use phpseclib3\Crypt\Hash; use phpseclib3\Crypt\Random; +use phpseclib3\Math\BigInteger; class Ed25519 extends TwistedEdwards { diff --git a/phpseclib/Crypt/EC/Curves/Ed448.php b/phpseclib/Crypt/EC/Curves/Ed448.php index 53704e7b..5979e28c 100644 --- a/phpseclib/Crypt/EC/Curves/Ed448.php +++ b/phpseclib/Crypt/EC/Curves/Ed448.php @@ -15,9 +15,9 @@ namespace phpseclib3\Crypt\EC\Curves; use phpseclib3\Crypt\EC\BaseCurves\TwistedEdwards; -use phpseclib3\Math\BigInteger; use phpseclib3\Crypt\Hash; use phpseclib3\Crypt\Random; +use phpseclib3\Math\BigInteger; class Ed448 extends TwistedEdwards { diff --git a/phpseclib/Crypt/EC/Formats/Keys/Common.php b/phpseclib/Crypt/EC/Formats/Keys/Common.php index c8a63be1..bf7e9aca 100644 --- a/phpseclib/Crypt/EC/Formats/Keys/Common.php +++ b/phpseclib/Crypt/EC/Formats/Keys/Common.php @@ -16,16 +16,15 @@ namespace phpseclib3\Crypt\EC\Formats\Keys; use ParagonIE\ConstantTime\Hex; -use phpseclib3\Crypt\EC\BaseCurves\Base as BaseCurve; -use phpseclib3\Crypt\EC\BaseCurves\Prime as PrimeCurve; -use phpseclib3\Crypt\EC\BaseCurves\Binary as BinaryCurve; -use phpseclib3\Crypt\EC\BaseCurves\TwistedEdwards as TwistedEdwardsCurve; use phpseclib3\Common\Functions\Strings; -use phpseclib3\Math\BigInteger; -use phpseclib3\Math\PrimeField; +use phpseclib3\Crypt\EC\BaseCurves\Base as BaseCurve; +use phpseclib3\Crypt\EC\BaseCurves\Binary as BinaryCurve; +use phpseclib3\Crypt\EC\BaseCurves\Prime as PrimeCurve; +use phpseclib3\Crypt\EC\BaseCurves\TwistedEdwards as TwistedEdwardsCurve; +use phpseclib3\Exception\UnsupportedCurveException; use phpseclib3\File\ASN1; use phpseclib3\File\ASN1\Maps; -use phpseclib3\Exception\UnsupportedCurveException; +use phpseclib3\Math\BigInteger; /** * Generic EC Key Parsing Helper functions diff --git a/phpseclib/Crypt/EC/Formats/Keys/MontgomeryPrivate.php b/phpseclib/Crypt/EC/Formats/Keys/MontgomeryPrivate.php index 92420ba1..01fb8515 100644 --- a/phpseclib/Crypt/EC/Formats/Keys/MontgomeryPrivate.php +++ b/phpseclib/Crypt/EC/Formats/Keys/MontgomeryPrivate.php @@ -22,11 +22,11 @@ namespace phpseclib3\Crypt\EC\Formats\Keys; +use phpseclib3\Crypt\EC\BaseCurves\Montgomery as MontgomeryCurve; use phpseclib3\Crypt\EC\Curves\Curve25519; use phpseclib3\Crypt\EC\Curves\Curve448; -use phpseclib3\Crypt\EC\BaseCurves\Montgomery as MontgomeryCurve; -use phpseclib3\Math\BigInteger; use phpseclib3\Exception\UnsupportedFormatException; +use phpseclib3\Math\BigInteger; /** * Montgomery Curve Private Key Handler diff --git a/phpseclib/Crypt/EC/Formats/Keys/MontgomeryPublic.php b/phpseclib/Crypt/EC/Formats/Keys/MontgomeryPublic.php index 72dc80b1..91a88bd4 100644 --- a/phpseclib/Crypt/EC/Formats/Keys/MontgomeryPublic.php +++ b/phpseclib/Crypt/EC/Formats/Keys/MontgomeryPublic.php @@ -15,10 +15,9 @@ namespace phpseclib3\Crypt\EC\Formats\Keys; +use phpseclib3\Crypt\EC\BaseCurves\Montgomery as MontgomeryCurve; use phpseclib3\Crypt\EC\Curves\Curve25519; use phpseclib3\Crypt\EC\Curves\Curve448; -use phpseclib3\Crypt\EC\BaseCurves\Montgomery as MontgomeryCurve; -use phpseclib3\Math\Common\FiniteField\Integer; use phpseclib3\Math\BigInteger; /** diff --git a/phpseclib/Crypt/EC/Formats/Keys/OpenSSH.php b/phpseclib/Crypt/EC/Formats/Keys/OpenSSH.php index fed992b4..269ec0f8 100644 --- a/phpseclib/Crypt/EC/Formats/Keys/OpenSSH.php +++ b/phpseclib/Crypt/EC/Formats/Keys/OpenSSH.php @@ -17,13 +17,12 @@ namespace phpseclib3\Crypt\EC\Formats\Keys; -use ParagonIE\ConstantTime\Base64; -use phpseclib3\Math\BigInteger; use phpseclib3\Common\Functions\Strings; use phpseclib3\Crypt\Common\Formats\Keys\OpenSSH as Progenitor; use phpseclib3\Crypt\EC\BaseCurves\Base as BaseCurve; -use phpseclib3\Exception\UnsupportedCurveException; use phpseclib3\Crypt\EC\Curves\Ed25519; +use phpseclib3\Exception\UnsupportedCurveException; +use phpseclib3\Math\BigInteger; /** * OpenSSH Formatted EC Key Handler diff --git a/phpseclib/Crypt/EC/Formats/Keys/PKCS1.php b/phpseclib/Crypt/EC/Formats/Keys/PKCS1.php index 1aae7d94..dc494536 100644 --- a/phpseclib/Crypt/EC/Formats/Keys/PKCS1.php +++ b/phpseclib/Crypt/EC/Formats/Keys/PKCS1.php @@ -27,16 +27,16 @@ namespace phpseclib3\Crypt\EC\Formats\Keys; +use ParagonIE\ConstantTime\Base64; +use phpseclib3\Common\Functions\Strings; use phpseclib3\Crypt\Common\Formats\Keys\PKCS1 as Progenitor; +use phpseclib3\Crypt\EC\BaseCurves\Base as BaseCurve; +use phpseclib3\Crypt\EC\BaseCurves\Montgomery as MontgomeryCurve; +use phpseclib3\Crypt\EC\BaseCurves\TwistedEdwards as TwistedEdwardsCurve; +use phpseclib3\Exception\UnsupportedCurveException; use phpseclib3\File\ASN1; use phpseclib3\File\ASN1\Maps; -use phpseclib3\Crypt\EC\BaseCurves\Base as BaseCurve; use phpseclib3\Math\BigInteger; -use ParagonIE\ConstantTime\Base64; -use phpseclib3\Crypt\EC\BaseCurves\TwistedEdwards as TwistedEdwardsCurve; -use phpseclib3\Crypt\EC\BaseCurves\Montgomery as MontgomeryCurve; -use phpseclib3\Exception\UnsupportedCurveException; -use phpseclib3\Common\Functions\Strings; /** * "PKCS1" (RFC5915) Formatted EC Key Handler diff --git a/phpseclib/Crypt/EC/Formats/Keys/PKCS8.php b/phpseclib/Crypt/EC/Formats/Keys/PKCS8.php index 3546fc4a..a2d0ff28 100644 --- a/phpseclib/Crypt/EC/Formats/Keys/PKCS8.php +++ b/phpseclib/Crypt/EC/Formats/Keys/PKCS8.php @@ -25,17 +25,17 @@ namespace phpseclib3\Crypt\EC\Formats\Keys; -use phpseclib3\Math\BigInteger; +use phpseclib3\Common\Functions\Strings; use phpseclib3\Crypt\Common\Formats\Keys\PKCS8 as Progenitor; -use phpseclib3\File\ASN1; -use phpseclib3\File\ASN1\Maps; use phpseclib3\Crypt\EC\BaseCurves\Base as BaseCurve; -use phpseclib3\Crypt\EC\BaseCurves\TwistedEdwards as TwistedEdwardsCurve; use phpseclib3\Crypt\EC\BaseCurves\Montgomery as MontgomeryCurve; +use phpseclib3\Crypt\EC\BaseCurves\TwistedEdwards as TwistedEdwardsCurve; use phpseclib3\Crypt\EC\Curves\Ed25519; use phpseclib3\Crypt\EC\Curves\Ed448; use phpseclib3\Exception\UnsupportedCurveException; -use phpseclib3\Common\Functions\Strings; +use phpseclib3\File\ASN1; +use phpseclib3\File\ASN1\Maps; +use phpseclib3\Math\BigInteger; /** * PKCS#8 Formatted EC Key Handler diff --git a/phpseclib/Crypt/EC/Formats/Keys/PuTTY.php b/phpseclib/Crypt/EC/Formats/Keys/PuTTY.php index c6b2bd37..60ac545d 100644 --- a/phpseclib/Crypt/EC/Formats/Keys/PuTTY.php +++ b/phpseclib/Crypt/EC/Formats/Keys/PuTTY.php @@ -16,11 +16,11 @@ namespace phpseclib3\Crypt\EC\Formats\Keys; use ParagonIE\ConstantTime\Base64; -use phpseclib3\Math\BigInteger; use phpseclib3\Common\Functions\Strings; use phpseclib3\Crypt\Common\Formats\Keys\PuTTY as Progenitor; use phpseclib3\Crypt\EC\BaseCurves\Base as BaseCurve; use phpseclib3\Crypt\EC\BaseCurves\TwistedEdwards as TwistedEdwardsCurve; +use phpseclib3\Math\BigInteger; /** * PuTTY Formatted EC Key Handler diff --git a/phpseclib/Crypt/EC/Formats/Keys/XML.php b/phpseclib/Crypt/EC/Formats/Keys/XML.php index d2e6fdda..9d399d72 100644 --- a/phpseclib/Crypt/EC/Formats/Keys/XML.php +++ b/phpseclib/Crypt/EC/Formats/Keys/XML.php @@ -21,13 +21,13 @@ namespace phpseclib3\Crypt\EC\Formats\Keys; use ParagonIE\ConstantTime\Base64; -use phpseclib3\Math\BigInteger; +use phpseclib3\Common\Functions\Strings; use phpseclib3\Crypt\EC\BaseCurves\Base as BaseCurve; +use phpseclib3\Crypt\EC\BaseCurves\Montgomery as MontgomeryCurve; use phpseclib3\Crypt\EC\BaseCurves\Prime as PrimeCurve; use phpseclib3\Crypt\EC\BaseCurves\TwistedEdwards as TwistedEdwardsCurve; -use phpseclib3\Crypt\EC\BaseCurves\Montgomery as MontgomeryCurve; -use phpseclib3\Common\Functions\Strings; use phpseclib3\Exception\UnsupportedCurveException; +use phpseclib3\Math\BigInteger; /** * XML Formatted EC Key Handler diff --git a/phpseclib/Crypt/EC/Formats/Keys/libsodium.php b/phpseclib/Crypt/EC/Formats/Keys/libsodium.php index 666de0b5..ef815b60 100644 --- a/phpseclib/Crypt/EC/Formats/Keys/libsodium.php +++ b/phpseclib/Crypt/EC/Formats/Keys/libsodium.php @@ -20,8 +20,8 @@ namespace phpseclib3\Crypt\EC\Formats\Keys; use phpseclib3\Crypt\EC\Curves\Ed25519; -use phpseclib3\Math\BigInteger; use phpseclib3\Exception\UnsupportedFormatException; +use phpseclib3\Math\BigInteger; /** * libsodium Key Handler diff --git a/phpseclib/Crypt/EC/Formats/Signature/ASN1.php b/phpseclib/Crypt/EC/Formats/Signature/ASN1.php index 3509eb61..82f0545d 100644 --- a/phpseclib/Crypt/EC/Formats/Signature/ASN1.php +++ b/phpseclib/Crypt/EC/Formats/Signature/ASN1.php @@ -18,9 +18,9 @@ namespace phpseclib3\Crypt\EC\Formats\Signature; -use phpseclib3\Math\BigInteger; use phpseclib3\File\ASN1 as Encoder; use phpseclib3\File\ASN1\Maps\EcdsaSigValue; +use phpseclib3\Math\BigInteger; /** * ASN1 Signature Handler diff --git a/phpseclib/Crypt/EC/Formats/Signature/SSH2.php b/phpseclib/Crypt/EC/Formats/Signature/SSH2.php index 261100db..e63c022d 100644 --- a/phpseclib/Crypt/EC/Formats/Signature/SSH2.php +++ b/phpseclib/Crypt/EC/Formats/Signature/SSH2.php @@ -17,8 +17,8 @@ namespace phpseclib3\Crypt\EC\Formats\Signature; -use phpseclib3\Math\BigInteger; use phpseclib3\Common\Functions\Strings; +use phpseclib3\Math\BigInteger; /** * SSH2 Signature Handler diff --git a/phpseclib/Crypt/EC/PrivateKey.php b/phpseclib/Crypt/EC/PrivateKey.php index 345660fc..01e71d69 100644 --- a/phpseclib/Crypt/EC/PrivateKey.php +++ b/phpseclib/Crypt/EC/PrivateKey.php @@ -13,18 +13,18 @@ namespace phpseclib3\Crypt\EC; -use phpseclib3\Crypt\EC; -use phpseclib3\Crypt\EC\Formats\Signature\ASN1 as ASN1Signature; -use phpseclib3\Math\BigInteger; -use phpseclib3\Crypt\EC\BaseCurves\TwistedEdwards as TwistedEdwardsCurve; -use phpseclib3\Crypt\EC\BaseCurves\Montgomery as MontgomeryCurve; -use phpseclib3\Crypt\Hash; -use phpseclib3\Crypt\EC\Curves\Ed25519; -use phpseclib3\Crypt\EC\Curves\Curve25519; -use phpseclib3\Crypt\EC\Formats\Keys\PKCS1; -use phpseclib3\Crypt\Common; -use phpseclib3\Exception\UnsupportedOperationException; use phpseclib3\Common\Functions\Strings; +use phpseclib3\Crypt\Common; +use phpseclib3\Crypt\EC; +use phpseclib3\Crypt\EC\BaseCurves\Montgomery as MontgomeryCurve; +use phpseclib3\Crypt\EC\BaseCurves\TwistedEdwards as TwistedEdwardsCurve; +use phpseclib3\Crypt\EC\Curves\Curve25519; +use phpseclib3\Crypt\EC\Curves\Ed25519; +use phpseclib3\Crypt\EC\Formats\Keys\PKCS1; +use phpseclib3\Crypt\EC\Formats\Signature\ASN1 as ASN1Signature; +use phpseclib3\Crypt\Hash; +use phpseclib3\Exception\UnsupportedOperationException; +use phpseclib3\Math\BigInteger; /** * EC Private Key diff --git a/phpseclib/Crypt/EC/PublicKey.php b/phpseclib/Crypt/EC/PublicKey.php index ac85e04a..de01cf8b 100644 --- a/phpseclib/Crypt/EC/PublicKey.php +++ b/phpseclib/Crypt/EC/PublicKey.php @@ -13,17 +13,17 @@ namespace phpseclib3\Crypt\EC; +use phpseclib3\Common\Functions\Strings; +use phpseclib3\Crypt\Common; use phpseclib3\Crypt\EC; -use phpseclib3\Crypt\Hash; -use phpseclib3\Math\BigInteger; -use phpseclib3\Crypt\EC\Formats\Signature\ASN1 as ASN1Signature; -use phpseclib3\Crypt\EC\BaseCurves\TwistedEdwards as TwistedEdwardsCurve; use phpseclib3\Crypt\EC\BaseCurves\Montgomery as MontgomeryCurve; +use phpseclib3\Crypt\EC\BaseCurves\TwistedEdwards as TwistedEdwardsCurve; use phpseclib3\Crypt\EC\Curves\Ed25519; use phpseclib3\Crypt\EC\Formats\Keys\PKCS1; -use phpseclib3\Crypt\Common; +use phpseclib3\Crypt\EC\Formats\Signature\ASN1 as ASN1Signature; +use phpseclib3\Crypt\Hash; use phpseclib3\Exception\UnsupportedOperationException; -use phpseclib3\Common\Functions\Strings; +use phpseclib3\Math\BigInteger; /** * EC Public Key diff --git a/phpseclib/Crypt/Hash.php b/phpseclib/Crypt/Hash.php index 706de214..feed7896 100644 --- a/phpseclib/Crypt/Hash.php +++ b/phpseclib/Crypt/Hash.php @@ -33,11 +33,10 @@ namespace phpseclib3\Crypt; -use phpseclib3\Math\BigInteger; -use phpseclib3\Exception\UnsupportedAlgorithmException; -use phpseclib3\Exception\InsufficientSetupException; use phpseclib3\Common\Functions\Strings; -use phpseclib3\Crypt\AES; +use phpseclib3\Exception\InsufficientSetupException; +use phpseclib3\Exception\UnsupportedAlgorithmException; +use phpseclib3\Math\BigInteger; use phpseclib3\Math\PrimeField; /** diff --git a/phpseclib/Crypt/PublicKeyLoader.php b/phpseclib/Crypt/PublicKeyLoader.php index ff93a6ec..ccb8556c 100644 --- a/phpseclib/Crypt/PublicKeyLoader.php +++ b/phpseclib/Crypt/PublicKeyLoader.php @@ -16,8 +16,8 @@ namespace phpseclib3\Crypt; use phpseclib3\Crypt\Common\AsymmetricKey; -use phpseclib3\Crypt\Common\PublicKey; use phpseclib3\Crypt\Common\PrivateKey; +use phpseclib3\Crypt\Common\PublicKey; use phpseclib3\Exception\NoKeyLoadedException; use phpseclib3\File\X509; diff --git a/phpseclib/Crypt/RSA.php b/phpseclib/Crypt/RSA.php index ff6194ac..54248a17 100644 --- a/phpseclib/Crypt/RSA.php +++ b/phpseclib/Crypt/RSA.php @@ -56,12 +56,12 @@ namespace phpseclib3\Crypt; use phpseclib3\Crypt\Common\AsymmetricKey; +use phpseclib3\Crypt\RSA\Formats\Keys\PSS; use phpseclib3\Crypt\RSA\PrivateKey; use phpseclib3\Crypt\RSA\PublicKey; -use phpseclib3\Math\BigInteger; -use phpseclib3\Exception\UnsupportedAlgorithmException; use phpseclib3\Exception\InconsistentSetupException; -use phpseclib3\Crypt\RSA\Formats\Keys\PSS; +use phpseclib3\Exception\UnsupportedAlgorithmException; +use phpseclib3\Math\BigInteger; /** * Pure-PHP PKCS#1 compliant implementation of RSA. diff --git a/phpseclib/Crypt/RSA/Formats/Keys/MSBLOB.php b/phpseclib/Crypt/RSA/Formats/Keys/MSBLOB.php index 74771204..0077bdb8 100644 --- a/phpseclib/Crypt/RSA/Formats/Keys/MSBLOB.php +++ b/phpseclib/Crypt/RSA/Formats/Keys/MSBLOB.php @@ -20,9 +20,9 @@ namespace phpseclib3\Crypt\RSA\Formats\Keys; use ParagonIE\ConstantTime\Base64; -use phpseclib3\Math\BigInteger; use phpseclib3\Common\Functions\Strings; use phpseclib3\Exception\UnsupportedFormatException; +use phpseclib3\Math\BigInteger; /** * Microsoft BLOB Formatted RSA Key Handler diff --git a/phpseclib/Crypt/RSA/Formats/Keys/OpenSSH.php b/phpseclib/Crypt/RSA/Formats/Keys/OpenSSH.php index 0f92c100..73057803 100644 --- a/phpseclib/Crypt/RSA/Formats/Keys/OpenSSH.php +++ b/phpseclib/Crypt/RSA/Formats/Keys/OpenSSH.php @@ -17,10 +17,9 @@ namespace phpseclib3\Crypt\RSA\Formats\Keys; -use ParagonIE\ConstantTime\Base64; -use phpseclib3\Math\BigInteger; use phpseclib3\Common\Functions\Strings; use phpseclib3\Crypt\Common\Formats\Keys\OpenSSH as Progenitor; +use phpseclib3\Math\BigInteger; /** * OpenSSH Formatted RSA Key Handler diff --git a/phpseclib/Crypt/RSA/Formats/Keys/PKCS1.php b/phpseclib/Crypt/RSA/Formats/Keys/PKCS1.php index 5203e463..8562ba2f 100644 --- a/phpseclib/Crypt/RSA/Formats/Keys/PKCS1.php +++ b/phpseclib/Crypt/RSA/Formats/Keys/PKCS1.php @@ -24,11 +24,11 @@ namespace phpseclib3\Crypt\RSA\Formats\Keys; -use phpseclib3\Math\BigInteger; +use phpseclib3\Common\Functions\Strings; use phpseclib3\Crypt\Common\Formats\Keys\PKCS1 as Progenitor; use phpseclib3\File\ASN1; use phpseclib3\File\ASN1\Maps; -use phpseclib3\Common\Functions\Strings; +use phpseclib3\Math\BigInteger; /** * PKCS#1 Formatted RSA Key Handler diff --git a/phpseclib/Crypt/RSA/Formats/Keys/PKCS8.php b/phpseclib/Crypt/RSA/Formats/Keys/PKCS8.php index 8ead2c95..0bbdfe6e 100644 --- a/phpseclib/Crypt/RSA/Formats/Keys/PKCS8.php +++ b/phpseclib/Crypt/RSA/Formats/Keys/PKCS8.php @@ -27,10 +27,10 @@ namespace phpseclib3\Crypt\RSA\Formats\Keys; -use phpseclib3\Math\BigInteger; +use phpseclib3\Common\Functions\Strings; use phpseclib3\Crypt\Common\Formats\Keys\PKCS8 as Progenitor; use phpseclib3\File\ASN1; -use phpseclib3\Common\Functions\Strings; +use phpseclib3\Math\BigInteger; /** * PKCS#8 Formatted RSA Key Handler diff --git a/phpseclib/Crypt/RSA/Formats/Keys/PSS.php b/phpseclib/Crypt/RSA/Formats/Keys/PSS.php index 813653ae..be7224e5 100644 --- a/phpseclib/Crypt/RSA/Formats/Keys/PSS.php +++ b/phpseclib/Crypt/RSA/Formats/Keys/PSS.php @@ -25,11 +25,11 @@ namespace phpseclib3\Crypt\RSA\Formats\Keys; -use phpseclib3\Math\BigInteger; +use phpseclib3\Common\Functions\Strings; use phpseclib3\Crypt\Common\Formats\Keys\PKCS8 as Progenitor; use phpseclib3\File\ASN1; use phpseclib3\File\ASN1\Maps; -use phpseclib3\Common\Functions\Strings; +use phpseclib3\Math\BigInteger; /** * PKCS#8 Formatted RSA-PSS Key Handler diff --git a/phpseclib/Crypt/RSA/Formats/Keys/PuTTY.php b/phpseclib/Crypt/RSA/Formats/Keys/PuTTY.php index 4c93b873..cba85c30 100644 --- a/phpseclib/Crypt/RSA/Formats/Keys/PuTTY.php +++ b/phpseclib/Crypt/RSA/Formats/Keys/PuTTY.php @@ -15,9 +15,9 @@ namespace phpseclib3\Crypt\RSA\Formats\Keys; -use phpseclib3\Math\BigInteger; use phpseclib3\Common\Functions\Strings; use phpseclib3\Crypt\Common\Formats\Keys\PuTTY as Progenitor; +use phpseclib3\Math\BigInteger; /** * PuTTY Formatted RSA Key Handler diff --git a/phpseclib/Crypt/RSA/Formats/Keys/XML.php b/phpseclib/Crypt/RSA/Formats/Keys/XML.php index 389f93a8..f5b4bfde 100644 --- a/phpseclib/Crypt/RSA/Formats/Keys/XML.php +++ b/phpseclib/Crypt/RSA/Formats/Keys/XML.php @@ -23,9 +23,9 @@ namespace phpseclib3\Crypt\RSA\Formats\Keys; use ParagonIE\ConstantTime\Base64; -use phpseclib3\Math\BigInteger; use phpseclib3\Common\Functions\Strings; use phpseclib3\Exception\UnsupportedFormatException; +use phpseclib3\Math\BigInteger; /** * XML Formatted RSA Key Handler diff --git a/phpseclib/Crypt/RSA/PrivateKey.php b/phpseclib/Crypt/RSA/PrivateKey.php index 895565bd..4a3c288d 100644 --- a/phpseclib/Crypt/RSA/PrivateKey.php +++ b/phpseclib/Crypt/RSA/PrivateKey.php @@ -13,16 +13,12 @@ namespace phpseclib3\Crypt\RSA; -use phpseclib3\Crypt\RSA; -use phpseclib3\Math\BigInteger; -use phpseclib3\File\ASN1; -use phpseclib3\Common\Functions\Strings; -use phpseclib3\Crypt\Hash; -use phpseclib3\Exceptions\NoKeyLoadedException; -use phpseclib3\Exception\UnsupportedFormatException; -use phpseclib3\Crypt\Random; use phpseclib3\Crypt\Common; +use phpseclib3\Crypt\Random; +use phpseclib3\Crypt\RSA; use phpseclib3\Crypt\RSA\Formats\Keys\PSS; +use phpseclib3\Exception\UnsupportedFormatException; +use phpseclib3\Math\BigInteger; /** * Raw RSA Key Handler diff --git a/phpseclib/Crypt/RSA/PublicKey.php b/phpseclib/Crypt/RSA/PublicKey.php index 1d046bcc..aa56292d 100644 --- a/phpseclib/Crypt/RSA/PublicKey.php +++ b/phpseclib/Crypt/RSA/PublicKey.php @@ -13,18 +13,17 @@ namespace phpseclib3\Crypt\RSA; -use phpseclib3\Crypt\RSA; -use phpseclib3\Math\BigInteger; -use phpseclib3\File\ASN1; use phpseclib3\Common\Functions\Strings; -use phpseclib3\Crypt\Hash; -use phpseclib3\Exception\NoKeyLoadedException; -use phpseclib3\Exception\UnsupportedFormatException; -use phpseclib3\Exception\UnsupportedAlgorithmException; -use phpseclib3\Crypt\Random; use phpseclib3\Crypt\Common; -use phpseclib3\File\ASN1\Maps\DigestInfo; +use phpseclib3\Crypt\Hash; +use phpseclib3\Crypt\Random; +use phpseclib3\Crypt\RSA; use phpseclib3\Crypt\RSA\Formats\Keys\PSS; +use phpseclib3\Exception\UnsupportedAlgorithmException; +use phpseclib3\Exception\UnsupportedFormatException; +use phpseclib3\File\ASN1; +use phpseclib3\File\ASN1\Maps\DigestInfo; +use phpseclib3\Math\BigInteger; /** * Raw RSA Key Handler diff --git a/phpseclib/Crypt/Rijndael.php b/phpseclib/Crypt/Rijndael.php index 8aafc7a6..d5f1e007 100644 --- a/phpseclib/Crypt/Rijndael.php +++ b/phpseclib/Crypt/Rijndael.php @@ -54,13 +54,13 @@ namespace phpseclib3\Crypt; -use phpseclib3\Crypt\Common\BlockCipher; - use phpseclib3\Common\Functions\Strings; -use phpseclib3\Exception\BadModeException; -use phpseclib3\Exception\InsufficientSetupException; -use phpseclib3\Exception\InconsistentSetupException; + +use phpseclib3\Crypt\Common\BlockCipher; use phpseclib3\Exception\BadDecryptionException; +use phpseclib3\Exception\BadModeException; +use phpseclib3\Exception\InconsistentSetupException; +use phpseclib3\Exception\InsufficientSetupException; /** * Pure-PHP implementation of Rijndael. diff --git a/phpseclib/Crypt/Salsa20.php b/phpseclib/Crypt/Salsa20.php index 06283ed6..a6b4c3f2 100644 --- a/phpseclib/Crypt/Salsa20.php +++ b/phpseclib/Crypt/Salsa20.php @@ -15,10 +15,10 @@ namespace phpseclib3\Crypt; -use phpseclib3\Crypt\Common\StreamCipher; -use phpseclib3\Exception\InsufficientSetupException; -use phpseclib3\Exception\BadDecryptionException; use phpseclib3\Common\Functions\Strings; +use phpseclib3\Crypt\Common\StreamCipher; +use phpseclib3\Exception\BadDecryptionException; +use phpseclib3\Exception\InsufficientSetupException; /** * Pure-PHP implementation of Salsa20. diff --git a/phpseclib/File/ASN1.php b/phpseclib/File/ASN1.php index b7cb3db3..3e45d7c6 100644 --- a/phpseclib/File/ASN1.php +++ b/phpseclib/File/ASN1.php @@ -23,12 +23,11 @@ namespace phpseclib3\File; +use DateTime; use ParagonIE\ConstantTime\Base64; +use phpseclib3\Common\Functions\Strings; use phpseclib3\File\ASN1\Element; use phpseclib3\Math\BigInteger; -use phpseclib3\Common\Functions\Strings; -use DateTime; -use DateTimeZone; /** * Pure-PHP ASN.1 Parser @@ -1030,9 +1029,9 @@ abstract class ASN1 $format = $mapping['type'] == self::TYPE_UTC_TIME ? 'y' : 'Y'; $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')); + $date = new \DateTime($source, new \DateTimeZone('GMT')); // if $source _does_ include timezone information within it then convert the time to GMT - $date->setTimezone(new DateTimeZone('GMT')); + $date->setTimezone(new \DateTimeZone('GMT')); $value = $date->format($format) . 'Z'; break; case self::TYPE_BIT_STRING: @@ -1308,7 +1307,7 @@ abstract class ASN1 // error supression isn't necessary as of PHP 7.0: // http://php.net/manual/en/migration70.other-changes.php - return @DateTime::createFromFormat($format, $content); + return @\DateTime::createFromFormat($format, $content); } /** diff --git a/phpseclib/File/X509.php b/phpseclib/File/X509.php index 9d46fa85..a4781d94 100644 --- a/phpseclib/File/X509.php +++ b/phpseclib/File/X509.php @@ -26,9 +26,6 @@ namespace phpseclib3\File; -use DateTimeImmutable; -use DateTimeInterface; -use DateTimeZone; use ParagonIE\ConstantTime\Base64; use ParagonIE\ConstantTime\Hex; use phpseclib3\Crypt\Common\PrivateKey; @@ -36,6 +33,7 @@ use phpseclib3\Crypt\Common\PublicKey; use phpseclib3\Crypt\DSA; use phpseclib3\Crypt\EC; use phpseclib3\Crypt\Hash; +use phpseclib3\Crypt\PublicKeyLoader; use phpseclib3\Crypt\Random; use phpseclib3\Crypt\RSA; use phpseclib3\Crypt\RSA\Formats\Keys\PSS; @@ -43,7 +41,6 @@ use phpseclib3\Exception\UnsupportedAlgorithmException; use phpseclib3\File\ASN1\Element; use phpseclib3\File\ASN1\Maps; use phpseclib3\Math\BigInteger; -use phpseclib3\Crypt\PublicKeyLoader; /** * Pure-PHP X.509 Parser @@ -1124,7 +1121,7 @@ class X509 * * If $date isn't defined it is assumed to be the current date. * - * @param DateTimeInterface|string $date optional + * @param \DateTimeInterface|string $date optional * @access public * @return boolean */ @@ -1135,7 +1132,7 @@ class X509 } if (!isset($date)) { - $date = new DateTimeImmutable(null, new DateTimeZone(@date_default_timezone_get())); + $date = new \DateTimeImmutable(null, new \DateTimeZone(@date_default_timezone_get())); } $notBefore = $this->currentCert['tbsCertificate']['validity']['notBefore']; @@ -1145,11 +1142,11 @@ class X509 $notAfter = isset($notAfter['generalTime']) ? $notAfter['generalTime'] : $notAfter['utcTime']; if (is_string($date)) { - $date = new DateTimeImmutable($date, new DateTimeZone(@date_default_timezone_get())); + $date = new \DateTimeImmutable($date, new \DateTimeZone(@date_default_timezone_get())); } - $notBefore = new DateTimeImmutable($notBefore, new DateTimeZone(@date_default_timezone_get())); - $notAfter = new DateTimeImmutable($notAfter, new DateTimeZone(@date_default_timezone_get())); + $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; } @@ -2580,7 +2577,7 @@ class X509 if ($date instanceof Element) { return $date; } - $dateObj = new DateTimeImmutable($date, new DateTimeZone('GMT')); + $dateObj = new \DateTimeImmutable($date, new \DateTimeZone('GMT')); $year = $dateObj->format('Y'); // the same way ASN1.php parses this if ($year < 2050) { return ['utcTime' => $date]; @@ -2656,10 +2653,10 @@ class X509 return false; } - $startDate = new DateTimeImmutable('now', new DateTimeZone(@date_default_timezone_get())); + $startDate = new \DateTimeImmutable('now', new \DateTimeZone(@date_default_timezone_get())); $startDate = !empty($this->startDate) ? $this->startDate : $startDate->format('D, d M Y H:i:s O'); - $endDate = new DateTimeImmutable('+1 year', new DateTimeZone(@date_default_timezone_get())); + $endDate = new \DateTimeImmutable('+1 year', new \DateTimeZone(@date_default_timezone_get())); $endDate = !empty($this->endDate) ? $this->endDate : $endDate->format('D, d M Y H:i:s O'); /* "The serial number MUST be a positive integer" @@ -2924,7 +2921,7 @@ class X509 $signatureSubject = isset($this->signatureSubject) ? $this->signatureSubject : null; $signatureAlgorithm = self::identifySignatureAlgorithm($issuer->privateKey); - $thisUpdate = new DateTimeImmutable('now', new DateTimeZone(@date_default_timezone_get())); + $thisUpdate = new \DateTimeImmutable('now', new \DateTimeZone(@date_default_timezone_get())); $thisUpdate = !empty($this->startDate) ? $this->startDate : $thisUpdate->format('D, d M Y H:i:s O'); if (isset($crl->currentCert) && is_array($crl->currentCert) && isset($crl->currentCert['tbsCertList'])) { @@ -3098,13 +3095,13 @@ class X509 /** * Set certificate start date * - * @param DateTimeInterface|string $date + * @param \DateTimeInterface|string $date * @access public */ public function setStartDate($date) { - if (!is_object($date) || !($date instanceof DateTimeInterface)) { - $date = new DateTimeImmutable($date, new DateTimeZone(@date_default_timezone_get())); + if (!is_object($date) || !($date instanceof \DateTimeInterface)) { + $date = new \DateTimeImmutable($date, new \DateTimeZone(@date_default_timezone_get())); } $this->startDate = $date->format('D, d M Y H:i:s O'); @@ -3113,7 +3110,7 @@ class X509 /** * Set certificate end date * - * @param DateTimeInterface|string $date + * @param \DateTimeInterface|string $date * @access public */ public function setEndDate($date) @@ -3130,8 +3127,8 @@ class X509 $temp = chr(ASN1::TYPE_GENERALIZED_TIME) . ASN1::encodeLength(strlen($temp)) . $temp; $this->endDate = new Element($temp); } else { - if (!is_object($date) || !($date instanceof DateTimeInterface)) { - $date = new DateTimeImmutable($date, new DateTimeZone(@date_default_timezone_get())); + if (!is_object($date) || !($date instanceof \DateTimeInterface)) { + $date = new \DateTimeImmutable($date, new \DateTimeZone(@date_default_timezone_get())); } $this->endDate = $date->format('D, d M Y H:i:s O'); @@ -3867,7 +3864,7 @@ class X509 } $i = count($rclist); - $revocationDate = new DateTimeImmutable('now', new DateTimeZone(@date_default_timezone_get())); + $revocationDate = new \DateTimeImmutable('now', new \DateTimeZone(@date_default_timezone_get())); $rclist[] = ['userCertificate' => $serial, 'revocationDate' => $this->timeField($revocationDate->format('D, d M Y H:i:s O'))]; return $i; diff --git a/phpseclib/Math/BigInteger/Engines/BCMath/Reductions/EvalBarrett.php b/phpseclib/Math/BigInteger/Engines/BCMath/Reductions/EvalBarrett.php index 35a3f313..80acbdb5 100644 --- a/phpseclib/Math/BigInteger/Engines/BCMath/Reductions/EvalBarrett.php +++ b/phpseclib/Math/BigInteger/Engines/BCMath/Reductions/EvalBarrett.php @@ -15,8 +15,8 @@ namespace phpseclib3\Math\BigInteger\Engines\BCMath\Reductions; -use phpseclib3\Math\BigInteger\Engines\BCMath\Base; use phpseclib3\Math\BigInteger\Engines\BCMath; +use phpseclib3\Math\BigInteger\Engines\BCMath\Base; /** * PHP Barrett Modular Exponentiation Engine diff --git a/phpseclib/Math/BigInteger/Engines/Engine.php b/phpseclib/Math/BigInteger/Engines/Engine.php index fd9eb828..717a48cc 100644 --- a/phpseclib/Math/BigInteger/Engines/Engine.php +++ b/phpseclib/Math/BigInteger/Engines/Engine.php @@ -16,10 +16,10 @@ namespace phpseclib3\Math\BigInteger\Engines; use ParagonIE\ConstantTime\Hex; -use phpseclib3\Exception\BadConfigurationException; -use phpseclib3\Crypt\Random; -use phpseclib3\Math\BigInteger; use phpseclib3\Common\Functions\Strings; +use phpseclib3\Crypt\Random; +use phpseclib3\Exception\BadConfigurationException; +use phpseclib3\Math\BigInteger; /** * Base Engine. diff --git a/phpseclib/Math/BigInteger/Engines/GMP.php b/phpseclib/Math/BigInteger/Engines/GMP.php index 74272da8..cf848305 100644 --- a/phpseclib/Math/BigInteger/Engines/GMP.php +++ b/phpseclib/Math/BigInteger/Engines/GMP.php @@ -15,7 +15,6 @@ namespace phpseclib3\Math\BigInteger\Engines; -use ParagonIE\ConstantTime\Hex; use phpseclib3\Exception\BadConfigurationException; /** diff --git a/phpseclib/Math/BigInteger/Engines/OpenSSL.php b/phpseclib/Math/BigInteger/Engines/OpenSSL.php index d61eb821..6109def7 100644 --- a/phpseclib/Math/BigInteger/Engines/OpenSSL.php +++ b/phpseclib/Math/BigInteger/Engines/OpenSSL.php @@ -15,7 +15,6 @@ namespace phpseclib3\Math\BigInteger\Engines; -use phpseclib3\Crypt\RSA; use phpseclib3\Crypt\RSA\Formats\Keys\PKCS8; use phpseclib3\Math\BigInteger; diff --git a/phpseclib/Math/BigInteger/Engines/PHP/Montgomery.php b/phpseclib/Math/BigInteger/Engines/PHP/Montgomery.php index 0ebbd71a..5bee6d02 100644 --- a/phpseclib/Math/BigInteger/Engines/PHP/Montgomery.php +++ b/phpseclib/Math/BigInteger/Engines/PHP/Montgomery.php @@ -15,10 +15,9 @@ namespace phpseclib3\Math\BigInteger\Engines\PHP; -use phpseclib3\Math\BigInteger\Engines\PHP\Reductions\PowerOfTwo; -use phpseclib3\Math\BigInteger\Engines\PHP; -use phpseclib3\Math\BigInteger\Engines\PHP\Base; use phpseclib3\Math\BigInteger\Engines\Engine; +use phpseclib3\Math\BigInteger\Engines\PHP; +use phpseclib3\Math\BigInteger\Engines\PHP\Reductions\PowerOfTwo; /** * PHP Montgomery Modular Exponentiation Engine diff --git a/phpseclib/Math/BigInteger/Engines/PHP/Reductions/EvalBarrett.php b/phpseclib/Math/BigInteger/Engines/PHP/Reductions/EvalBarrett.php index c9f82c70..84f21708 100644 --- a/phpseclib/Math/BigInteger/Engines/PHP/Reductions/EvalBarrett.php +++ b/phpseclib/Math/BigInteger/Engines/PHP/Reductions/EvalBarrett.php @@ -15,8 +15,8 @@ namespace phpseclib3\Math\BigInteger\Engines\PHP\Reductions; -use phpseclib3\Math\BigInteger\Engines\PHP\Base; use phpseclib3\Math\BigInteger\Engines\PHP; +use phpseclib3\Math\BigInteger\Engines\PHP\Base; /** * PHP Dynamic Barrett Modular Exponentiation Engine diff --git a/phpseclib/Math/BigInteger/Engines/PHP/Reductions/MontgomeryMult.php b/phpseclib/Math/BigInteger/Engines/PHP/Reductions/MontgomeryMult.php index 31e8af21..0c21d034 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; -use phpseclib3\Math\BigInteger\Engines\PHP\Base; /** * PHP Montgomery Modular Exponentiation Engine with interleaved multiplication diff --git a/phpseclib/Math/BigInteger/Engines/PHP32.php b/phpseclib/Math/BigInteger/Engines/PHP32.php index a1b4a7a5..e1d15554 100644 --- a/phpseclib/Math/BigInteger/Engines/PHP32.php +++ b/phpseclib/Math/BigInteger/Engines/PHP32.php @@ -15,7 +15,6 @@ namespace phpseclib3\Math\BigInteger\Engines; -use ParagonIE\ConstantTime\Hex; /** * Pure-PHP 32-bit Engine. diff --git a/phpseclib/Math/BigInteger/Engines/PHP64.php b/phpseclib/Math/BigInteger/Engines/PHP64.php index 42d1982d..08754d51 100644 --- a/phpseclib/Math/BigInteger/Engines/PHP64.php +++ b/phpseclib/Math/BigInteger/Engines/PHP64.php @@ -15,7 +15,6 @@ namespace phpseclib3\Math\BigInteger\Engines; -use ParagonIE\ConstantTime\Hex; /** * Pure-PHP 64-bit Engine. diff --git a/phpseclib/Math/BinaryField.php b/phpseclib/Math/BinaryField.php index 7457b720..096b482b 100644 --- a/phpseclib/Math/BinaryField.php +++ b/phpseclib/Math/BinaryField.php @@ -16,10 +16,9 @@ namespace phpseclib3\Math; -use ParagonIE\ConstantTime\Hex; -use phpseclib3\Math\Common\FiniteField; -use phpseclib3\Math\BinaryField\Integer; use phpseclib3\Common\Functions\Strings; +use phpseclib3\Math\BinaryField\Integer; +use phpseclib3\Math\Common\FiniteField; /** * Binary Finite Fields diff --git a/phpseclib/Math/BinaryField/Integer.php b/phpseclib/Math/BinaryField/Integer.php index fc7a11ad..8d176a93 100644 --- a/phpseclib/Math/BinaryField/Integer.php +++ b/phpseclib/Math/BinaryField/Integer.php @@ -22,10 +22,10 @@ namespace phpseclib3\Math\BinaryField; -use phpseclib3\Math\Common\FiniteField\Integer as Base; +use ParagonIE\ConstantTime\Hex; use phpseclib3\Math\BigInteger; use phpseclib3\Math\BinaryField; -use ParagonIE\ConstantTime\Hex; +use phpseclib3\Math\Common\FiniteField\Integer as Base; /** * Binary Finite Fields diff --git a/phpseclib/Math/PrimeField/Integer.php b/phpseclib/Math/PrimeField/Integer.php index c933f5c1..825aaf8e 100644 --- a/phpseclib/Math/PrimeField/Integer.php +++ b/phpseclib/Math/PrimeField/Integer.php @@ -14,9 +14,9 @@ namespace phpseclib3\Math\PrimeField; -use phpseclib3\Math\Common\FiniteField\Integer as Base; -use phpseclib3\Math\BigInteger; use ParagonIE\ConstantTime\Hex; +use phpseclib3\Math\BigInteger; +use phpseclib3\Math\Common\FiniteField\Integer as Base; /** * Prime Finite Fields diff --git a/phpseclib/Net/SFTP.php b/phpseclib/Net/SFTP.php index dc624658..fe75e778 100644 --- a/phpseclib/Net/SFTP.php +++ b/phpseclib/Net/SFTP.php @@ -35,10 +35,8 @@ namespace phpseclib3\Net; -use phpseclib3\Exception\FileNotFoundException; use phpseclib3\Common\Functions\Strings; -use phpseclib3\Crypt\Common\AsymmetricKey; -use phpseclib3\System\SSH\Agent; +use phpseclib3\Exception\FileNotFoundException; /** * Pure-PHP implementations of SFTP. diff --git a/phpseclib/Net/SSH2.php b/phpseclib/Net/SSH2.php index 9f595d7e..20a0fd3f 100644 --- a/phpseclib/Net/SSH2.php +++ b/phpseclib/Net/SSH2.php @@ -47,32 +47,31 @@ namespace phpseclib3\Net; +use phpseclib3\Common\Functions\Strings; use phpseclib3\Crypt\Blowfish; +use phpseclib3\Crypt\ChaCha20; +use phpseclib3\Crypt\Common\AsymmetricKey; +use phpseclib3\Crypt\Common\PrivateKey; +use phpseclib3\Crypt\Common\PublicKey; use phpseclib3\Crypt\Common\SymmetricKey; +use phpseclib3\Crypt\DH; +use phpseclib3\Crypt\DSA; +use phpseclib3\Crypt\EC; use phpseclib3\Crypt\Hash; use phpseclib3\Crypt\Random; use phpseclib3\Crypt\RC4; use phpseclib3\Crypt\Rijndael; -use phpseclib3\Crypt\Common\PublicKey; -use phpseclib3\Crypt\Common\PrivateKey; use phpseclib3\Crypt\RSA; -use phpseclib3\Crypt\DSA; -use phpseclib3\Crypt\EC; -use phpseclib3\Crypt\DH; -use phpseclib3\Crypt\TripleDES; +use phpseclib3\Crypt\TripleDES; // Used to do Diffie-Hellman key exchange and DSA/RSA signature verification. use phpseclib3\Crypt\Twofish; -use phpseclib3\Crypt\ChaCha20; -use phpseclib3\Math\BigInteger; // Used to do Diffie-Hellman key exchange and DSA/RSA signature verification. -use phpseclib3\System\SSH\Agent; -use phpseclib3\System\SSH\Agent\Identity as AgentIdentity; +use phpseclib3\Exception\ConnectionClosedException; +use phpseclib3\Exception\InsufficientSetupException; use phpseclib3\Exception\NoSupportedAlgorithmsException; +use phpseclib3\Exception\UnableToConnectException; use phpseclib3\Exception\UnsupportedAlgorithmException; use phpseclib3\Exception\UnsupportedCurveException; -use phpseclib3\Exception\ConnectionClosedException; -use phpseclib3\Exception\UnableToConnectException; -use phpseclib3\Exception\InsufficientSetupException; -use phpseclib3\Common\Functions\Strings; -use phpseclib3\Crypt\Common\AsymmetricKey; +use phpseclib3\Math\BigInteger; +use phpseclib3\System\SSH\Agent; /** * Pure-PHP implementation of SSHv2. diff --git a/phpseclib/System/SSH/Agent.php b/phpseclib/System/SSH/Agent.php index d2b955ae..bc39874c 100644 --- a/phpseclib/System/SSH/Agent.php +++ b/phpseclib/System/SSH/Agent.php @@ -34,11 +34,11 @@ namespace phpseclib3\System\SSH; +use phpseclib3\Common\Functions\Strings; +use phpseclib3\Crypt\PublicKeyLoader; use phpseclib3\Crypt\RSA; use phpseclib3\Exception\BadConfigurationException; use phpseclib3\System\SSH\Agent\Identity; -use phpseclib3\Common\Functions\Strings; -use phpseclib3\Crypt\PublicKeyLoader; /** * Pure-PHP ssh-agent client identity factory diff --git a/phpseclib/System/SSH/Agent/Identity.php b/phpseclib/System/SSH/Agent/Identity.php index 20b0a958..237986e2 100644 --- a/phpseclib/System/SSH/Agent/Identity.php +++ b/phpseclib/System/SSH/Agent/Identity.php @@ -17,13 +17,13 @@ namespace phpseclib3\System\SSH\Agent; -use phpseclib3\Crypt\RSA; -use phpseclib3\Crypt\DSA; -use phpseclib3\Crypt\EC; -use phpseclib3\Exception\UnsupportedAlgorithmException; -use phpseclib3\System\SSH\Agent; use phpseclib3\Common\Functions\Strings; use phpseclib3\Crypt\Common\PrivateKey; +use phpseclib3\Crypt\DSA; +use phpseclib3\Crypt\EC; +use phpseclib3\Crypt\RSA; +use phpseclib3\Exception\UnsupportedAlgorithmException; +use phpseclib3\System\SSH\Agent; /** * Pure-PHP ssh-agent client identity object diff --git a/tests/Functional/Net/SFTPLargeFileTest.php b/tests/Functional/Net/SFTPLargeFileTest.php index 68c40149..7b58dccb 100644 --- a/tests/Functional/Net/SFTPLargeFileTest.php +++ b/tests/Functional/Net/SFTPLargeFileTest.php @@ -6,7 +6,6 @@ * @license http://www.opensource.org/licenses/mit-license.html MIT License */ -use phpseclib3\Crypt\Base; use phpseclib3\Net\SFTP; class Functional_Net_SFTPLargeFileTest extends Functional_Net_SFTPTestCase diff --git a/tests/Functional/Net/SFTPWrongServerTest.php b/tests/Functional/Net/SFTPWrongServerTest.php index 0afe454b..f1287028 100644 --- a/tests/Functional/Net/SFTPWrongServerTest.php +++ b/tests/Functional/Net/SFTPWrongServerTest.php @@ -1,7 +1,7 @@ getMockBuilder('stdClass') - ->setMethods(array('callbackMethod')) + ->setMethods(['callbackMethod']) ->getMock(); $callbackObject ->expects($this->atLeastOnce()) diff --git a/tests/PhpseclibFunctionalTestCase.php b/tests/PhpseclibFunctionalTestCase.php index 00f2f62e..b49aebdb 100644 --- a/tests/PhpseclibFunctionalTestCase.php +++ b/tests/PhpseclibFunctionalTestCase.php @@ -5,8 +5,6 @@ * @license http://www.opensource.org/licenses/mit-license.html MIT License */ -use phpseclib3\Crypt\Hash; -use phpseclib3\Math\BigInteger; abstract class PhpseclibFunctionalTestCase extends PhpseclibTestCase { diff --git a/tests/Unit/Crypt/AES/EvalTest.php b/tests/Unit/Crypt/AES/EvalTest.php index 5b0ad846..9426a995 100644 --- a/tests/Unit/Crypt/AES/EvalTest.php +++ b/tests/Unit/Crypt/AES/EvalTest.php @@ -5,7 +5,6 @@ * @license http://www.opensource.org/licenses/mit-license.html MIT License */ -use phpseclib3\Crypt\Common\BlockCipher; class Unit_Crypt_AES_EvalTest extends Unit_Crypt_AES_TestCase { diff --git a/tests/Unit/Crypt/AES/McryptTest.php b/tests/Unit/Crypt/AES/McryptTest.php index dcba5432..e1b981ed 100644 --- a/tests/Unit/Crypt/AES/McryptTest.php +++ b/tests/Unit/Crypt/AES/McryptTest.php @@ -5,7 +5,6 @@ * @license http://www.opensource.org/licenses/mit-license.html MIT License */ -use phpseclib3\Crypt\Common\BlockCipher; class Unit_Crypt_AES_McryptTest extends Unit_Crypt_AES_TestCase { diff --git a/tests/Unit/Crypt/AES/OpenSSLTest.php b/tests/Unit/Crypt/AES/OpenSSLTest.php index cb22c795..fe3a6adf 100644 --- a/tests/Unit/Crypt/AES/OpenSSLTest.php +++ b/tests/Unit/Crypt/AES/OpenSSLTest.php @@ -5,7 +5,6 @@ * @license http://www.opensource.org/licenses/mit-license.html MIT License */ -use phpseclib3\Crypt\Common\BlockCipher; class Unit_Crypt_AES_OpenSSLTest extends Unit_Crypt_AES_TestCase { diff --git a/tests/Unit/Crypt/AES/PurePHPTest.php b/tests/Unit/Crypt/AES/PurePHPTest.php index 43495088..27e5f5b2 100644 --- a/tests/Unit/Crypt/AES/PurePHPTest.php +++ b/tests/Unit/Crypt/AES/PurePHPTest.php @@ -5,7 +5,6 @@ * @license http://www.opensource.org/licenses/mit-license.html MIT License */ -use phpseclib3\Crypt\Common\BlockCipher; class Unit_Crypt_AES_PurePHPTest extends Unit_Crypt_AES_TestCase { diff --git a/tests/Unit/Crypt/AES/TestCase.php b/tests/Unit/Crypt/AES/TestCase.php index 2b159911..46164418 100644 --- a/tests/Unit/Crypt/AES/TestCase.php +++ b/tests/Unit/Crypt/AES/TestCase.php @@ -6,7 +6,6 @@ */ use phpseclib3\Crypt\AES; -use phpseclib3\Crypt\Common\BlockCipher; use phpseclib3\Crypt\Rijndael; use phpseclib3\Exception\InconsistentSetupException; use phpseclib3\Exception\InsufficientSetupException; diff --git a/tests/Unit/Crypt/DHTest.php b/tests/Unit/Crypt/DHTest.php index cf911b61..71314b74 100644 --- a/tests/Unit/Crypt/DHTest.php +++ b/tests/Unit/Crypt/DHTest.php @@ -5,13 +5,13 @@ * @license http://www.opensource.org/licenses/mit-license.html MIT License */ +use phpseclib3\Crypt\AES; use phpseclib3\Crypt\DH; -use phpseclib3\Crypt\DH\PublicKey; -use phpseclib3\Crypt\DH\PrivateKey; use phpseclib3\Crypt\DH\Parameters; +use phpseclib3\Crypt\DH\PrivateKey; +use phpseclib3\Crypt\DH\PublicKey; use phpseclib3\Crypt\EC; use phpseclib3\Math\BigInteger; -use phpseclib3\Crypt\AES; class Unit_Crypt_DHTest extends PhpseclibTestCase { diff --git a/tests/Unit/Crypt/DSA/CreateKeyTest.php b/tests/Unit/Crypt/DSA/CreateKeyTest.php index bf3a190e..1398808d 100644 --- a/tests/Unit/Crypt/DSA/CreateKeyTest.php +++ b/tests/Unit/Crypt/DSA/CreateKeyTest.php @@ -8,8 +8,8 @@ use phpseclib3\Crypt\DSA; use phpseclib3\Crypt\DSA\Parameters; -use phpseclib3\Crypt\DSA\PublicKey; use phpseclib3\Crypt\DSA\PrivateKey; +use phpseclib3\Crypt\DSA\PublicKey; /** * @requires PHP 7.0 diff --git a/tests/Unit/Crypt/DSA/LoadDSAKeyTest.php b/tests/Unit/Crypt/DSA/LoadDSAKeyTest.php index d981136e..53ecf568 100644 --- a/tests/Unit/Crypt/DSA/LoadDSAKeyTest.php +++ b/tests/Unit/Crypt/DSA/LoadDSAKeyTest.php @@ -5,14 +5,10 @@ * @license http://www.opensource.org/licenses/mit-license.html MIT License */ -use phpseclib3\Crypt\PublicKeyLoader; +use phpseclib3\Crypt\DSA\Parameters; use phpseclib3\Crypt\DSA\PrivateKey; use phpseclib3\Crypt\DSA\PublicKey; -use phpseclib3\Crypt\DSA\Parameters; -use phpseclib3\Crypt\DSA\Formats\Keys\PKCS1; -use phpseclib3\Crypt\DSA\Formats\Keys\PKCS8; -use phpseclib3\Crypt\DSA\Formats\Keys\PuTTY; -use phpseclib3\Math\BigInteger; +use phpseclib3\Crypt\PublicKeyLoader; use phpseclib3\Exception\NoKeyLoadedException; class Unit_Crypt_DSA_LoadDSAKeyTest extends PhpseclibTestCase diff --git a/tests/Unit/Crypt/EC/CurveTest.php b/tests/Unit/Crypt/EC/CurveTest.php index 478a584c..cf2ad0a0 100644 --- a/tests/Unit/Crypt/EC/CurveTest.php +++ b/tests/Unit/Crypt/EC/CurveTest.php @@ -6,12 +6,11 @@ * @license http://www.opensource.org/licenses/mit-license.html MIT License */ -use phpseclib3\Crypt\EC; -use phpseclib3\File\ASN1; -use phpseclib3\Crypt\EC\Curves\Ed448; -use phpseclib3\Math\BigInteger; -use phpseclib3\Crypt\PublicKeyLoader; use phpseclib3\Common\Functions\Strings; +use phpseclib3\Crypt\EC; +use phpseclib3\Crypt\EC\Curves\Ed448; +use phpseclib3\Crypt\PublicKeyLoader; +use phpseclib3\File\ASN1; class Ed448PublicKey { diff --git a/tests/Unit/Crypt/EC/KeyTest.php b/tests/Unit/Crypt/EC/KeyTest.php index 02629dbe..db3651a3 100644 --- a/tests/Unit/Crypt/EC/KeyTest.php +++ b/tests/Unit/Crypt/EC/KeyTest.php @@ -6,13 +6,13 @@ */ use phpseclib3\Crypt\EC; +use phpseclib3\Crypt\EC\Formats\Keys\OpenSSH; use phpseclib3\Crypt\EC\Formats\Keys\PKCS1; use phpseclib3\Crypt\EC\Formats\Keys\PKCS8; use phpseclib3\Crypt\EC\Formats\Keys\PuTTY; -use phpseclib3\Crypt\EC\Formats\Keys\OpenSSH; use phpseclib3\Crypt\EC\Formats\Keys\XML; -use phpseclib3\Crypt\PublicKeyLoader; use phpseclib3\Crypt\EC\PrivateKey; +use phpseclib3\Crypt\PublicKeyLoader; class Unit_Crypt_EC_KeyTest extends PhpseclibTestCase { diff --git a/tests/Unit/Crypt/RC4Test.php b/tests/Unit/Crypt/RC4Test.php index 92df2c42..e634afcd 100644 --- a/tests/Unit/Crypt/RC4Test.php +++ b/tests/Unit/Crypt/RC4Test.php @@ -5,8 +5,8 @@ * @license http://www.opensource.org/licenses/mit-license.html MIT License */ -use phpseclib3\Crypt\RC4; use phpseclib3\Crypt\Random; +use phpseclib3\Crypt\RC4; class Unit_Crypt_RC4Test extends PhpseclibTestCase { diff --git a/tests/Unit/Crypt/RSA/LoadKeyTest.php b/tests/Unit/Crypt/RSA/LoadKeyTest.php index 5fc4d9c2..d7219d70 100644 --- a/tests/Unit/Crypt/RSA/LoadKeyTest.php +++ b/tests/Unit/Crypt/RSA/LoadKeyTest.php @@ -5,18 +5,18 @@ * @license http://www.opensource.org/licenses/mit-license.html MIT License */ -use phpseclib3\Crypt\RSA; use phpseclib3\Crypt\PublicKeyLoader; -use phpseclib3\Crypt\RSA\PrivateKey; -use phpseclib3\Crypt\RSA\PublicKey; +use phpseclib3\Crypt\RSA; +use phpseclib3\Crypt\RSA\Formats\Keys\OpenSSH; use phpseclib3\Crypt\RSA\Formats\Keys\PKCS1; use phpseclib3\Crypt\RSA\Formats\Keys\PKCS8; -use phpseclib3\Crypt\RSA\Formats\Keys\PuTTY; -use phpseclib3\Crypt\RSA\Formats\Keys\OpenSSH; use phpseclib3\Crypt\RSA\Formats\Keys\PSS; -use phpseclib3\Math\BigInteger; -use phpseclib3\Exception\UnsupportedFormatException; +use phpseclib3\Crypt\RSA\Formats\Keys\PuTTY; +use phpseclib3\Crypt\RSA\PrivateKey; +use phpseclib3\Crypt\RSA\PublicKey; use phpseclib3\Exception\NoKeyLoadedException; +use phpseclib3\Exception\UnsupportedFormatException; +use phpseclib3\Math\BigInteger; class Unit_Crypt_RSA_LoadKeyTest extends PhpseclibTestCase { diff --git a/tests/Unit/Crypt/RSA/ModeTest.php b/tests/Unit/Crypt/RSA/ModeTest.php index e1238b1e..c7ec8dcb 100644 --- a/tests/Unit/Crypt/RSA/ModeTest.php +++ b/tests/Unit/Crypt/RSA/ModeTest.php @@ -5,10 +5,10 @@ * @license http://www.opensource.org/licenses/mit-license.html MIT License */ -use phpseclib3\Crypt\RSA; -use phpseclib3\Math\BigInteger; use phpseclib3\Crypt\PublicKeyLoader; +use phpseclib3\Crypt\RSA; use phpseclib3\Crypt\RSA\Formats\Keys\PKCS8; +use phpseclib3\Math\BigInteger; class Unit_Crypt_RSA_ModeTest extends PhpseclibTestCase { diff --git a/tests/Unit/File/ASN1Test.php b/tests/Unit/File/ASN1Test.php index 3e701387..1d5b6161 100644 --- a/tests/Unit/File/ASN1Test.php +++ b/tests/Unit/File/ASN1Test.php @@ -310,12 +310,12 @@ class Unit_File_ASN1Test extends PhpseclibTestCase public function testApplicationTag() { - $map = array( + $map = [ 'type' => ASN1::TYPE_SEQUENCE, - 'children' => array( + 'children' => [ // technically, default implies optional, but we'll define it as being optional, none-the-less, just to // reenforce that fact - 'version' => array( + 'version' => [ // if class isn't present it's assumed to be ASN1::CLASS_UNIVERSAL or // (if constant is present) ASN1::CLASS_CONTEXT_SPECIFIC 'class' => ASN1::CLASS_APPLICATION, @@ -324,12 +324,12 @@ class Unit_File_ASN1Test extends PhpseclibTestCase 'explicit' => true, 'default' => 'v1', 'type' => ASN1::TYPE_INTEGER, - 'mapping' => array('v1', 'v2', 'v3') - ) - ) - ); + 'mapping' => ['v1', 'v2', 'v3'] + ] + ] + ]; - $data = array('version' => 'v3'); + $data = ['version' => 'v3']; $str = ASN1::encodeDER($data, $map); @@ -376,21 +376,21 @@ class Unit_File_ASN1Test extends PhpseclibTestCase */ public function testExplicitImplicitDate() { - $map = array( + $map = [ 'type' => ASN1::TYPE_SEQUENCE, - 'children' => array( - 'notBefore' => array( + 'children' => [ + 'notBefore' => [ 'constant' => 0, 'optional' => true, 'implicit' => true, - 'type' => ASN1::TYPE_GENERALIZED_TIME), - 'notAfter' => array( + 'type' => ASN1::TYPE_GENERALIZED_TIME], + 'notAfter' => [ 'constant' => 1, 'optional' => true, 'implicit' => true, - 'type' => ASN1::TYPE_GENERALIZED_TIME) - ) - ); + 'type' => ASN1::TYPE_GENERALIZED_TIME] + ] + ]; $a = pack('H*', '3026a011180f32303137303432313039303535305aa111180f32303138303432313230353935395a'); $a = ASN1::decodeBER($a); diff --git a/tests/Unit/File/X509/CSRTest.php b/tests/Unit/File/X509/CSRTest.php index cbe387cb..d3a14ab3 100644 --- a/tests/Unit/File/X509/CSRTest.php +++ b/tests/Unit/File/X509/CSRTest.php @@ -5,9 +5,9 @@ * @license http://www.opensource.org/licenses/mit-license.html MIT License */ -use phpseclib3\File\X509; -use phpseclib3\Crypt\RSA; use phpseclib3\Crypt\PublicKeyLoader; +use phpseclib3\Crypt\RSA; +use phpseclib3\File\X509; class Unit_File_X509_CSRTest extends PhpseclibTestCase { diff --git a/tests/Unit/File/X509/SPKACTest.php b/tests/Unit/File/X509/SPKACTest.php index fd1caeee..bf49fd37 100644 --- a/tests/Unit/File/X509/SPKACTest.php +++ b/tests/Unit/File/X509/SPKACTest.php @@ -5,8 +5,8 @@ * @license http://www.opensource.org/licenses/mit-license.html MIT License */ -use phpseclib3\File\X509; use phpseclib3\Crypt\RSA; +use phpseclib3\File\X509; class Unit_File_X509_SPKACTest extends PhpseclibTestCase { diff --git a/tests/Unit/File/X509/X509Test.php b/tests/Unit/File/X509/X509Test.php index d7af1fe9..eb1318b2 100644 --- a/tests/Unit/File/X509/X509Test.php +++ b/tests/Unit/File/X509/X509Test.php @@ -5,11 +5,11 @@ * @license http://www.opensource.org/licenses/mit-license.html MIT License */ +use phpseclib3\Crypt\PublicKeyLoader; +use phpseclib3\Crypt\RSA; use phpseclib3\File\ASN1; use phpseclib3\File\ASN1\Element; use phpseclib3\File\X509; -use phpseclib3\Crypt\RSA; -use phpseclib3\Crypt\PublicKeyLoader; class Unit_File_X509_X509Test extends PhpseclibTestCase { @@ -1046,7 +1046,7 @@ ut3+b2Xvzq8yzmHMFtLIJ6Afu1jJpqD82BUAFcvi5vhnP8M7b974R18WCOpgNQvXDI+2/8ZINeU= -----END CERTIFICATE-----'); $r = $x509->saveX509($r); $r = $x509->loadX509($r); - $this->assertSame($r['tbsCertificate']['extensions'][5]['extnValue']['excludedSubtrees'][1]['base']['iPAddress'], array('0.0.0.0', '0.0.0.0')); + $this->assertSame($r['tbsCertificate']['extensions'][5]['extnValue']['excludedSubtrees'][1]['base']['iPAddress'], ['0.0.0.0', '0.0.0.0']); } /** diff --git a/tests/Unit/Math/BigInteger/BCMathTest.php b/tests/Unit/Math/BigInteger/BCMathTest.php index 1aab9ebd..5870a3f3 100644 --- a/tests/Unit/Math/BigInteger/BCMathTest.php +++ b/tests/Unit/Math/BigInteger/BCMathTest.php @@ -5,7 +5,7 @@ * @license http://www.opensource.org/licenses/mit-license.html MIT License */ -use \phpseclib3\Math\BigInteger\Engines\BCMath; +use phpseclib3\Math\BigInteger\Engines\BCMath; class Unit_Math_BigInteger_BCMathTest extends Unit_Math_BigInteger_TestCase { diff --git a/tests/Unit/Math/BigInteger/DefaultTest.php b/tests/Unit/Math/BigInteger/DefaultTest.php index 640d06d4..868e6b2a 100644 --- a/tests/Unit/Math/BigInteger/DefaultTest.php +++ b/tests/Unit/Math/BigInteger/DefaultTest.php @@ -5,7 +5,7 @@ * @license http://www.opensource.org/licenses/mit-license.html MIT License */ -use \phpseclib3\Math\BigInteger; +use phpseclib3\Math\BigInteger; class Unit_Math_BigInteger_DefaultTest extends Unit_Math_BigInteger_TestCase { diff --git a/tests/Unit/Math/BigInteger/GMPTest.php b/tests/Unit/Math/BigInteger/GMPTest.php index bcbecdc3..a10c6a9f 100644 --- a/tests/Unit/Math/BigInteger/GMPTest.php +++ b/tests/Unit/Math/BigInteger/GMPTest.php @@ -5,7 +5,7 @@ * @license http://www.opensource.org/licenses/mit-license.html MIT License */ -use \phpseclib3\Math\BigInteger\Engines\GMP; +use phpseclib3\Math\BigInteger\Engines\GMP; class Unit_Math_BigInteger_GMPTest extends Unit_Math_BigInteger_TestCase { diff --git a/tests/Unit/Math/BigInteger/PHP32Test.php b/tests/Unit/Math/BigInteger/PHP32Test.php index c9b3cfdd..584ef584 100644 --- a/tests/Unit/Math/BigInteger/PHP32Test.php +++ b/tests/Unit/Math/BigInteger/PHP32Test.php @@ -5,7 +5,7 @@ * @license http://www.opensource.org/licenses/mit-license.html MIT License */ -use \phpseclib3\Math\BigInteger\Engines\PHP32; +use phpseclib3\Math\BigInteger\Engines\PHP32; class Unit_Math_BigInteger_PHP32Test extends Unit_Math_BigInteger_TestCase { diff --git a/tests/Unit/Math/BigInteger/PHP64OpenSSLTest.php b/tests/Unit/Math/BigInteger/PHP64OpenSSLTest.php index a49eecab..f9828f60 100644 --- a/tests/Unit/Math/BigInteger/PHP64OpenSSLTest.php +++ b/tests/Unit/Math/BigInteger/PHP64OpenSSLTest.php @@ -5,7 +5,7 @@ * @license http://www.opensource.org/licenses/mit-license.html MIT License */ -use \phpseclib3\Math\BigInteger\Engines\PHP64; +use phpseclib3\Math\BigInteger\Engines\PHP64; class Unit_Math_BigInteger_PHP64OpenSSLTest extends Unit_Math_BigInteger_TestCase { diff --git a/tests/Unit/Math/BigInteger/PHP64Test.php b/tests/Unit/Math/BigInteger/PHP64Test.php index f1c89093..5caa1588 100644 --- a/tests/Unit/Math/BigInteger/PHP64Test.php +++ b/tests/Unit/Math/BigInteger/PHP64Test.php @@ -5,7 +5,7 @@ * @license http://www.opensource.org/licenses/mit-license.html MIT License */ -use \phpseclib3\Math\BigInteger\Engines\PHP64; +use phpseclib3\Math\BigInteger\Engines\PHP64; class Unit_Math_BigInteger_PHP64Test extends Unit_Math_BigInteger_TestCase { diff --git a/tests/Unit/Math/BigInteger/TestCase.php b/tests/Unit/Math/BigInteger/TestCase.php index c2402fb6..bf2db6f4 100644 --- a/tests/Unit/Math/BigInteger/TestCase.php +++ b/tests/Unit/Math/BigInteger/TestCase.php @@ -488,10 +488,10 @@ abstract class Unit_Math_BigInteger_TestCase extends PhpseclibTestCase public function testNegativePrecision() { - $vals = array( + $vals = [ '-9223372036854775808', // eg. 8000 0000 0000 0000 '-1' - ); + ]; foreach ($vals as $val) { $x = $this->getInstance($val); $x->setPrecision(64); // ie. 8 bytes diff --git a/travis/setup-composer.sh b/travis/setup-composer.sh index 3416074c..e1ef46cf 100755 --- a/travis/setup-composer.sh +++ b/travis/setup-composer.sh @@ -1,3 +1,6 @@ #!/bin/sh composer self-update --no-interaction composer install --no-interaction +if [ "$TRAVIS_PHP_VERSION" = '8.1.0' ]; then + composer install --no-interaction --working-dir=build +fi From 9b1c21866489c9f84a374cf6169a6e92d79da94a Mon Sep 17 00:00:00 2001 From: Jack Worman Date: Sun, 30 Jan 2022 11:20:45 -0600 Subject: [PATCH 2/4] psalm ci psalm-ci psalm-ci psalm-ci --- .travis.yml | 1 + build/composer.json | 10 +++++----- psalm.xml => build/psalm.xml | 9 +++------ phpseclib/Crypt/Common/SymmetricKey.php | 3 +++ phpseclib/Net/SSH2.php | 15 +++++++++++++-- 5 files changed, 25 insertions(+), 13 deletions(-) rename psalm.xml => build/psalm.xml (75%) diff --git a/.travis.yml b/.travis.yml index 924c6d27..27ef1e35 100644 --- a/.travis.yml +++ b/.travis.yml @@ -35,4 +35,5 @@ install: 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/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/build/composer.json b/build/composer.json index fd870b48..cf54ef9d 100644 --- a/build/composer.json +++ b/build/composer.json @@ -1,12 +1,12 @@ { - "name": "phpseclib/tools", - "description": "", + "name": "phpseclib/build", + "description": "A separate composer.json file to house build related dependencies.", "minimum-stability": "stable", - "license": "proprietary", - "authors": [{"name": "Jack Worman", "email": "jworman@healthcall.com"}], + "license": "MIT", "require": { "php": "^8.1.0", - "friendsofphp/php-cs-fixer": "^3.5" + "friendsofphp/php-cs-fixer": "^3.5", + "vimeo/psalm": "^4.19" }, "config": { "sort-packages": true diff --git a/psalm.xml b/build/psalm.xml similarity index 75% rename from psalm.xml rename to build/psalm.xml index 4d54fb20..5a89feab 100644 --- a/psalm.xml +++ b/build/psalm.xml @@ -9,20 +9,17 @@ sealAllMethods="true" > - + - - - - + - + diff --git a/phpseclib/Crypt/Common/SymmetricKey.php b/phpseclib/Crypt/Common/SymmetricKey.php index 519a284e..0f0ea978 100644 --- a/phpseclib/Crypt/Common/SymmetricKey.php +++ b/phpseclib/Crypt/Common/SymmetricKey.php @@ -213,6 +213,9 @@ abstract class SymmetricKey self::ENGINE_OPENSSL_GCM => 'OpenSSL (GCM)' ]; + /** @var string|false */ + public $fixed; + /** * The Encryption Mode * diff --git a/phpseclib/Net/SSH2.php b/phpseclib/Net/SSH2.php index 20a0fd3f..cc02b79b 100644 --- a/phpseclib/Net/SSH2.php +++ b/phpseclib/Net/SSH2.php @@ -404,7 +404,7 @@ class SSH2 * Server to Client Encryption Object * * @see self::_get_binary_packet() - * @var object + * @var SymmetricKey|false * @access private */ private $decrypt = false; @@ -440,7 +440,7 @@ class SSH2 * Client to Server Encryption Object * * @see self::_send_binary_packet() - * @var object + * @var SymmetricKey|false * @access private */ private $encrypt = false; @@ -3457,6 +3457,11 @@ class SSH2 $remaining_length = 0; break; case 'chacha20-poly1305@openssh.com': + // This should be impossible, but we are checking anyway to narrow the type for Psalm. + if (!($this->decrypt instanceof ChaCha20)) { + throw new \LogicException('$this->decrypt is not a ' . ChaCha20::class); + } + $nonce = pack('N2', 0, $this->get_seq_no); $this->lengthDecrypt->setNonce($nonce); @@ -4204,6 +4209,11 @@ class SSH2 $packet = $temp . $this->encrypt->encrypt(substr($packet, 4)); break; case 'chacha20-poly1305@openssh.com': + // This should be impossible, but we are checking anyway to narrow the type for Psalm. + if (!($this->encrypt instanceof ChaCha20)) { + throw new \LogicException('$this->encrypt is not a ' . ChaCha20::class); + } + $nonce = pack('N2', 0, $this->send_seq_no); $this->encrypt->setNonce($nonce); @@ -5154,6 +5164,7 @@ class SSH2 * @return string * @access public */ + #[\ReturnTypeWillChange] public function __toString() { return $this->getResourceId(); From f900045772260c55d8c4ca93c3c6044d02ea251a Mon Sep 17 00:00:00 2001 From: Jack Worman Date: Tue, 1 Feb 2022 12:10:17 -0600 Subject: [PATCH 3/4] updated contribution steps updated contribution steps --- README.md | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 8daa10b7..774bba96 100644 --- a/README.md +++ b/README.md @@ -80,22 +80,21 @@ Special Thanks to our $50+ sponsors!: 2. Ensure you have Composer installed (see [Composer Download Instructions](https://getcomposer.org/download/)) 3. Install Development Dependencies - - ``` sh + ```sh composer install ``` 4. Create a Feature Branch -5. (Recommended) Run the Test Suite - - ``` sh - vendor/bin/phpunit - ``` -6. (Recommended) Check whether your code conforms to our Coding Standards by running - - ``` sh - vendor/bin/phing -f build/build.xml sniff - ``` - -7. Send us a Pull Request +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 + 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 + ``` + +6. Send us a Pull Request From 56973d40db123d981efb5b875ba8e1b3ec7da61f Mon Sep 17 00:00:00 2001 From: terrafrost Date: Tue, 1 Feb 2022 21:17:10 -0600 Subject: [PATCH 4/4] SSH2: stop using more dynamic properties in SymmetricKey --- phpseclib/Crypt/Common/SymmetricKey.php | 3 --- phpseclib/Net/SSH2.php | 28 +++++++++++++++++++++---- 2 files changed, 24 insertions(+), 7 deletions(-) diff --git a/phpseclib/Crypt/Common/SymmetricKey.php b/phpseclib/Crypt/Common/SymmetricKey.php index 0f0ea978..519a284e 100644 --- a/phpseclib/Crypt/Common/SymmetricKey.php +++ b/phpseclib/Crypt/Common/SymmetricKey.php @@ -213,9 +213,6 @@ abstract class SymmetricKey self::ENGINE_OPENSSL_GCM => 'OpenSSL (GCM)' ]; - /** @var string|false */ - public $fixed; - /** * The Encryption Mode * diff --git a/phpseclib/Net/SSH2.php b/phpseclib/Net/SSH2.php index cc02b79b..d18bf1e2 100644 --- a/phpseclib/Net/SSH2.php +++ b/phpseclib/Net/SSH2.php @@ -427,6 +427,16 @@ class SSH2 */ private $decryptInvocationCounter; + /** + * Fixed Part of Nonce + * + * Used by GCM + * + * @var string|null + * @access private + */ + private $decryptFixedPart; + /** * Server to Client Length Encryption Object * @@ -463,6 +473,16 @@ class SSH2 */ private $encryptInvocationCounter; + /** + * Fixed Part of Nonce + * + * Used by GCM + * + * @var string|null + * @access private + */ + private $encryptFixedPart; + /** * Client to Server Length Encryption Object * @@ -1926,7 +1946,7 @@ class SSH2 case 'aes128-gcm@openssh.com': case 'aes256-gcm@openssh.com': $nonce = $kexHash->hash($keyBytes . $this->exchange_hash . 'A' . $this->session_id); - $this->encrypt->fixed = substr($nonce, 0, 4); + $this->encryptFixedPart = substr($nonce, 0, 4); $this->encryptInvocationCounter = substr($nonce, 4, 8); case 'chacha20-poly1305@openssh.com': break; @@ -1971,7 +1991,7 @@ class SSH2 case 'aes256-gcm@openssh.com': // see https://tools.ietf.org/html/rfc5647#section-7.1 $nonce = $kexHash->hash($keyBytes . $this->exchange_hash . 'B' . $this->session_id); - $this->decrypt->fixed = substr($nonce, 0, 4); + $this->decryptFixedPart = substr($nonce, 0, 4); $this->decryptInvocationCounter = substr($nonce, 4, 8); case 'chacha20-poly1305@openssh.com': break; @@ -3438,7 +3458,7 @@ class SSH2 case 'aes128-gcm@openssh.com': case 'aes256-gcm@openssh.com': $this->decrypt->setNonce( - $this->decrypt->fixed . + $this->decryptFixedPart . $this->decryptInvocationCounter ); Strings::increment_str($this->decryptInvocationCounter); @@ -4201,7 +4221,7 @@ class SSH2 case 'aes128-gcm@openssh.com': case 'aes256-gcm@openssh.com': $this->encrypt->setNonce( - $this->encrypt->fixed . + $this->encryptFixedPart . $this->encryptInvocationCounter ); Strings::increment_str($this->encryptInvocationCounter);