Merge branch '3.0'

This commit is contained in:
terrafrost 2022-02-19 18:08:40 -06:00
commit 004aec954f
208 changed files with 1301 additions and 1182 deletions

View File

@ -33,7 +33,7 @@ install:
- travis/setup-composer.sh
script:
- sh -c "if [ '$TRAVIS_PHP_VERSION' = '5.5' ]; then vendor/bin/phing -f build/build.xml sniff; fi"
- sh -c "if [ -d build/vendor ]; then build/vendor/bin/phpcs --standard=build/phpcs_ruleset.xml; fi"
- sh -c "if [ -d build/vendor ]; then build/vendor/bin/php-cs-fixer fix --config=build/php-cs-fixer.php --diff --dry-run; fi"
- sh -c "if [ -d build/vendor ]; then build/vendor/bin/psalm --config="build/psalm.xml" --no-cache --long-progress --report-show-info=false --output-format=text; fi"
- travis/run-phpunit.sh

View File

@ -82,6 +82,7 @@ Special Thanks to our $50+ sponsors!:
3. Install Development Dependencies
```sh
composer install
composer install --no-interaction --working-dir=build
```
4. Create a Feature Branch
@ -89,10 +90,9 @@ Special Thanks to our $50+ sponsors!:
5. Run continuous integration checks:
```sh
vendor/bin/phpunit
vendor/bin/phing -f build/build.xml sniff
# The following tools are from the build specific composer.json:
composer install --no-interaction --working-dir=build
# The following tools are from the build specific composer.json using the most recent PHP version:
build/vendor/bin/phpcs --standard=build/phpcs_ruleset.xml
build/vendor/bin/php-cs-fixer fix --config=build/php-cs-fixer.php --diff --dry-run
build/vendor/bin/psalm --config=build/psalm.xml --no-cache --long-progress --report-show-info=false --output-format=text
```

View File

@ -1,25 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project name="phpseclib"
description="PHP Secure Communications Library"
default="all"
>
<target name="all" depends="sniff" />
<!-- Code Sniffer -->
<target name="sniff" depends="sniff-php-code,sniff-php-tests" />
<target name="sniff-php-code">
<exec command="vendor/bin/phpcs -s
--extensions=php
--standard=build/code-sniffer-ruleset.xml
phpseclib/"
dir=".." checkreturn="true" passthru="true" />
</target>
<target name="sniff-php-tests">
<exec command="vendor/bin/phpcs -s
--extensions=php
--standard=build/code-sniffer-ruleset-tests.xml
tests/"
dir=".." checkreturn="true" passthru="true" />
</target>
</project>

View File

@ -1,17 +0,0 @@
<?xml version="1.0"?>
<ruleset name="phpseclib Test Standard">
<description>phpseclib coding standard for tests</description>
<!-- In general rules that apply to library code also apply to tests. -->
<rule ref="./code-sniffer-ruleset.xml">
<!-- Exceptions to the library coding standard follow. -->
<!-- Test classes do not have to be namespaced but may use pseudo-namespacing
using underscore. -->
<exclude name="PSR1.Classes.ClassDeclaration.MissingNamespace" />
<exclude name="Squiz.Classes.ValidClassName.NotCamelCaps" />
<exclude name="PSR1.Files.SideEffects.FoundWithSymbols" />
</rule>
</ruleset>

View File

@ -1,35 +0,0 @@
<?xml version="1.0"?>
<ruleset name="phpseclib Standard">
<description>phpseclib coding standard</description>
<!-- We are using the PSR2 standard as a base -->
<rule ref="PSR2">
<!-- Exceptions due to legacy code with PHP4 compatibility -->
<exclude name="PSR2.Classes.PropertyDeclaration.ScopeMissing" />
<exclude name="PSR2.Classes.PropertyDeclaration.VarUsed" />
<exclude name="Squiz.Scope.MethodScope.Missing" />
<!-- Exceptions for backward compatibility -->
<exclude name="PSR1.Methods.CamelCapsMethodName.NotCamelCaps" />
<exclude name="PSR2.Methods.MethodDeclaration.Underscore" />
<!-- Exceptions for whitespacing -->
<exclude name="Generic.Functions.FunctionCallArgumentSpacing.TooMuchSpaceAfterComma" />
<exclude name="PSR2.ControlStructures.SwitchDeclaration.SpaceBeforeColonCASE" />
<exclude name="PSR2.ControlStructures.SwitchDeclaration.SpaceBeforeColonDEFAULT" />
<!-- Other Exceptions -->
<exclude name="Generic.Files.LineLength.TooLong" />
<exclude name="PSR2.ControlStructures.SwitchDeclaration.TerminatingComment" />
</rule>
<!-- Useful additional rules follow -->
<!-- "for (; bar; )" should be "while (bar)" instead -->
<rule ref="Generic.CodeAnalysis.ForLoopShouldBeWhileLoop" />
<!-- A method MUST not only call its parent -->
<rule ref="Generic.CodeAnalysis.UselessOverridingMethod" />
</ruleset>

View File

