mirror of
https://github.com/phpseclib/phpseclib.git
synced 2024-12-27 03:42:40 +00:00
1st round of comments
This commit is contained in:
parent
97902d4bd3
commit
beafe2a8a1
@ -1,8 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<files psalm-version="4.23.0@f1fe6ff483bf325c803df9f510d09a03fd796f88">
|
||||
<file src="../phpseclib/Common/Functions/Strings.php">
|
||||
<MissingParamType occurrences="2">
|
||||
<code>$trim</code>
|
||||
<MissingParamType occurrences="1">
|
||||
<code>$var</code>
|
||||
</MissingParamType>
|
||||
<MixedArgument occurrences="8">
|
||||
@ -4090,9 +4089,8 @@
|
||||
<code>$order</code>
|
||||
<code>$p</code>
|
||||
</MissingConstructor>
|
||||
<MissingParamType occurrences="2">
|
||||
<MissingParamType occurrences="1">
|
||||
<code>$m</code>
|
||||
<code>$modulo</code>
|
||||
</MissingParamType>
|
||||
<MixedAssignment occurrences="10">
|
||||
<code>$lhs</code>
|
||||
@ -4414,9 +4412,8 @@
|
||||
<InvalidPropertyAssignmentValue occurrences="2">
|
||||
<code>new PrimeField($modulo)</code>
|
||||
</InvalidPropertyAssignmentValue>
|
||||
<InvalidReturnStatement occurrences="4">
|
||||
<InvalidReturnStatement occurrences="3">
|
||||
<code>$jsf</code>
|
||||
<code>$res</code>
|
||||
<code>$this->convertToAffine($acc)</code>
|
||||
<code>$this->p</code>
|
||||
</InvalidReturnStatement>
|
||||
@ -4453,10 +4450,8 @@
|
||||
<code>$two</code>
|
||||
<code>$two</code>
|
||||
</MissingConstructor>
|
||||
<MissingParamType occurrences="3">
|
||||
<MissingParamType occurrences="1">
|
||||
<code>$m</code>
|
||||
<code>$point</code>
|
||||
<code>$wnd</code>
|
||||
</MissingParamType>
|
||||
<MixedArgument occurrences="14">
|
||||
<code>$m</code>
|
||||
@ -4464,28 +4459,24 @@
|
||||
<code>$naf[$b]</code>
|
||||
<code>$p</code>
|
||||
<code>$point</code>
|
||||
<code>$point</code>
|
||||
<code>$points[$a]</code>
|
||||
<code>$points[$a]</code>
|
||||
<code>$points[$b]</code>
|
||||
<code>$points[$b]</code>
|
||||
<code>$res[$i - 1]</code>
|
||||
<code>$points[$i]</code>
|
||||
<code>$points[0]</code>
|
||||
<code>$scalars[$a]</code>
|
||||
<code>$scalars[$b]</code>
|
||||
<code>$wnd[$j][(-$z - 1) >> 1]</code>
|
||||
</MixedArgument>
|
||||
<MixedArrayAccess occurrences="3">
|
||||
<code>$point['naf']</code>
|
||||
<MixedArrayAccess occurrences="2">
|
||||
<code>$points[$i]['nafwidth']</code>
|
||||
<code>$points[0]['nafwidth']</code>
|
||||
</MixedArrayAccess>
|
||||
<MixedArrayAssignment occurrences="1">
|
||||
<code>$point['naf']</code>
|
||||
</MixedArrayAssignment>
|
||||
<MixedArrayOffset occurrences="1">
|
||||
<code>$wnd[$j][($z - 1) >> 1]</code>
|
||||
</MixedArrayOffset>
|
||||
<MixedAssignment occurrences="43">
|
||||
<MixedAssignment occurrences="42">
|
||||
<code>$b</code>
|
||||
<code>$bn</code>
|
||||
<code>$jsf[0][]</code>
|
||||
@ -4507,7 +4498,6 @@
|
||||
<code>$m8</code>
|
||||
<code>$m8</code>
|
||||
<code>$m8</code>
|
||||
<code>$max</code>
|
||||
<code>$naf[$a]</code>
|
||||
<code>$naf[$b]</code>
|
||||
<code>$p</code>
|
||||
@ -4540,7 +4530,7 @@
|
||||
<code>FiniteField[]</code>
|
||||
<code>FiniteField[]</code>
|
||||
<code>boolean</code>
|
||||
<code>int[]</code>
|
||||
<code>list<array></code>
|
||||
</MixedInferredReturnType>
|
||||
<MixedMethodCall occurrences="40">
|
||||
<code>add</code>
|
||||
@ -4584,7 +4574,7 @@
|
||||
<code>testBit</code>
|
||||
<code>testBit</code>
|
||||
</MixedMethodCall>
|
||||
<MixedOperand occurrences="25">
|
||||
<MixedOperand occurrences="23">
|
||||
<code>$k1->testBit(0)</code>
|
||||
<code>$k1->testBit(0)</code>
|
||||
<code>$k1->testBit(1)</code>
|
||||
@ -4607,9 +4597,7 @@
|
||||
<code>$m8</code>
|
||||
<code>$u1</code>
|
||||
<code>$u2</code>
|
||||
<code>$wnd</code>
|
||||
<code>$z</code>
|
||||
<code>1 << $wnd</code>
|
||||
</MixedOperand>
|
||||
<MixedReturnStatement occurrences="2">
|
||||
<code>$lhs->equals($rhs)</code>
|
||||
@ -4629,10 +4617,6 @@
|
||||
<NonInvariantDocblockPropertyType occurrences="1">
|
||||
<code>$factory</code>
|
||||
</NonInvariantDocblockPropertyType>
|
||||
<PossiblyInvalidArgument occurrences="2">
|
||||
<code>$p</code>
|
||||
<code>$wnd[$j][(-$z - 1) >> 1]</code>
|
||||
</PossiblyInvalidArgument>
|
||||
<PossiblyNullArgument occurrences="1">
|
||||
<code>$dbl</code>
|
||||
</PossiblyNullArgument>
|
||||
@ -7663,13 +7647,10 @@
|
||||
<InvalidPropertyAssignmentValue occurrences="2">
|
||||
<code>$length >> 3</code>
|
||||
</InvalidPropertyAssignmentValue>
|
||||
<MissingParamType occurrences="1">
|
||||
<code>$t1</code>
|
||||
</MissingParamType>
|
||||
<MixedArgument occurrences="1">
|
||||
<code>$l</code>
|
||||
</MixedArgument>
|
||||
<MixedArrayOffset occurrences="18">
|
||||
<MixedArrayOffset occurrences="13">
|
||||
<code>$keys[$r0 & 0x3F]</code>
|
||||
<code>$keys[$r0 & 0x3F]</code>
|
||||
<code>$keys[$r1 & 0x3F]</code>
|
||||
@ -7678,20 +7659,13 @@
|
||||
<code>$keys[$r2 & 0x3F]</code>
|
||||
<code>$keys[$r3 & 0x3F]</code>
|
||||
<code>$keys[$r3 & 0x3F]</code>
|
||||
<code>$l[$i + $t8]</code>
|
||||
<code>$l[$i + 1]</code>
|
||||
<code>$l[$i]</code>
|
||||
<code>$l[$i]</code>
|
||||
<code>$l[$i]</code>
|
||||
<code>$pitable[$l[$i + 1] ^ $l[$i + $t8]]</code>
|
||||
<code>$pitable[$l[$i - 1] + $l[$i - $t]]</code>
|
||||
<code>$pitable[$l[$i] & $tm]</code>
|
||||
<code>self::$invpitable[$l[0]]</code>
|
||||
<code>self::$pitable[$l['a']]</code>
|
||||
</MixedArrayOffset>
|
||||
<MixedAssignment occurrences="33">
|
||||
<code>$i</code>
|
||||
<code>$i</code>
|
||||
<MixedAssignment occurrences="28">
|
||||
<code>$l[$i]</code>
|
||||
<code>$l[$i]</code>
|
||||
<code>$l[$i]</code>
|
||||
@ -7720,14 +7694,8 @@
|
||||
<code>$r3</code>
|
||||
<code>$r3</code>
|
||||
<code>$r3</code>
|
||||
<code>$t8</code>
|
||||
<code>$this->current_key_length</code>
|
||||
<code>$tm</code>
|
||||
</MixedAssignment>
|
||||
<MixedOperand occurrences="80">
|
||||
<code>$i</code>
|
||||
<code>$i</code>
|
||||
<code>$i</code>
|
||||
<MixedOperand occurrences="73">
|
||||
<code>$keys[$j++]</code>
|
||||
<code>$keys[$j++]</code>
|
||||
<code>$keys[$j++]</code>
|
||||
@ -7788,9 +7756,6 @@
|
||||
<code>$r3</code>
|
||||
<code>$r3</code>
|
||||
<code>$r3</code>
|
||||
<code>$t1</code>
|
||||
<code>$t8</code>
|
||||
<code>$t8</code>
|
||||
<code>($r0 + $keys[$j++] + ((($r1 ^ $r2) & $r3) ^ $r1)) & 0xFFFF</code>
|
||||
<code>($r0 ^ $r1) & $r2</code>
|
||||
<code>($r0 ^ $r1) & $r2</code>
|
||||
@ -7803,7 +7768,6 @@
|
||||
<code>($r3 + $keys[$j++] + ((($r0 ^ $r1) & $r2) ^ $r0)) & 0xFFFF</code>
|
||||
<code>($r3 ^ $r0) & $r1</code>
|
||||
<code>($r3 ^ $r0) & $r1</code>
|
||||
<code>8 * $t8</code>
|
||||
<code>self::$pitable[$l['a']]</code>
|
||||
</MixedOperand>
|
||||
<PossiblyFalseArgument occurrences="5">
|
||||
@ -8040,9 +8004,6 @@
|
||||
<code>modInverse</code>
|
||||
<code>subtract</code>
|
||||
</PossiblyFalseReference>
|
||||
<PossiblyInvalidMethodCall occurrences="1">
|
||||
<code>toBytes</code>
|
||||
</PossiblyInvalidMethodCall>
|
||||
<PossiblyUndefinedIntArrayOffset occurrences="2">
|
||||
<code>$primes[1]</code>
|
||||
<code>$primes[2]</code>
|
||||
@ -8515,19 +8476,11 @@
|
||||
<code>!empty($password) && is_string($password)</code>
|
||||
<code>is_string($password)</code>
|
||||
</RedundantCondition>
|
||||
<TypeDoesNotContainType occurrences="1">
|
||||
<code>Strings::is_stringable($key)</code>
|
||||
</TypeDoesNotContainType>
|
||||
<UnusedClass occurrences="1">
|
||||
<code>XML</code>
|
||||
</UnusedClass>
|
||||
</file>
|
||||
<file src="../phpseclib/Crypt/RSA/PrivateKey.php">
|
||||
<InvalidArrayAccess occurrences="3">
|
||||
<code>$em[0]</code>
|
||||
<code>$em[0]</code>
|
||||
<code>$em[1]</code>
|
||||
</InvalidArrayAccess>
|
||||
<InvalidOperand occurrences="3">
|
||||
<code>!$hashesMatch</code>
|
||||
<code>$m[$i] === "\0"</code>
|
||||
@ -8540,16 +8493,10 @@
|
||||
<InvalidReturnType occurrences="1">
|
||||
<code>string</code>
|
||||
</InvalidReturnType>
|
||||
<InvalidScalarArgument occurrences="1">
|
||||
<code>$em</code>
|
||||
</InvalidScalarArgument>
|
||||
<MissingPropertyType occurrences="1">
|
||||
<code>$publicExponent</code>
|
||||
</MissingPropertyType>
|
||||
<MixedArgument occurrences="30">
|
||||
<code>$em[0]</code>
|
||||
<code>$em[0]</code>
|
||||
<code>$em[1]</code>
|
||||
<MixedArgument occurrences="27">
|
||||
<code>$key</code>
|
||||
<code>$r</code>
|
||||
<code>$r->multiply($h)</code>
|
||||
@ -8610,11 +8557,12 @@
|
||||
<PossiblyFalseOperand occurrences="1">
|
||||
<code>strpos($em, chr(0), 2)</code>
|
||||
</PossiblyFalseOperand>
|
||||
<PossiblyInvalidArgument occurrences="4">
|
||||
<code>$em</code>
|
||||
<code>$em</code>
|
||||
<code>$em</code>
|
||||
<code>$em</code>
|
||||
<PossiblyInvalidArgument occurrences="5">
|
||||
<code>$m</code>
|
||||
<code>$m</code>
|
||||
<code>$s</code>
|
||||
<code>$s</code>
|
||||
<code>$temp</code>
|
||||
</PossiblyInvalidArgument>
|
||||
<PossiblyUndefinedIntArrayOffset occurrences="11">
|
||||
<code>$this->coefficients[2]</code>
|
||||
@ -8649,15 +8597,13 @@
|
||||
<code>false</code>
|
||||
<code>false</code>
|
||||
</FalsableReturnStatement>
|
||||
<InvalidReturnStatement occurrences="3">
|
||||
<code>$c</code>
|
||||
<InvalidReturnStatement occurrences="2">
|
||||
<code>$this->rsassa_pss_verify($message, $signature)</code>
|
||||
<code>hash_equals($h, $h2)</code>
|
||||
</InvalidReturnStatement>
|
||||
<InvalidReturnType occurrences="3">
|
||||
<InvalidReturnType occurrences="2">
|
||||
<code>bool</code>
|
||||
<code>string</code>
|
||||
<code>string</code>
|
||||
</InvalidReturnType>
|
||||
<MixedArgument occurrences="3">
|
||||
<code>$decoded[0]</code>
|
||||
@ -8685,11 +8631,13 @@
|
||||
<MixedReturnStatement occurrences="1">
|
||||
<code>$type::savePublicKey($this->modulus, $this->publicExponent, $options)</code>
|
||||
</MixedReturnStatement>
|
||||
<PossiblyInvalidArgument occurrences="4">
|
||||
<code>$em</code>
|
||||
<code>$em</code>
|
||||
<code>$em</code>
|
||||
<code>$em</code>
|
||||
<PossiblyInvalidArgument occurrences="6">
|
||||
<code>$c</code>
|
||||
<code>$c</code>
|
||||
<code>$m2</code>
|
||||
<code>$m2</code>
|
||||
<code>$m2</code>
|
||||
<code>$temp</code>
|
||||
</PossiblyInvalidArgument>
|
||||
<PossiblyInvalidArrayAccess occurrences="2">
|
||||
<code>$decoded['digest']</code>
|
||||
@ -8713,8 +8661,11 @@
|
||||
<code>PublicKey</code>
|
||||
<code>PublicKey</code>
|
||||
</PropertyNotSetInConstructor>
|
||||
<TypeDoesNotContainType occurrences="1">
|
||||
<TypeDoesNotContainType occurrences="4">
|
||||
<code>!is_array($decoded)</code>
|
||||
<code>$em === false</code>
|
||||
<code>$em === false</code>
|
||||
<code>$em === false</code>
|
||||
</TypeDoesNotContainType>
|
||||
<UndefinedMethod occurrences="4">
|
||||
<code>$decoded</code>
|
||||
@ -9976,12 +9927,6 @@
|
||||
<code>$le_longs[7]</code>
|
||||
<code>$le_longs[8]</code>
|
||||
</PossiblyInvalidArrayAccess>
|
||||
<PossiblyInvalidOperand occurrences="4">
|
||||
<code>$A</code>
|
||||
<code>$A</code>
|
||||
<code>$B</code>
|
||||
<code>$B</code>
|
||||
</PossiblyInvalidOperand>
|
||||
<PossiblyUndefinedIntArrayOffset occurrences="122">
|
||||
<code>$K[0]</code>
|
||||
<code>$K[0]</code>
|
||||
@ -14893,6 +14838,9 @@
|
||||
<code>$value</code>
|
||||
<code>$value</code>
|
||||
</MixedOperand>
|
||||
<MixedPropertyAssignment occurrences="1">
|
||||
<code>$this->$this</code>
|
||||
</MixedPropertyAssignment>
|
||||
<MixedPropertyFetch occurrences="2">
|
||||
<code>$result['.']->lstat</code>
|
||||
<code>$result['.']->stat</code>
|
||||
@ -14926,9 +14874,10 @@
|
||||
<code>unpack('Nlength', Strings::shift($this->packet_buffer, 4))</code>
|
||||
<code>unpack('Npacket_id', Strings::shift($this->packet_buffer, 4))</code>
|
||||
</PossiblyFalseArgument>
|
||||
<PossiblyFalseOperand occurrences="8">
|
||||
<PossiblyFalseOperand occurrences="9">
|
||||
<code>$attr</code>
|
||||
<code>$this->pwd</code>
|
||||
<code>$this->pwd</code>
|
||||
</PossiblyFalseOperand>
|
||||
<PossiblyFalsePropertyAssignmentValue occurrences="2">
|
||||
<code>false</code>
|
||||
@ -14968,9 +14917,10 @@
|
||||
<code>preg_replace('#^/|/(?=/)|/$#', '', $path)</code>
|
||||
<code>preg_replace('#^/|/(?=/)|/$#', '', $path)</code>
|
||||
</PossiblyNullArgument>
|
||||
<PossiblyUndefinedIntArrayOffset occurrences="3">
|
||||
<PossiblyUndefinedIntArrayOffset occurrences="4">
|
||||
<code>$dirs[0]</code>
|
||||
<code>$this->channel_status[self::CHANNEL]</code>
|
||||
<code>$this->channel_status[self::CHANNEL]</code>
|
||||
<code>$this->server_channels[self::CHANNEL]</code>
|
||||
</PossiblyUndefinedIntArrayOffset>
|
||||
<PossiblyUndefinedStringArrayOffset occurrences="20">
|
||||
@ -15805,8 +15755,7 @@
|
||||
<PossiblyUndefinedStringArrayOffset occurrences="1">
|
||||
<code>$temp['length']</code>
|
||||
</PossiblyUndefinedStringArrayOffset>
|
||||
<PossiblyUndefinedVariable occurrences="8">
|
||||
<code>$elapsed</code>
|
||||
<PossiblyUndefinedVariable occurrences="7">
|
||||
<code>$matches</code>
|
||||
<code>$matches</code>
|
||||
<code>$matches</code>
|
||||
|
@ -278,7 +278,7 @@ abstract class Strings
|
||||
/**
|
||||
* Convert bits to binary data
|
||||
*/
|
||||
public static function bin2bits(string $x, $trim = true): string
|
||||
public static function bin2bits(string $x, bool $trim = true): string
|
||||
{
|
||||
/*
|
||||
// the pure-PHP approach is slower than the GMP approach BUT
|
||||
|
@ -86,7 +86,7 @@ class Binary extends Base
|
||||
/**
|
||||
* Sets the modulo
|
||||
*/
|
||||
public function setModulo(...$modulo): void
|
||||
public function setModulo(int ...$modulo): void
|
||||
{
|
||||
$this->modulo = $modulo;
|
||||
$this->factory = new BinaryField(...$modulo);
|
||||
|
@ -640,9 +640,9 @@ class Prime extends Base
|
||||
* Adapted from:
|
||||
* https://github.com/indutny/elliptic/blob/725bd91/lib/elliptic/curve/base.js#L351
|
||||
*
|
||||
* @return int[]
|
||||
* @return list<array>
|
||||
*/
|
||||
private function getNAFPoints($point, $wnd): array
|
||||
private function getNAFPoints(array $point, int $wnd): array
|
||||
{
|
||||
if (isset($point['naf'])) {
|
||||
return $point['naf'];
|
||||
|
@ -324,16 +324,16 @@ class RC2 extends BlockCipher
|
||||
* @throws \LengthException if the key length isn't supported
|
||||
*@see \phpseclib3\Crypt\Common\SymmetricKey::setKey()
|
||||
*/
|
||||
public function setKey(string $key, $t1 = false): void
|
||||
public function setKey(string $key, ?int $t1 = null): void
|
||||
{
|
||||
$this->orig_key = $key;
|
||||
|
||||
if ($t1 === false) {
|
||||
if ($t1 === null) {
|
||||
$t1 = $this->default_key_length;
|
||||
}
|
||||
|
||||
if ($t1 < 1 || $t1 > 1024) {
|
||||
//throw new \LengthException('Key size of ' . $t1 . ' bits is not supported by this algorithm. Only keys between 1 and 1024 bits, inclusive, are supported');
|
||||
throw new \LengthException('Key size of ' . $t1 . ' bits is not supported by this algorithm. Only keys between 1 and 1024 bits, inclusive, are supported');
|
||||
}
|
||||
|
||||
$this->current_key_length = $t1;
|
||||
|
@ -196,7 +196,7 @@ abstract class RSA extends AsymmetricKey
|
||||
/**
|
||||
* Modulus (ie. n)
|
||||
*
|
||||
* @var \phpseclib3\Math\BigInteger
|
||||
* @var BigInteger
|
||||
*/
|
||||
protected $modulus;
|
||||
|
||||
@ -210,7 +210,7 @@ abstract class RSA extends AsymmetricKey
|
||||
/**
|
||||
* Exponent (ie. e or d)
|
||||
*
|
||||
* @var \phpseclib3\Math\BigInteger
|
||||
* @var BigInteger
|
||||
*/
|
||||
protected $exponent;
|
||||
|
||||
@ -491,15 +491,9 @@ abstract class RSA extends AsymmetricKey
|
||||
* Integer-to-Octet-String primitive
|
||||
*
|
||||
* See {@link http://tools.ietf.org/html/rfc3447#section-4.1 RFC3447#section-4.1}.
|
||||
*
|
||||
* @param bool|\phpseclib3\Math\BigInteger $x
|
||||
* @return bool|string
|
||||
*/
|
||||
protected function i2osp($x, int $xLen)
|
||||
protected function i2osp(BigInteger $x, int $xLen): string
|
||||
{
|
||||
if ($x === false) {
|
||||
return false;
|
||||
}
|
||||
$x = $x->toBytes();
|
||||
if (strlen($x) > $xLen) {
|
||||
throw new \OutOfRangeException('Resultant string length out of range');
|
||||
|
@ -38,9 +38,9 @@ abstract class XML
|
||||
/**
|
||||
* Break a public or private key down into its constituent components
|
||||
*
|
||||
* @param string|false $password
|
||||
* @param string|array $key
|
||||
*/
|
||||
public static function load(string $key, $password = ''): array
|
||||
public static function load($key): array
|
||||
{
|
||||
if (!Strings::is_stringable($key)) {
|
||||
throw new \UnexpectedValueException('Key should be a string - not a ' . gettype($key));
|
||||
|
@ -523,10 +523,8 @@ class Twofish extends BlockCipher
|
||||
|
||||
/**
|
||||
* _mdsrem function using by the twofish cipher algorithm
|
||||
* @param string|int $A
|
||||
* @param string|int $B
|
||||
*/
|
||||
private function mdsrem($A, $B): array
|
||||
private function mdsrem(int $A, int $B): array
|
||||
{
|
||||
// No gain by unrolling this loop.
|
||||
for ($i = 0; $i < 8; ++$i) {
|
||||
|
Loading…
Reference in New Issue
Block a user