From 8bc9f4ba25c1dfeb190c9b7016dc6a60c80d6566 Mon Sep 17 00:00:00 2001 From: terrafrost Date: Sat, 17 Apr 2021 00:31:54 -0500 Subject: [PATCH 1/4] Travis: don't use parallels or xdebug --- .travis.yml | 8 +------- travis/run-phpunit.sh | 17 +++++------------ 2 files changed, 6 insertions(+), 19 deletions(-) diff --git a/.travis.yml b/.travis.yml index b6a5d303..5e0d7727 100644 --- a/.travis.yml +++ b/.travis.yml @@ -28,13 +28,7 @@ matrix: before_install: true install: - - wget http://ftp.gnu.org/gnu/parallel/parallel-20170822.tar.bz2 - - tar -xvjf parallel* - - cd parallel-20170822 - - ./configure - - make - - sudo make install - - cd .. + - phpenv config-rm xdebug.ini - eval `ssh-agent -s` - travis/setup-secure-shell.sh - sh -c "if [ '$TRAVIS_PHP_VERSION' != 'hhvm' -a `php -r "echo (int) version_compare(PHP_VERSION, '7.0', '<');"` = "1" ]; then travis/install-php-extensions.sh; fi" diff --git a/travis/run-phpunit.sh b/travis/run-phpunit.sh index 31b98afc..97d98fda 100755 --- a/travis/run-phpunit.sh +++ b/travis/run-phpunit.sh @@ -37,15 +37,8 @@ then find tests -type f -name "*.php" -print0 | xargs -0 sed -i 's/extends Unit_Crypt_Hash_\(SHA512Test\|SHA256Test\)/extends \1/g' fi -if [ "$TRAVIS_PHP_VERSION" = 'hhvm' -o `php -r "echo (int) version_compare(PHP_VERSION, '7.0', '>=');"` = "1" ] -then - find tests -type f -name "*Test.php" | \ - parallel --gnu --keep-order \ - "echo '== {} =='; \"$PHPUNIT\" $PHPUNIT_ARGS {};" -else - "$PHPUNIT" \ - $PHPUNIT_ARGS \ - --coverage-text \ - --coverage-clover code_coverage/clover.xml \ - --coverage-html code_coverage/ -fi +"$PHPUNIT" \ + $PHPUNIT_ARGS \ + --coverage-text \ + --coverage-clover code_coverage/clover.xml \ + --coverage-html code_coverage/ From c3aecf503e700ffe980a9883ffb7c8b8dcd47cdd Mon Sep 17 00:00:00 2001 From: terrafrost Date: Sat, 17 Apr 2021 06:27:14 -0500 Subject: [PATCH 2/4] Tests: updates now that parallels is not being used --- tests/Unit/Crypt/Hash/SHA256_96Test.php | 4 ---- tests/Unit/Crypt/Hash/SHA512_96Test.php | 4 ---- 2 files changed, 8 deletions(-) diff --git a/tests/Unit/Crypt/Hash/SHA256_96Test.php b/tests/Unit/Crypt/Hash/SHA256_96Test.php index 24a09be4..85aaf295 100644 --- a/tests/Unit/Crypt/Hash/SHA256_96Test.php +++ b/tests/Unit/Crypt/Hash/SHA256_96Test.php @@ -7,10 +7,6 @@ use phpseclib\Crypt\Hash; -if (version_compare(PHP_VERSION, '7.0', '>=')) { - require 'SHA256Test.php'; -} - class Unit_Crypt_Hash_SHA256_96Test extends Unit_Crypt_Hash_SHA256Test { public function getInstance() diff --git a/tests/Unit/Crypt/Hash/SHA512_96Test.php b/tests/Unit/Crypt/Hash/SHA512_96Test.php index 0d48a7fb..760fa243 100644 --- a/tests/Unit/Crypt/Hash/SHA512_96Test.php +++ b/tests/Unit/Crypt/Hash/SHA512_96Test.php @@ -7,10 +7,6 @@ use phpseclib\Crypt\Hash; -if (version_compare(PHP_VERSION, '7.0', '>=')) { - require 'SHA512Test.php'; -} - class Unit_Crypt_Hash_SHA512_96Test extends Unit_Crypt_Hash_SHA512Test { public function getInstance() From 5fccc4cadafd59f175034263125d19e914e02980 Mon Sep 17 00:00:00 2001 From: terrafrost Date: Sat, 17 Apr 2021 07:36:50 -0500 Subject: [PATCH 3/4] fix bad merge --- tests/Unit/Crypt/Hash/SHA256_96Test.php | 32 ------------------------- tests/Unit/Crypt/Hash/SHA512_96Test.php | 32 ------------------------- 2 files changed, 64 deletions(-) delete mode 100644 tests/Unit/Crypt/Hash/SHA256_96Test.php delete mode 100644 tests/Unit/Crypt/Hash/SHA512_96Test.php diff --git a/tests/Unit/Crypt/Hash/SHA256_96Test.php b/tests/Unit/Crypt/Hash/SHA256_96Test.php deleted file mode 100644 index 85aaf295..00000000 --- a/tests/Unit/Crypt/Hash/SHA256_96Test.php +++ /dev/null @@ -1,32 +0,0 @@ - - * @copyright 2014 Andreas Fischer - * @license http://www.opensource.org/licenses/mit-license.html MIT License - */ - -use phpseclib\Crypt\Hash; - -class Unit_Crypt_Hash_SHA256_96Test extends Unit_Crypt_Hash_SHA256Test -{ - public function getInstance() - { - return new Hash('sha256-96'); - } - - /** - * @dataProvider hashData() - */ - public function testHash($message, $longResult) - { - parent::testHash($message, substr($longResult, 0, 24)); - } - - /** - * @dataProvider hmacData() - */ - public function testHMAC($key, $message, $longResult) - { - parent::testHMAC($key, $message, substr($longResult, 0, 24)); - } -} diff --git a/tests/Unit/Crypt/Hash/SHA512_96Test.php b/tests/Unit/Crypt/Hash/SHA512_96Test.php deleted file mode 100644 index 760fa243..00000000 --- a/tests/Unit/Crypt/Hash/SHA512_96Test.php +++ /dev/null @@ -1,32 +0,0 @@ - - * @copyright 2014 Andreas Fischer - * @license http://www.opensource.org/licenses/mit-license.html MIT License - */ - -use phpseclib\Crypt\Hash; - -class Unit_Crypt_Hash_SHA512_96Test extends Unit_Crypt_Hash_SHA512Test -{ - public function getInstance() - { - return new Hash('sha512-96'); - } - - /** - * @dataProvider hashData() - */ - public function testHash($message, $longResult) - { - parent::testHash($message, substr($longResult, 0, 24)); - } - - /** - * @dataProvider hmacData() - */ - public function testHMAC($key, $message, $longResult) - { - parent::testHMAC($key, $message, substr($longResult, 0, 24)); - } -} From 0d9d1eedb1f1039710600fefce8aa5c28852c6ac Mon Sep 17 00:00:00 2001 From: terrafrost Date: Sat, 17 Apr 2021 08:18:11 -0500 Subject: [PATCH 4/4] Tests/EC: now that Parallels isn't running these plugins linger --- tests/Unit/Crypt/EC/CurveTest.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tests/Unit/Crypt/EC/CurveTest.php b/tests/Unit/Crypt/EC/CurveTest.php index 93d20d64..1a8a2cc8 100644 --- a/tests/Unit/Crypt/EC/CurveTest.php +++ b/tests/Unit/Crypt/EC/CurveTest.php @@ -11,6 +11,7 @@ use phpseclib3\File\ASN1; use phpseclib3\Crypt\EC\Curves\Ed448; use phpseclib3\Math\BigInteger; use phpseclib3\Crypt\PublicKeyLoader; +use phpseclib3\Common\Functions\Strings; class Ed448PublicKey { @@ -18,6 +19,10 @@ class Ed448PublicKey public static function load($key, $password = '') { + if (!Strings::is_stringable($key)) { + throw new \UnexpectedValueException('Key should be a string - not a ' . gettype($key)); + } + $components = ['curve' => new Ed448()]; $components['QA'] = self::extractPoint($key, $components['curve']); @@ -29,6 +34,10 @@ class Ed448PrivateKey { public static function load($key, $password = '') { + if (!Strings::is_stringable($key)) { + throw new \UnexpectedValueException('Key should be a string - not a ' . gettype($key)); + } + $components = ['curve' => new Ed448()]; $components['dA'] = $components['curve']->extractSecret($key); $components['QA'] = $components['curve']->multiplyPoint($components['curve']->getBasePoint(), $components['dA']);