@ -6,6 +6,7 @@
"require": {
"php": "^8.1.0",
"friendsofphp/php-cs-fixer": "^3.5",
"squizlabs/php_codesniffer": "^3.6",
"vimeo/psalm": "^4.19"
},
"config": {

22
build/phpcs_ruleset.xml Normal file
View File

@ -0,0 +1,22 @@
<?xml version="1.0"?>
<ruleset name="phpseclib">
<file>../build/php-cs-fixer.php</file>
<file>../phpseclib/</file>
<file>../tests/</file>
<arg name="extensions" value="php"/>
<arg name="basepath" value=".."/>
<arg name="report" value="emacs"/>
<arg value="s"/>
<arg value="n"/>
<arg value="p"/>
<rule ref="PSR12">
<exclude name="Squiz.Classes.ValidClassName.NotCamelCaps"/>
<exclude name="PSR1.Methods.CamelCapsMethodName.NotCamelCaps"/>
<exclude name="PSR2.Methods.MethodDeclaration.Underscore"/>
<exclude name="PSR2.ControlStructures.SwitchDeclaration.TerminatingComment"/>
<exclude name="PSR1.Classes.ClassDeclaration.MissingNamespace"/>
<exclude name="PSR1.Classes.ClassDeclaration.MultipleClasses"/>
</rule>
</ruleset>

View File

@ -56,9 +56,7 @@
"php": ">=5.6.1"
},
"require-dev": {
"phing/phing": "~2.7",
"phpunit/phpunit": "^5.7|^6.0|^9.4",
"squizlabs/php_codesniffer": "~2.0"
"phpunit/phpunit": "^5.7|^6.0|^9.4"
},
"suggest": {
"ext-libsodium": "SSH2/SFTP can make use of some algorithms provided by the libsodium-php extension.",

View File

@ -280,10 +280,15 @@ class ChaCha20 extends Salsa20
*/
protected static function quarterRound(&$a, &$b, &$c, &$d)
{
// in https://datatracker.ietf.org/doc/html/rfc7539#section-2.1 the addition,
// xor'ing and rotation are all on the same line so i'm keeping it on the same
// line here as well
// @codingStandardsIgnoreStart
$a+= $b; $d = self::leftRotate($d ^ $a, 16);
$c+= $d; $b = self::leftRotate($b ^ $c, 12);
$a+= $b; $d = self::leftRotate($d ^ $a, 8);
$c+= $d; $b = self::leftRotate($b ^ $c, 7);
// @codingStandardsIgnoreEnd
}
/**
@ -355,6 +360,7 @@ class ChaCha20 extends Salsa20
$z14 = $x14;
$z15 = $x15;
// @codingStandardsIgnoreStart
// columnRound
$x0+= $x4; $x12 = self::leftRotate($x12 ^ $x0, 16);
$x8+= $x12; $x4 = self::leftRotate($x4 ^ $x8, 12);
@ -774,6 +780,7 @@ class ChaCha20 extends Salsa20
$x9+= $x14; $x4 = self::leftRotate($x4 ^ $x9, 12);
$x3+= $x4; $x14 = self::leftRotate($x14 ^ $x3, 8);
$x9+= $x14; $x4 = self::leftRotate($x4 ^ $x9, 7);
// @codingStandardsIgnoreEnd
$x0 += $z0;
$x1 += $z1;

View File

@ -337,7 +337,7 @@ abstract class AsymmetricKey
* @param string $method optional
* @return mixed
*/
protected static function validatePlugin($format, $type, $method = NULL)
protected static function validatePlugin($format, $type, $method = null)
{
$type = strtolower($type);
if (!isset(self::$plugins[static::ALGORITHM][$format][$type])) {

View File

@ -275,8 +275,7 @@ abstract class PKCS8 extends PKCS
if (!static::$childOIDsLoaded) {
ASN1::loadOIDs(is_array(static::OID_NAME) ?
array_combine(static::OID_NAME, static::OID_VALUE) :
[static::OID_NAME => static::OID_VALUE]
);
[static::OID_NAME => static::OID_VALUE]);
static::$childOIDsLoaded = true;
}
if (!self::$oidsLoaded) {

View File

@ -1270,7 +1270,8 @@ abstract class SymmetricKey
}
if ($this->engine === self::ENGINE_MCRYPT) {
set_error_handler(function() {});
set_error_handler(function () {
});
if ($this->enchanged) {
mcrypt_generic_init($this->enmcrypt, $this->key, $this->getIV($this->encryptIV));
$this->enchanged = false;
@ -1660,7 +1661,8 @@ abstract class SymmetricKey
}
if ($this->engine === self::ENGINE_MCRYPT) {
set_error_handler(function() {});
set_error_handler(function () {
});
$block_size = $this->block_size;
if ($this->dechanged) {
mcrypt_generic_init($this->demcrypt, $this->key, $this->getIV($this->decryptIV));
@ -2270,7 +2272,8 @@ abstract class SymmetricKey
}
return false;
case self::ENGINE_MCRYPT:
set_error_handler(function() {});
set_error_handler(function () {
});
$result = $this->cipher_name_mcrypt &&
extension_loaded('mcrypt') &&
in_array($this->cipher_name_mcrypt, mcrypt_list_algorithms());
@ -2388,7 +2391,8 @@ abstract class SymmetricKey
}
if ($this->engine != self::ENGINE_MCRYPT && $this->enmcrypt) {
set_error_handler(function() {});
set_error_handler(function () {
});
// 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);
@ -2508,7 +2512,8 @@ abstract class SymmetricKey
case self::ENGINE_MCRYPT:
$this->enchanged = $this->dechanged = true;
set_error_handler(function() {});
set_error_handler(function () {
});
if (!isset($this->enmcrypt)) {
static $mcrypt_modes = [
@ -2531,7 +2536,6 @@ abstract class SymmetricKey
if ($this->mode == self::MODE_CFB) {
$this->ecb = mcrypt_module_open($this->cipher_name_mcrypt, '', MCRYPT_MODE_ECB, '');
}
} // else should mcrypt_generic_deinit be called?
if ($this->mode == self::MODE_CFB) {

View File

@ -82,7 +82,7 @@ abstract class DH extends AsymmetricKey
*/
public static function createParameters(...$args)
{
$params = new Parameters;
$params = new Parameters();
if (count($args) == 2 && $args[0] instanceof BigInteger && $args[1] instanceof BigInteger) {
//if (!$args[0]->isPrime()) {
// throw new \InvalidArgumentException('The first parameter should be a prime number');
@ -252,7 +252,7 @@ abstract class DH extends AsymmetricKey
$max = $params->prime->subtract($one);
}
$key = new PrivateKey;
$key = new PrivateKey();
$key->prime = $params->prime;
$key->base = $params->base;
$key->privateKey = BigInteger::randomRange($one, $max);
@ -324,7 +324,8 @@ abstract class DH extends AsymmetricKey
{
try {
return EC::load($key, $password);
} catch (NoKeyLoadedException $e) {}
} catch (NoKeyLoadedException $e) {
}
return parent::load($key, $password);
}
@ -339,11 +340,11 @@ abstract class DH extends AsymmetricKey
protected static function onLoad($components)
{
if (!isset($components['privateKey']) && !isset($components['publicKey'])) {
$new = new Parameters;
$new = new Parameters();
} else {
$new = isset($components['privateKey']) ?
new PrivateKey :
new PublicKey;
new PrivateKey() :
new PublicKey();
}
$new->prime = $components['prime'];

View File

@ -169,7 +169,7 @@ abstract class DSA extends AsymmetricKey
$h = $h->add(self::$one);
}
$dsa = new Parameters;
$dsa = new Parameters();
$dsa->p = $p;
$dsa->q = $q;
$dsa->g = $g;
@ -207,7 +207,7 @@ abstract class DSA extends AsymmetricKey
throw new InsufficientSetupException('Valid parameters are either two integers (L and N), a single DSA object or no parameters at all.');
}
$private = new PrivateKey;
$private = new PrivateKey();
$private->p = $params->p;
$private->q = $params->q;
$private->g = $params->g;
@ -237,12 +237,12 @@ abstract class DSA extends AsymmetricKey
}
if (!isset($components['x']) && !isset($components['y'])) {
$new = new Parameters;
$new = new Parameters();
} elseif (isset($components['x'])) {
$new = new PrivateKey;
$new = new PrivateKey();
$new->x = $components['x'];
} else {
$new = new PublicKey;
$new = new PublicKey();
}
$new->p = $components['p'];

View File

@ -70,7 +70,9 @@ abstract class SSH2
if ($r->getLength() > 160 || $s->getLength() > 160) {
return false;
}
return Strings::packSSH2('ss', 'ssh-dss',
return Strings::packSSH2(
'ss',
'ssh-dss',
str_pad($r->toBytes(), 20, "\0", STR_PAD_LEFT) .
str_pad($s->toBytes(), 20, "\0", STR_PAD_LEFT)
);

View File

@ -158,7 +158,7 @@ abstract class EC extends AsymmetricKey
return $privatekey;
}
$privatekey = new PrivateKey;
$privatekey = new PrivateKey();
$curveName = $curve;
if (preg_match('#(?:^curve|^ed)\d+$#', $curveName)) {
@ -217,14 +217,14 @@ abstract class EC extends AsymmetricKey
}
if (!isset($components['dA']) && !isset($components['QA'])) {
$new = new Parameters;
$new = new Parameters();
$new->curve = $components['curve'];
return $new;
}
$new = isset($components['dA']) ?
new PrivateKey :
new PublicKey;
new PrivateKey() :
new PublicKey();
$new->curve = $components['curve'];
$new->QA = $components['QA'];

View File

@ -202,7 +202,8 @@ class KoblitzPrime extends Prime
$f = $e->multiply($e);
$x3 = $f->subtract($this->two->multiply($d));
$y3 = $e->multiply($d->subtract($x3))->subtract(
$this->eight->multiply($c));
$this->eight->multiply($c)
);
$z3 = $this->two->multiply($y1)->multiply($z1);
return [$x3, $y3, $z3];
}

View File

@ -207,8 +207,10 @@ class Prime extends Base
$v = $u1->multiply($h2);
$x3 = $r->multiply($r)->subtract($h3)->subtract($v->multiply($this->two));
$y3 = $r->multiply(
$v->subtract($x3))->subtract(
$s1->multiply($h3));
$v->subtract($x3)
)->subtract(
$s1->multiply($h3)
);
return [$x3, $y3, $h];
}
@ -242,8 +244,10 @@ class Prime extends Base
$v = $u1->multiply($h2);
$x3 = $r->multiply($r)->subtract($h3)->subtract($v->multiply($this->two));
$y3 = $r->multiply(
$v->subtract($x3))->subtract(
$s1->multiply($h3));
$v->subtract($x3)
)->subtract(
$s1->multiply($h3)
);
$z3 = $h->multiply($z1);
return [$x3, $y3, $z3];
}
@ -279,8 +283,10 @@ class Prime extends Base
$v = $u1->multiply($h2);
$x3 = $r->multiply($r)->subtract($h3)->subtract($v->multiply($this->two));
$y3 = $r->multiply(
$v->subtract($x3))->subtract(
$s1->multiply($h3));
$v->subtract($x3)
)->subtract(
$s1->multiply($h3)
);
$z3 = $h->multiply($z1)->multiply($z2);
return [$x3, $y3, $z3];
}
@ -370,7 +376,8 @@ class Prime extends Base
$m = $m1->add($m2);
$x1 = $m->multiply($m)->subtract($this->two->multiply($s));
$y1 = $m->multiply($s->subtract($x1))->subtract(
$this->eight->multiply($y2->multiply($y2)));
$this->eight->multiply($y2->multiply($y2))
);
$z1 = $this->two->multiply($y)->multiply($z);
return [$x1, $y1, $z1];
}
@ -390,7 +397,8 @@ class Prime extends Base
$m = $m1->add($this->a);
$x1 = $m->multiply($m)->subtract($this->two->multiply($s));
$y1 = $m->multiply($s->subtract($x1))->subtract(
$this->eight->multiply($y2->multiply($y2)));
$this->eight->multiply($y2->multiply($y2))
);
$z1 = $this->two->multiply($y);
return [$x1, $y1, $z1];
}
@ -439,8 +447,12 @@ class Prime extends Base
$x = new BigInteger($m, 256);
$xp = $this->convertInteger($x);
switch ($y) {
case 2: $ypn = false; break;
case 3: $ypn = true; break;
case 2:
$ypn = false;
break;
case 3:
$ypn = true;
break;
default:
throw new \RuntimeException('Coordinate not in recognized format');
}

