From d7295e827c0fc3f9c486c87f070d8552cc4f6066 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20M=C3=BCller?= Date: Tue, 20 Sep 2016 11:39:41 +0200 Subject: [PATCH 1/5] Adding php 7.1 to travis --- .travis.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index d54c933a..faf3dce1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,6 +7,7 @@ php: - 5.5 - 5.6 - 7.0 + - 7.1 - hhvm env: @@ -27,7 +28,7 @@ install: - cd .. - eval `ssh-agent -s` - travis/setup-secure-shell.sh - - sh -c "if [ '$TRAVIS_PHP_VERSION' != 'hhvm' -a '$TRAVIS_PHP_VERSION' != '7.0' ]; then travis/install-php-extensions.sh; fi" + - sh -c "if [ '$TRAVIS_PHP_VERSION' != 'hhvm' -a '$TRAVIS_PHP_VERSION' != '7.0' -a '$TRAVIS_PHP_VERSION' != '7.1' ]; then travis/install-php-extensions.sh; fi" - travis/setup-composer.sh script: From e4489a176509436550c9bfc0311dda1b3ec3e0bc Mon Sep 17 00:00:00 2001 From: terrafrost Date: Wed, 21 Sep 2016 01:03:26 -0500 Subject: [PATCH 2/5] fix PHP 7.1 compatibility errors --- phpseclib/Crypt/Base.php | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/phpseclib/Crypt/Base.php b/phpseclib/Crypt/Base.php index 4c8f721c..dfe99637 100644 --- a/phpseclib/Crypt/Base.php +++ b/phpseclib/Crypt/Base.php @@ -826,7 +826,7 @@ class Crypt_Base $this->changed = false; } if ($this->enchanged) { - mcrypt_generic_init($this->enmcrypt, $this->key, $this->encryptIV); + @mcrypt_generic_init($this->enmcrypt, $this->key, $this->encryptIV); $this->enchanged = false; } @@ -859,15 +859,15 @@ class Crypt_Base if ($len >= $block_size) { if ($this->enbuffer['enmcrypt_init'] === false || $len > $this->cfb_init_len) { if ($this->enbuffer['enmcrypt_init'] === true) { - mcrypt_generic_init($this->enmcrypt, $this->key, $iv); + @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; } else { while ($len >= $block_size) { - $iv = mcrypt_generic($this->ecb, $iv) ^ substr($plaintext, $i, $block_size); + $iv = @mcrypt_generic($this->ecb, $iv) ^ substr($plaintext, $i, $block_size); $ciphertext.= $iv; $len-= $block_size; $i+= $block_size; @@ -876,7 +876,7 @@ class Crypt_Base } if ($len) { - $iv = mcrypt_generic($this->ecb, $iv); + $iv = @mcrypt_generic($this->ecb, $iv); $block = $iv ^ substr($plaintext, -$len); $iv = substr_replace($iv, $block, 0, $len); $ciphertext.= $block; @@ -886,10 +886,10 @@ class Crypt_Base return $ciphertext; } - $ciphertext = mcrypt_generic($this->enmcrypt, $plaintext); + $ciphertext = @mcrypt_generic($this->enmcrypt, $plaintext); if (!$this->continuousBuffer) { - mcrypt_generic_init($this->enmcrypt, $this->key, $this->encryptIV); + @mcrypt_generic_init($this->enmcrypt, $this->key, $this->encryptIV); } return $ciphertext; @@ -1138,7 +1138,7 @@ class Crypt_Base $this->changed = false; } if ($this->dechanged) { - mcrypt_generic_init($this->demcrypt, $this->key, $this->decryptIV); + @mcrypt_generic_init($this->demcrypt, $this->key, $this->decryptIV); $this->dechanged = false; } @@ -1166,12 +1166,12 @@ class Crypt_Base } 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; } if ($len) { - $iv = mcrypt_generic($this->ecb, $iv); + $iv = @mcrypt_generic($this->ecb, $iv); $plaintext.= $iv ^ substr($ciphertext, -$len); $iv = substr_replace($iv, substr($ciphertext, -$len), 0, $len); $pos = $len; @@ -1183,7 +1183,7 @@ class Crypt_Base $plaintext = mdecrypt_generic($this->demcrypt, $ciphertext); if (!$this->continuousBuffer) { - mcrypt_generic_init($this->demcrypt, $this->key, $this->decryptIV); + @mcrypt_generic_init($this->demcrypt, $this->key, $this->decryptIV); } return $this->paddable ? $this->_unpad($plaintext) : $plaintext; @@ -1645,7 +1645,7 @@ class Crypt_Base case CRYPT_ENGINE_MCRYPT: return $this->cipher_name_mcrypt && extension_loaded('mcrypt') && - in_array($this->cipher_name_mcrypt, mcrypt_list_algorithms()); + in_array($this->cipher_name_mcrypt, @mcrypt_list_algorithms()); case CRYPT_ENGINE_INTERNAL: return true; } @@ -1724,13 +1724,13 @@ class Crypt_Base if ($this->engine != CRYPT_ENGINE_MCRYPT && $this->enmcrypt) { // 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); - mcrypt_module_close($this->demcrypt); + @mcrypt_module_close($this->enmcrypt); + @mcrypt_module_close($this->demcrypt); $this->enmcrypt = null; $this->demcrypt = null; if ($this->ecb) { - mcrypt_module_close($this->ecb); + @mcrypt_module_close($this->ecb); $this->ecb = null; } } @@ -1850,19 +1850,19 @@ class Crypt_Base CRYPT_MODE_STREAM => MCRYPT_MODE_STREAM, ); - $this->demcrypt = mcrypt_module_open($this->cipher_name_mcrypt, '', $mcrypt_modes[$this->mode], ''); - $this->enmcrypt = mcrypt_module_open($this->cipher_name_mcrypt, '', $mcrypt_modes[$this->mode], ''); + $this->demcrypt = @mcrypt_module_open($this->cipher_name_mcrypt, '', $mcrypt_modes[$this->mode], ''); + $this->enmcrypt = @mcrypt_module_open($this->cipher_name_mcrypt, '', $mcrypt_modes[$this->mode], ''); // we need the $ecb mcrypt resource (only) in MODE_CFB with enableContinuousBuffer() // to workaround mcrypt's broken ncfb implementation in buffered mode // see: {@link http://phpseclib.sourceforge.net/cfb-demo.phps} if ($this->mode == CRYPT_MODE_CFB) { - $this->ecb = mcrypt_module_open($this->cipher_name_mcrypt, '', MCRYPT_MODE_ECB, ''); + $this->ecb = @mcrypt_module_open($this->cipher_name_mcrypt, '', MCRYPT_MODE_ECB, ''); } } // else should mcrypt_generic_deinit be called? if ($this->mode == CRYPT_MODE_CFB) { - mcrypt_generic_init($this->ecb, $this->key, str_repeat("\0", $this->block_size)); + @mcrypt_generic_init($this->ecb, $this->key, str_repeat("\0", $this->block_size)); } } From 640f10609fdb2aa825f8a42c6bee975879974e1c Mon Sep 17 00:00:00 2001 From: terrafrost Date: Wed, 21 Sep 2016 01:03:26 -0500 Subject: [PATCH 3/5] fix PHP 7.1 compatibility errors --- phpseclib/Crypt/Base.php | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/phpseclib/Crypt/Base.php b/phpseclib/Crypt/Base.php index 4c8f721c..91ebe593 100644 --- a/phpseclib/Crypt/Base.php +++ b/phpseclib/Crypt/Base.php @@ -826,7 +826,7 @@ class Crypt_Base $this->changed = false; } if ($this->enchanged) { - mcrypt_generic_init($this->enmcrypt, $this->key, $this->encryptIV); + @mcrypt_generic_init($this->enmcrypt, $this->key, $this->encryptIV); $this->enchanged = false; } @@ -859,15 +859,15 @@ class Crypt_Base if ($len >= $block_size) { if ($this->enbuffer['enmcrypt_init'] === false || $len > $this->cfb_init_len) { if ($this->enbuffer['enmcrypt_init'] === true) { - mcrypt_generic_init($this->enmcrypt, $this->key, $iv); + @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; } else { while ($len >= $block_size) { - $iv = mcrypt_generic($this->ecb, $iv) ^ substr($plaintext, $i, $block_size); + $iv = @mcrypt_generic($this->ecb, $iv) ^ substr($plaintext, $i, $block_size); $ciphertext.= $iv; $len-= $block_size; $i+= $block_size; @@ -876,7 +876,7 @@ class Crypt_Base } if ($len) { - $iv = mcrypt_generic($this->ecb, $iv); + $iv = @mcrypt_generic($this->ecb, $iv); $block = $iv ^ substr($plaintext, -$len); $iv = substr_replace($iv, $block, 0, $len); $ciphertext.= $block; @@ -886,10 +886,10 @@ class Crypt_Base return $ciphertext; } - $ciphertext = mcrypt_generic($this->enmcrypt, $plaintext); + $ciphertext = @mcrypt_generic($this->enmcrypt, $plaintext); if (!$this->continuousBuffer) { - mcrypt_generic_init($this->enmcrypt, $this->key, $this->encryptIV); + @mcrypt_generic_init($this->enmcrypt, $this->key, $this->encryptIV); } return $ciphertext; @@ -1138,7 +1138,7 @@ class Crypt_Base $this->changed = false; } if ($this->dechanged) { - mcrypt_generic_init($this->demcrypt, $this->key, $this->decryptIV); + @mcrypt_generic_init($this->demcrypt, $this->key, $this->decryptIV); $this->dechanged = false; } @@ -1166,12 +1166,12 @@ class Crypt_Base } 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; } if ($len) { - $iv = mcrypt_generic($this->ecb, $iv); + $iv = @mcrypt_generic($this->ecb, $iv); $plaintext.= $iv ^ substr($ciphertext, -$len); $iv = substr_replace($iv, substr($ciphertext, -$len), 0, $len); $pos = $len; @@ -1180,10 +1180,10 @@ class Crypt_Base return $plaintext; } - $plaintext = mdecrypt_generic($this->demcrypt, $ciphertext); + $plaintext = @mdecrypt_generic($this->demcrypt, $ciphertext); if (!$this->continuousBuffer) { - mcrypt_generic_init($this->demcrypt, $this->key, $this->decryptIV); + @mcrypt_generic_init($this->demcrypt, $this->key, $this->decryptIV); } return $this->paddable ? $this->_unpad($plaintext) : $plaintext; @@ -1645,7 +1645,7 @@ class Crypt_Base case CRYPT_ENGINE_MCRYPT: return $this->cipher_name_mcrypt && extension_loaded('mcrypt') && - in_array($this->cipher_name_mcrypt, mcrypt_list_algorithms()); + in_array($this->cipher_name_mcrypt, @mcrypt_list_algorithms()); case CRYPT_ENGINE_INTERNAL: return true; } @@ -1724,13 +1724,13 @@ class Crypt_Base if ($this->engine != CRYPT_ENGINE_MCRYPT && $this->enmcrypt) { // 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); - mcrypt_module_close($this->demcrypt); + @mcrypt_module_close($this->enmcrypt); + @mcrypt_module_close($this->demcrypt); $this->enmcrypt = null; $this->demcrypt = null; if ($this->ecb) { - mcrypt_module_close($this->ecb); + @mcrypt_module_close($this->ecb); $this->ecb = null; } } @@ -1850,19 +1850,19 @@ class Crypt_Base CRYPT_MODE_STREAM => MCRYPT_MODE_STREAM, ); - $this->demcrypt = mcrypt_module_open($this->cipher_name_mcrypt, '', $mcrypt_modes[$this->mode], ''); - $this->enmcrypt = mcrypt_module_open($this->cipher_name_mcrypt, '', $mcrypt_modes[$this->mode], ''); + $this->demcrypt = @mcrypt_module_open($this->cipher_name_mcrypt, '', $mcrypt_modes[$this->mode], ''); + $this->enmcrypt = @mcrypt_module_open($this->cipher_name_mcrypt, '', $mcrypt_modes[$this->mode], ''); // we need the $ecb mcrypt resource (only) in MODE_CFB with enableContinuousBuffer() // to workaround mcrypt's broken ncfb implementation in buffered mode // see: {@link http://phpseclib.sourceforge.net/cfb-demo.phps} if ($this->mode == CRYPT_MODE_CFB) { - $this->ecb = mcrypt_module_open($this->cipher_name_mcrypt, '', MCRYPT_MODE_ECB, ''); + $this->ecb = @mcrypt_module_open($this->cipher_name_mcrypt, '', MCRYPT_MODE_ECB, ''); } } // else should mcrypt_generic_deinit be called? if ($this->mode == CRYPT_MODE_CFB) { - mcrypt_generic_init($this->ecb, $this->key, str_repeat("\0", $this->block_size)); + @mcrypt_generic_init($this->ecb, $this->key, str_repeat("\0", $this->block_size)); } } From d68975117c4595b820bd0bf932fa04e0501cafaa Mon Sep 17 00:00:00 2001 From: terrafrost Date: Fri, 23 Sep 2016 21:55:26 -0500 Subject: [PATCH 4/5] RC2: rm empty constructor --- phpseclib/Crypt/RC2.php | 28 ---------------------------- 1 file changed, 28 deletions(-) diff --git a/phpseclib/Crypt/RC2.php b/phpseclib/Crypt/RC2.php index 1d10a8af..97b4550c 100644 --- a/phpseclib/Crypt/RC2.php +++ b/phpseclib/Crypt/RC2.php @@ -332,34 +332,6 @@ class Crypt_RC2 extends Crypt_Base 0x70, 0x02, 0xC2, 0x1E, 0xB8, 0x0A, 0xFC, 0xE6 ); - /** - * Default Constructor. - * - * Determines whether or not the mcrypt extension should be used. - * - * $mode could be: - * - * - CRYPT_RC2_MODE_ECB - * - * - CRYPT_RC2_MODE_CBC - * - * - CRYPT_RC2_MODE_CTR - * - * - CRYPT_RC2_MODE_CFB - * - * - CRYPT_RC2_MODE_OFB - * - * If not explicitly set, CRYPT_RC2_MODE_CBC will be used. - * - * @see Crypt_Base::Crypt_Base() - * @param int $mode - * @access public - */ - function Crypt_RC2($mode = CRYPT_RC2_MODE_CBC) - { - parent::Crypt_Base($mode); - } - /** * Test for engine validity * From e81b8d90d3fa98d155c0e050f3d56b32affbcae7 Mon Sep 17 00:00:00 2001 From: terrafrost Date: Sat, 24 Sep 2016 11:57:59 -0500 Subject: [PATCH 5/5] Travis: PHP 7.1 tweaks --- .travis.yml | 2 +- travis/run-phpunit.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index faf3dce1..c3f3ce7b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -28,7 +28,7 @@ install: - cd .. - eval `ssh-agent -s` - travis/setup-secure-shell.sh - - sh -c "if [ '$TRAVIS_PHP_VERSION' != 'hhvm' -a '$TRAVIS_PHP_VERSION' != '7.0' -a '$TRAVIS_PHP_VERSION' != '7.1' ]; then travis/install-php-extensions.sh; fi" + - 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" - travis/setup-composer.sh script: diff --git a/travis/run-phpunit.sh b/travis/run-phpunit.sh index 5ee69d66..ce393a77 100755 --- a/travis/run-phpunit.sh +++ b/travis/run-phpunit.sh @@ -20,7 +20,7 @@ then PHPUNIT_ARGS="$PHPUNIT_ARGS -d zend.enable_gc=0" fi -if [ "$TRAVIS_PHP_VERSION" = 'hhvm' -o "$TRAVIS_PHP_VERSION" = '7.0' ] +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 \