1st round of comments

This commit is contained in:
Jack Worman 2022-06-19 08:03:28 -05:00
parent 97902d4bd3
commit beafe2a8a1
8 changed files with 54 additions and 113 deletions

View File

@ -1,8 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<files psalm-version="4.23.0@f1fe6ff483bf325c803df9f510d09a03fd796f88"> <files psalm-version="4.23.0@f1fe6ff483bf325c803df9f510d09a03fd796f88">
<file src="../phpseclib/Common/Functions/Strings.php"> <file src="../phpseclib/Common/Functions/Strings.php">
<MissingParamType occurrences="2"> <MissingParamType occurrences="1">
<code>$trim</code>
<code>$var</code> <code>$var</code>
</MissingParamType> </MissingParamType>
<MixedArgument occurrences="8"> <MixedArgument occurrences="8">
@ -4090,9 +4089,8 @@
<code>$order</code> <code>$order</code>
<code>$p</code> <code>$p</code>
</MissingConstructor> </MissingConstructor>
<MissingParamType occurrences="2"> <MissingParamType occurrences="1">
<code>$m</code> <code>$m</code>
<code>$modulo</code>
</MissingParamType> </MissingParamType>
<MixedAssignment occurrences="10"> <MixedAssignment occurrences="10">
<code>$lhs</code> <code>$lhs</code>
@ -4414,9 +4412,8 @@
<InvalidPropertyAssignmentValue occurrences="2"> <InvalidPropertyAssignmentValue occurrences="2">
<code>new PrimeField($modulo)</code> <code>new PrimeField($modulo)</code>
</InvalidPropertyAssignmentValue> </InvalidPropertyAssignmentValue>
<InvalidReturnStatement occurrences="4"> <InvalidReturnStatement occurrences="3">
<code>$jsf</code> <code>$jsf</code>
<code>$res</code>
<code>$this-&gt;convertToAffine($acc)</code> <code>$this-&gt;convertToAffine($acc)</code>
<code>$this-&gt;p</code> <code>$this-&gt;p</code>
</InvalidReturnStatement> </InvalidReturnStatement>
@ -4453,10 +4450,8 @@
<code>$two</code> <code>$two</code>
<code>$two</code> <code>$two</code>
</MissingConstructor> </MissingConstructor>
<MissingParamType occurrences="3"> <MissingParamType occurrences="1">
<code>$m</code> <code>$m</code>
<code>$point</code>
<code>$wnd</code>
</MissingParamType> </MissingParamType>
<MixedArgument occurrences="14"> <MixedArgument occurrences="14">
<code>$m</code> <code>$m</code>
@ -4464,28 +4459,24 @@
<code>$naf[$b]</code> <code>$naf[$b]</code>
<code>$p</code> <code>$p</code>
<code>$point</code> <code>$point</code>
<code>$point</code>
<code>$points[$a]</code> <code>$points[$a]</code>
<code>$points[$a]</code> <code>$points[$a]</code>
<code>$points[$b]</code> <code>$points[$b]</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[$a]</code>
<code>$scalars[$b]</code> <code>$scalars[$b]</code>
<code>$wnd[$j][(-$z - 1) &gt;&gt; 1]</code> <code>$wnd[$j][(-$z - 1) &gt;&gt; 1]</code>
</MixedArgument> </MixedArgument>
<MixedArrayAccess occurrences="3"> <MixedArrayAccess occurrences="2">
<code>$point['naf']</code>
<code>$points[$i]['nafwidth']</code> <code>$points[$i]['nafwidth']</code>
<code>$points[0]['nafwidth']</code> <code>$points[0]['nafwidth']</code>
</MixedArrayAccess> </MixedArrayAccess>
<MixedArrayAssignment occurrences="1">
<code>$point['naf']</code>
</MixedArrayAssignment>
<MixedArrayOffset occurrences="1"> <MixedArrayOffset occurrences="1">
<code>$wnd[$j][($z - 1) &gt;&gt; 1]</code> <code>$wnd[$j][($z - 1) &gt;&gt; 1]</code>
</MixedArrayOffset> </MixedArrayOffset>
<MixedAssignment occurrences="43"> <MixedAssignment occurrences="42">
<code>$b</code> <code>$b</code>
<code>$bn</code> <code>$bn</code>
<code>$jsf[0][]</code> <code>$jsf[0][]</code>
@ -4507,7 +4498,6 @@
<code>$m8</code> <code>$m8</code>
<code>$m8</code> <code>$m8</code>
<code>$m8</code> <code>$m8</code>
<code>$max</code>
<code>$naf[$a]</code> <code>$naf[$a]</code>
<code>$naf[$b]</code> <code>$naf[$b]</code>
<code>$p</code> <code>$p</code>
@ -4540,7 +4530,7 @@
<code>FiniteField[]</code> <code>FiniteField[]</code>
<code>FiniteField[]</code> <code>FiniteField[]</code>
<code>boolean</code> <code>boolean</code>
<code>int[]</code> <code>list&lt;array&gt;</code>
</MixedInferredReturnType> </MixedInferredReturnType>
<MixedMethodCall occurrences="40"> <MixedMethodCall occurrences="40">
<code>add</code> <code>add</code>
@ -4584,7 +4574,7 @@
<code>testBit</code> <code>testBit</code>
<code>testBit</code> <code>testBit</code>
</MixedMethodCall> </MixedMethodCall>
<MixedOperand occurrences="25"> <MixedOperand occurrences="23">
<code>$k1-&gt;testBit(0)</code> <code>$k1-&gt;testBit(0)</code>
<code>$k1-&gt;testBit(0)</code> <code>$k1-&gt;testBit(0)</code>
<code>$k1-&gt;testBit(1)</code> <code>$k1-&gt;testBit(1)</code>
@ -4607,9 +4597,7 @@
<code>$m8</code> <code>$m8</code>
<code>$u1</code> <code>$u1</code>
<code>$u2</code> <code>$u2</code>
<code>$wnd</code>
<code>$z</code> <code>$z</code>
<code>1 &lt;&lt; $wnd</code>
</MixedOperand> </MixedOperand>
<MixedReturnStatement occurrences="2"> <MixedReturnStatement occurrences="2">
<code>$lhs-&gt;equals($rhs)</code> <code>$lhs-&gt;equals($rhs)</code>
@ -4629,10 +4617,6 @@
<NonInvariantDocblockPropertyType occurrences="1"> <NonInvariantDocblockPropertyType occurrences="1">
<code>$factory</code> <code>$factory</code>
</NonInvariantDocblockPropertyType> </NonInvariantDocblockPropertyType>
<PossiblyInvalidArgument occurrences="2">
<code>$p</code>
<code>$wnd[$j][(-$z - 1) &gt;&gt; 1]</code>
</PossiblyInvalidArgument>
<PossiblyNullArgument occurrences="1"> <PossiblyNullArgument occurrences="1">
<code>$dbl</code> <code>$dbl</code>
</PossiblyNullArgument> </PossiblyNullArgument>
@ -7663,13 +7647,10 @@
<InvalidPropertyAssignmentValue occurrences="2"> <InvalidPropertyAssignmentValue occurrences="2">
<code>$length &gt;&gt; 3</code> <code>$length &gt;&gt; 3</code>
</InvalidPropertyAssignmentValue> </InvalidPropertyAssignmentValue>
<MissingParamType occurrences="1">
<code>$t1</code>
</MissingParamType>
<MixedArgument occurrences="1"> <MixedArgument occurrences="1">
<code>$l</code> <code>$l</code>
</MixedArgument> </MixedArgument>
<MixedArrayOffset occurrences="18"> <MixedArrayOffset occurrences="13">
<code>$keys[$r0 &amp; 0x3F]</code> <code>$keys[$r0 &amp; 0x3F]</code>
<code>$keys[$r0 &amp; 0x3F]</code> <code>$keys[$r0 &amp; 0x3F]</code>
<code>$keys[$r1 &amp; 0x3F]</code> <code>$keys[$r1 &amp; 0x3F]</code>
@ -7678,20 +7659,13 @@
<code>$keys[$r2 &amp; 0x3F]</code> <code>$keys[$r2 &amp; 0x3F]</code>
<code>$keys[$r3 &amp; 0x3F]</code> <code>$keys[$r3 &amp; 0x3F]</code>
<code>$keys[$r3 &amp; 0x3F]</code> <code>$keys[$r3 &amp; 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 + $t8]]</code>
<code>$pitable[$l[$i - 1] + $l[$i - $t]]</code> <code>$pitable[$l[$i - 1] + $l[$i - $t]]</code>
<code>$pitable[$l[$i] &amp; $tm]</code> <code>$pitable[$l[$i] &amp; $tm]</code>
<code>self::$invpitable[$l[0]]</code> <code>self::$invpitable[$l[0]]</code>
<code>self::$pitable[$l['a']]</code> <code>self::$pitable[$l['a']]</code>
</MixedArrayOffset> </MixedArrayOffset>
<MixedAssignment occurrences="33"> <MixedAssignment occurrences="28">
<code>$i</code>
<code>$i</code>
<code>$l[$i]</code> <code>$l[$i]</code>
<code>$l[$i]</code> <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>$r3</code>
<code>$r3</code> <code>$r3</code>
<code>$t8</code>
<code>$this-&gt;current_key_length</code>
<code>$tm</code>
</MixedAssignment> </MixedAssignment>
<MixedOperand occurrences="80"> <MixedOperand occurrences="73">
<code>$i</code>
<code>$i</code>
<code>$i</code>
<code>$keys[$j++]</code> <code>$keys[$j++]</code>
<code>$keys[$j++]</code> <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>$r3</code>
<code>$r3</code> <code>$r3</code>
<code>$t1</code>
<code>$t8</code>
<code>$t8</code>
<code>($r0 + $keys[$j++] + ((($r1 ^ $r2) &amp; $r3) ^ $r1)) &amp; 0xFFFF</code> <code>($r0 + $keys[$j++] + ((($r1 ^ $r2) &amp; $r3) ^ $r1)) &amp; 0xFFFF</code>
<code>($r0 ^ $r1) &amp; $r2</code> <code>($r0 ^ $r1) &amp; $r2</code>
<code>($r0 ^ $r1) &amp; $r2</code> <code>($r0 ^ $r1) &amp; $r2</code>
@ -7803,7 +7768,6 @@
<code>($r3 + $keys[$j++] + ((($r0 ^ $r1) &amp; $r2) ^ $r0)) &amp; 0xFFFF</code> <code>($r3 + $keys[$j++] + ((($r0 ^ $r1) &amp; $r2) ^ $r0)) &amp; 0xFFFF</code>
<code>($r3 ^ $r0) &amp; $r1</code> <code>($r3 ^ $r0) &amp; $r1</code>
<code>($r3 ^ $r0) &amp; $r1</code> <code>($r3 ^ $r0) &amp; $r1</code>
<code>8 * $t8</code>
<code>self::$pitable[$l['a']]</code> <code>self::$pitable[$l['a']]</code>
</MixedOperand> </MixedOperand>
<PossiblyFalseArgument occurrences="5"> <PossiblyFalseArgument occurrences="5">
@ -8040,9 +8004,6 @@
<code>modInverse</code> <code>modInverse</code>
<code>subtract</code> <code>subtract</code>
</PossiblyFalseReference> </PossiblyFalseReference>
<PossiblyInvalidMethodCall occurrences="1">
<code>toBytes</code>
</PossiblyInvalidMethodCall>
<PossiblyUndefinedIntArrayOffset occurrences="2"> <PossiblyUndefinedIntArrayOffset occurrences="2">
<code>$primes[1]</code> <code>$primes[1]</code>
<code>$primes[2]</code> <code>$primes[2]</code>
@ -8515,19 +8476,11 @@
<code>!empty($password) &amp;&amp; is_string($password)</code> <code>!empty($password) &amp;&amp; is_string($password)</code>
<code>is_string($password)</code> <code>is_string($password)</code>
</RedundantCondition> </RedundantCondition>
<TypeDoesNotContainType occurrences="1">
<code>Strings::is_stringable($key)</code>
</TypeDoesNotContainType>
<UnusedClass occurrences="1"> <UnusedClass occurrences="1">
<code>XML</code> <code>XML</code>
</UnusedClass> </UnusedClass>
</file> </file>
<file src="../phpseclib/Crypt/RSA/PrivateKey.php"> <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"> <InvalidOperand occurrences="3">
<code>!$hashesMatch</code> <code>!$hashesMatch</code>
<code>$m[$i] === "\0"</code> <code>$m[$i] === "\0"</code>
@ -8540,16 +8493,10 @@
<InvalidReturnType occurrences="1"> <InvalidReturnType occurrences="1">
<code>string</code> <code>string</code>
</InvalidReturnType> </InvalidReturnType>
<InvalidScalarArgument occurrences="1">
<code>$em</code>
</InvalidScalarArgument>
<MissingPropertyType occurrences="1"> <MissingPropertyType occurrences="1">
<code>$publicExponent</code> <code>$publicExponent</code>
</MissingPropertyType> </MissingPropertyType>
<MixedArgument occurrences="30"> <MixedArgument occurrences="27">
<code>$em[0]</code>
<code>$em[0]</code>
<code>$em[1]</code>
<code>$key</code> <code>$key</code>
<code>$r</code> <code>$r</code>
<code>$r-&gt;multiply($h)</code> <code>$r-&gt;multiply($h)</code>
@ -8610,11 +8557,12 @@
<PossiblyFalseOperand occurrences="1"> <PossiblyFalseOperand occurrences="1">
<code>strpos($em, chr(0), 2)</code> <code>strpos($em, chr(0), 2)</code>
</PossiblyFalseOperand> </PossiblyFalseOperand>
<PossiblyInvalidArgument occurrences="4"> <PossiblyInvalidArgument occurrences="5">
<code>$em</code> <code>$m</code>
<code>$em</code> <code>$m</code>
<code>$em</code> <code>$s</code>
<code>$em</code> <code>$s</code>
<code>$temp</code>
</PossiblyInvalidArgument> </PossiblyInvalidArgument>
<PossiblyUndefinedIntArrayOffset occurrences="11"> <PossiblyUndefinedIntArrayOffset occurrences="11">
<code>$this-&gt;coefficients[2]</code> <code>$this-&gt;coefficients[2]</code>
@ -8649,15 +8597,13 @@
<code>false</code> <code>false</code>
<code>false</code> <code>false</code>
</FalsableReturnStatement> </FalsableReturnStatement>
<InvalidReturnStatement occurrences="3"> <InvalidReturnStatement occurrences="2">
<code>$c</code>
<code>$this-&gt;rsassa_pss_verify($message, $signature)</code> <code>$this-&gt;rsassa_pss_verify($message, $signature)</code>
<code>hash_equals($h, $h2)</code> <code>hash_equals($h, $h2)</code>
</InvalidReturnStatement> </InvalidReturnStatement>
<InvalidReturnType occurrences="3"> <InvalidReturnType occurrences="2">
<code>bool</code> <code>bool</code>
<code>string</code> <code>string</code>
<code>string</code>
</InvalidReturnType> </InvalidReturnType>
<MixedArgument occurrences="3"> <MixedArgument occurrences="3">
<code>$decoded[0]</code> <code>$decoded[0]</code>
@ -8685,11 +8631,13 @@
<MixedReturnStatement occurrences="1"> <MixedReturnStatement occurrences="1">
<code>$type::savePublicKey($this-&gt;modulus, $this-&gt;publicExponent, $options)</code> <code>$type::savePublicKey($this-&gt;modulus, $this-&gt;publicExponent, $options)</code>
</MixedReturnStatement> </MixedReturnStatement>
<PossiblyInvalidArgument occurrences="4"> <PossiblyInvalidArgument occurrences="6">
<code>$em</code> <code>$c</code>
<code>$em</code> <code>$c</code>
<code>$em</code> <code>$m2</code>
<code>$em</code> <code>$m2</code>
<code>$m2</code>
<code>$temp</code>
</PossiblyInvalidArgument> </PossiblyInvalidArgument>
<PossiblyInvalidArrayAccess occurrences="2"> <PossiblyInvalidArrayAccess occurrences="2">
<code>$decoded['digest']</code> <code>$decoded['digest']</code>
@ -8713,8 +8661,11 @@
<code>PublicKey</code> <code>PublicKey</code>
<code>PublicKey</code> <code>PublicKey</code>
</PropertyNotSetInConstructor> </PropertyNotSetInConstructor>
<TypeDoesNotContainType occurrences="1"> <TypeDoesNotContainType occurrences="4">
<code>!is_array($decoded)</code> <code>!is_array($decoded)</code>
<code>$em === false</code>
<code>$em === false</code>
<code>$em === false</code>
</TypeDoesNotContainType> </TypeDoesNotContainType>
<UndefinedMethod occurrences="4"> <UndefinedMethod occurrences="4">
<code>$decoded</code> <code>$decoded</code>
@ -9976,12 +9927,6 @@
<code>$le_longs[7]</code> <code>$le_longs[7]</code>
<code>$le_longs[8]</code> <code>$le_longs[8]</code>
</PossiblyInvalidArrayAccess> </PossiblyInvalidArrayAccess>
<PossiblyInvalidOperand occurrences="4">
<code>$A</code>
<code>$A</code>
<code>$B</code>
<code>$B</code>
</PossiblyInvalidOperand>
<PossiblyUndefinedIntArrayOffset occurrences="122"> <PossiblyUndefinedIntArrayOffset occurrences="122">
<code>$K[0]</code> <code>$K[0]</code>
<code>$K[0]</code> <code>$K[0]</code>
@ -14893,6 +14838,9 @@
<code>$value</code> <code>$value</code>
<code>$value</code> <code>$value</code>
</MixedOperand> </MixedOperand>
<MixedPropertyAssignment occurrences="1">
<code>$this-&gt;$this</code>
</MixedPropertyAssignment>
<MixedPropertyFetch occurrences="2"> <MixedPropertyFetch occurrences="2">
<code>$result['.']-&gt;lstat</code> <code>$result['.']-&gt;lstat</code>
<code>$result['.']-&gt;stat</code> <code>$result['.']-&gt;stat</code>
@ -14926,9 +14874,10 @@
<code>unpack('Nlength', Strings::shift($this-&gt;packet_buffer, 4))</code> <code>unpack('Nlength', Strings::shift($this-&gt;packet_buffer, 4))</code>
<code>unpack('Npacket_id', Strings::shift($this-&gt;packet_buffer, 4))</code> <code>unpack('Npacket_id', Strings::shift($this-&gt;packet_buffer, 4))</code>
</PossiblyFalseArgument> </PossiblyFalseArgument>
<PossiblyFalseOperand occurrences="8"> <PossiblyFalseOperand occurrences="9">
<code>$attr</code> <code>$attr</code>
<code>$this-&gt;pwd</code> <code>$this-&gt;pwd</code>
<code>$this-&gt;pwd</code>
</PossiblyFalseOperand> </PossiblyFalseOperand>
<PossiblyFalsePropertyAssignmentValue occurrences="2"> <PossiblyFalsePropertyAssignmentValue occurrences="2">
<code>false</code> <code>false</code>
@ -14968,9 +14917,10 @@
<code>preg_replace('#^/|/(?=/)|/$#', '', $path)</code> <code>preg_replace('#^/|/(?=/)|/$#', '', $path)</code>
<code>preg_replace('#^/|/(?=/)|/$#', '', $path)</code> <code>preg_replace('#^/|/(?=/)|/$#', '', $path)</code>
</PossiblyNullArgument> </PossiblyNullArgument>
<PossiblyUndefinedIntArrayOffset occurrences="3"> <PossiblyUndefinedIntArrayOffset occurrences="4">
<code>$dirs[0]</code> <code>$dirs[0]</code>
<code>$this-&gt;channel_status[self::CHANNEL]</code> <code>$this-&gt;channel_status[self::CHANNEL]</code>
<code>$this-&gt;channel_status[self::CHANNEL]</code>
<code>$this-&gt;server_channels[self::CHANNEL]</code> <code>$this-&gt;server_channels[self::CHANNEL]</code>
</PossiblyUndefinedIntArrayOffset> </PossiblyUndefinedIntArrayOffset>
<PossiblyUndefinedStringArrayOffset occurrences="20"> <PossiblyUndefinedStringArrayOffset occurrences="20">
@ -15805,8 +15755,7 @@
<PossiblyUndefinedStringArrayOffset occurrences="1"> <PossiblyUndefinedStringArrayOffset occurrences="1">
<code>$temp['length']</code> <code>$temp['length']</code>
</PossiblyUndefinedStringArrayOffset> </PossiblyUndefinedStringArrayOffset>
<PossiblyUndefinedVariable occurrences="8"> <PossiblyUndefinedVariable occurrences="7">
<code>$elapsed</code>
<code>$matches</code> <code>$matches</code>
<code>$matches</code> <code>$matches</code>
<code>$matches</code> <code>$matches</code>