View File

@ -25,13 +25,17 @@ class Curve448 extends Montgomery
// 2^448 - 2^224 - 1
$this->setModulo(new BigInteger(
'FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFE' .
'FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF', 16));
'FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF',
16
));
$this->a24 = $this->factory->newInteger(new BigInteger('39081'));
$this->p = [$this->factory->newInteger(new BigInteger(5))];
// 2^446 - 0x8335dc163bb124b65129c96fde933d8d723a70aadc873d6d54a7bb0d
$this->setOrder(new BigInteger(
'3FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF' .
'7CCA23E9C44EDB49AED63690216CC2728DC58F552378C292AB5844F3', 16));
'7CCA23E9C44EDB49AED63690216CC2728DC58F552378C292AB5844F3',
16
));
/*
$this->setCoefficients(

View File

@ -29,7 +29,9 @@ class Ed448 extends TwistedEdwards
// 2^448 - 2^224 - 1
$this->setModulo(new BigInteger(
'FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFE' .
'FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF', 16));
'FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF',
16
));
$this->setCoefficients(
new BigInteger(1),
// -39081
@ -44,7 +46,9 @@ class Ed448 extends TwistedEdwards
);
$this->setOrder(new BigInteger(
'3FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF' .
'7CCA23E9C44EDB49AED63690216CC2728DC58F552378C292AB5844F3', 16));
'7CCA23E9C44EDB49AED63690216CC2728DC58F552378C292AB5844F3',
16
));
}
/**

View File

@ -24,25 +24,37 @@ class brainpoolP384r1 extends Prime
{
$this->setModulo(new BigInteger(
'8CB91E82A3386D280F5D6F7E50E641DF152F7109ED5456B412B1DA197FB71123ACD3A729901D1A7' .
'1874700133107EC53', 16));
'1874700133107EC53',
16
));
$this->setCoefficients(
new BigInteger(
'7BC382C63D8C150C3C72080ACE05AFA0C2BEA28E4FB22787139165EFBA91F90F8AA5814A503' .
'AD4EB04A8C7DD22CE2826', 16),
'AD4EB04A8C7DD22CE2826',
16
),
new BigInteger(
'4A8C7DD22CE28268B39B55416F0447C2FB77DE107DCD2A62E880EA53EEB62D57CB4390295DB' .
'C9943AB78696FA504C11', 16)
'C9943AB78696FA504C11',
16
)
);
$this->setBasePoint(
new BigInteger(
'1D1C64F068CF45FFA2A63A81B7C13F6B8847A3E77EF14FE3DB7FCAFE0CBD10E8E826E03436D' .
'646AAEF87B2E247D4AF1E', 16),
'646AAEF87B2E247D4AF1E',
16
),
new BigInteger(
'8ABE1D7520F9C2A45CB1EB8E95CFD55262B70B29FEEC5864E19C054FF99129280E464621779' .
'1811142820341263C5315', 16)
'1811142820341263C5315',
16
)
);
$this->setOrder(new BigInteger(
'8CB91E82A3386D280F5D6F7E50E641DF152F7109ED5456B31F166E6CAC0425A7CF3AB6AF6B7FC31' .
'03B883202E9046565', 16));
'03B883202E9046565',
16
));
}
}

View File

@ -24,25 +24,37 @@ class brainpoolP384t1 extends Prime
{
$this->setModulo(new BigInteger(
'8CB91E82A3386D280F5D6F7E50E641DF152F7109ED5456B412B1DA197FB71123ACD3A729901D1A7' .
'1874700133107EC53', 16));
'1874700133107EC53',
16
));
$this->setCoefficients(
new BigInteger(
'8CB91E82A3386D280F5D6F7E50E641DF152F7109ED5456B412B1DA197FB71123ACD3A729901' .
'D1A71874700133107EC50', 16), // eg. -3
'D1A71874700133107EC50',
16
), // eg. -3
new BigInteger(
'7F519EADA7BDA81BD826DBA647910F8C4B9346ED8CCDC64E4B1ABD11756DCE1D2074AA263B8' .
'8805CED70355A33B471EE', 16)
'8805CED70355A33B471EE',
16
)
);
$this->setBasePoint(
new BigInteger(
'18DE98B02DB9A306F2AFCD7235F72A819B80AB12EBD653172476FECD462AABFFC4FF191B946' .
'A5F54D8D0AA2F418808CC', 16),
'A5F54D8D0AA2F418808CC',
16
),
new BigInteger(
'25AB056962D30651A114AFD2755AD336747F93475B7A1FCA3B88F2B6A208CCFE469408584DC' .
'2B2912675BF5B9E582928', 16)
'2B2912675BF5B9E582928',
16
)
);
$this->setOrder(new BigInteger(
'8CB91E82A3386D280F5D6F7E50E641DF152F7109ED5456B31F166E6CAC0425A7CF3AB6AF6B7FC31' .
'03B883202E9046565', 16));
'03B883202E9046565',
16
));
}
}

View File

@ -24,25 +24,37 @@ class brainpoolP512r1 extends Prime
{
$this->setModulo(new BigInteger(
'AADD9DB8DBE9C48B3FD4E6AE33C9FC07CB308DB3B3C9D20ED6639CCA703308717D4D9B009BC' .
'66842AECDA12AE6A380E62881FF2F2D82C68528AA6056583A48F3', 16));
'66842AECDA12AE6A380E62881FF2F2D82C68528AA6056583A48F3',
16
));
$this->setCoefficients(
new BigInteger(
'7830A3318B603B89E2327145AC234CC594CBDD8D3DF91610A83441CAEA9863BC2DED5D5AA82' .
'53AA10A2EF1C98B9AC8B57F1117A72BF2C7B9E7C1AC4D77FC94CA', 16),
'53AA10A2EF1C98B9AC8B57F1117A72BF2C7B9E7C1AC4D77FC94CA',
16
),
new BigInteger(
'3DF91610A83441CAEA9863BC2DED5D5AA8253AA10A2EF1C98B9AC8B57F1117A72BF2C7B9E7C' .
'1AC4D77FC94CADC083E67984050B75EBAE5DD2809BD638016F723', 16)
'1AC4D77FC94CADC083E67984050B75EBAE5DD2809BD638016F723',
16
)
);
$this->setBasePoint(
new BigInteger(
'81AEE4BDD82ED9645A21322E9C4C6A9385ED9F70B5D916C1B43B62EEF4D0098EFF3B1F78E2D' .
'0D48D50D1687B93B97D5F7C6D5047406A5E688B352209BCB9F822', 16),
'0D48D50D1687B93B97D5F7C6D5047406A5E688B352209BCB9F822',
16
),
new BigInteger(
'7DDE385D566332ECC0EABFA9CF7822FDF209F70024A57B1AA000C55B881F8111B2DCDE494A5' .
'F485E5BCA4BD88A2763AED1CA2B2FA8F0540678CD1E0F3AD80892', 16)
'F485E5BCA4BD88A2763AED1CA2B2FA8F0540678CD1E0F3AD80892',
16
)
);
$this->setOrder(new BigInteger(
'AADD9DB8DBE9C48B3FD4E6AE33C9FC07CB308DB3B3C9D20ED6639CCA70330870553E5C414CA' .
'92619418661197FAC10471DB1D381085DDADDB58796829CA90069', 16));
'92619418661197FAC10471DB1D381085DDADDB58796829CA90069',
16
));
}
}

View File

@ -24,25 +24,37 @@ class brainpoolP512t1 extends Prime
{
$this->setModulo(new BigInteger(
'AADD9DB8DBE9C48B3FD4E6AE33C9FC07CB308DB3B3C9D20ED6639CCA703308717D4D9B009BC' .
'66842AECDA12AE6A380E62881FF2F2D82C68528AA6056583A48F3', 16));
'66842AECDA12AE6A380E62881FF2F2D82C68528AA6056583A48F3',
16
));
$this->setCoefficients(
new BigInteger(
'AADD9DB8DBE9C48B3FD4E6AE33C9FC07CB308DB3B3C9D20ED6639CCA703308717D4D9B009BC' .
'66842AECDA12AE6A380E62881FF2F2D82C68528AA6056583A48F0', 16), // eg. -3
'66842AECDA12AE6A380E62881FF2F2D82C68528AA6056583A48F0',
16
), // eg. -3
new BigInteger(
'7CBBBCF9441CFAB76E1890E46884EAE321F70C0BCB4981527897504BEC3E36A62BCDFA23049' .
'76540F6450085F2DAE145C22553B465763689180EA2571867423E', 16)
'76540F6450085F2DAE145C22553B465763689180EA2571867423E',
16
)
);
$this->setBasePoint(
new BigInteger(
'640ECE5C12788717B9C1BA06CBC2A6FEBA85842458C56DDE9DB1758D39C0313D82BA51735CD' .
'B3EA499AA77A7D6943A64F7A3F25FE26F06B51BAA2696FA9035DA', 16),
'B3EA499AA77A7D6943A64F7A3F25FE26F06B51BAA2696FA9035DA',
16
),
new BigInteger(
'5B534BD595F5AF0FA2C892376C84ACE1BB4E3019B71634C01131159CAE03CEE9D9932184BEE' .
'F216BD71DF2DADF86A627306ECFF96DBB8BACE198B61E00F8B332', 16)
'F216BD71DF2DADF86A627306ECFF96DBB8BACE198B61E00F8B332',
16
)
);
$this->setOrder(new BigInteger(
'AADD9DB8DBE9C48B3FD4E6AE33C9FC07CB308DB3B3C9D20ED6639CCA70330870553E5C414CA' .
'92619418661197FAC10471DB1D381085DDADDB58796829CA90069', 16));
'92619418661197FAC10471DB1D381085DDADDB58796829CA90069',
16
));
}
}

View File

@ -33,7 +33,8 @@ class sect409k1 extends Binary
);
$this->setOrder(new BigInteger(
'7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFE5F' .
'83B2D4EA20400EC4557D5ED3E3E7CA5B4B5C83B8E01E5FCF', 16
'83B2D4EA20400EC4557D5ED3E3E7CA5B4B5C83B8E01E5FCF',
16
));
}
}

View File

@ -33,7 +33,8 @@ class sect409r1 extends Binary
);
$this->setOrder(new BigInteger(
'010000000000000000000000000000000000000000000000000001E2' .
'AAD6A612F33307BE5FA47C3C9E052F838164CD37D9A21173', 16
'AAD6A612F33307BE5FA47C3C9E052F838164CD37D9A21173',
16
));
}
}

View File

@ -37,7 +37,8 @@ class sect571k1 extends Binary
);
$this->setOrder(new BigInteger(
'020000000000000000000000000000000000000000000000000000000000000000000000' .
'131850E1F19A63E4B391A8DB917F4138B630D84BE5D639381E91DEB45CFE778F637C1001', 16
'131850E1F19A63E4B391A8DB917F4138B630D84BE5D639381E91DEB45CFE778F637C1001',
16
));
}
}

View File

@ -37,7 +37,8 @@ class sect571r1 extends Binary
);
$this->setOrder(new BigInteger(
'03FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF' .
'E661CE18FF55987308059B186823851EC7DD9CA1161DE93D5174D66E8382E9BB2FE84E47', 16
'E661CE18FF55987308059B186823851EC7DD9CA1161DE93D5174D66E8382E9BB2FE84E47',
16
));
}
}

View File

@ -56,10 +56,10 @@ abstract class MontgomeryPrivate
{
switch (strlen($key)) {
case 32:
$curve = new Curve25519;
$curve = new Curve25519();
break;
case 56:
$curve = new Curve448;
$curve = new Curve448();
break;
default:
throw new \LengthException('The only supported lengths are 32 and 56');

View File

@ -48,10 +48,10 @@ abstract class MontgomeryPublic
{
switch (strlen($key)) {
case 32:
$curve = new Curve25519;
$curve = new Curve25519();
break;
case 56:
$curve = new Curve448;
$curve = new Curve448();
break;
default:
throw new \LengthException('The only supported lengths are 32 and 56');

View File

@ -635,7 +635,7 @@ class Hash
// Perform NH hash on the chunks, pairing words for multiplication
// which are 4 apart to accommodate vector-parallelism.
//
$y = new BigInteger;
$y = new BigInteger();
$y->setPrecision(64);
$i = 0;
while ($i < $t) {

View File

@ -42,15 +42,18 @@ abstract class PublicKeyLoader
{
try {
return EC::load($key, $password);
} catch (NoKeyLoadedException $e) {}
} catch (NoKeyLoadedException $e) {
}
try {
return RSA::load($key, $password);
} catch (NoKeyLoadedException $e) {}
} catch (NoKeyLoadedException $e) {
}
try {
return DSA::load($key, $password);
} catch (NoKeyLoadedException $e) {}
} catch (NoKeyLoadedException $e) {
}
try {
$x509 = new X509();
@ -59,7 +62,8 @@ abstract class PublicKeyLoader
if ($key) {
return $key;
}
} catch (\Exception $e) {}
} catch (\Exception $e) {
}
throw new NoKeyLoadedException('Unable to read key');
}

View File

@ -425,7 +425,7 @@ abstract class RSA extends AsymmetricKey
// coefficient INTEGER, -- (inverse of q) mod p
// otherPrimeInfos OtherPrimeInfos OPTIONAL
// }
$privatekey = new PrivateKey;
$privatekey = new PrivateKey();
$privatekey->modulus = $n;
$privatekey->k = $bits >> 3;
$privatekey->publicExponent = $e;
@ -456,8 +456,8 @@ abstract class RSA extends AsymmetricKey
protected static function onLoad($components)
{
$key = $components['isPublicKey'] ?
new PublicKey :
new PrivateKey;
new PublicKey() :
new PrivateKey();
$key->modulus = $components['modulus'];
$key->publicExponent = $components['publicExponent'];

View File

@ -164,9 +164,15 @@ abstract class Raw
'e' => clone $e,
'n' => clone $n,
'd' => clone $d,
'primes' => array_map(function($var) { return clone $var; }, $primes),
'exponents' => array_map(function($var) { return clone $var; }, $exponents),
'coefficients' => array_map(function($var) { return clone $var; }, $coefficients)
'primes' => array_map(function ($var) {
return clone $var;
}, $primes),
'exponents' => array_map(function ($var) {
return clone $var;
}, $exponents),
'coefficients' => array_map(function ($var) {
return clone $var;
}, $coefficients)
];
}

View File

@ -512,7 +512,7 @@ class PublicKey extends RSA implements Common\PublicKey
*/
public function asPrivateKey()
{
$new = new PrivateKey;
$new = new PrivateKey();
$new->exponent = $this->exponent;
$new->modulus = $this->modulus;
$new->k = $this->k;

View File

@ -55,7 +55,6 @@
namespace phpseclib3\Crypt;
use phpseclib3\Common\Functions\Strings;
use phpseclib3\Crypt\Common\BlockCipher;
use phpseclib3\Exception\BadDecryptionException;
use phpseclib3\Exception\BadModeException;

View File

@ -1966,7 +1966,9 @@ class X509
$value = array_pop($value); // Always strip data type.
}
} elseif (is_object($value) && $value instanceof Element) {
$callback = function($x) { return '\x' . bin2hex($x[0]); };
$callback = function ($x) {
return '\x' . bin2hex($x[0]);
};
$value = strtoupper(preg_replace_callback('#[^\x20-\x7E]#', $callback, $value->element));
}
$output .= $desc . '=' . $value;

