diff --git a/.travis.yml b/.travis.yml index b9e3f0a1..9ae12b4a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -19,7 +19,13 @@ env: before_install: true install: - - sudo apt-get install parallel + - wget http://ftp.gnu.org/gnu/parallel/parallel-20120522.tar.bz2 + - tar -xvjf parallel* + - cd parallel* + - ./configure + - make + - sudo make 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" diff --git a/phpseclib/Crypt/RSA.php b/phpseclib/Crypt/RSA.php index 5e55917f..ba2a8d83 100644 --- a/phpseclib/Crypt/RSA.php +++ b/phpseclib/Crypt/RSA.php @@ -188,7 +188,7 @@ class RSA /** * PKCS#8 formatted private key */ - const PRIVATE_FORMAT_PKCS8 = 3; + const PRIVATE_FORMAT_PKCS8 = 8; /**#@-*/ /**#@+ diff --git a/phpseclib/Math/BigInteger.php b/phpseclib/Math/BigInteger.php index a43a39ac..6befb591 100644 --- a/phpseclib/Math/BigInteger.php +++ b/phpseclib/Math/BigInteger.php @@ -812,7 +812,28 @@ class BigInteger */ function __debugInfo() { - return array('value' => '0x' . $this->toHex(true)); + $opts = array(); + switch (MATH_BIGINTEGER_MODE) { + case self::MODE_GMP: + $engine = 'gmp'; + break; + case self::MODE_BCMATH: + $engine = 'bcmath'; + break; + case self::MODE_INTERNAL: + $engine = 'internal'; + $opts[] = PHP_INT_SIZE == 8 ? '64-bit' : '32-bit'; + } + if (MATH_BIGINTEGER_MODE != self::MODE_GMP && defined('MATH_BIGINTEGER_OPENSSL_ENABLED')) { + $opts[] = 'OpenSSL'; + } + if (!empty($opts)) { + $engine.= ' (' . implode($opts, ', ') . ')'; + } + return array( + 'value' => '0x' . $this->toHex(true), + 'engine' => $engine + ); } /** diff --git a/phpseclib/Net/SSH2.php b/phpseclib/Net/SSH2.php index 1fcf1370..0f7c8318 100644 --- a/phpseclib/Net/SSH2.php +++ b/phpseclib/Net/SSH2.php @@ -2862,6 +2862,17 @@ class SSH2 return (bool) ($this->bitmap & self::MASK_CONNECTED); } + /** + * Have you successfully been logged in? + * + * @return bool + * @access public + */ + function isAuthenticated() + { + return (bool) ($this->bitmap & self::MASK_LOGIN); + } + /** * Gets Binary Packets * diff --git a/tests/Functional/Net/SSH2Test.php b/tests/Functional/Net/SSH2Test.php index 51373705..4c18abed 100644 --- a/tests/Functional/Net/SSH2Test.php +++ b/tests/Functional/Net/SSH2Test.php @@ -34,6 +34,11 @@ class Functional_Net_SSH2Test extends PhpseclibFunctionalTestCase 'Failed asserting that SSH2 is not connected after construction.' ); + $this->assertFalse( + $ssh->isAuthenticated(), + 'Failed asserting that SSH2 is not authenticated after construction.' + ); + $this->assertNotEmpty( $ssh->getServerPublicHostKey(), 'Failed asserting that a non-empty public host key was fetched.' @@ -55,6 +60,31 @@ class Functional_Net_SSH2Test extends PhpseclibFunctionalTestCase /** * @depends testPreLogin */ + public function testBadPassword($ssh) + { + $username = $this->getEnv('SSH_USERNAME'); + $password = $this->getEnv('SSH_PASSWORD'); + $this->assertFalse( + $ssh->login($username, 'zzz' . $password), + 'SSH2 login using password succeeded.' + ); + + $this->assertTrue( + $ssh->isConnected(), + 'Failed asserting that SSH2 is connected after bad login attempt.' + ); + + $this->assertFalse( + $ssh->isAuthenticated(), + 'Failed asserting that SSH2 is not authenticated after bad login attempt.' + ); + + return $ssh; + } + + /** + * @depends testBadPassword + */ public function testPasswordLogin($ssh) { $username = $this->getEnv('SSH_USERNAME'); @@ -64,6 +94,11 @@ class Functional_Net_SSH2Test extends PhpseclibFunctionalTestCase 'SSH2 login using password failed.' ); + $this->assertTrue( + $ssh->isAuthenticated(), + 'Failed asserting that SSH2 is authenticated after good login attempt.' + ); + return $ssh; } diff --git a/tests/Unit/Math/BigInteger/TestCase.php b/tests/Unit/Math/BigInteger/TestCase.php index bb5293b3..f352e7ed 100644 --- a/tests/Unit/Math/BigInteger/TestCase.php +++ b/tests/Unit/Math/BigInteger/TestCase.php @@ -355,4 +355,15 @@ abstract class Unit_Math_BigInteger_TestCase extends PhpseclibTestCase 'Failed asserting that Alice and Bob share the same BigInteger.' ); } + + /** + * @requires PHP 5.6 + */ + public function testDebugInfo() + { + $num = $this->getInstance(50); + $str = print_r($num, true); + $this->assertContains('[value] => 0x32', $str); + return $str; + } } diff --git a/travis/install-php-extensions.sh b/travis/install-php-extensions.sh index 2acfdfd7..5244261c 100755 --- a/travis/install-php-extensions.sh +++ b/travis/install-php-extensions.sh @@ -21,10 +21,5 @@ function install_php_extension } # runkit -if [ "$TRAVIS_PHP_VERSION" == "5.6" ] -then - git clone https://github.com/adrianguenter/runkit.git -else - git clone https://github.com/zenovich/runkit.git -fi +git clone https://github.com/zenovich/runkit.git install_php_extension 'runkit'