Merge branch '3.0'

This commit is contained in:
terrafrost 2024-02-07 21:17:27 -06:00
commit 414b0b0d3b
12 changed files with 32 additions and 32 deletions

View File

@ -950,6 +950,8 @@ class SSH2
* Default Constructor.
*
* $host can either be a string, representing the host, or a stream resource.
* If $host is a stream resource then $port doesn't do anything, altho $timeout
* still will be used
*
* @see self::login()
*/
@ -957,6 +959,8 @@ class SSH2
{
self::$connections[$this->getResourceId()] = \WeakReference::create($this);
$this->timeout = $timeout;
if (is_resource($host)) {
$this->fsock = $host;
return;
@ -965,7 +969,6 @@ class SSH2
if (Strings::is_stringable($host)) {
$this->host = $host;
$this->port = $port;
$this->timeout = $timeout;
}
}
@ -3195,6 +3198,9 @@ class SSH2
}
$start = microtime(true);
$sec = (int) floor($this->curTimeout);
$usec = (int) (1000000 * ($this->curTimeout - $sec));
stream_set_timeout($this->fsock, $sec, $usec);
$raw = stream_get_contents($this->fsock, $this->decrypt_block_size);
if (!strlen($raw)) {

View File

@ -30,7 +30,7 @@ abstract class TestCase extends PhpseclibTestCase
/**
* Produces all combinations of test values.
*/
public function continuousBufferCombos(): array
public static function continuousBufferCombos(): array
{
$modes = [
'ctr',
@ -133,7 +133,7 @@ abstract class TestCase extends PhpseclibTestCase
*
* @return list<array{string, string, array}>
*/
public function continuousBufferBatteryCombos(): array
public static function continuousBufferBatteryCombos(): array
{
$modes = [
'ctr',
@ -178,7 +178,7 @@ abstract class TestCase extends PhpseclibTestCase
*/
public function continuousBufferBatteryCombosWithoutSingleCombos(): array
{
return array_filter($this->continuousBufferBatteryCombos(), fn (array $continuousBufferBatteryCombo) => count($continuousBufferBatteryCombo[2]) > 1);
return array_filter(self::$continuousBufferBatteryCombos(), fn (array $continuousBufferBatteryCombo) => count($continuousBufferBatteryCombo[2]) > 1);
}
/**

View File

@ -16,7 +16,7 @@ use phpseclib3\Tests\PhpseclibTestCase;
class BlowfishTest extends PhpseclibTestCase
{
public function engineVectors(): array
public static function engineVectors(): array
{
$engines = [
'PHP',

View File

@ -18,7 +18,7 @@ use phpseclib3\Tests\PhpseclibTestCase;
class CurveTest extends PhpseclibTestCase
{
public function curves(): array
public static function curves(): array
{
$curves = [];
foreach (new \DirectoryIterator(__DIR__ . '/../../../../phpseclib/Crypt/EC/Curves/') as $file) {
@ -40,7 +40,7 @@ class CurveTest extends PhpseclibTestCase
return $curves;
}
public function allCurves(): array
public static function allCurves(): array
{
$curves = [];
foreach (new \DirectoryIterator(__DIR__ . '/../../../../phpseclib/Crypt/EC/Curves/') as $file) {
@ -57,7 +57,7 @@ class CurveTest extends PhpseclibTestCase
return $curves;
}
public function curvesWithOIDs(): array
public static function curvesWithOIDs(): array
{
$class = new \ReflectionClass('phpseclib3\Crypt\EC\Formats\Keys\PKCS8');

View File

@ -18,7 +18,7 @@ class GCMTest extends PhpseclibTestCase
/**
* Produces all combinations of test values.
*/
public function engine128Vectors(): array
public static function engine128Vectors(): array
{
$engines = [
'PHP',
@ -128,7 +128,7 @@ class GCMTest extends PhpseclibTestCase
/**
* Produces all combinations of test values.
*/
public function engine256Vectors(): array
public static function engine256Vectors(): array
{
$engines = [
'PHP',

View File

@ -428,7 +428,7 @@ class HashTest extends PhpseclibTestCase
$this->assertSame($hash->getLengthInBytes(), $length);
}
public function lengths(): array
public static function lengths(): array
{
return [
// known
@ -441,7 +441,7 @@ class HashTest extends PhpseclibTestCase
];
}
public function UMACs(): array
public static function UMACs(): array
{
return [
['', 'umac-32', '113145FB', "umac-32 and message of <empty>"],

View File

@ -15,13 +15,13 @@ use phpseclib3\Tests\PhpseclibTestCase;
class RC2Test extends PhpseclibTestCase
{
public $engines = [
public static $engines = [
'PHP',
'Eval',
'OpenSSL',
];
public function engineVectors(): array
public static function engineVectors(): array
{
// tests from https://tools.ietf.org/html/rfc2268#page-8
$tests = [
@ -38,7 +38,7 @@ class RC2Test extends PhpseclibTestCase
$result = [];
foreach ($this->engines as $engine) {
foreach (self::$engines as $engine) {
foreach ($tests as $test) {
$result[] = [$engine, $test[0], $test[1], $test[2], $test[3]];
}

View File

@ -16,7 +16,7 @@ use phpseclib3\Tests\PhpseclibTestCase;
class RC4Test extends PhpseclibTestCase
{
public function engineVectors(): array
public static function engineVectors(): array
{
$engines = [
'PHP',

View File

@ -15,9 +15,9 @@ use phpseclib3\Tests\PhpseclibTestCase;
class RandomTest extends PhpseclibTestCase
{
public function stringLengthData(): array
public static function stringLengthData(): array
{
return array_map([$this, 'wrap'], [
return array_map(fn($x) => [$x], [
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 17, 19, 20, 23, 29, 31, 37,
41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 111, 128, 1000,
1024, 10000, 12345, 100000, 123456,
@ -52,10 +52,4 @@ class RandomTest extends PhpseclibTestCase
$values[$rand] = true;
}
}
protected function wrap($x): array
{
// array() is not a function, but $this->wrap() is.
return [$x];
}
}

View File

@ -15,7 +15,7 @@ use phpseclib3\Tests\PhpseclibTestCase;
class Salsa20Test extends PhpseclibTestCase
{
public function engineVectors(): array
public static function engineVectors(): array
{
$engines = [
'PHP',

View File

@ -15,13 +15,13 @@ use phpseclib3\Tests\PhpseclibTestCase;
class TripleDESTest extends PhpseclibTestCase
{
public $engines = [
public static $engines = [
'PHP',
'Eval',
'OpenSSL',
];
public function engineVectors(): array
public static function engineVectors(): array
{
// tests from http://csrc.nist.gov/publications/nistpubs/800-20/800-20.pdf#page=273
$tests = [
@ -95,7 +95,7 @@ class TripleDESTest extends PhpseclibTestCase
$result = [];
foreach ($this->engines as $engine) {
foreach (self::$engines as $engine) {
foreach ($tests as $test) {
$result[] = [$engine, $test[0], $test[1], $test[2]];
}
@ -122,7 +122,7 @@ class TripleDESTest extends PhpseclibTestCase
$this->assertEquals($result, $expected, "Failed asserting that $plaintext yielded expected output in $engine engine");
}
public function engineIVVectors(): array
public static function engineIVVectors(): array
{
$engines = [
'PHP',
@ -184,7 +184,7 @@ class TripleDESTest extends PhpseclibTestCase
$des->setKey('abcdefghijklmnopqrstuvwx');
$des->setIV(str_repeat("\0", $des->getBlockLength() >> 3));
foreach ($this->engines as $engine) {
foreach (self::$engines as $engine) {
$des->setPreferredEngine($engine);
if (!$des->isValidEngine($engine)) {
self::markTestSkipped("Unable to initialize $engine engine");
@ -209,7 +209,7 @@ class TripleDESTest extends PhpseclibTestCase
/**
* @return list<array{string, string}>
*/
public function provideForCorrectSelfUseInLambda(): array
public static function provideForCorrectSelfUseInLambda(): array
{
return [
['YWFhYWFhYWFhYWFhYWFhYWFhYWG9l9gm', 'fDSmC5bbLdx8NKYLltst3Hw0pguW2y3cfDSmC5bbLdxmhqEOIeS2ig=='],

View File

@ -16,7 +16,7 @@ use phpseclib3\Tests\PhpseclibTestCase;
class SSH2UnitTest extends PhpseclibTestCase
{
public function formatLogDataProvider(): array
public static function formatLogDataProvider(): array
{
return [
[