View File

@ -248,7 +248,7 @@ class BigInteger
* @param bool $twos_compliment
* @return string
*/
function toBits($twos_compliment = false)
public function toBits($twos_compliment = false)
{
return $this->value->toBits($twos_compliment);
}
@ -270,7 +270,7 @@ class BigInteger
* @param BigInteger $y
* @return BigInteger
*/
function subtract(BigInteger $y)
public function subtract(BigInteger $y)
{
return new static($this->value->subtract($y->value));
}
@ -324,8 +324,9 @@ class BigInteger
* Calculates modular inverses.
*
* Say you have (30 mod 17 * x mod 17) mod 17 == 1. x can be found using modular inverses.
* @return BigInteger
*
* @param BigInteger $n
* @return BigInteger
*/
public function modInverse(BigInteger $n)
{
@ -336,8 +337,9 @@ class BigInteger
* Calculates modular inverses.
*
* Say you have (30 mod 17 * x mod 17) mod 17 == 1. x can be found using modular inverses.
* @return BigInteger[]
*
* @param BigInteger $n
* @return BigInteger[]
*/
public function extendedGCD(BigInteger $n)
{
@ -470,8 +472,8 @@ class BigInteger
/**
* Compares two numbers.
*
* Although one might think !$x->compare($y) means $x != $y, it, in fact, means the opposite. The reason for this is
* demonstrated thusly:
* Although one might think !$x->compare($y) means $x != $y, it, in fact, means the opposite. The reason for this
* is demonstrated thusly:
*
* $x > $y: $x->compare($y) > 0
* $x < $y: $x->compare($y) < 0
@ -754,7 +756,9 @@ class BigInteger
public static function min(BigInteger ...$nums)
{
$class = self::$mainEngine;
$nums = array_map(function($num) { return $num->value; }, $nums);
$nums = array_map(function ($num) {
return $num->value;
}, $nums);
return new static($class::min(...$nums));
}
@ -767,7 +771,9 @@ class BigInteger
public static function max(BigInteger ...$nums)
{
$class = self::$mainEngine;
$nums = array_map(function($num) { return $num->value; }, $nums);
$nums = array_map(function ($num) {
return $num->value;
}, $nums);
return new static($class::max(...$nums));
}

View File

@ -89,8 +89,8 @@ class BCMath extends Engine
/**
* Test for engine validity
*
* @see parent::__construct()
* @return bool
* @see parent::__construct()
*/
public static function isValidEngine()
{
@ -102,8 +102,8 @@ class BCMath extends Engine
*
* @param mixed $x integer Base-10 number or base-$base number if $base set.
* @param int $base
* @see parent::__construct()
* @return \phpseclib3\Math\BigInteger\Engines\BCMath
* @see parent::__construct()
*/
public function __construct($x = 0, $base = 10)
{
@ -137,7 +137,13 @@ class BCMath extends Engine
$this->value = '0';
for ($i = 0; $i < $len; $i += 4) {
$this->value = bcmul($this->value, '4294967296', 0); // 4294967296 == 2**32
$this->value = bcadd($this->value, 0x1000000 * ord($x[$i]) + ((ord($x[$i + 1]) << 16) | (ord($x[$i + 2]) << 8) | ord($x[$i + 3])), 0);
$this->value = bcadd(
$this->value,
0x1000000 * ord($x[$i]) + ((ord($x[$i + 1]) << 16) | (ord(
$x[$i + 2]
) << 8) | ord($x[$i + 3])),
0
);
}
if ($this->is_negative) {
@ -177,7 +183,7 @@ class BCMath extends Engine
* @param bool $twos_compliment
* @return string
*/
function toBytes($twos_compliment = false)
public function toBytes($twos_compliment = false)
{
if ($twos_compliment) {
return $this->toBytesHelper();
@ -274,8 +280,8 @@ class BCMath extends Engine
*
* Say you have (30 mod 17 * x mod 17) mod 17 == 1. x can be found using modular inverses.
*
* @return false|BCMath
* @param \phpseclib3\Math\BigInteger\Engines\BCMath $n
* @return false|BCMath
*/
public function modInverse(BCMath $n)
{
@ -428,8 +434,8 @@ class BCMath extends Engine
/**
* Compares two numbers.
*
* Although one might think !$x->compare($y) means $x != $y, it, in fact, means the opposite. The reason for this is
* demonstrated thusly:
* Although one might think !$x->compare($y) means $x != $y, it, in fact, means the opposite. The reason for this
* is demonstrated thusly:
*
* $x > $y: $x->compare($y) > 0
* $x < $y: $x->compare($y) < 0
@ -604,9 +610,9 @@ class BCMath extends Engine
*
* ie. $s = gmp_scan1($n, 0) and $r = gmp_div_q($n, gmp_pow(gmp_init('2'), $s));
*
* @see self::isPrime()
* @param BCMath $r
* @return int
* @see self::isPrime()
*/
public static function scan1divide(BCMath $r)
{
@ -672,8 +678,8 @@ class BCMath extends Engine
/**
* Set Bitmask
*
* @return Engine
* @param int $bits
* @return Engine
* @see self::setPrecision()
*/
protected static function setBitmask($bits)

View File

@ -90,8 +90,8 @@ class GMP extends Engine
/**
* Test for engine validity
*
* @see parent::__construct()
* @return bool
* @see parent::__construct()
*/
public static function isValidEngine()
{
@ -103,8 +103,8 @@ class GMP extends Engine
*
* @param mixed $x integer Base-10 number or base-$base number if $base set.
* @param int $base
* @see parent::__construct()
* @return \phpseclib3\Math\BigInteger\Engines\GMP
* @see parent::__construct()
*/
public function __construct($x = 0, $base = 10)
{
@ -191,7 +191,7 @@ class GMP extends Engine
* @param bool $twos_compliment
* @return string
*/
function toBytes($twos_compliment = false)
public function toBytes($twos_compliment = false)
{
if ($twos_compliment) {
return $this->toBytesHelper();
@ -278,8 +278,8 @@ class GMP extends Engine
/**
* Compares two numbers.
*
* Although one might think !$x->compare($y) means $x != $y, it, in fact, means the opposite. The reason for this is
* demonstrated thusly:
* Although one might think !$x->compare($y) means $x != $y, it, in fact, means the opposite. The reason for this
* is demonstrated thusly:
*
* $x > $y: $x->compare($y) > 0
* $x < $y: $x->compare($y) < 0

View File

@ -76,8 +76,8 @@ abstract class PHP extends Engine
*
* @param mixed $x integer Base-10 number or base-$base number if $base set.
* @param int $base
* @see parent::__construct()
* @return \phpseclib3\Math\BigInteger\Engines\PHP
* @see parent::__construct()
*/
public function __construct($x = 0, $base = 10)
{
@ -119,7 +119,12 @@ abstract class PHP extends Engine
$x = substr($x, 1);
}
$x = str_pad($x, strlen($x) + ((static::MAX10LEN - 1) * strlen($x)) % static::MAX10LEN, 0, STR_PAD_LEFT);
$x = str_pad(
$x,
strlen($x) + ((static::MAX10LEN - 1) * strlen($x)) % static::MAX10LEN,
0,
STR_PAD_LEFT
);
while (strlen($x)) {
$temp = $temp->multiply($multiplier);
$temp = $temp->add(new static($this->int2bytes(substr($x, 0, static::MAX10LEN)), 256));
@ -165,7 +170,12 @@ abstract class PHP extends Engine
$result = '';
while (count($temp->value)) {
list($temp, $mod) = $temp->divide($divisor);
$result = str_pad(isset($mod->value[0]) ? $mod->value[0] : '', static::MAX10LEN, '0', STR_PAD_LEFT) . $result;
$result = str_pad(
isset($mod->value[0]) ? $mod->value[0] : '',
static::MAX10LEN,
'0',
STR_PAD_LEFT
) . $result;
}
$result = ltrim($result, '0');
if (empty($result)) {
@ -199,7 +209,12 @@ abstract class PHP extends Engine
$result = implode('', array_map('chr', $result));
return $this->precision > 0 ?
str_pad(substr($result, -(($this->precision + 7) >> 3)), ($this->precision + 7) >> 3, chr(0), STR_PAD_LEFT) :
str_pad(
substr($result, -(($this->precision + 7) >> 3)),
($this->precision + 7) >> 3,
chr(0),
STR_PAD_LEFT
) :
$result;
}
@ -297,7 +312,7 @@ abstract class PHP extends Engine
* @param bool $y_negative
* @return array
*/
static function subtractHelper(array $x_value, $x_negative, array $y_value, $y_negative)
public static function subtractHelper(array $x_value, $x_negative, array $y_value, $y_negative)
{
$x_size = count($x_value);
$y_size = count($y_value);
@ -517,7 +532,8 @@ abstract class PHP extends Engine
*
* @param \phpseclib3\Math\BigInteger\engines\PHP $y
* @return array
* @internal This function is based off of {@link http://www.cacr.math.uwaterloo.ca/hac/about/chap14.pdf#page=9 HAC 14.20}.
* @internal This function is based off of
* {@link http://www.cacr.math.uwaterloo.ca/hac/about/chap14.pdf#page=9 HAC 14.20}.
*/
protected function divideHelper(PHP $y)
{
@ -1108,9 +1124,9 @@ abstract class PHP extends Engine
*
* ie. $s = gmp_scan1($n, 0) and $r = gmp_div_q($n, gmp_pow(gmp_init('2'), $s));
*
* @see self::isPrime()
* @param PHP $r
* @return int
* @see self::isPrime()
*/
public static function scan1divide(PHP $r)
{

View File

@ -94,7 +94,7 @@ abstract class Base extends PHP
}
if ($e->value == [2]) {
$temp = new $class;
$temp = new $class();
$temp->value = $class::square($x->value);
list(, $temp) = $temp->divide($n);
return $x->normalize($temp);

View File

@ -15,7 +15,6 @@
namespace phpseclib3\Math\BigInteger\Engines\PHP\Reductions;
/**
* PHP Montgomery Modular Exponentiation Engine with interleaved multiplication
*

View File

@ -15,7 +15,6 @@
namespace phpseclib3\Math\BigInteger\Engines;
/**
* Pure-PHP 32-bit Engine.
*

View File

@ -15,7 +15,6 @@
namespace phpseclib3\Math\BigInteger\Engines;
/**
* Pure-PHP 64-bit Engine.
*

View File

@ -38,7 +38,7 @@ class Stream
*
* @var array
*/
static $instances;
public static $instances;
/**
* SFTP instance

View File

@ -1746,7 +1746,8 @@ class SSH2
$keyBytes = "\0$keyBytes";
}
$this->exchange_hash = Strings::packSSH2('s5',
$this->exchange_hash = Strings::packSSH2(
's5',
$this->identifier,
$this->server_identifier,
$kexinit_payload_client,
@ -1754,7 +1755,8 @@ class SSH2
$this->server_public_host_key
);
$this->exchange_hash .= $exchange_hash_rfc4419;
$this->exchange_hash.= Strings::packSSH2('s3',
$this->exchange_hash .= Strings::packSSH2(
's3',
$ourPublicBytes,
$theirPublicBytes,
$keyBytes
@ -1909,7 +1911,7 @@ class SSH2
if (!$this->encrypt->usesNonce()) {
list($this->hmac_create, $createKeyLength) = self::mac_algorithm_to_hash_instance($mac_algorithm_out);
} else {
$this->hmac_create = new \stdClass;
$this->hmac_create = new \stdClass();
$this->hmac_create_name = $mac_algorithm_out;
//$mac_algorithm_out = 'none';
$createKeyLength = 0;
@ -1929,7 +1931,7 @@ class SSH2
list($this->hmac_check, $checkKeyLength) = self::mac_algorithm_to_hash_instance($mac_algorithm_in);
$this->hmac_size = $this->hmac_check->getLengthInBytes();
} else {
$this->hmac_check = new \stdClass;
$this->hmac_check = new \stdClass();
$this->hmac_check_name = $mac_algorithm_in;
//$mac_algorithm_in = 'none';
$checkKeyLength = 0;
@ -2673,7 +2675,7 @@ class SSH2
* @param int $interval
* @access public
*/
function setKeepAlive($interval)
public function setKeepAlive($interval)
{
$this->keepAlive = $interval;
}

View File

@ -9,6 +9,7 @@
*
* @license http://www.opensource.org/licenses/mit-license.html MIT License
*/
if (extension_loaded('mbstring')) {
// 2 - MB_OVERLOAD_STRING
// mbstring.func_overload is deprecated in php 7.2 and removed in php 8.0.

View File

@ -11,10 +11,10 @@ use phpseclib3\Net\SFTP\FileType;
class Functional_Net_SFTPUserStoryTest extends PhpseclibFunctionalTestCase
{
static protected $scratchDir;
static protected $exampleData;
static protected $exampleDataLength;
static protected $buffer;
protected static $scratchDir;
protected static $exampleData;
protected static $exampleDataLength;
protected static $buffer;
public static function setUpBeforeClass()
{
@ -136,7 +136,7 @@ class Functional_Net_SFTPUserStoryTest extends PhpseclibFunctionalTestCase
return $sftp;
}
static function demoCallback($length)
public static function demoCallback($length)
{
$r = substr(self::$buffer, 0, $length);
self::$buffer = substr(self::$buffer, $length);
@ -487,6 +487,7 @@ class Functional_Net_SFTPUserStoryTest extends PhpseclibFunctionalTestCase
/**
* on older versions this would result in a fatal error
*
* @depends testStatOnCWD
* @group github402
*/
@ -765,7 +766,14 @@ class Functional_Net_SFTPUserStoryTest extends PhpseclibFunctionalTestCase
$list_cache_disabled = $sftp->rawlist('.', true);
$this->assertEquals($list_cache_enabled, $list_cache_disabled, 'The files should be the same regardless of stat cache', 0.0, 10, true);
$this->assertEquals(
$list_cache_enabled,
$list_cache_disabled,
'The files should be the same regardless of stat cache',
0.0,
10,
true
);
return $sftp;
}

View File

@ -24,7 +24,7 @@ class Functional_Net_SSH2AgentTest extends PhpseclibFunctionalTestCase
public function testAgentLogin()
{
$ssh = new SSH2($this->getEnv('SSH_HOSTNAME'));
$agent = new Agent;
$agent = new Agent();
$this->assertTrue(
$ssh->login($this->getEnv('SSH_USERNAME'), $agent),

View File

@ -1,4 +1,5 @@
<?php
/**
* @author Andreas Fischer <bantu@phpbb.com>
* @copyright 2014 Andreas Fischer

View File

@ -1,4 +1,5 @@
<?php
/**
* @author Andreas Fischer <bantu@phpbb.com>
* @copyright 2013 Andreas Fischer

View File

@ -1,4 +1,5 @@
<?php
/**
* @author Andreas Fischer <bantu@phpbb.com>
* @copyright 2013 Andreas Fischer

View File

@ -1,4 +1,5 @@
<?php
/**
* @author Andreas Fischer <bantu@phpbb.com>
* @copyright 2013 Andreas Fischer

View File

@ -1,4 +1,5 @@
<?php
/**
* @author Andreas Fischer <bantu@phpbb.com>
* @copyright 2013 Andreas Fischer

View File

@ -1,4 +1,5 @@
<?php
/**
* @author Andreas Fischer <bantu@phpbb.com>
* @copyright 2013 Andreas Fischer

View File

@ -1,4 +1,5 @@
<?php
/**
* @author Andreas Fischer <bantu@phpbb.com>
* @copyright 2013 Andreas Fischer

View File

@ -1,4 +1,5 @@
<?php
/**
* @author Andreas Fischer <bantu@phpbb.com>
* @copyright MMXIII Andreas Fischer

View File

@ -1,4 +1,5 @@
<?php
/**
* @author Jim Wigginton <terrafrost@php.net>
* @copyright 2014 Jim Wigginton
@ -92,7 +93,7 @@ class Unit_Crypt_ChaCha20Test extends PhpseclibTestCase
$expected = str_replace(':', '', $expected);
$expected = pack('H*', $expected);
$c = new ChaCha20;
$c = new ChaCha20();
$c->setPoly1305Key($key);
$r = new \ReflectionClass(get_class($c));
// this unit test is testing Poly1305 independent of ChaCha20, which phpseclib doesn't

View File

@ -1,4 +1,5 @@
<?php
/**
* @author Andreas Fischer <bantu@phpbb.com>
* @copyright 2013 Andreas Fischer
@ -231,11 +232,13 @@ Q3ADAIcv9LEmTBnSAOsCs1K9ExAmSv/T2/4+9dW28UYb+p/uV477d1wf+nCWS6VU
{
// utilizing test vector from https://tools.ietf.org/html/rfc7748#section-6.2
$alicePrivate = EC::loadFormat('MontgomeryPrivate', pack('H*',
$alicePrivate = EC::loadFormat('MontgomeryPrivate', pack(
'H*',
'9a8f4925d1519f5775cf46b04b5800d4ee9ee8bae8bc5565d498c28d' .
'd9c9baf574a9419744897391006382a6f127ab1d9ac2d8c0a598726b'
));
$bobPrivate = EC::loadFormat('MontgomeryPrivate', pack('H*',
$bobPrivate = EC::loadFormat('MontgomeryPrivate', pack(
'H*',
'1c306a7ac2a0e2e0990b294470cba339e6453772b075811d8fad0d1d' .
'6927c120bb5ee8972b0d3e21374c9c921b09d1b0366f10b65173992d'
));
@ -255,7 +258,8 @@ Q3ADAIcv9LEmTBnSAOsCs1K9ExAmSv/T2/4+9dW28UYb+p/uV477d1wf+nCWS6VU
bin2hex($bobPublic->toString('MontgomeryPublic'))
);
$expected = pack('H*',
$expected = pack(
'H*',
'07fff4181ac6cc95ec1c16a94a0f74d12da232ce40a77552281d282b' .
'b60c0b56fd2464c335543936521c24403085d59a449a5037514a879d'
);

View File

@ -1,4 +1,5 @@
<?php
/**
* @author Jim Wigginton <terrafrost@php.net>
* @copyright 2013 Jim Wigginton

View File

@ -114,7 +114,7 @@ class Unit_Crypt_EC_CurveTest extends PhpseclibTestCase
public function testBasePoint($name)
{
$class = 'phpseclib3\Crypt\EC\Curves\\' . $name;
$curve = new $class;
$curve = new $class();
$this->assertTrue($curve->verifyPoint($curve->getBasePoint()), "Failed to verify basepoint of curve $name");
}
@ -127,7 +127,7 @@ class Unit_Crypt_EC_CurveTest extends PhpseclibTestCase
public function testKeyGeneration($name)
{
$class = 'phpseclib3\Crypt\EC\Curves\\' . $name;
$curve = new $class;
$curve = new $class();
$dA = $curve->createRandomMultiplier();
$QA = $curve->multiplyPoint($curve->getBasePoint(), $dA);
$this->assertTrue($curve->verifyPoint($QA), "Failed to verify point multiplication on curve $name with $dA");

View File

@ -1,4 +1,5 @@
<?php
/**
* @author Jim Wigginton <terrafrost@php.net>
* @copyright 2013 Jim Wigginton
@ -348,7 +349,6 @@ Private-MAC: 97a990a3d5f6b8f268d4be9c4ab9ebfd8fa79849
OpenSSH::setComment('ecdsa-key-20181105');
$this->assertSameNL($expected, $key->toString('OpenSSH'));
}
public function testPuTTYnistp521()

View File

@ -1,4 +1,5 @@
<?php
/**
* @author Andreas Fischer <bantu@phpbb.com>
* @copyright 2013 Andreas Fischer

View File

@ -1,4 +1,5 @@
<?php
/**
* @author Andreas Fischer <bantu@phpbb.com>
* @copyright 2012 Andreas Fischer

View File

@ -1,4 +1,5 @@
<?php
/**
* @author Andreas Fischer <bantu@phpbb.com>
* @copyright MMXIII Andreas Fischer
@ -9,7 +10,7 @@ use phpseclib3\Crypt\RC2;
class Unit_Crypt_RC2Test extends PhpseclibTestCase
{
var $engines = [
public $engines = [
'PHP',
'Eval',
'mcrypt',

View File

@ -1,4 +1,5 @@
<?php
/**
* @author Jim Wigginton <terrafrost@php.net>
* @copyright 2014 Jim Wigginton

View File

@ -1,4 +1,5 @@
<?php
/**
* @author Jim Wigginton <terrafrost@php.net>
* @copyright 2013 Jim Wigginton

View File

@ -1,4 +1,5 @@
<?php
/**
* @author Jim Wigginton <terrafrost@php.net>
* @copyright 2013 Jim Wigginton

View File

@ -1,4 +1,5 @@
<?php
/**
* @author Andreas Fischer <bantu@phpbb.com>
* @copyright 2014 Andreas Fischer

View File

@ -1,4 +1,5 @@
<?php
/**
* @author Jim Wigginton <terrafrost@php.net>
* @copyright 2014 Jim Wigginton

View File

@ -1,4 +1,5 @@
<?php
/**
* @author Jim Wigginton <terrafrost@php.net>
* @copyright 2014 Jim Wigginton
@ -9,7 +10,7 @@ use phpseclib3\Crypt\TripleDES;
class Unit_Crypt_TripleDESTest extends PhpseclibTestCase
{
var $engines = [
public $engines = [
'PHP',
'Eval',
'mcrypt',

View File

@ -1,4 +1,5 @@
<?php
/**
* @author Andreas Fischer <bantu@phpbb.com>
* @copyright MMXIII Andreas Fischer

View File

@ -1,4 +1,5 @@
<?php
/**
* @author Jim Wigginton <terrafrost@php.net>
* @copyright 2014 Jim Wigginton

View File

@ -1,4 +1,5 @@
<?php
/**
* @author Jim Wigginton <terrafrost@php.net>
* @copyright 2014 Jim Wigginton

View File

@ -1,4 +1,5 @@
<?php
/**
* @author Jim Wigginton <terrafrost@php.net>
* @copyright 2017 Jim Wigginton

View File

@ -1,4 +1,5 @@
<?php
/**
* @author Jim Wigginton <terrafrost@php.net>
* @copyright 2014 Jim Wigginton
@ -130,7 +131,7 @@ U9VQQSQzY1oZMVX8i1m5WUTLPz2yLJIBQVdXqhMCQBGoiuSoSjafUhV7i1cEGpb88h5NBYZzWXGZ
*/
public function testPKCS1CSR()
{
$x509 = new X509;
$x509 = new X509();
$x509->loadCSR('-----BEGIN CERTIFICATE REQUEST-----
MIICijCCAXICAQAwRTELMAkGA1UEBhMCQVUxEzARBgNVBAgMClNvbWUtU3RhdGUx
ITAfBgNVBAoMGEludGVybmV0IFdpZGdpdHMgUHR5IEx0ZDCCASIwDQYJKoZIhvcN
@ -156,7 +157,7 @@ fUQvcGEA9FSQ8Y0nfF9vzzcCjLtOI6xJluYL9XCk8WVEBEawA2zmHWTzzuHFHHEM
*/
public function testPSSCSR()
{
$x509 = new X509;
$x509 = new X509();
$x509->loadCSR('-----BEGIN CERTIFICATE REQUEST-----
MIICuTCCAXACAQAwRTELMAkGA1UEBhMCQVUxEzARBgNVBAgMClNvbWUtU3RhdGUx
ITAfBgNVBAoMGEludGVybmV0IFdpZGdpdHMgUHR5IEx0ZDCCASAwCwYJKoZIhvcN

View File

@ -1,4 +1,5 @@
<?php
/**
* @author Jim Wigginton <terrafrost@php.net>
* @copyright 2014 Jim Wigginton

View File

@ -1,4 +1,5 @@
<?php
/**
* @author Jim Wigginton <terrafrost@php.net>
* @copyright 2014 Jim Wigginton

View File

@ -1,4 +1,5 @@
<?php
/**
* @author Jim Wigginton <terrafrost@php.net>
* @copyright 2014 Jim Wigginton
@ -1189,7 +1190,7 @@ qzFkAKWjJj4KjfrbZX4C0Spfxw==
$key = ASN1::encodeDER($key, ['type' => ASN1::TYPE_BIT_STRING]);
$key = new Element($key);
$x509 = new X509;
$x509 = new X509();
$this->assertIsString($x509->computeKeyIdentifier($key));
}
@ -1241,15 +1242,15 @@ QwinX0cR9Hx84rSMrFndxZi52o9EOLJ7cithncoW1KOAf7lIJIUzP0oIKkskAndQ
o2UiZsxgoMYuq02T07DOknc=
-----END ENCRYPTED PRIVATE KEY-----', 'demo');
$subject = new X509;
$subject = new X509();
$subject->setDNProp('id-at-organizationName', 'phpseclib demo cert');
$subject->setPublicKey($private->getPublicKey());
$issuer = new X509;
$issuer = new X509();
$issuer->setPrivateKey($private);
$issuer->setDNProp('id-at-organizationName', 'phpseclib CA cert');
$x509 = new X509;
$x509 = new X509();
$x509->sign($issuer, $subject);
}

View File

@ -1,4 +1,5 @@
<?php
/**
* @author Andreas Fischer <bantu@phpbb.com>
* @copyright 2013 Andreas Fischer

View File

@ -1,4 +1,5 @@
<?php
/**
* @author Andreas Fischer <bantu@phpbb.com>
* @copyright 2013 Andreas Fischer

View File

@ -1,4 +1,5 @@
<?php
/**
* @author Andreas Fischer <bantu@phpbb.com>
* @copyright 2013 Andreas Fischer

View File

@ -1,4 +1,5 @@
<?php
/**
* @author Andreas Fischer <bantu@phpbb.com>
* @copyright 2013 Andreas Fischer

View File

@ -1,4 +1,5 @@
<?php
/**
* @author Andreas Fischer <bantu@phpbb.com>
* @copyright 2013 Andreas Fischer

View File

@ -1,4 +1,5 @@
<?php
/**
* @author Andreas Fischer <bantu@phpbb.com>
* @copyright 2013 Andreas Fischer

View File

@ -1,4 +1,5 @@
<?php
/**
* @author Andreas Fischer <bantu@phpbb.com>
* @copyright 2012 Andreas Fischer

View File

@ -8,12 +8,12 @@ use phpseclib3\Math\BigInteger\Engines\PHP64;
class Unit_Math_BigIntegerTest extends PhpseclibTestCase
{
/**
* @param string $className
* @param bool $isValid
*/
private static function mockEngine($className, $isValid) {
private static function mockEngine($className, $isValid)
{
eval(<<<ENGINE
namespace phpseclib3\Math\BigInteger\Engines;
class ${className} extends \phpseclib3\Math\BigInteger\Engines\Engine {
@ -26,7 +26,8 @@ ENGINE
);
}
public static function provideBadConfigurationException() {
public static function provideBadConfigurationException()
{
return [
[
GMP::class,
@ -61,7 +62,8 @@ ENGINE
* @param string $expectedEngineClass
* @param array[] ...$engines
*/
public function testBadConfigurationException($expectedEngineClass, array ...$engines) {
public function testBadConfigurationException($expectedEngineClass, array ...$engines)
{
foreach ($engines as $engine) {
static::mockEngine($engine[0], $engine[1]);
}

View File

@ -1,4 +1,5 @@
<?php
/**
* @author Andreas Fischer <bantu@phpbb.com>
* @copyright 2014 Andreas Fischer

View File

@ -1,4 +1,5 @@
<?php
/**
* Bootstrapping File for phpseclib Test Suite
*