View File

@ -278,7 +278,7 @@ abstract class Strings
/** /**
* Convert bits to binary data * 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 // the pure-PHP approach is slower than the GMP approach BUT

View File

@ -86,7 +86,7 @@ class Binary extends Base
/** /**
* Sets the modulo * Sets the modulo
*/ */
public function setModulo(...$modulo): void public function setModulo(int ...$modulo): void
{ {
$this->modulo = $modulo; $this->modulo = $modulo;
$this->factory = new BinaryField(...$modulo); $this->factory = new BinaryField(...$modulo);

View File

@ -640,9 +640,9 @@ class Prime extends Base
* Adapted from: * Adapted from:
* https://github.com/indutny/elliptic/blob/725bd91/lib/elliptic/curve/base.js#L351 * 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'])) { if (isset($point['naf'])) {
return $point['naf']; return $point['naf'];

View File

@ -324,16 +324,16 @@ class RC2 extends BlockCipher
* @throws \LengthException if the key length isn't supported * @throws \LengthException if the key length isn't supported
*@see \phpseclib3\Crypt\Common\SymmetricKey::setKey() *@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; $this->orig_key = $key;
if ($t1 === false) { if ($t1 === null) {
$t1 = $this->default_key_length; $t1 = $this->default_key_length;
} }
if ($t1 < 1 || $t1 > 1024) { 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; $this->current_key_length = $t1;

View File

@ -196,7 +196,7 @@ abstract class RSA extends AsymmetricKey
/** /**
* Modulus (ie. n) * Modulus (ie. n)
* *
* @var \phpseclib3\Math\BigInteger * @var BigInteger
*/ */
protected $modulus; protected $modulus;
@ -210,7 +210,7 @@ abstract class RSA extends AsymmetricKey
/** /**
* Exponent (ie. e or d) * Exponent (ie. e or d)
* *
* @var \phpseclib3\Math\BigInteger * @var BigInteger
*/ */
protected $exponent; protected $exponent;
@ -491,15 +491,9 @@ abstract class RSA extends AsymmetricKey
* Integer-to-Octet-String primitive * Integer-to-Octet-String primitive
* *
* See {@link http://tools.ietf.org/html/rfc3447#section-4.1 RFC3447#section-4.1}. * 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(); $x = $x->toBytes();
if (strlen($x) > $xLen) { if (strlen($x) > $xLen) {
throw new \OutOfRangeException('Resultant string length out of range'); throw new \OutOfRangeException('Resultant string length out of range');

View File

@ -38,9 +38,9 @@ abstract class XML
/** /**
* Break a public or private key down into its constituent components * 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)) { if (!Strings::is_stringable($key)) {
throw new \UnexpectedValueException('Key should be a string - not a ' . gettype($key)); throw new \UnexpectedValueException('Key should be a string - not a ' . gettype($key));

View File

@ -523,10 +523,8 @@ class Twofish extends BlockCipher
/** /**
* _mdsrem function using by the twofish cipher algorithm * _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. // No gain by unrolling this loop.
for ($i = 0; $i < 8; ++$i) { for ($i = 0; $i < 8; ++$i) {