mirror of
https://github.com/danog/tgseclib.git
synced 2024-11-27 04:34:45 +01:00
Merge branch 'master' of https://github.com/phpseclib/phpseclib into spkac
This commit is contained in:
commit
daa466db94
6
.scrutinizer.yml
Normal file
6
.scrutinizer.yml
Normal file
@ -0,0 +1,6 @@
|
||||
imports:
|
||||
- php
|
||||
|
||||
tools:
|
||||
external_code_coverage:
|
||||
runs: 5 # No Code Coverage on PHP 5.2 and HHVM
|
@ -1,5 +1,7 @@
|
||||
language: php
|
||||
|
||||
# When adding environments here, the number of runs specified in .scrutinizer.yml
|
||||
# may have to be adjusted.
|
||||
php:
|
||||
- 5.2
|
||||
- 5.3.3
|
||||
@ -25,4 +27,5 @@ script:
|
||||
- travis/run-phpunit.sh
|
||||
|
||||
after_success:
|
||||
- sh -c "if $TRAVIS_SECURE_ENV_VARS; then travis/upload-code-coverage.sh; fi"
|
||||
- sh -c "if $TRAVIS_SECURE_ENV_VARS; then travis/upload-code-coverage-html.sh; fi"
|
||||
- sh -c "if [ '$TRAVIS_PHP_VERSION' != '5.2' -a '$TRAVIS_PHP_VERSION' != 'hhvm' ]; then travis/upload-code-coverage-scrutinizer.sh; fi"
|
||||
|
@ -19,7 +19,7 @@
|
||||
* Here's a short example of how to use this library:
|
||||
* <code>
|
||||
* <?php
|
||||
* include('Crypt/AES.php');
|
||||
* include 'Crypt/AES.php';
|
||||
*
|
||||
* $aes = new Crypt_AES();
|
||||
*
|
||||
|
@ -14,7 +14,7 @@
|
||||
* Here's a short example of how to use this library:
|
||||
* <code>
|
||||
* <?php
|
||||
* include('Crypt/Blowfish.php');
|
||||
* include 'Crypt/Blowfish.php';
|
||||
*
|
||||
* $blowfish = new Crypt_Blowfish();
|
||||
*
|
||||
|
@ -16,7 +16,7 @@
|
||||
* Here's a short example of how to use this library:
|
||||
* <code>
|
||||
* <?php
|
||||
* include('Crypt/DES.php');
|
||||
* include 'Crypt/DES.php';
|
||||
*
|
||||
* $des = new Crypt_DES();
|
||||
*
|
||||
|
@ -18,7 +18,7 @@
|
||||
* Here's a short example of how to use this library:
|
||||
* <code>
|
||||
* <?php
|
||||
* include('Crypt/Hash.php');
|
||||
* include 'Crypt/Hash.php';
|
||||
*
|
||||
* $hash = new Crypt_Hash('sha1');
|
||||
*
|
||||
|
@ -14,7 +14,7 @@
|
||||
* Here's a short example of how to use this library:
|
||||
* <code>
|
||||
* <?php
|
||||
* include('Crypt/RC2.php');
|
||||
* include 'Crypt/RC2.php';
|
||||
*
|
||||
* $rc2 = new Crypt_RC2();
|
||||
*
|
||||
|
@ -18,7 +18,7 @@
|
||||
* Here's a short example of how to use this library:
|
||||
* <code>
|
||||
* <?php
|
||||
* include('Crypt/RC4.php');
|
||||
* include 'Crypt/RC4.php';
|
||||
*
|
||||
* $rc4 = new Crypt_RC4();
|
||||
*
|
||||
|
@ -8,7 +8,7 @@
|
||||
* Here's an example of how to encrypt and decrypt text with this library:
|
||||
* <code>
|
||||
* <?php
|
||||
* include('Crypt/RSA.php');
|
||||
* include 'Crypt/RSA.php';
|
||||
*
|
||||
* $rsa = new Crypt_RSA();
|
||||
* extract($rsa->createKey());
|
||||
@ -26,7 +26,7 @@
|
||||
* Here's an example of how to create signatures and verify signatures with this library:
|
||||
* <code>
|
||||
* <?php
|
||||
* include('Crypt/RSA.php');
|
||||
* include 'Crypt/RSA.php';
|
||||
*
|
||||
* $rsa = new Crypt_RSA();
|
||||
* extract($rsa->createKey());
|
||||
@ -1482,6 +1482,19 @@ class Crypt_RSA
|
||||
$this->publicExponent = false;
|
||||
}
|
||||
|
||||
switch ($type) {
|
||||
case CRYPT_RSA_PUBLIC_FORMAT_OPENSSH:
|
||||
case CRYPT_RSA_PUBLIC_FORMAT_RAW:
|
||||
$this->setPublicKey();
|
||||
break;
|
||||
case CRYPT_RSA_PRIVATE_FORMAT_PKCS1:
|
||||
switch (true) {
|
||||
case strpos($key, '-BEGIN PUBLIC KEY-') !== false:
|
||||
case strpos($key, '-BEGIN RSA PUBLIC KEY-') !== false:
|
||||
$this->setPublicKey();
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -1508,7 +1521,9 @@ class Crypt_RSA
|
||||
* used in certain contexts. For example, in SSH-2, RSA authentication works by sending the public key along with a
|
||||
* message signed by the private key to the server. The SSH-2 server looks the public key up in an index of public keys
|
||||
* and if it's present then proceeds to verify the signature. Problem is, if your private key doesn't include the public
|
||||
* exponent this won't work unless you manually add the public exponent.
|
||||
* exponent this won't work unless you manually add the public exponent. phpseclib tries to guess if the key being used
|
||||
* is the public key but in the event that it guesses incorrectly you might still want to explicitly set the key as being
|
||||
* public.
|
||||
*
|
||||
* Do note that when a new key is loaded the index will be cleared.
|
||||
*
|
||||
@ -1564,6 +1579,40 @@ class Crypt_RSA
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Defines the private key
|
||||
*
|
||||
* If phpseclib guessed a private key was a public key and loaded it as such it might be desirable to force
|
||||
* phpseclib to treat the key as a private key. This function will do that.
|
||||
*
|
||||
* Do note that when a new key is loaded the index will be cleared.
|
||||
*
|
||||
* Returns true on success, false on failure
|
||||
*
|
||||
* @see getPublicKey()
|
||||
* @access public
|
||||
* @param String $key optional
|
||||
* @param Integer $type optional
|
||||
* @return Boolean
|
||||
*/
|
||||
function setPrivateKey($key = false, $type = false)
|
||||
{
|
||||
if ($key === false && !empty($this->publicExponent)) {
|
||||
unset($this->publicExponent);
|
||||
return true;
|
||||
}
|
||||
|
||||
$rsa = new Crypt_RSA();
|
||||
if (!$rsa->loadKey($key, $type)) {
|
||||
return false;
|
||||
}
|
||||
unset($rsa->publicExponent);
|
||||
|
||||
// don't overwrite the old key if the new key is invalid
|
||||
$this->loadKey($rsa);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the public key
|
||||
*
|
||||
|
@ -8,7 +8,7 @@
|
||||
* Here's a short example of how to use this library:
|
||||
* <code>
|
||||
* <?php
|
||||
* include('Crypt/Random.php');
|
||||
* include 'Crypt/Random.php';
|
||||
*
|
||||
* echo bin2hex(crypt_random_string(8));
|
||||
* ?>
|
||||
|
@ -28,7 +28,7 @@
|
||||
* Here's a short example of how to use this library:
|
||||
* <code>
|
||||
* <?php
|
||||
* include('Crypt/Rijndael.php');
|
||||
* include 'Crypt/Rijndael.php';
|
||||
*
|
||||
* $rijndael = new Crypt_Rijndael();
|
||||
*
|
||||
|
@ -10,7 +10,7 @@
|
||||
* Here's a short example of how to use this library:
|
||||
* <code>
|
||||
* <?php
|
||||
* include('Crypt/TripleDES.php');
|
||||
* include 'Crypt/TripleDES.php';
|
||||
*
|
||||
* $des = new Crypt_TripleDES();
|
||||
*
|
||||
|
@ -14,7 +14,7 @@
|
||||
* Here's a short example of how to use this library:
|
||||
* <code>
|
||||
* <?php
|
||||
* include('Crypt/Twofish.php');
|
||||
* include 'Crypt/Twofish.php';
|
||||
*
|
||||
* $twofish = new Crypt_Twofish();
|
||||
*
|
||||
|
@ -31,7 +31,7 @@
|
||||
* Here's an example of how to use this library:
|
||||
* <code>
|
||||
* <?php
|
||||
* include('Math/BigInteger.php');
|
||||
* include 'Math/BigInteger.php';
|
||||
*
|
||||
* $a = new Math_BigInteger(2);
|
||||
* $b = new Math_BigInteger(3);
|
||||
@ -238,7 +238,7 @@ class Math_BigInteger
|
||||
* Here's an example:
|
||||
* <code>
|
||||
* <?php
|
||||
* include('Math/BigInteger.php');
|
||||
* include 'Math/BigInteger.php';
|
||||
*
|
||||
* $a = new Math_BigInteger('0x32', 16); // 50 in base-16
|
||||
*
|
||||
@ -506,7 +506,7 @@ class Math_BigInteger
|
||||
* Here's an example:
|
||||
* <code>
|
||||
* <?php
|
||||
* include('Math/BigInteger.php');
|
||||
* include 'Math/BigInteger.php';
|
||||
*
|
||||
* $a = new Math_BigInteger('65');
|
||||
*
|
||||
@ -603,7 +603,7 @@ class Math_BigInteger
|
||||
* Here's an example:
|
||||
* <code>
|
||||
* <?php
|
||||
* include('Math/BigInteger.php');
|
||||
* include 'Math/BigInteger.php';
|
||||
*
|
||||
* $a = new Math_BigInteger('65');
|
||||
*
|
||||
@ -630,7 +630,7 @@ class Math_BigInteger
|
||||
* Here's an example:
|
||||
* <code>
|
||||
* <?php
|
||||
* include('Math/BigInteger.php');
|
||||
* include 'Math/BigInteger.php';
|
||||
*
|
||||
* $a = new Math_BigInteger('65');
|
||||
*
|
||||
@ -668,7 +668,7 @@ class Math_BigInteger
|
||||
* Here's an example:
|
||||
* <code>
|
||||
* <?php
|
||||
* include('Math/BigInteger.php');
|
||||
* include 'Math/BigInteger.php';
|
||||
*
|
||||
* $a = new Math_BigInteger('50');
|
||||
*
|
||||
@ -821,7 +821,7 @@ class Math_BigInteger
|
||||
* Here's an example:
|
||||
* <code>
|
||||
* <?php
|
||||
* include('Math/BigInteger.php');
|
||||
* include 'Math/BigInteger.php';
|
||||
*
|
||||
* $a = new Math_BigInteger('10');
|
||||
* $b = new Math_BigInteger('20');
|
||||
@ -952,7 +952,7 @@ class Math_BigInteger
|
||||
* Here's an example:
|
||||
* <code>
|
||||
* <?php
|
||||
* include('Math/BigInteger.php');
|
||||
* include 'Math/BigInteger.php';
|
||||
*
|
||||
* $a = new Math_BigInteger('10');
|
||||
* $b = new Math_BigInteger('20');
|
||||
@ -1088,7 +1088,7 @@ class Math_BigInteger
|
||||
* Here's an example:
|
||||
* <code>
|
||||
* <?php
|
||||
* include('Math/BigInteger.php');
|
||||
* include 'Math/BigInteger.php';
|
||||
*
|
||||
* $a = new Math_BigInteger('10');
|
||||
* $b = new Math_BigInteger('20');
|
||||
@ -1372,7 +1372,7 @@ class Math_BigInteger
|
||||
* Here's an example:
|
||||
* <code>
|
||||
* <?php
|
||||
* include('Math/BigInteger.php');
|
||||
* include 'Math/BigInteger.php';
|
||||
*
|
||||
* $a = new Math_BigInteger('10');
|
||||
* $b = new Math_BigInteger('20');
|
||||
@ -1591,7 +1591,7 @@ class Math_BigInteger
|
||||
* Here's an example:
|
||||
* <code>
|
||||
* <?php
|
||||
* include('Math/BigInteger.php');
|
||||
* include 'Math/BigInteger.php';
|
||||
*
|
||||
* $a = new Math_BigInteger('10');
|
||||
* $b = new Math_BigInteger('20');
|
||||
@ -2396,7 +2396,7 @@ class Math_BigInteger
|
||||
* Here's an example:
|
||||
* <code>
|
||||
* <?php
|
||||
* include('Math/BigInteger.php');
|
||||
* include 'Math/BigInteger.php';
|
||||
*
|
||||
* $a = new Math_BigInteger(30);
|
||||
* $b = new Math_BigInteger(17);
|
||||
@ -2464,7 +2464,7 @@ class Math_BigInteger
|
||||
* Here's an example:
|
||||
* <code>
|
||||
* <?php
|
||||
* include('Math/BigInteger.php');
|
||||
* include 'Math/BigInteger.php';
|
||||
*
|
||||
* $a = new Math_BigInteger(693);
|
||||
* $b = new Math_BigInteger(609);
|
||||
@ -2599,7 +2599,7 @@ class Math_BigInteger
|
||||
* Here's an example:
|
||||
* <code>
|
||||
* <?php
|
||||
* include('Math/BigInteger.php');
|
||||
* include 'Math/BigInteger.php';
|
||||
*
|
||||
* $a = new Math_BigInteger(693);
|
||||
* $b = new Math_BigInteger(609);
|
||||
|
@ -10,8 +10,8 @@
|
||||
* Here's a short example of how to use this library:
|
||||
* <code>
|
||||
* <?php
|
||||
* include('Net/SCP.php');
|
||||
* include('Net/SSH2.php');
|
||||
* include 'Net/SCP.php';
|
||||
* include 'Net/SSH2.php';
|
||||
*
|
||||
* $ssh = new Net_SSH2('www.domain.tld');
|
||||
* if (!$ssh->login('username', 'password')) {
|
||||
|
@ -14,7 +14,7 @@
|
||||
* Here's a short example of how to use this library:
|
||||
* <code>
|
||||
* <?php
|
||||
* include('Net/SFTP.php');
|
||||
* include 'Net/SFTP.php';
|
||||
*
|
||||
* $sftp = new Net_SFTP('www.domain.tld');
|
||||
* if (!$sftp->login('username', 'password')) {
|
||||
|
@ -8,7 +8,7 @@
|
||||
* Here's a short example of how to use this library:
|
||||
* <code>
|
||||
* <?php
|
||||
* include('Net/SSH1.php');
|
||||
* include 'Net/SSH1.php';
|
||||
*
|
||||
* $ssh = new Net_SSH1('www.domain.tld');
|
||||
* if (!$ssh->login('username', 'password')) {
|
||||
@ -22,7 +22,7 @@
|
||||
* Here's another short example:
|
||||
* <code>
|
||||
* <?php
|
||||
* include('Net/SSH1.php');
|
||||
* include 'Net/SSH1.php';
|
||||
*
|
||||
* $ssh = new Net_SSH1('www.domain.tld');
|
||||
* if (!$ssh->login('username', 'password')) {
|
||||
@ -704,7 +704,7 @@ class Net_SSH1
|
||||
break;
|
||||
//case NET_SSH1_CIPHER_RC4:
|
||||
// if (!class_exists('Crypt_RC4')) {
|
||||
// include_once('Crypt/RC4.php');
|
||||
// include_once 'Crypt/RC4.php';
|
||||
// }
|
||||
// $this->crypto = new Crypt_RC4();
|
||||
// $this->crypto->enableContinuousBuffer();
|
||||
|
@ -8,7 +8,7 @@
|
||||
* Here are some examples of how to use this library:
|
||||
* <code>
|
||||
* <?php
|
||||
* include('Net/SSH2.php');
|
||||
* include 'Net/SSH2.php';
|
||||
*
|
||||
* $ssh = new Net_SSH2('www.domain.tld');
|
||||
* if (!$ssh->login('username', 'password')) {
|
||||
@ -22,8 +22,8 @@
|
||||
*
|
||||
* <code>
|
||||
* <?php
|
||||
* include('Crypt/RSA.php');
|
||||
* include('Net/SSH2.php');
|
||||
* include 'Crypt/RSA.php';
|
||||
* include 'Net/SSH2.php';
|
||||
*
|
||||
* $key = new Crypt_RSA();
|
||||
* //$key->setPassword('whatever');
|
||||
|
@ -7,8 +7,8 @@
|
||||
* Here are some examples of how to use this library:
|
||||
* <code>
|
||||
* <?php
|
||||
* include('System/SSH/Agent.php');
|
||||
* include('Net/SSH2.php');
|
||||
* include 'System/SSH/Agent.php';
|
||||
* include 'Net/SSH2.php';
|
||||
*
|
||||
* $agent = new System_SSH_Agent();
|
||||
*
|
||||
|
@ -4,8 +4,11 @@
|
||||
colors="true"
|
||||
>
|
||||
<testsuites>
|
||||
<testsuite name="phpseclib Test Suite">
|
||||
<directory>./tests/</directory>
|
||||
<testsuite name="phpseclib Unit Test Suite">
|
||||
<directory>./tests/Unit/</directory>
|
||||
</testsuite>
|
||||
<testsuite name="phpseclib Functional Test Suite">
|
||||
<directory>./tests/Functional/</directory>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||
*/
|
||||
|
||||
class Net_SFTPFunctionalTest extends PhpseclibFunctionalTestCase
|
||||
class Functional_Net_SFTPUserStoryTest extends PhpseclibFunctionalTestCase
|
||||
{
|
||||
static protected $scratchDir;
|
||||
static protected $exampleData;
|
@ -6,7 +6,7 @@
|
||||
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||
*/
|
||||
|
||||
class Net_SSH2FunctionalTest extends PhpseclibFunctionalTestCase
|
||||
class Functional_Net_SSH2Test extends PhpseclibFunctionalTestCase
|
||||
{
|
||||
public function setUp()
|
||||
{
|
@ -5,7 +5,7 @@
|
||||
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||
*/
|
||||
|
||||
class Crypt_AES_ContinuousBufferTest extends Crypt_AES_TestCase
|
||||
class Unit_Crypt_AES_ContinuousBufferTest extends Unit_Crypt_AES_TestCase
|
||||
{
|
||||
// String intented
|
||||
protected $modes = array(
|
@ -7,7 +7,7 @@
|
||||
|
||||
require_once 'Crypt/AES.php';
|
||||
|
||||
abstract class Crypt_AES_TestCase extends PhpseclibTestCase
|
||||
abstract class Unit_Crypt_AES_TestCase extends PhpseclibTestCase
|
||||
{
|
||||
static public function setUpBeforeClass()
|
||||
{
|
@ -5,7 +5,7 @@
|
||||
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||
*/
|
||||
|
||||
class Crypt_Hash_MD5Test extends Crypt_Hash_TestCase
|
||||
class Unit_Crypt_Hash_MD5Test extends Unit_Crypt_Hash_TestCase
|
||||
{
|
||||
public function getInstance()
|
||||
{
|
@ -7,7 +7,7 @@
|
||||
|
||||
require_once 'Crypt/Hash.php';
|
||||
|
||||
abstract class Crypt_Hash_TestCase extends PhpseclibTestCase
|
||||
abstract class Unit_Crypt_Hash_TestCase extends PhpseclibTestCase
|
||||
{
|
||||
static public function setUpBeforeClass()
|
||||
{
|
@ -7,7 +7,7 @@
|
||||
|
||||
require_once 'Crypt/RSA.php' ;
|
||||
|
||||
class Crypt_RSA_LoadKeyTest extends PhpseclibTestCase
|
||||
class Unit_Crypt_RSA_LoadKeyTest extends PhpseclibTestCase
|
||||
{
|
||||
public function testBadKey()
|
||||
{
|
||||
@ -37,6 +37,7 @@ U9VQQSQzY1oZMVX8i1m5WUTLPz2yLJIBQVdXqhMCQBGoiuSoSjafUhV7i1cEGpb88h5NBYZzWXGZ
|
||||
-----END RSA PRIVATE KEY-----';
|
||||
|
||||
$this->assertTrue($rsa->loadKey($key));
|
||||
$this->assertInternalType('string', $rsa->getPrivateKey());
|
||||
}
|
||||
|
||||
public function testPKCS1SpacesKey()
|
||||
@ -59,6 +60,7 @@ U9VQQSQzY1oZMVX8i1m5WUTLPz2yLJIBQVdXqhMCQBGoiuSoSjafUhV7i1cEGpb88h5NBYZzWXGZ
|
||||
$key = str_replace(array("\r", "\n", "\r\n"), ' ', $key);
|
||||
|
||||
$this->assertTrue($rsa->loadKey($key));
|
||||
$this->assertInternalType('string', $rsa->getPrivateKey());
|
||||
}
|
||||
|
||||
public function testPKCS1NoHeaderKey()
|
||||
@ -78,6 +80,7 @@ U9VQQSQzY1oZMVX8i1m5WUTLPz2yLJIBQVdXqhMCQBGoiuSoSjafUhV7i1cEGpb88h5NBYZzWXGZ
|
||||
37sJ5QsW+sJyoNde3xH8vdXhzU7eT82D6X/scw9RZz+/6rCJ4p0=';
|
||||
|
||||
$this->assertTrue($rsa->loadKey($key));
|
||||
$this->assertInternalType('string', $rsa->getPrivateKey());
|
||||
}
|
||||
|
||||
public function testPKCS1NoWhitespaceNoHeaderKey()
|
||||
@ -95,7 +98,9 @@ U9VQQSQzY1oZMVX8i1m5WUTLPz2yLJIBQVdXqhMCQBGoiuSoSjafUhV7i1cEGpb88h5NBYZzWXGZ
|
||||
'X6zk7S0ljKtt2jny2+00VsBerQJBAJGC1Mg5Oydo5NwD6BiROrPxGo2bpTbu/fhrT8ebHkTz2epl' .
|
||||
'U9VQQSQzY1oZMVX8i1m5WUTLPz2yLJIBQVdXqhMCQBGoiuSoSjafUhV7i1cEGpb88h5NBYZzWXGZ' .
|
||||
'37sJ5QsW+sJyoNde3xH8vdXhzU7eT82D6X/scw9RZz+/6rCJ4p0=';
|
||||
|
||||
$this->assertTrue($rsa->loadKey($key));
|
||||
$this->assertInternalType('string', $rsa->getPrivateKey());
|
||||
}
|
||||
|
||||
public function testRawPKCS1Key()
|
||||
@ -116,5 +121,76 @@ U9VQQSQzY1oZMVX8i1m5WUTLPz2yLJIBQVdXqhMCQBGoiuSoSjafUhV7i1cEGpb88h5NBYZzWXGZ
|
||||
$key = base64_decode($key);
|
||||
|
||||
$this->assertTrue($rsa->loadKey($key));
|
||||
$this->assertInternalType('string', $rsa->getPrivateKey());
|
||||
}
|
||||
|
||||
public function testPubKey1()
|
||||
{
|
||||
$rsa = new Crypt_RSA();
|
||||
|
||||
$key = '-----BEGIN RSA PUBLIC KEY-----
|
||||
MIIBCgKCAQEA61BjmfXGEvWmegnBGSuS+rU9soUg2FnODva32D1AqhwdziwHINFa
|
||||
D1MVlcrYG6XRKfkcxnaXGfFDWHLEvNBSEVCgJjtHAGZIm5GL/KA86KDp/CwDFMSw
|
||||
luowcXwDwoyinmeOY9eKyh6aY72xJh7noLBBq1N0bWi1e2i+83txOCg4yV2oVXhB
|
||||
o8pYEJ8LT3el6Smxol3C1oFMVdwPgc0vTl25XucMcG/ALE/KNY6pqC2AQ6R2ERlV
|
||||
gPiUWOPatVkt7+Bs3h5Ramxh7XjBOXeulmCpGSynXNcpZ/06+vofGi/2MlpQZNhH
|
||||
Ao8eayMp6FcvNucIpUndo1X8dKMv3Y26ZQIDAQAB
|
||||
-----END RSA PUBLIC KEY-----';
|
||||
|
||||
$this->assertTrue($rsa->loadKey($key));
|
||||
$this->assertInternalType('string', $rsa->getPublicKey());
|
||||
$this->assertFalse($rsa->getPrivateKey());
|
||||
}
|
||||
|
||||
public function testPubKey2()
|
||||
{
|
||||
$rsa = new Crypt_RSA();
|
||||
|
||||
$key = '-----BEGIN PUBLIC KEY-----
|
||||
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA61BjmfXGEvWmegnBGSuS
|
||||
+rU9soUg2FnODva32D1AqhwdziwHINFaD1MVlcrYG6XRKfkcxnaXGfFDWHLEvNBS
|
||||
EVCgJjtHAGZIm5GL/KA86KDp/CwDFMSwluowcXwDwoyinmeOY9eKyh6aY72xJh7n
|
||||
oLBBq1N0bWi1e2i+83txOCg4yV2oVXhBo8pYEJ8LT3el6Smxol3C1oFMVdwPgc0v
|
||||
Tl25XucMcG/ALE/KNY6pqC2AQ6R2ERlVgPiUWOPatVkt7+Bs3h5Ramxh7XjBOXeu
|
||||
lmCpGSynXNcpZ/06+vofGi/2MlpQZNhHAo8eayMp6FcvNucIpUndo1X8dKMv3Y26
|
||||
ZQIDAQAB
|
||||
-----END PUBLIC KEY-----';
|
||||
|
||||
$this->assertTrue($rsa->loadKey($key));
|
||||
$this->assertInternalType('string', $rsa->getPublicKey());
|
||||
$this->assertFalse($rsa->getPrivateKey());
|
||||
}
|
||||
|
||||
public function testSSHPubKey()
|
||||
{
|
||||
$rsa = new Crypt_RSA();
|
||||
|
||||
$key = 'ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAgQCqGKukO1De7zhZj6+H0qtjTkVxwTCpvKe4e' .
|
||||
'CZ0FPqri0cb2JZfXJ/DgYSF6vUpwmJG8wVQZKjeGcjDOL5UlsuusFncCzWBQ7RKNUSesmQRMS' .
|
||||
'GkVb1/3j+skZ6UtW+5u09lHNsj6tQ51s1SPrCBkedbNf0Tp0GbMJDyR4e9T04ZZw== ' .
|
||||
'phpseclib-generated-key';
|
||||
|
||||
$this->assertTrue($rsa->loadKey($key));
|
||||
$this->assertInternalType('string', $rsa->getPublicKey());
|
||||
$this->assertFalse($rsa->getPrivateKey());
|
||||
}
|
||||
|
||||
public function testSetPrivate()
|
||||
{
|
||||
$rsa = new Crypt_RSA();
|
||||
|
||||
$key = '-----BEGIN RSA PUBLIC KEY-----
|
||||
MIIBCgKCAQEA61BjmfXGEvWmegnBGSuS+rU9soUg2FnODva32D1AqhwdziwHINFa
|
||||
D1MVlcrYG6XRKfkcxnaXGfFDWHLEvNBSEVCgJjtHAGZIm5GL/KA86KDp/CwDFMSw
|
||||
luowcXwDwoyinmeOY9eKyh6aY72xJh7noLBBq1N0bWi1e2i+83txOCg4yV2oVXhB
|
||||
o8pYEJ8LT3el6Smxol3C1oFMVdwPgc0vTl25XucMcG/ALE/KNY6pqC2AQ6R2ERlV
|
||||
gPiUWOPatVkt7+Bs3h5Ramxh7XjBOXeulmCpGSynXNcpZ/06+vofGi/2MlpQZNhH
|
||||
Ao8eayMp6FcvNucIpUndo1X8dKMv3Y26ZQIDAQAB
|
||||
-----END RSA PUBLIC KEY-----';
|
||||
|
||||
$this->assertTrue($rsa->loadKey($key));
|
||||
$this->assertTrue($rsa->setPrivateKey());
|
||||
$this->assertGreaterThanOrEqual(1, strlen("$rsa"));
|
||||
$this->assertFalse($rsa->getPublicKey());
|
||||
}
|
||||
}
|
@ -7,7 +7,7 @@
|
||||
|
||||
require_once 'File/ASN1.php';
|
||||
|
||||
class File_ASN1_DevTest extends PhpseclibTestCase
|
||||
class Unit_File_ASN1_DevTest extends PhpseclibTestCase
|
||||
{
|
||||
/**
|
||||
* on older versions of File_ASN1 this would yield a PHP Warning
|
@ -5,7 +5,7 @@
|
||||
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||
*/
|
||||
|
||||
class Math_BigInteger_BCMathTest extends Math_BigInteger_TestCase
|
||||
class Unit_Math_BigInteger_BCMathTest extends Unit_Math_BigInteger_TestCase
|
||||
{
|
||||
static public function setUpBeforeClass()
|
||||
{
|
@ -5,7 +5,7 @@
|
||||
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||
*/
|
||||
|
||||
class Math_BigInteger_GMPTest extends Math_BigInteger_TestCase
|
||||
class Unit_Math_BigInteger_GMPTest extends Unit_Math_BigInteger_TestCase
|
||||
{
|
||||
static public function setUpBeforeClass()
|
||||
{
|
@ -5,7 +5,7 @@
|
||||
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||
*/
|
||||
|
||||
class Math_BigInteger_InternalOpenSSLTest extends Math_BigInteger_TestCase
|
||||
class Unit_Math_BigInteger_InternalOpenSSLTest extends Unit_Math_BigInteger_TestCase
|
||||
{
|
||||
static public function setUpBeforeClass()
|
||||
{
|
@ -5,7 +5,7 @@
|
||||
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||
*/
|
||||
|
||||
class Math_BigInteger_InternalTest extends Math_BigInteger_TestCase
|
||||
class Math_BigInteger_InternalTest extends Unit_Math_BigInteger_TestCase
|
||||
{
|
||||
static public function setUpBeforeClass()
|
||||
{
|
@ -7,7 +7,7 @@
|
||||
|
||||
require_once 'Math/BigInteger.php';
|
||||
|
||||
abstract class Math_BigInteger_TestCase extends PhpseclibTestCase
|
||||
abstract class Unit_Math_BigInteger_TestCase extends PhpseclibTestCase
|
||||
{
|
||||
static public function setUpBeforeClass()
|
||||
{
|
@ -5,7 +5,7 @@
|
||||
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||
*/
|
||||
|
||||
class Net_SSH1Test extends PhpseclibTestCase
|
||||
class Unit_Net_SSH1Test extends PhpseclibTestCase
|
||||
{
|
||||
public function formatLogDataProvider()
|
||||
{
|
@ -6,7 +6,7 @@
|
||||
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||
*/
|
||||
|
||||
class Net_SSH2Test extends PhpseclibTestCase
|
||||
class Unit_Net_SSH2Test extends PhpseclibTestCase
|
||||
{
|
||||
public function formatLogDataProvider()
|
||||
{
|
||||
@ -36,38 +36,27 @@ class Net_SSH2Test extends PhpseclibTestCase
|
||||
$this->assertEquals($expected, $result);
|
||||
}
|
||||
|
||||
public function generateIdentifierProvider()
|
||||
public function testGenerateIdentifier()
|
||||
{
|
||||
return array(
|
||||
array('SSH-2.0-phpseclib_0.3', array()),
|
||||
array('SSH-2.0-phpseclib_0.3 (gmp)', array('gmp')),
|
||||
array('SSH-2.0-phpseclib_0.3 (bcmath)', array('bcmath')),
|
||||
array('SSH-2.0-phpseclib_0.3 (mcrypt)', array('mcrypt')),
|
||||
array('SSH-2.0-phpseclib_0.3 (mcrypt, gmp)', array('mcrypt', 'gmp')),
|
||||
array('SSH-2.0-phpseclib_0.3 (mcrypt, bcmath)', array('mcrypt', 'bcmath')),
|
||||
);
|
||||
}
|
||||
$identifier = $this->createSSHMock()->_generate_identifier();
|
||||
$this->assertStringStartsWith('SSH-2.0-phpseclib_0.3', $identifier);
|
||||
|
||||
/**
|
||||
* @dataProvider generateIdentifierProvider
|
||||
*/
|
||||
public function testGenerateIdentifier($expected, array $requiredExtensions)
|
||||
{
|
||||
$notAllowed = array('gmp', 'bcmath', 'mcrypt', 'gmp');
|
||||
foreach ($notAllowed as $notAllowedExtension) {
|
||||
if (in_array($notAllowedExtension, $requiredExtensions)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (extension_loaded($notAllowedExtension)) {
|
||||
$this->markTestSkipped('Extension ' . $notAllowedExtension . ' is not allowed for this data-set');
|
||||
}
|
||||
if (extension_loaded('mcrypt')) {
|
||||
$this->assertContains('mcrypt', $identifier);
|
||||
} else {
|
||||
$this->assertNotContains('mcrypt', $identifier);
|
||||
}
|
||||
|
||||
$ssh = $this->createSSHMock();
|
||||
$identifier = $ssh->_generate_identifier();
|
||||
|
||||
$this->assertEquals($expected, $identifier);
|
||||
if (extension_loaded('gmp')) {
|
||||
$this->assertContains('gmp', $identifier);
|
||||
$this->assertNotContains('bcmath', $identifier);
|
||||
} else if (extension_loaded('bcmath')) {
|
||||
$this->assertNotContains('gmp', $identifier);
|
||||
$this->assertContains('bcmath', $identifier);
|
||||
} else {
|
||||
$this->assertNotContains('gmp', $identifier);
|
||||
$this->assertNotContains('bcmath', $identifier);
|
||||
}
|
||||
}
|
||||
|
||||
public function testGetExitStatusIfNotConnected()
|
@ -24,4 +24,5 @@ fi
|
||||
$PHPUNIT_EXTRA_ARGS \
|
||||
--verbose \
|
||||
--coverage-text \
|
||||
--coverage-clover code_coverage/clover.xml \
|
||||
--coverage-html code_coverage/
|
||||
|
13
travis/upload-code-coverage-scrutinizer.sh
Executable file
13
travis/upload-code-coverage-scrutinizer.sh
Executable file
@ -0,0 +1,13 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# This file is part of the phpseclib project.
|
||||
#
|
||||
# (c) Andreas Fischer <bantu@phpbb.com>
|
||||
#
|
||||
# For the full copyright and license information, please view the LICENSE
|
||||
# file that was distributed with this source code.
|
||||
#
|
||||
set -e
|
||||
|
||||
wget https://scrutinizer-ci.com/ocular.phar
|
||||
php ocular.phar code-coverage:upload --format=php-clover code_coverage/clover.xml
|
Loading…
Reference in New Issue
Block a user