Skip to content

Commit

Permalink
CS adjustments
Browse files Browse the repository at this point in the history
  • Loading branch information
terrafrost committed May 25, 2024
1 parent 0db8742 commit 4cdcb74
Show file tree
Hide file tree
Showing 11 changed files with 13 additions and 19 deletions.
4 changes: 2 additions & 2 deletions phpseclib/Crypt/Blowfish.php
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ protected function setupKey(): void
/* key-expanding p[] and S-Box building sb[] */
$this->bctx = [
'p' => [],
'sb' => self::$sbox
'sb' => self::$sbox,
];

// unpack binary string in unsigned chars
Expand Down Expand Up @@ -543,7 +543,7 @@ private static function expand0state(array $key, array &$sbox, array &$p): void
[$p[16], $p[17]] = self::encryptBlockHelperFast($p[14], $p[15], $sbox, $p);
// @codingStandardsIgnoreEnd

list($sbox[0], $sbox[1]) = self::encryptBlockHelperFast($p[16], $p[17], $sbox, $p);
[$sbox[0], $sbox[1]] = self::encryptBlockHelperFast($p[16], $p[17], $sbox, $p);
for ($i = 2; $i < 1024; $i += 2) {
[$sbox[$i], $sbox[$i + 1]] = self::encryptBlockHelperFast($sbox[$i - 2], $sbox[$i - 1], $sbox, $p);
}
Expand Down
2 changes: 1 addition & 1 deletion phpseclib/Crypt/Common/AsymmetricKey.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ protected static function initialize_static_variables(): void
* Load the key
*
* @param string|array $key
* @return \phpseclib3\Crypt\Common\PublicKey|\phpseclib3\Crypt\Common\PrivateKey
* @return PublicKey|PrivateKey
*/
public static function load($key, ?string $password = null): AsymmetricKey
{
Expand Down
4 changes: 2 additions & 2 deletions phpseclib/Crypt/Common/Formats/Keys/PKCS8.php
Original file line number Diff line number Diff line change
Expand Up @@ -669,7 +669,7 @@ public static function extractEncryptionAlgorithm(string $key): array

$decoded = self::preParse($key);

$r = ASN1::asn1map($decoded[0], ASN1\Maps\EncryptedPrivateKeyInfo::MAP);
$r = ASN1::asn1map($decoded[0], Maps\EncryptedPrivateKeyInfo::MAP);
if (!is_array($r)) {
throw new RuntimeException('Unable to parse using EncryptedPrivateKeyInfo map');
}
Expand All @@ -679,7 +679,7 @@ public static function extractEncryptionAlgorithm(string $key): array
if (!$decoded) {
throw new RuntimeException('Unable to decode BER');
}
$r['encryptionAlgorithm']['parameters'] = ASN1::asn1map($decoded[0], ASN1\Maps\PBES2params::MAP);
$r['encryptionAlgorithm']['parameters'] = ASN1::asn1map($decoded[0], Maps\PBES2params::MAP);

$kdf = &$r['encryptionAlgorithm']['parameters']['keyDerivationFunc'];
switch ($kdf['algorithm']) {
Expand Down
2 changes: 0 additions & 2 deletions phpseclib/Crypt/DH/PrivateKey.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@ final class PrivateKey extends DH

/**
* Returns the public key
*
* @return DH\PublicKey
*/
public function getPublicKey(): PublicKey
{
Expand Down
4 changes: 2 additions & 2 deletions phpseclib/Crypt/EC/BaseCurves/Base.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public function convertInteger(BigInteger $x)
/**
* Returns the length, in bytes, of the modulo
*
* @return integer
* @return Integer
*/
public function getLengthInBytes(): int
{
Expand All @@ -74,7 +74,7 @@ public function getLengthInBytes(): int
/**
* Returns the length, in bits, of the modulo
*
* @return integer
* @return Integer
*/
public function getLength(): int
{
Expand Down
4 changes: 2 additions & 2 deletions phpseclib/Math/BigInteger.php
Original file line number Diff line number Diff line change
Expand Up @@ -164,15 +164,15 @@ private static function initialize_static_variables(): void
* If the second parameter - $base - is negative, then it will be assumed that the number's are encoded using
* two's compliment. The sole exception to this is -10, which is treated the same as 10 is.
*
* @param string|int|BigInteger\Engines\Engine $x Base-10 number or base-$base number if $base set.
* @param string|int|Engine $x Base-10 number or base-$base number if $base set.
*/
public function __construct($x = 0, int $base = 10)
{
self::initialize_static_variables();

if ($x instanceof self::$mainEngine) {
$this->value = clone $x;
} elseif ($x instanceof BigInteger\Engines\Engine) {
} elseif ($x instanceof Engine) {
$this->value = new static("$x");
$this->value->setPrecision($x->getPrecision());
} else {
Expand Down
1 change: 0 additions & 1 deletion phpseclib/Net/SFTP.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
use phpseclib3\Net\SFTP\OpenFlag5;
use phpseclib3\Net\SFTP\PacketType as SFTPPacketType;
use phpseclib3\Net\SFTP\StatusCode;
use phpseclib3\Net\SSH2\DisconnectReason;
use phpseclib3\Net\SSH2\MessageType as SSH2MessageType;

/**
Expand Down
3 changes: 0 additions & 3 deletions phpseclib/Net/SSH2.php
Original file line number Diff line number Diff line change
Expand Up @@ -3024,9 +3024,6 @@ public function __destruct()
* 2: phpseclib takes an active approach to see if the connection is still active by sending an SSH_MSG_CHANNEL_OPEN
* packet and imediately trying to close that channel. some routers, in particular, however, will only let you
* open one channel, so this approach could yield false positives
*
* @param int $level
* @return bool
*/
public function isConnected(int $level = 0): bool
{
Expand Down
4 changes: 2 additions & 2 deletions tests/Unit/Crypt/RSA/LoadKeyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1426,14 +1426,14 @@ public function testPKCS8DES(): void
/**
* @group github1994
*/
public function testCloseNumbers()
public function testCloseNumbers(): void
{
$rsa = PublicKeyLoader::load([
// Modulus
'n' => new BigInteger('5BDD6AFB1E1AFB50D1B2989F70B549B8D44AE3712B444F2C5D862C46C99526E998B79BF0B4F1461524E39D263F3130B9E08F3B17C2070785EFB0EDEC1E75C6C2B8185FA9596886D5DAF8B68E92FCF5F1B33E7CD772845555B086D2A2466B6398A04DFE1C727BB020g1ED2BF3F03D2826F89616D0846C18B1D87064616FAD394462', 16),

// Exponent
'e' => new BigInteger('6FE4F5D0AFCC16E8A5CC68955D4EF28255A546D06F34DD103540B9A7D202AEC96353072DB65D9C360E9030F413971142EE6A28974767CCF3ABFA4E7ADDAEAD81D3F8AE5FF1B8241CA9EF51C10941FFFA74482A636CBD909D29CF7A0346653D3C286EA1F392F4968AEF1489EC4B4BCEA4F248F3931B1C9BE2808DBD33B049731A', 16)
'e' => new BigInteger('6FE4F5D0AFCC16E8A5CC68955D4EF28255A546D06F34DD103540B9A7D202AEC96353072DB65D9C360E9030F413971142EE6A28974767CCF3ABFA4E7ADDAEAD81D3F8AE5FF1B8241CA9EF51C10941FFFA74482A636CBD909D29CF7A0346653D3C286EA1F392F4968AEF1489EC4B4BCEA4F248F3931B1C9BE2808DBD33B049731A', 16),
])
->withPadding(RSA::SIGNATURE_PKCS1)
->withHash('md5')
Expand Down
2 changes: 1 addition & 1 deletion tests/Unit/File/ASN1Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,7 @@ public function testBadTagSecondOctet(): void
$this->assertNull($decoded);
}

public function testLongOID()
public function testLongOID(): void
{
$cert = file_get_contents(dirname(__FILE__) . '/ASN1/mal-cert-02.der');

Expand Down
2 changes: 1 addition & 1 deletion tests/Unit/File/X509/X509Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -1395,7 +1395,7 @@ public function testWeirdCharsCert(): void
$this->assertFalse($x509->validateURL('https://aa'));
}

public function testLargeInteger()
public function testLargeInteger(): void
{
// cert has an elliptic curve public key with a specified curve (vs a named curve) with
// an excessively large integer value
Expand Down

0 comments on commit 4cdcb74

Please sign in to comment.