diff --git a/AUTHORS b/AUTHORS
index 9f10d267..88378c15 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -4,4 +4,4 @@ phpseclib Developers: monnerat (Patrick Monnerat)
bantu (Andreas Fischer)
petrich (Hans-Jürgen Petrich)
GrahamCampbell (Graham Campbell)
- hc-jworman
\ No newline at end of file
+ jack-worman (Jack Worman)
diff --git a/build/php-cs-fixer.php b/build/php-cs-fixer.php
index f51e0f72..27fe4781 100644
--- a/build/php-cs-fixer.php
+++ b/build/php-cs-fixer.php
@@ -26,7 +26,7 @@ return (new PhpCsFixer\Config())
'phpdoc_trim_consecutive_blank_line_separation' => true,
'phpdoc_trim' => true,
- '@PHP71Migration:risky' => true,
- '@PHP73Migration' => true,
+ '@PHP81Migration' => true,
+ '@PHP80Migration:risky' => true,
]
);
diff --git a/build/php_codesniffer.xml b/build/php_codesniffer.xml
index de09391e..4a7b18d7 100644
--- a/build/php_codesniffer.xml
+++ b/build/php_codesniffer.xml
@@ -6,7 +6,7 @@
-
+
diff --git a/build/psalm_baseline.xml b/build/psalm_baseline.xml
index f012cc1a..f3701c3b 100644
--- a/build/psalm_baseline.xml
+++ b/build/psalm_baseline.xml
@@ -1,5 +1,5 @@
-
+
$var
@@ -117,11 +117,13 @@
-
+
+ pack("N*", $r, $l)
+ pack('L*', ...$cdata)
pack('N*', $r ^ $p[0], $l ^ $p[1])
- pack('N*', $r ^ $p[17], $l ^ $p[16])
-
+
+ string
string
string
@@ -129,44 +131,48 @@
$j
-
- $sb_0[$l >> 24 & 0xff] + $sb_1[$l >> 16 & 0xff]
- $sb_0[$l >> 24 & 0xff] + $sb_1[$l >> 16 & 0xff]
- $sb_0[$r >> 24 & 0xff] + $sb_1[$r >> 16 & 0xff]
- $sb_0[$r >> 24 & 0xff] + $sb_1[$r >> 16 & 0xff]
+
+ $cdata[$j + 1]
+ $cdata[$j]
+ $l
+ $p
+ $r
+ $sb_0
+ $sb_1
+ $sb_2
+ $sb_3
-
- $p[$i + 1]
+
+ $p
+ $sbox0
+ $sbox1
+ $sbox2
+ $sbox3
+ $sha2pass
+ $sha2pass
+ $sha2salt
+ $sha2salt
+
+
$p[$i + 1]
$p[$i - 1]
$p[$i - 1]
$p[$i]
$p[$i]
$p[$i]
- $p[$i]
$p[0]
$p[0]
$p[16]
- $p[16]
- $p[17]
$p[17]
$p[1]
$p[1]
$sb_0[$l >> 24 & 0xff]
- $sb_0[$l >> 24 & 0xff]
- $sb_0[$r >> 24 & 0xff]
$sb_0[$r >> 24 & 0xff]
$sb_1[$l >> 16 & 0xff]
- $sb_1[$l >> 16 & 0xff]
- $sb_1[$r >> 16 & 0xff]
$sb_1[$r >> 16 & 0xff]
$sb_2[$l >> 8 & 0xff]
- $sb_2[$l >> 8 & 0xff]
- $sb_2[$r >> 8 & 0xff]
$sb_2[$r >> 8 & 0xff]
$sb_3[$l & 0xff]
- $sb_3[$l & 0xff]
- $sb_3[$r & 0xff]
$sb_3[$r & 0xff]
$this->bctx['sb'][0]
$this->bctx['sb'][0]
@@ -177,32 +183,22 @@
$this->bctx['sb'][3]
$this->bctx['sb'][3]
-
- $sb_0[$l >> 24 & 0xff]
+
$sb_0[$l >> 24 & 0xff]
$sb_0[$r >> 24 & 0xff]
- $sb_0[$r >> 24 & 0xff]
- $sb_1[$l >> 16 & 0xff]
$sb_1[$l >> 16 & 0xff]
$sb_1[$r >> 16 & 0xff]
- $sb_1[$r >> 16 & 0xff]
- $sb_2[$l >> 8 & 0xff]
$sb_2[$l >> 8 & 0xff]
$sb_2[$r >> 8 & 0xff]
- $sb_2[$r >> 8 & 0xff]
$sb_3[$l & 0xff]
- $sb_3[$l & 0xff]
- $sb_3[$r & 0xff]
$sb_3[$r & 0xff]
-
+
$data
$l
$l
$l
$l
- $l
- $l
$p
$p
$p
@@ -210,8 +206,6 @@
$r
$r
$r
- $r
- $r
$sb_0
$sb_0
$sb_1
@@ -221,7 +215,7 @@
$sb_3
$sb_3
-
+
$data
$l
$l
@@ -230,13 +224,6 @@
$l
$l
$l
- $l
- $l
- $l
- $l
- $l
- $l
- $l
$p[$i + 1]
$p[$i - 1]
$p[$i]
@@ -252,28 +239,25 @@
$r
$r
$r
- $r
- $r
- $r
- $r
- $r
- $r
- $r
- $sb_0[$l >> 24 & 0xff]
$sb_0[$l >> 24 & 0xff]
$sb_0[$r >> 24 & 0xff]
- $sb_0[$r >> 24 & 0xff]
- $sb_2[$l >> 8 & 0xff]
- $sb_2[$l >> 8 & 0xff]
- $sb_2[$r >> 8 & 0xff]
- $sb_2[$r >> 8 & 0xff]
self::$parray[$i]
-
+
+ $sha2pass
+ $sha2pass
+ $sha2salt
+ $sha2salt
unpack('C*', $this->key)
unpack('N*', $data = $this->encryptBlock($data))
unpack('N*', $data = $this->encryptBlock($data))
+ unpack('N*', $sha2pass)
+ unpack('N*', $sha2salt)
+ unpack('N*', 'OxychromaticBlowfishSwatDynamite')
+
+ pack('N', $count++)
+
$in[1]
$in[1]
@@ -283,11 +267,113 @@
$this->openssl_translate_mode()
-
+
+ $data[0]
+ $data[1]
+ $data[2]
+ $data[3]
$in[1]
$in[1]
$in[2]
$in[2]
+ $key[0]
+ $key[0]
+ $key[10]
+ $key[10]
+ $key[11]
+ $key[11]
+ $key[12]
+ $key[12]
+ $key[13]
+ $key[13]
+ $key[14]
+ $key[14]
+ $key[15]
+ $key[15]
+ $key[1]
+ $key[1]
+ $key[2]
+ $key[2]
+ $key[3]
+ $key[3]
+ $key[4]
+ $key[4]
+ $key[5]
+ $key[5]
+ $key[6]
+ $key[6]
+ $key[7]
+ $key[7]
+ $key[8]
+ $key[8]
+ $key[9]
+ $key[9]
+ $p[0]
+ $p[0]
+ $p[0]
+ $p[10]
+ $p[10]
+ $p[10]
+ $p[11]
+ $p[11]
+ $p[11]
+ $p[12]
+ $p[12]
+ $p[12]
+ $p[13]
+ $p[13]
+ $p[13]
+ $p[14]
+ $p[14]
+ $p[14]
+ $p[15]
+ $p[15]
+ $p[15]
+ $p[16]
+ $p[16]
+ $p[16]
+ $p[17]
+ $p[17]
+ $p[17]
+ $p[1]
+ $p[1]
+ $p[1]
+ $p[2]
+ $p[2]
+ $p[2]
+ $p[3]
+ $p[3]
+ $p[3]
+ $p[4]
+ $p[4]
+ $p[4]
+ $p[5]
+ $p[5]
+ $p[5]
+ $p[6]
+ $p[6]
+ $p[6]
+ $p[7]
+ $p[7]
+ $p[7]
+ $p[8]
+ $p[8]
+ $p[8]
+ $p[9]
+ $p[9]
+ $p[9]
+ $sbox0[254]
+ $sbox0[254]
+ $sbox0[255]
+ $sbox0[255]
+ $sbox1[254]
+ $sbox1[254]
+ $sbox1[255]
+ $sbox1[255]
+ $sbox2[254]
+ $sbox2[254]
+ $sbox2[255]
+ $sbox2[255]
$this->bctx['p']
@@ -1726,14 +1812,18 @@
-$rolen
self::$invisiblePlugins[static::ALGORITHM]
-
+
$components['comment']
+ $components['secret']
+ $components['secret']
self::$plugins[static::ALGORITHM]['Keys']
self::$plugins[static::ALGORITHM]['Keys']
-
+
$components['format']
$components['format']
+ $components['secret']
+ $components['secret']
self::$invisiblePlugins[static::ALGORITHM][]
self::$plugins[static::ALGORITHM][$format]
self::$plugins[static::ALGORITHM][$format]
@@ -1752,12 +1842,14 @@
self::$plugins[static::ALGORITHM]
self::$plugins[static::ALGORITHM]
-
+
$comment
$components
$components
$components['format']
$components['format']
+ $components['secret']
+ $components['secret']
$format
$format
$new
@@ -1858,29 +1950,49 @@
-
+
+ $salt
+ 32
+ 32
+
+
$checkint
$checkint
$comment
$kdfoptions
$paddedKey
$publicKey
+ $rounds
+ $rounds
+ $rounds
+ $salt
$type
$type
static::$types
static::$types
-
+
$comment
+ $paddedKey
+ $rounds
-
+
+ decrypt
+
+
$asciiType
+ $ciphername
+ $kdfname
+
+ $rounds
+
$checkint
-
+
$key
+ $password
$parts[0]
@@ -1888,8 +2000,7 @@
setBinaryOutput
-
- !empty($password) && is_string($password)
+
is_string($password)
@@ -2458,13 +2569,17 @@
openssl_encrypt($plaintext, $this->cipher_name_openssl, $this->key, OPENSSL_RAW_DATA | OPENSSL_ZERO_PADDING)
openssl_encrypt($plaintext, $this->cipher_name_openssl, $this->key, OPENSSL_RAW_DATA | OPENSSL_ZERO_PADDING)
-
+
$func_args[0]
+ $salt
$xor[0]
$xor[0]
+
+ $salt
+
string
@@ -2475,16 +2590,10 @@
$length >> 3
-
- $x
-
-
- int
-
setupKey
-
+
$buffer['ciphertext']
$buffer['ciphertext']
$buffer['ciphertext']
@@ -2523,6 +2632,9 @@
$key
$key
$key
+ $keylen
+ $keylen
+ $keylen + $this->block_size
$len
$len
$one
@@ -2544,11 +2656,10 @@
-$overflow
-$overflow - $this->block_size
-
+
$reverseMap[$engine]
- $this->buffer['pos']
-
+
$bindedClosure
$ciphertext
$decrypt_block
@@ -2562,6 +2673,7 @@
$init_decrypt
$init_encrypt
$key_length
+ $keylen
$len
$len
$len
@@ -2598,7 +2710,7 @@
string
string
-
+
$buffer['ciphertext']
$buffer['ciphertext']
$buffer['ciphertext']
@@ -2651,6 +2763,7 @@
$init_encrypt
$init_encrypt
$key_length
+ $keylen
$len
$len
$len
@@ -2712,7 +2825,7 @@
false
false
-
+
$count
$count
$count
@@ -2720,6 +2833,9 @@
$dkLen
$dkLen
$dkLen
+ $keylen
+ $keylen
+ $rounds
$salt
$salt
@@ -2737,7 +2853,10 @@
null
-
+
+ $func_args[0]
+
+
$buffer['ciphertext']
$buffer['ciphertext']
$buffer['ciphertext']
@@ -2772,6 +2891,7 @@
$buffer['xor']
$cipher_code['decrypt_block']
$cipher_code['encrypt_block']
+ $this->debuffer['pos']
$this->enbuffer['pos']
@@ -2828,25 +2948,16 @@
setupInlineCrypt
-
- $this->h->key
-
-
- $this->h->key
-
$this->key_length
- $this->buffer
+ $this->key_length
$this->key_length
$this->key_length
$this->openssl_options
$this->openssl_options
-
- break;
-
new static('ctr')
new static('ctr')
@@ -3164,8 +3275,9 @@
$key_length
$openssl_mode_names
-
+
$keys
+ $kl
DES
DES
DES
@@ -3176,9 +3288,6 @@
DES
DES
-
- $this->kl
-
@@ -3201,10 +3310,8 @@
$new->publicKey
$type
-
+
$type::saveParameters($this->prime, $this->base)
- powMod
- toBytes
$args[0]
@@ -3219,13 +3326,9 @@
onLoad
-
+
$new->privateKey
- $new->publicKey
-
- $public->publicKey
-
@@ -3295,7 +3398,8 @@
$type::saveParameters($this->prime, $this->base, $options)
-
+
+ Parameters
Parameters
Parameters
Parameters
@@ -3342,26 +3446,21 @@
$type
-
- \phpseclib3\Math\BigInteger
+
string
$type::savePublicKey($this->prime, $this->base, $this->publicKey, $options)
-
- $this->publicKey
+
$type::savePublicKey($this->prime, $this->base, $this->publicKey, $options)
-
+
+ PublicKey
PublicKey
PublicKey
PublicKey
-
- $this->publicKey
- $this->publicKey
-
@@ -3788,26 +3887,39 @@
getParameters
-
+
$components['curve']::HASH
+ $curve->getBasePoint()
$curve::HASH
+ $dA
$dA->toBytes()
$decoded[0]
$key
$params
$this->QA[0]->toBytes(true)
-
+
+ $arr['dA']
+ $arr['secret']
+
+
+ $arr
+ $dA
$dA
$key
$new->QA
$new->curve
$new->curve
$new->dA
+ $new->secret
+ $new->sigFormat
$params
$privatekey->QA
$privatekey->dA
+ $privatekey->dA
+ $privatekey->secret
$this->curveName
+ $this->sigFormat
$type
@@ -3855,10 +3967,11 @@
$this->QA[0]
$this->QA[1]
-
+
$components['QA']
$components['curve']
$components['curve']
+ $components['secret']
self::$engines['OpenSSL']
self::$engines['libsodium']
self::$engines['libsodium']
@@ -3892,19 +4005,17 @@
is_string($context)
-
+
$decoded
encodePoint
+ extractSecret
withSignatureFormat
$new->dA
- $new->sigFormat
+ $new->secret
$privatekey->curveName
-
- $this->sigFormat
-
$namedCurves
@@ -4105,6 +4216,9 @@
$this->p[0]
+
+ static::extendedGCD($lambda->toBigInteger(), $this->order)
+
BigInteger[]
@@ -4112,69 +4226,49 @@
$p
-
+
+ $basis
+ $beta
+
+
$basis['a']->toHex(true)
$basis['b']->toHex(true)
+ $k
+ $one
+ $one
$one
$p
$p['naf']
- $r->multiply($two)
- $r->multiply($two)
$rhs
$two
+ $two
-
- $c1
- $c2
+
$p['naf']
$p['nafwidth']
$p[0]
$p[0]
$p[1]
$p[1]
- $r
- $r
- $v1
- $v1['a']
- $v1['b']
- $v1['b']
- $v2
- $v2['a']
- $v2['b']
- $v2['b']
-
+
$a2
$b2
$beta['nafwidth']
- $c1
- $c1
- $c2
- $c2
$inv
$k
- $k1
- $k1
- $k2
- $k2
$lhs
$lhs
$npoints[$pos]
$nscalars[$pos]
$nscalars[$pos]
$p
- $p1
- $p2
- $q1
- $q2
$rhs
$rhs
$rhs
$s
$temp
- [$c1, $r]
- [$c2, $r]
- [$v1, $v2]
+ $this->beta
FiniteField[]
@@ -4182,21 +4276,14 @@
FiniteField[]
boolean
-
- add
- add
- add
+
add
add
add
compare
divide
- divide
- divide
equals
equals
- isNegative
- isNegative
multiply
multiply
multiply
@@ -4206,25 +4293,11 @@
multiply
multiply
multiply
- multiply
- multiply
- multiply
- multiply
- multiply
- multiply
- multiply
- multiply
- negate
- negate
- negate
- negate
negate
negate
negate
squareRoot
subtract
- subtract
- subtract
toBigInteger
toHex
toHex
@@ -4244,6 +4317,10 @@
$b0
$b0
+
+ isset($this->basis)
+ isset($this->beta)
+
$this->factory
$this->factory
@@ -4255,10 +4332,6 @@
$basis
$basis
-
- $this->basis
- $this->beta
-
@@ -4718,15 +4791,9 @@
-
- $dA
- $this->extractSecret(Random::string(32))
+
clone $this->zero
-
- BigInteger
- \phpseclib3\Math\PrimeField\Integer
-
[clone $this->zero, clone $this->one, clone $this->one, clone $this->zero]
@@ -4755,7 +4822,8 @@
$y[0]
$y[0]
-
+
+ BigInteger
FiniteField[]
FiniteField[]
@@ -4785,6 +4853,9 @@
$y[0]
$y[0]
+
+ $this->extractSecret(Random::string(32))['dA']
+
$p
$p
@@ -4796,6 +4867,9 @@
$p[0]
$p[1]
+
+ $this->extractSecret(Random::string(32))['dA']
+
addPoint
doublePoint
@@ -4817,20 +4891,11 @@
FiniteField[]
FiniteField[]
-
- $dA->secret
-
-
- $dA
- $this->extractSecret(Random::string(57))
+
clone $this->zero
-
- BigInteger
- \phpseclib3\Math\PrimeField\Integer
-
[clone $this->zero, clone $this->one, clone $this->one]
@@ -4843,7 +4908,8 @@
$y
$y2
-
+
+ BigInteger
FiniteField[]
FiniteField[]
@@ -4866,6 +4932,9 @@
$y->toBytes()
+
+ $this->extractSecret(Random::string(57))['dA']
+
$p
$p
@@ -4873,6 +4942,9 @@
\phpseclib3\Math\PrimeField\Integer[]
object[]
+
+ $this->extractSecret(Random::string(57))['dA']
+
addPoint
doublePoint
@@ -4895,9 +4967,6 @@
FiniteField[]
FiniteField[]
-
- $dA->secret
-
@@ -5384,6 +5453,9 @@
+
+ $this->beta
+
newInteger
@@ -5403,12 +5475,6 @@
$this->factory
-
- $this->basis
- $this->basis
- $this->basis
- $this->beta
-
$this->factory
@@ -5453,6 +5519,9 @@
+
+ $this->beta
+
newInteger
@@ -5472,12 +5541,6 @@
$this->factory
-
- $this->basis
- $this->basis
- $this->basis
- $this->beta
-
$this->factory
@@ -5501,6 +5564,9 @@
+
+ $this->beta
+
newInteger
@@ -5520,12 +5586,6 @@
$this->factory
-
- $this->basis
- $this->basis
- $this->basis
- $this->beta
-
$this->factory
@@ -5549,6 +5609,9 @@
+
+ $this->beta
+
newInteger
@@ -5568,12 +5631,6 @@
$this->factory
-
- $this->basis
- $this->basis
- $this->basis
- $this->beta
-
$this->factory
@@ -6103,14 +6160,16 @@
new $curveName()
-
+
+ string|false
+
+
$key
$paddedKey
$parsed['publicKey']
$parsed['publicKey']
$parsed['publicKey']
$privateKey
- $privateKey->secret
$comment
@@ -6133,6 +6192,10 @@
rangeCheck
+
+ $password
+ $password
+
$publicKey[0]
$publicKey[0]
@@ -6224,11 +6287,9 @@
-
- $components['dA']
-
-
+
$components['curve']->getBasePoint()
+ $components['dA']
$curve->encodePoint($publicKey)
$decoded[0]
$decoded[0]
@@ -6246,9 +6307,12 @@
$key['privateKeyAlgorithm']['algorithm']
$key['publicKeyAlgorithm']['algorithm']
-
+
+ $components['dA']
+ $components['secret']
+
+
$key['publicKey']
- $privateKey->secret
$key[$type . 'Algorithm']['parameters']->element
@@ -6278,6 +6342,9 @@
$key['privateKey']
+
+ $secret
+
$key
@@ -6293,7 +6360,9 @@
$publicKey[1]
$publicKey[1]
-
+
+ $arr['dA']
+ $arr['secret']
$key[$type . 'Algorithm']
$key[$type . 'Algorithm']
$key['privateKey']
@@ -6317,25 +6386,27 @@
toBytes
toBytes
-
- $privateKey->secret
-
$publicKey
-
+
$components['type']
$length
$length
$private
$private
$private
- $privateKey->secret
-
+
+ $arr['dA']
+ $arr['secret']
+
+
+ $arr
$components['dA']
+ $components['secret']
$private
@@ -6350,8 +6421,9 @@
$length
$length
-
+
$password
+ $secret
$public[1]
@@ -6376,9 +6448,6 @@
extractSecret
-
- $privateKey->secret
-
@@ -6573,16 +6642,21 @@
$curve->multiplyPoint($curve->getBasePoint(), $components['dA'])
-
- $components['dA']
-
+ $components['dA']
$private
- $privateKey->secret
+
+ $components['dA']
+ $components['secret']
+
$components['dA']
+
+ $arr['dA']
+ $arr['secret']
+
savePrivateKey
savePublicKey
@@ -6685,11 +6759,18 @@
$this->dA
$this->dA
+
+ $format === false
+
+
+ $format::save($r, $s)
+ $format::save($r, $s, $this->getCurve())
+
getPublicKey
sign
-
+
$curve::HASH
$curve::SIZE
$curve::SIZE
@@ -6697,16 +6778,14 @@
$key
$point[0]->toBytes(true)
$this->curve->getBasePoint()
- $this->dA->secret
$this->dA->toBytes()
$r
-
+
$A
$R
- $format
$key
$key
$key
@@ -6719,12 +6798,10 @@
string
string
-
- $format::save($r, $s)
+
$format::save($r, $s)
$format::save($r, $s, $this->getCurve())
- $format::save($r, $s, $this->getCurve())
- $type::savePrivateKey($this->dA, $this->curve, $this->QA, $this->password, $options)
+ $type::savePrivateKey($this->dA, $this->curve, $this->QA, $this->secret, $this->password, $options)
$type::savePublicKey($this->curve, $this->QA)
divide
equals
@@ -6746,7 +6823,7 @@
$this->curve->encodePoint($point)
- $type::savePrivateKey($this->dA, $this->curve, $this->QA, $this->password, $options)
+ $type::savePrivateKey($this->dA, $this->curve, $this->QA, $this->secret, $this->password, $options)
$this->getCurve()
@@ -6796,17 +6873,20 @@
getBasePoint
withSignatureFormat
-
- $this->sigFormat
-
$y
+
+ $format === false
+
toBigInteger
+
+ $format::load($signature)
+
$Ln
$curve::HASH
@@ -6831,10 +6911,9 @@
$u2
$x1
-
+
$A
$Ln
- $format
$n_1
$params
$rhs
@@ -6849,8 +6928,7 @@
bool
string
-
- $format::load($signature)
+
$type::savePublicKey($this->curve, $this->QA, $options)
between
between
@@ -6909,9 +6987,6 @@
encodePoint
getBasePoint
-
- $this->sigFormat
-
@@ -7148,9 +7223,7 @@
$algo($text, ...array_values($this->parameters))
call_user_func($this->algo, $this->key)
-
- int
- int
+
string
@@ -7215,7 +7288,7 @@
toBytes
toBytes
-
+
$hash[0]->toBytes()
$hash[2]->toBytes()
$hash[3]->toBytes()
@@ -7269,7 +7342,6 @@
$st[$i][4]
$st[$i][4][0]
$st[$i][4][1]
- $this->blockSize
unpack('C', $index)[1]
~$st[$i][0]
~$st[$i][0][0]
@@ -7287,9 +7359,7 @@
~$st[$i][4][0]
~$st[$i][4][1]
-
- $this->blockSize
- $this->blockSize >> 3
+
$y->toBytes()
@@ -7402,8 +7472,9 @@
$index
-
+
$algo
+ $blockSize
$c
$hashParam
$ipad
@@ -7416,21 +7487,6 @@
hash($this->algo, $this->key, true)
is_string($this->key)
-
- $this->blockSize
- $this->blockSize
- $this->blockSize
- $this->blockSize
- $this->blockSize
- $this->blockSize
- $this->blockSize
- $this->blockSize
- $this->blockSize
-
-
- $this->blockSize
- $this->blockSize
-
$b
@@ -7726,6 +7782,10 @@
RSA::load($privatekeystr)
+
+ $privateExponent
+ $publicExponent
+
$bits
$components['MGFHash']
@@ -7863,12 +7923,10 @@
!isset($this->modulus)
$this->modulus->getLength()
-
+
$key->coefficients
$key->exponents
$key->primes
- $key->privateExponent
- $key->publicExponent
$i0
@@ -8245,9 +8303,9 @@
- function ($var) {
- function ($var) {
- function ($var) {
+ fn ($var) => clone $var
+ fn ($var) => clone $var
+ fn ($var) => clone $var
$components['primes'][1]
@@ -8338,9 +8396,6 @@
string
-
- $publicExponent
-
$key
$r
@@ -8517,9 +8572,6 @@
$decoded
$decoded
-
- $this->publicExponent
-
$pkcs15_compat
@@ -8528,8 +8580,7 @@
$length
-
- 0
+
1
@@ -8560,9 +8611,8 @@
$r
$r
-
+
$old_session_id
- $old_use_cookies
isset($_COOKIE)
@@ -9196,13 +9246,7 @@
string
-
- $A + $B
- $A + $B
- $A + $B
- $A + $B
- $A + $B
- $A + $B
+
$le_longs[1]
$le_longs[1]
$le_longs[1]
@@ -9221,14 +9265,6 @@
$le_longs[6]
$le_longs[7]
$le_longs[8]
- $t0 + $t1 + $K[++$ki]
- $t0 + $t1 + $K[++$ki]
- $t0 + $t1 + $K[--$ki]
- $t0 + $t1 + $K[--$ki]
- $t0 + ($t1 << 1) + $K[++$ki]
- $t0 + ($t1 << 1) + $K[++$ki]
- $t0 + ($t1 << 1) + $K[--$ki]
- $t0 + ($t1 << 1) + $K[--$ki]
$S0[ $R0 & 0xff]
@@ -9372,7 +9408,13 @@
$q1[$q1[$q0[$q1[$i] ^ $sf] ^ $sb] ^ $s7]
$q1[$q1[$q0[$q1[$j] ^ $key[32]] ^ $key[24]] ^ $key[16]]
-
+
+ $A
+ $A
+ $A
+ $A
+ $A
+ $A
$A
$A
$A
@@ -9382,6 +9424,12 @@
$B
$B
$B
+ $K[]
+ $K[]
+ $K[]
+ $K[]
+ $K[]
+ $K[]
$R0
$R0
$R0
@@ -9423,13 +9471,19 @@
$t1
$t1
-
+
+ $A
+ $A
+ $A
+ $A
+ $A
+ $A
+ $A
+ $A
+ $A
$A
$A
$A
- $B
- $B
- $B
$B
$B
$B
@@ -10603,7 +10657,7 @@
$x
- function ($x) {
+ fn ($x) => '\x' . bin2hex($x[0])
$dn
@@ -11169,8 +11223,8 @@
$parts['host']
+ $parts['path']
$parts['scheme']
- $parts[path]
$results[$i + 1]
$results[$i]
@@ -11259,8 +11313,8 @@
$parts['host']
+ $parts['path']
$parts['scheme']
- $parts[path]
$decoded[0]
@@ -11785,7 +11839,7 @@
$this->value[0]
$y->value[0]
-
+
$current
$current
$current
@@ -11810,7 +11864,6 @@
$this->value
$this->value
$this->value
- $this->value
$u
$v
$v
@@ -12778,6 +12831,9 @@
toBytes
+
+ new $class($result, 256)
+
@@ -12788,11 +12844,10 @@
$x
-
+
$prime
$s
$temp
- $temp
$temp->value
$temp[self::VALUE]
$temp[self::VALUE]
@@ -13722,7 +13777,7 @@
$custom_reduction
-
+
$class::BASE_FULL
$class::BASE_FULL
$class::MAX_DIGIT2
@@ -13730,11 +13785,13 @@
$class::MAX_DIGIT2
$class::MAX_DIGIT2
$known[$j] * $class::BASE_FULL + $known[$i]
- $m
- $m->value
$m1
$u
+
+ array_map(self::class . '::float2string', $m)
+ array_map(self::class . '::float2string', $m->value)
+
$m1
$u
@@ -13808,18 +13865,10 @@
$m->value
$m->value
-
- $m
- $m->value
-
generateCustomReduction
reduce
-
- $m
- $m->value
-
@@ -14362,8 +14411,7 @@
randomInteger
setReduction
-
- $this->modulo
+
$this->reduce
@@ -14450,7 +14498,7 @@
readlink
realpath
-
+
$a['filename']
$attr['mode']
$b['filename']
@@ -14523,13 +14571,16 @@
$this->realpath($path)
$this->server_channels[self::CHANNEL]
$this->server_channels[self::CHANNEL]
+ NET_SFTP_LOGGING
-
+
$props['type']
$props['type']
$result->{$type}[$prop]
$temp[$dir]
$temp[$dir]
+ $this->packet_types[$this->packet_type]
+ $this->packet_types[$type]
$this->requestBuffer[$request_id]['packet']
$this->requestBuffer[$request_id]['packet_type']
@@ -14621,7 +14672,7 @@
string
string|bool
-
+
$a[$sort]
$a[$sort]
$attr
@@ -14644,6 +14695,8 @@
$subtemp
$temp
$temp
+ $this->packet_types[$this->packet_type]
+ $this->packet_types[$type]
$this->realpath($dir . '/..')
$value
$value
@@ -14696,7 +14749,7 @@
false
false
-
+
$data
$data
$data
@@ -14704,6 +14757,7 @@
$data
$local_file
$local_file
+ $this->realtime_log_file
$stat['atime']
@@ -14810,8 +14864,12 @@
bool
-
+
$defaultVersion
+ $log_size
+ $realtime_log_file
+ $realtime_log_size
+ $realtime_log_wrap
$version
SFTP
SFTP
@@ -14830,6 +14888,13 @@
is_string($mode)
is_string($mode) && is_int($filename)
+
+ NET_SFTP_LOGGING
+
+
+ $this->packet_types
+ $this->packet_types
+
break;
@@ -15059,7 +15124,7 @@
-
+
$arg instanceof Agent
$arg instanceof PrivateKey || $arg instanceof Agent
$request_channel === false
@@ -15068,6 +15133,7 @@
is_array($arg)
is_array($arg)
is_null($this->exit_status)
+ isset($realtime_log_file)
false
@@ -15104,16 +15170,15 @@
$host
$password
-
+
$keepAlive
$quiet_mode
- $realtime_log_wrap
connect
get_channel_packet
-
+
$a['comp']
$a['crypt']
$a['mac']
@@ -15225,8 +15290,9 @@
$type
$type
$type
+ NET_SSH2_LOGGING
+ array_shift($message_log)
array_shift($this->channel_buffers[$client_channel])
- array_shift($this->message_log)
$diff
@@ -15472,13 +15538,12 @@
$packet
$packet
deflate_add($this->compress_context, $data, ZLIB_PARTIAL_FLUSH)
- ftell($this->realtime_log_file)
+ ftell($realtime_log_file)
pack('N', $this->get_seq_no)
pack('N', $this->send_seq_no)
pack('N', $this->send_seq_no)
-
- $fp
+
$this->hmac_create = false
@fsockopen($this->host, $this->port, $errno, $errstr, $this->curTimeout == 0 ? 100000 : $this->curTimeout)
false
@@ -15494,7 +15559,7 @@
false
inflate_init(ZLIB_ENCODING_RAW, ['window' => $cinfo + 8])
-
+
$args
$engine
$password
@@ -15513,6 +15578,7 @@
$this->decompress_context
$this->fsock
$this->fsock
+ $this->realtime_log_file
$temp['length']
@@ -15523,7 +15589,8 @@
$this->decryptInvocationCounter
$this->encryptInvocationCounter
- array_shift($this->message_log)
+ array_shift($message_log)
+ preg_replace_callback('#.#s', fn ($matches) => $this->log_boundary . str_pad(dechex(ord($matches[0])), 2, '0', STR_PAD_LEFT), $fragment)
$raw
@@ -15606,7 +15673,7 @@
($callback is callable ? bool : string|bool)
-
+
$agent
$curTimeout
$decompress_context
@@ -15623,6 +15690,7 @@
$port
$realtime_log_file
$realtime_log_size
+ $realtime_log_wrap
$server_public_host_key
$stdErrorLog
$timeout
@@ -15637,13 +15705,12 @@
isset($this->keyboard_requests_responses)
isset($this->realtime_log_file) && is_resource($this->realtime_log_file)
-
+
isset($this->agent)
isset($this->agent)
isset($this->realtime_log_file)
- isset($this->realtime_log_file)
-
+
$payload
$payload
$payload
@@ -15651,6 +15718,7 @@
$payload
$payload
$payload
+ $realtime_log_file
$response
$response
$response
@@ -15666,6 +15734,10 @@
$hasArray
$hasString
+
+ NET_SSH2_LOGGING
+ NET_SSH2_LOG_REALTIME_FILENAME
+
withPadding
withSignatureFormat
@@ -16255,7 +16327,7 @@
callFunc
getVar
-
+
$expected
$expected
$filename
@@ -16263,8 +16335,6 @@
$func
$obj
$obj
- $obj
- $obj
$params
$value
$var
@@ -16848,12 +16918,20 @@
-
- $components['dA']
-
$key
+
+ $components['dA']
+
+
+ $components['dA']
+ $components['secret']
+
+
+ $arr['dA']
+ $arr['secret']
+
load
diff --git a/composer.json b/composer.json
index 6ed2577a..9b94c1b6 100644
--- a/composer.json
+++ b/composer.json
@@ -21,7 +21,7 @@
"asn.1",
"BigInteger"
],
- "homepage": "http://phpseclib.sourceforge.net",
+ "homepage": "https://phpseclib.com/",
"license": "MIT",
"authors": [
{
@@ -48,10 +48,16 @@
"name": "Graham Campbell",
"email": "graham@alt-three.com",
"role": "Developer"
+ },
+ {
+ "name": "Jack Worman",
+ "email": "jack.worman@gmail.com",
+ "role": "Developer",
+ "homepage": "https://jackworman.com"
}
],
"require": {
- "php": ">=7.3",
+ "php": ">=8.1",
"paragonie/constant_time_encoding": "^2"
},
"require-dev": {
diff --git a/phpseclib/Crypt/Blowfish.php b/phpseclib/Crypt/Blowfish.php
index 980ecb46..fa51ab46 100644
--- a/phpseclib/Crypt/Blowfish.php
+++ b/phpseclib/Crypt/Blowfish.php
@@ -536,20 +536,13 @@ class Blowfish extends BlockCipher
$p[14] ^ $key[14],
$p[15] ^ $key[15],
$p[16] ^ $key[0],
- $p[17] ^ $key[1]
+ $p[17] ^ $key[1],
];
- // @codingStandardsIgnoreStart
- [ $p[0], $p[1]] = self::encryptBlockHelper( 0, 0, $sbox0, $sbox1, $sbox2, $sbox3, $p);
- [ $p[2], $p[3]] = self::encryptBlockHelper($p[ 0], $p[ 1], $sbox0, $sbox1, $sbox2, $sbox3, $p);
- [ $p[4], $p[5]] = self::encryptBlockHelper($p[ 2], $p[ 3], $sbox0, $sbox1, $sbox2, $sbox3, $p);
- [ $p[6], $p[7]] = self::encryptBlockHelper($p[ 4], $p[ 5], $sbox0, $sbox1, $sbox2, $sbox3, $p);
- [ $p[8], $p[9]] = self::encryptBlockHelper($p[ 6], $p[ 7], $sbox0, $sbox1, $sbox2, $sbox3, $p);
- [$p[10], $p[11]] = self::encryptBlockHelper($p[ 8], $p[ 9], $sbox0, $sbox1, $sbox2, $sbox3, $p);
- [$p[12], $p[13]] = self::encryptBlockHelper($p[10], $p[11], $sbox0, $sbox1, $sbox2, $sbox3, $p);
- [$p[14], $p[15]] = self::encryptBlockHelper($p[12], $p[13], $sbox0, $sbox1, $sbox2, $sbox3, $p);
- [$p[16], $p[17]] = self::encryptBlockHelper($p[14], $p[15], $sbox0, $sbox1, $sbox2, $sbox3, $p);
- // @codingStandardsIgnoreEnd
+ [$p[0], $p[1]] = self::encryptBlockHelper(0, 0, $sbox0, $sbox1, $sbox2, $sbox3, $p);
+ for ($i = 2; $i < 18; $i += 2) {
+ [$p[$i], $p[$i + 1]] = self::encryptBlockHelper($p[$i - 2], $p[$i - 1], $sbox0, $sbox1, $sbox2, $sbox3, $p);
+ }
[$sbox0[0], $sbox0[1]] = self::encryptBlockHelper($p[16], $p[17], $sbox0, $sbox1, $sbox2, $sbox3, $p);
for ($i = 2; $i < 256; $i += 2) {
@@ -605,20 +598,13 @@ class Blowfish extends BlockCipher
$p[14] ^ $key[14],
$p[15] ^ $key[15],
$p[16] ^ $key[0],
- $p[17] ^ $key[1]
+ $p[17] ^ $key[1],
];
- // @codingStandardsIgnoreStart
- [ $p[0], $p[1]] = self::encryptBlockHelper($data[ 0] , $data[ 1] , $sbox0, $sbox1, $sbox2, $sbox3, $p);
- [ $p[2], $p[3]] = self::encryptBlockHelper($data[ 2] ^ $p[ 0], $data[ 3] ^ $p[ 1], $sbox0, $sbox1, $sbox2, $sbox3, $p);
- [ $p[4], $p[5]] = self::encryptBlockHelper($data[ 4] ^ $p[ 2], $data[ 5] ^ $p[ 3], $sbox0, $sbox1, $sbox2, $sbox3, $p);
- [ $p[6], $p[7]] = self::encryptBlockHelper($data[ 6] ^ $p[ 4], $data[ 7] ^ $p[ 5], $sbox0, $sbox1, $sbox2, $sbox3, $p);
- [ $p[8], $p[9]] = self::encryptBlockHelper($data[ 8] ^ $p[ 6], $data[ 9] ^ $p[ 7], $sbox0, $sbox1, $sbox2, $sbox3, $p);
- [$p[10], $p[11]] = self::encryptBlockHelper($data[10] ^ $p[ 8], $data[11] ^ $p[ 9], $sbox0, $sbox1, $sbox2, $sbox3, $p);
- [$p[12], $p[13]] = self::encryptBlockHelper($data[12] ^ $p[10], $data[13] ^ $p[11], $sbox0, $sbox1, $sbox2, $sbox3, $p);
- [$p[14], $p[15]] = self::encryptBlockHelper($data[14] ^ $p[12], $data[15] ^ $p[13], $sbox0, $sbox1, $sbox2, $sbox3, $p);
- [$p[16], $p[17]] = self::encryptBlockHelper($data[ 0] ^ $p[14], $data[ 1] ^ $p[15], $sbox0, $sbox1, $sbox2, $sbox3, $p);
- // @codingStandardsIgnoreEnd
+ [$p[0], $p[1]] = self::encryptBlockHelper($data[0], $data[1], $sbox0, $sbox1, $sbox2, $sbox3, $p);
+ for ($i = 2, $j = 2; $i < 18; $i += 2, $j = ($j + 2) % 16) {
+ [$p[$i], $p[$i + 1]] = self::encryptBlockHelper($data[$j] ^ $p[$i - 2], $data[$j + 1] ^ $p[$i - 1], $sbox0, $sbox1, $sbox2, $sbox3, $p);
+ }
[$sbox0[0], $sbox0[1]] = self::encryptBlockHelper($data[2] ^ $p[16], $data[3] ^ $p[17], $sbox0, $sbox1, $sbox2, $sbox3, $p);
for ($i = 2, $j = 4; $i < 256; $i += 2, $j = ($j + 2) % 16) { // instead of 16 maybe count($data) would be better?
diff --git a/phpseclib/Crypt/Common/AsymmetricKey.php b/phpseclib/Crypt/Common/AsymmetricKey.php
index 465dbbb5..9e1f7aad 100644
--- a/phpseclib/Crypt/Common/AsymmetricKey.php
+++ b/phpseclib/Crypt/Common/AsymmetricKey.php
@@ -15,9 +15,7 @@ declare(strict_types=1);
namespace phpseclib3\Crypt\Common;
-use phpseclib3\Crypt\DSA;
use phpseclib3\Crypt\Hash;
-use phpseclib3\Crypt\RSA;
use phpseclib3\Exception\NoKeyLoadedException;
use phpseclib3\Exception\UnsupportedFormatException;
use phpseclib3\Math\BigInteger;
@@ -152,7 +150,7 @@ abstract class AsymmetricKey
}
$components['format'] = $format;
- $components['secret'] = $components['secret'] ?? '';
+ $components['secret'] ??= '';
$comment = $components['comment'] ?? null;
$new = static::onLoad($components);
$new->format = $format;
@@ -226,7 +224,7 @@ abstract class AsymmetricKey
}
$components['format'] = $format;
- $components['secret'] = $components['secret'] ?? '';
+ $components['secret'] ??= '';
$new = static::onLoad($components);
$new->format = $format;
diff --git a/phpseclib/Crypt/Common/Formats/Keys/OpenSSH.php b/phpseclib/Crypt/Common/Formats/Keys/OpenSSH.php
index 8df464a3..f0d38b6d 100644
--- a/phpseclib/Crypt/Common/Formats/Keys/OpenSSH.php
+++ b/phpseclib/Crypt/Common/Formats/Keys/OpenSSH.php
@@ -20,7 +20,6 @@ namespace phpseclib3\Crypt\Common\Formats\Keys;
use phpseclib3\Common\Functions\Strings;
use phpseclib3\Crypt\AES;
use phpseclib3\Crypt\Random;
-use phpseclib3\Exception\UnsupportedFormatException;
/**
* OpenSSH Formatted RSA Key Handler
@@ -67,7 +66,7 @@ abstract class OpenSSH
// key format is described here:
// https://cvsweb.openbsd.org/cgi-bin/cvsweb/src/usr.bin/ssh/PROTOCOL.key?annotate=HEAD
- if (strpos($key, 'BEGIN OPENSSH PRIVATE KEY') !== false) {
+ if (str_contains($key, 'BEGIN OPENSSH PRIVATE KEY')) {
$key = preg_replace('#(?:^-.*?-[\r\n]*$)|\s#ms', '', $key);
$key = Strings::base64_decode($key);
$magic = Strings::shift($key, 15);
diff --git a/phpseclib/Crypt/Common/Formats/Keys/PuTTY.php b/phpseclib/Crypt/Common/Formats/Keys/PuTTY.php
index 8d49ce13..3fd5cfcd 100644
--- a/phpseclib/Crypt/Common/Formats/Keys/PuTTY.php
+++ b/phpseclib/Crypt/Common/Formats/Keys/PuTTY.php
@@ -120,7 +120,7 @@ abstract class PuTTY
throw new \UnexpectedValueException('Key should be a string - not a ' . gettype($key));
}
- if (strpos($key, 'BEGIN SSH2 PUBLIC KEY') !== false) {
+ if (str_contains($key, 'BEGIN SSH2 PUBLIC KEY')) {
$lines = preg_split('#[\r\n]+#', $key);
switch (true) {
case $lines[0] != '---- BEGIN SSH2 PUBLIC KEY ----':
@@ -129,9 +129,7 @@ abstract class PuTTY
throw new \UnexpectedValueException('Key doesn\'t end with ---- END SSH2 PUBLIC KEY ----');
}
$lines = array_splice($lines, 1, -1);
- $lines = array_map(function ($line) {
- return rtrim($line, "\r\n");
- }, $lines);
+ $lines = array_map(fn ($line) => rtrim($line, "\r\n"), $lines);
$data = $current = '';
$values = [];
$in_value = false;
diff --git a/phpseclib/Crypt/DH/Formats/Keys/PKCS8.php b/phpseclib/Crypt/DH/Formats/Keys/PKCS8.php
index c774f0c0..2918af16 100644
--- a/phpseclib/Crypt/DH/Formats/Keys/PKCS8.php
+++ b/phpseclib/Crypt/DH/Formats/Keys/PKCS8.php
@@ -66,7 +66,7 @@ abstract class PKCS8 extends Progenitor
throw new \UnexpectedValueException('Key should be a string - not a ' . gettype($key));
}
- $isPublic = strpos($key, 'PUBLIC') !== false;
+ $isPublic = str_contains($key, 'PUBLIC');
$key = parent::load($key, $password);
diff --git a/phpseclib/Crypt/DSA/Formats/Keys/PKCS8.php b/phpseclib/Crypt/DSA/Formats/Keys/PKCS8.php
index f5a440a0..f90ead08 100644
--- a/phpseclib/Crypt/DSA/Formats/Keys/PKCS8.php
+++ b/phpseclib/Crypt/DSA/Formats/Keys/PKCS8.php
@@ -70,7 +70,7 @@ abstract class PKCS8 extends Progenitor
throw new \UnexpectedValueException('Key should be a string - not a ' . gettype($key));
}
- $isPublic = strpos($key, 'PUBLIC') !== false;
+ $isPublic = str_contains($key, 'PUBLIC');
$key = parent::load($key, $password);
diff --git a/phpseclib/Crypt/EC/Curves/Ed25519.php b/phpseclib/Crypt/EC/Curves/Ed25519.php
index fd467dea..74e0b2b3 100644
--- a/phpseclib/Crypt/EC/Curves/Ed25519.php
+++ b/phpseclib/Crypt/EC/Curves/Ed25519.php
@@ -18,7 +18,6 @@ use phpseclib3\Crypt\EC\BaseCurves\TwistedEdwards;
use phpseclib3\Crypt\Hash;
use phpseclib3\Crypt\Random;
use phpseclib3\Math\BigInteger;
-use phpseclib3\Math\PrimeField\Integer;
class Ed25519 extends TwistedEdwards
{
@@ -182,7 +181,7 @@ class Ed25519 extends TwistedEdwards
return [
'dA' => $dA,
- 'secret' => $str
+ 'secret' => $str,
];
}
diff --git a/phpseclib/Crypt/EC/Curves/Ed448.php b/phpseclib/Crypt/EC/Curves/Ed448.php
index b0b0827a..52920e01 100644
--- a/phpseclib/Crypt/EC/Curves/Ed448.php
+++ b/phpseclib/Crypt/EC/Curves/Ed448.php
@@ -123,7 +123,7 @@ class Ed448 extends TwistedEdwards
return [
'dA' => $dA,
- 'secret' => $str
+ 'secret' => $str,
];
}
diff --git a/phpseclib/Crypt/EC/Formats/Keys/OpenSSH.php b/phpseclib/Crypt/EC/Formats/Keys/OpenSSH.php
index 84f1d108..c5a59c54 100644
--- a/phpseclib/Crypt/EC/Formats/Keys/OpenSSH.php
+++ b/phpseclib/Crypt/EC/Formats/Keys/OpenSSH.php
@@ -110,9 +110,7 @@ abstract class OpenSSH extends Progenitor
$name = $reflect->getShortName();
$oid = self::$curveOIDs[$name];
- $aliases = array_filter(self::$curveOIDs, function ($v) use ($oid) {
- return $v == $oid;
- });
+ $aliases = array_filter(self::$curveOIDs, fn ($v) => $v == $oid);
$aliases = array_keys($aliases);
for ($i = 0; $i < count($aliases); $i++) {
diff --git a/phpseclib/Crypt/EC/Formats/Keys/PKCS8.php b/phpseclib/Crypt/EC/Formats/Keys/PKCS8.php
index c1c89c67..01e9db8f 100644
--- a/phpseclib/Crypt/EC/Formats/Keys/PKCS8.php
+++ b/phpseclib/Crypt/EC/Formats/Keys/PKCS8.php
@@ -79,7 +79,7 @@ abstract class PKCS8 extends Progenitor
throw new \UnexpectedValueException('Key should be a string - not a ' . gettype($key));
}
- $isPublic = strpos($key, 'PUBLIC') !== false;
+ $isPublic = str_contains($key, 'PUBLIC');
$key = parent::load($key, $password);
diff --git a/phpseclib/Crypt/RSA/Formats/Keys/PKCS1.php b/phpseclib/Crypt/RSA/Formats/Keys/PKCS1.php
index 0a35afba..eb08ad2b 100644
--- a/phpseclib/Crypt/RSA/Formats/Keys/PKCS1.php
+++ b/phpseclib/Crypt/RSA/Formats/Keys/PKCS1.php
@@ -49,9 +49,9 @@ abstract class PKCS1 extends Progenitor
throw new \UnexpectedValueException('Key should be a string - not a ' . gettype($key));
}
- if (strpos($key, 'PUBLIC') !== false) {
+ if (str_contains($key, 'PUBLIC')) {
$components = ['isPublicKey' => true];
- } elseif (strpos($key, 'PRIVATE') !== false) {
+ } elseif (str_contains($key, 'PRIVATE')) {
$components = ['isPublicKey' => false];
} else {
$components = [];
diff --git a/phpseclib/Crypt/RSA/Formats/Keys/PKCS8.php b/phpseclib/Crypt/RSA/Formats/Keys/PKCS8.php
index 6a6495a4..3c452eb5 100644
--- a/phpseclib/Crypt/RSA/Formats/Keys/PKCS8.php
+++ b/phpseclib/Crypt/RSA/Formats/Keys/PKCS8.php
@@ -71,9 +71,9 @@ abstract class PKCS8 extends Progenitor
throw new \UnexpectedValueException('Key should be a string - not a ' . gettype($key));
}
- if (strpos($key, 'PUBLIC') !== false) {
+ if (str_contains($key, 'PUBLIC')) {
$components = ['isPublicKey' => true];
- } elseif (strpos($key, 'PRIVATE') !== false) {
+ } elseif (str_contains($key, 'PRIVATE')) {
$components = ['isPublicKey' => false];
} else {
$components = [];
diff --git a/phpseclib/Crypt/RSA/Formats/Keys/PSS.php b/phpseclib/Crypt/RSA/Formats/Keys/PSS.php
index bf3b09bb..5db9aad0 100644
--- a/phpseclib/Crypt/RSA/Formats/Keys/PSS.php
+++ b/phpseclib/Crypt/RSA/Formats/Keys/PSS.php
@@ -103,7 +103,7 @@ abstract class PSS extends Progenitor
throw new \UnexpectedValueException('Key should be a string - not a ' . gettype($key));
}
- $components = ['isPublicKey' => strpos($key, 'PUBLIC') !== false];
+ $components = ['isPublicKey' => str_contains($key, 'PUBLIC')];
$key = parent::load($key, $password);
diff --git a/phpseclib/Crypt/RSA/Formats/Keys/Raw.php b/phpseclib/Crypt/RSA/Formats/Keys/Raw.php
index ff667dee..46268b88 100644
--- a/phpseclib/Crypt/RSA/Formats/Keys/Raw.php
+++ b/phpseclib/Crypt/RSA/Formats/Keys/Raw.php
@@ -149,15 +149,9 @@ 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(fn ($var) => clone $var, $primes),
+ 'exponents' => array_map(fn ($var) => clone $var, $exponents),
+ 'coefficients' => array_map(fn ($var) => clone $var, $coefficients),
]);
}
diff --git a/phpseclib/Exception/BadConfigurationException.php b/phpseclib/Exception/BadConfigurationException.php
index 3de7fb77..55972c8c 100644
--- a/phpseclib/Exception/BadConfigurationException.php
+++ b/phpseclib/Exception/BadConfigurationException.php
@@ -20,6 +20,6 @@ namespace phpseclib3\Exception;
*
* @author Jim Wigginton
*/
-class BadConfigurationException extends \RuntimeException
+class BadConfigurationException extends \RuntimeException implements ExceptionInterface
{
}
diff --git a/phpseclib/Exception/BadDecryptionException.php b/phpseclib/Exception/BadDecryptionException.php
index 87976c3a..6a36691c 100644
--- a/phpseclib/Exception/BadDecryptionException.php
+++ b/phpseclib/Exception/BadDecryptionException.php
@@ -20,6 +20,6 @@ namespace phpseclib3\Exception;
*
* @author Jim Wigginton
*/
-class BadDecryptionException extends \RuntimeException
+class BadDecryptionException extends \RuntimeException implements ExceptionInterface
{
}
diff --git a/phpseclib/Exception/BadModeException.php b/phpseclib/Exception/BadModeException.php
index 60e1b5e7..22e64459 100644
--- a/phpseclib/Exception/BadModeException.php
+++ b/phpseclib/Exception/BadModeException.php
@@ -20,6 +20,6 @@ namespace phpseclib3\Exception;
*
* @author Jim Wigginton
*/
-class BadModeException extends \RuntimeException
+class BadModeException extends \RuntimeException implements ExceptionInterface
{
}
diff --git a/phpseclib/Exception/ConnectionClosedException.php b/phpseclib/Exception/ConnectionClosedException.php
index 275c4731..1f700114 100644
--- a/phpseclib/Exception/ConnectionClosedException.php
+++ b/phpseclib/Exception/ConnectionClosedException.php
@@ -20,6 +20,6 @@ namespace phpseclib3\Exception;
*
* @author Jim Wigginton
*/
-class ConnectionClosedException extends \RuntimeException
+class ConnectionClosedException extends \RuntimeException implements ExceptionInterface
{
}
diff --git a/phpseclib/Exception/ExceptionInterface.php b/phpseclib/Exception/ExceptionInterface.php
new file mode 100644
index 00000000..7784cec3
--- /dev/null
+++ b/phpseclib/Exception/ExceptionInterface.php
@@ -0,0 +1,12 @@
+
*/
-class FileNotFoundException extends \RuntimeException
+class FileNotFoundException extends \RuntimeException implements ExceptionInterface
{
}
diff --git a/phpseclib/Exception/InconsistentSetupException.php b/phpseclib/Exception/InconsistentSetupException.php
index 7630a729..886a9ba8 100644
--- a/phpseclib/Exception/InconsistentSetupException.php
+++ b/phpseclib/Exception/InconsistentSetupException.php
@@ -20,6 +20,6 @@ namespace phpseclib3\Exception;
*
* @author Jim Wigginton
*/
-class InconsistentSetupException extends \RuntimeException
+class InconsistentSetupException extends \RuntimeException implements ExceptionInterface
{
}
diff --git a/phpseclib/Exception/InsufficientSetupException.php b/phpseclib/Exception/InsufficientSetupException.php
index f0fe8cd4..f1f13be3 100644
--- a/phpseclib/Exception/InsufficientSetupException.php
+++ b/phpseclib/Exception/InsufficientSetupException.php
@@ -20,6 +20,6 @@ namespace phpseclib3\Exception;
*
* @author Jim Wigginton
*/
-class InsufficientSetupException extends \RuntimeException
+class InsufficientSetupException extends \RuntimeException implements ExceptionInterface
{
}
diff --git a/phpseclib/Exception/NoKeyLoadedException.php b/phpseclib/Exception/NoKeyLoadedException.php
index 0724a2b0..c2c1b62a 100644
--- a/phpseclib/Exception/NoKeyLoadedException.php
+++ b/phpseclib/Exception/NoKeyLoadedException.php
@@ -20,6 +20,6 @@ namespace phpseclib3\Exception;
*
* @author Jim Wigginton
*/
-class NoKeyLoadedException extends \RuntimeException
+class NoKeyLoadedException extends \RuntimeException implements ExceptionInterface
{
}
diff --git a/phpseclib/Exception/NoSupportedAlgorithmsException.php b/phpseclib/Exception/NoSupportedAlgorithmsException.php
index 9f5e71c1..e1e2ef99 100644
--- a/phpseclib/Exception/NoSupportedAlgorithmsException.php
+++ b/phpseclib/Exception/NoSupportedAlgorithmsException.php
@@ -20,6 +20,6 @@ namespace phpseclib3\Exception;
*
* @author Jim Wigginton
*/
-class NoSupportedAlgorithmsException extends \RuntimeException
+class NoSupportedAlgorithmsException extends \RuntimeException implements ExceptionInterface
{
}
diff --git a/phpseclib/Exception/RuntimeException.php b/phpseclib/Exception/RuntimeException.php
new file mode 100644
index 00000000..6915803b
--- /dev/null
+++ b/phpseclib/Exception/RuntimeException.php
@@ -0,0 +1,9 @@
+
*/
-class UnableToConnectException extends \RuntimeException
+class UnableToConnectException extends \RuntimeException implements ExceptionInterface
{
}
diff --git a/phpseclib/Exception/UnsupportedAlgorithmException.php b/phpseclib/Exception/UnsupportedAlgorithmException.php
index d42dad24..d18b7171 100644
--- a/phpseclib/Exception/UnsupportedAlgorithmException.php
+++ b/phpseclib/Exception/UnsupportedAlgorithmException.php
@@ -20,6 +20,6 @@ namespace phpseclib3\Exception;
*
* @author Jim Wigginton
*/
-class UnsupportedAlgorithmException extends \RuntimeException
+class UnsupportedAlgorithmException extends \RuntimeException implements ExceptionInterface
{
}
diff --git a/phpseclib/Exception/UnsupportedCurveException.php b/phpseclib/Exception/UnsupportedCurveException.php
index 7d83e375..3a2e5f53 100644
--- a/phpseclib/Exception/UnsupportedCurveException.php
+++ b/phpseclib/Exception/UnsupportedCurveException.php
@@ -20,6 +20,6 @@ namespace phpseclib3\Exception;
*
* @author Jim Wigginton
*/
-class UnsupportedCurveException extends \RuntimeException
+class UnsupportedCurveException extends \RuntimeException implements ExceptionInterface
{
}
diff --git a/phpseclib/Exception/UnsupportedFormatException.php b/phpseclib/Exception/UnsupportedFormatException.php
index ecb1f013..f1b6c19b 100644
--- a/phpseclib/Exception/UnsupportedFormatException.php
+++ b/phpseclib/Exception/UnsupportedFormatException.php
@@ -20,6 +20,6 @@ namespace phpseclib3\Exception;
*
* @author Jim Wigginton
*/
-class UnsupportedFormatException extends \RuntimeException
+class UnsupportedFormatException extends \RuntimeException implements ExceptionInterface
{
}
diff --git a/phpseclib/Exception/UnsupportedOperationException.php b/phpseclib/Exception/UnsupportedOperationException.php
index ab8a26f3..f0dc0185 100644
--- a/phpseclib/Exception/UnsupportedOperationException.php
+++ b/phpseclib/Exception/UnsupportedOperationException.php
@@ -20,6 +20,6 @@ namespace phpseclib3\Exception;
*
* @author Jim Wigginton
*/
-class UnsupportedOperationException extends \RuntimeException
+class UnsupportedOperationException extends \RuntimeException implements ExceptionInterface
{
}
diff --git a/phpseclib/File/ASN1.php b/phpseclib/File/ASN1.php
index f617c801..2922f9c2 100644
--- a/phpseclib/File/ASN1.php
+++ b/phpseclib/File/ASN1.php
@@ -1252,7 +1252,7 @@ abstract class ASN1
}
$prefix = substr($content, 0, 2) >= 50 ? '19' : '20';
$content = $prefix . $content;
- } elseif (strpos($content, '.') !== false) {
+ } elseif (str_contains($content, '.')) {
$format .= '.u';
}
@@ -1260,7 +1260,7 @@ abstract class ASN1
$content = substr($content, 0, -1) . '+0000';
}
- if (strpos($content, '-') !== false || strpos($content, '+') !== false) {
+ if (str_contains($content, '-') || str_contains($content, '+')) {
$format .= 'O';
}
diff --git a/phpseclib/File/X509.php b/phpseclib/File/X509.php
index fc12dd30..96f95c40 100644
--- a/phpseclib/File/X509.php
+++ b/phpseclib/File/X509.php
@@ -1102,8 +1102,8 @@ class X509
if (isset($parts['query'])) {
$path .= '?' . $parts['query'];
}
- fputs($fsock, "GET $path HTTP/1.0\r\n");
- fputs($fsock, "Host: $parts[host]\r\n\r\n");
+ fwrite($fsock, "GET $path HTTP/1.0\r\n");
+ fwrite($fsock, "Host: $parts[host]\r\n\r\n");
$line = fgets($fsock, 1024);
if (strlen($line) < 3) {
return false;
@@ -1842,9 +1842,7 @@ 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 = fn ($x) => '\x' . bin2hex($x[0]);
$value = strtoupper(preg_replace_callback('#[^\x20-\x7E]#', $callback, $value->element));
}
$output .= $desc . '=' . $value;
diff --git a/phpseclib/Math/BigInteger.php b/phpseclib/Math/BigInteger.php
index 06966255..06d6ec46 100644
--- a/phpseclib/Math/BigInteger.php
+++ b/phpseclib/Math/BigInteger.php
@@ -665,9 +665,7 @@ class BigInteger implements \JsonSerializable
public static function min(BigInteger ...$nums): BigInteger
{
$class = self::$mainEngine;
- $nums = array_map(function ($num) {
- return $num->value;
- }, $nums);
+ $nums = array_map(fn ($num) => $num->value, $nums);
return new static($class::min(...$nums));
}
@@ -677,9 +675,7 @@ class BigInteger implements \JsonSerializable
public static function max(BigInteger ...$nums): BigInteger
{
$class = self::$mainEngine;
- $nums = array_map(function ($num) {
- return $num->value;
- }, $nums);
+ $nums = array_map(fn ($num) => $num->value, $nums);
return new static($class::max(...$nums));
}
@@ -755,9 +751,7 @@ class BigInteger implements \JsonSerializable
public function createRecurringModuloFunction()
{
$func = $this->value->createRecurringModuloFunction();
- return function (BigInteger $x) use ($func) {
- return new static($func($x->value));
- };
+ return fn (BigInteger $x) => new static($func($x->value));
}
/**
@@ -769,8 +763,6 @@ class BigInteger implements \JsonSerializable
*/
public function bitwise_split(int $split): array
{
- return array_map(function ($val) {
- return new static($val);
- }, $this->value->bitwise_split($split));
+ return array_map(fn ($val) => new static($val), $this->value->bitwise_split($split));
}
}
diff --git a/phpseclib/Math/BigInteger/Engines/GMP.php b/phpseclib/Math/BigInteger/Engines/GMP.php
index 5471f00b..544d20fd 100644
--- a/phpseclib/Math/BigInteger/Engines/GMP.php
+++ b/phpseclib/Math/BigInteger/Engines/GMP.php
@@ -537,9 +537,7 @@ class GMP extends Engine
public function createRecurringModuloFunction(): \Closure
{
$temp = $this->value;
- return function (GMP $x) use ($temp) {
- return new GMP($x->value % $temp);
- };
+ return fn (GMP $x) => new GMP($x->value % $temp);
}
/**
diff --git a/phpseclib/Math/BigInteger/Engines/OpenSSL.php b/phpseclib/Math/BigInteger/Engines/OpenSSL.php
index 7042037e..142f28cd 100644
--- a/phpseclib/Math/BigInteger/Engines/OpenSSL.php
+++ b/phpseclib/Math/BigInteger/Engines/OpenSSL.php
@@ -57,7 +57,7 @@ abstract class OpenSSL
throw new \UnexpectedValueException(openssl_error_string());
}
- $class = get_class($x);
+ $class = $x::class;
return new $class($result, 256);
}
}
diff --git a/phpseclib/Math/BigInteger/Engines/PHP.php b/phpseclib/Math/BigInteger/Engines/PHP.php
index 77a19281..2019787f 100644
--- a/phpseclib/Math/BigInteger/Engines/PHP.php
+++ b/phpseclib/Math/BigInteger/Engines/PHP.php
@@ -550,7 +550,7 @@ abstract class PHP extends Engine
$lhs = new static();
$rhs = new static();
}
- if (static::class != get_class($temp)) {
+ if (static::class != $temp::class) {
$temp = new static();
$lhs = new static();
$rhs = new static();
diff --git a/phpseclib/Net/SFTP.php b/phpseclib/Net/SFTP.php
index 52c8c2e8..9a7de538 100644
--- a/phpseclib/Net/SFTP.php
+++ b/phpseclib/Net/SFTP.php
@@ -1027,8 +1027,8 @@ class SFTP extends SSH2
}
break;
case 'mode':
- $a[$sort] &= 07777;
- $b[$sort] &= 07777;
+ $a[$sort] &= 0o7777;
+ $b[$sort] &= 0o7777;
// fall-through
default:
if ($a[$sort] === $b[$sort]) {
@@ -1450,7 +1450,7 @@ class SFTP extends SSH2
$filename = $temp;
}
- $attr = pack('N2', Attribute::PERMISSIONS, $mode & 07777);
+ $attr = pack('N2', Attribute::PERMISSIONS, $mode & 0o7777);
if (!$this->setstat($filename, $attr, $recursive)) {
return false;
}
@@ -2183,7 +2183,7 @@ class SFTP extends SSH2
} elseif (is_callable($local_file)) {
$local_file($temp);
} else {
- fputs($fp, $temp);
+ fwrite($fp, $temp);
}
if (is_callable($progressCallback)) {
call_user_func($progressCallback, $offset);
@@ -2825,26 +2825,26 @@ class SFTP extends SSH2
{
// values come from http://lxr.free-electrons.com/source/include/uapi/linux/stat.h#L12
// see, also, http://linux.die.net/man/2/stat
- switch ($mode & 0170000) {// ie. 1111 0000 0000 0000
- case 0000000: // no file type specified - figure out the file type using alternative means
+ switch ($mode & 0o170000) {// ie. 1111 0000 0000 0000
+ case 0: // no file type specified - figure out the file type using alternative means
return false;
- case 0040000:
+ case 0o040000:
return FileType::DIRECTORY;
- case 0100000:
+ case 0o100000:
return FileType::REGULAR;
- case 0120000:
+ case 0o120000:
return FileType::SYMLINK;
// new types introduced in SFTPv5+
// http://tools.ietf.org/html/draft-ietf-secsh-filexfer-05#section-5.2
- case 0010000: // named pipe (fifo)
+ case 0o010000: // named pipe (fifo)
return FileType::FIFO;
- case 0020000: // character special
+ case 0o020000: // character special
return FileType::CHAR_DEVICE;
- case 0060000: // block special
+ case 0o060000: // block special
return FileType::BLOCK_DEVICE;
- case 0140000: // socket
+ case 0o140000: // socket
return FileType::SOCKET;
- case 0160000: // whiteout
+ case 0o160000: // whiteout
// "SPECIAL should be used for files that are of
// a known type which cannot be expressed in the protocol"
return FileType::SPECIAL;
@@ -3030,7 +3030,7 @@ class SFTP extends SSH2
*
* Makes sure that only the last 1MB worth of packets will be logged
*/
- private function append_log(string $message_number, string $message)
+ private function append_log(string $message_number, string $message): void
{
$this->append_log_helper(
NET_SFTP_LOGGING,
diff --git a/phpseclib/Net/SSH2.php b/phpseclib/Net/SSH2.php
index 7dd2010e..adeeb0f5 100644
--- a/phpseclib/Net/SSH2.php
+++ b/phpseclib/Net/SSH2.php
@@ -67,6 +67,7 @@ use phpseclib3\Crypt\Twofish;
use phpseclib3\Exception\ConnectionClosedException;
use phpseclib3\Exception\InsufficientSetupException;
use phpseclib3\Exception\NoSupportedAlgorithmsException;
+use phpseclib3\Exception\RuntimeException;
use phpseclib3\Exception\UnableToConnectException;
use phpseclib3\Exception\UnsupportedAlgorithmException;
use phpseclib3\Exception\UnsupportedCurveException;
@@ -155,7 +156,7 @@ class SSH2
/**
* Outputs the message numbers real-time
*/
- const LOG_SIMPLE_REALTIME = 5;
+ public const LOG_SIMPLE_REALTIME = 5;
/**
* Make sure that the log never gets larger than this
*
@@ -1172,7 +1173,7 @@ class SSH2
$this->identifier = $this->generate_identifier();
if ($this->send_id_string_first) {
- fputs($this->fsock, $this->identifier . "\r\n");
+ fwrite($this->fsock, $this->identifier . "\r\n");
}
/* According to the SSH2 specs,
@@ -1251,7 +1252,7 @@ class SSH2
}
if (!$this->send_id_string_first) {
- fputs($this->fsock, $this->identifier . "\r\n");
+ fwrite($this->fsock, $this->identifier . "\r\n");
}
if (!$this->send_kex_first) {
@@ -1500,8 +1501,8 @@ class SSH2
$exchange_hash_rfc4419 = '';
- if (strpos($this->kex_algorithm, 'curve25519-sha256') === 0 || strpos($this->kex_algorithm, 'ecdh-sha2-nistp') === 0) {
- $curve = strpos($this->kex_algorithm, 'curve25519-sha256') === 0 ?
+ if (str_starts_with($this->kex_algorithm, 'curve25519-sha256') || str_starts_with($this->kex_algorithm, 'ecdh-sha2-nistp')) {
+ $curve = str_starts_with($this->kex_algorithm, 'curve25519-sha256') ?
'Curve25519' :
substr($this->kex_algorithm, 10);
$ourPrivate = EC::createKey($curve);
@@ -1509,7 +1510,7 @@ class SSH2
$clientKexInitMessage = MessageTypeExtra::KEX_ECDH_INIT;
$serverKexReplyMessage = MessageTypeExtra::KEX_ECDH_REPLY;
} else {
- if (strpos($this->kex_algorithm, 'diffie-hellman-group-exchange') === 0) {
+ if (str_starts_with($this->kex_algorithm, 'diffie-hellman-group-exchange')) {
$dh_group_sizes_packed = pack(
'NNN',
$this->kex_dh_group_size_min,
@@ -3264,18 +3265,18 @@ class SSH2
$cmf = ord($payload[0]);
$cm = $cmf & 0x0F;
if ($cm != 8) { // deflate
- user_error("Only CM = 8 ('deflate') is supported ($cm)");
+ throw new UnsupportedAlgorithmException("Only CM = 8 ('deflate') is supported ($cm)");
}
$cinfo = ($cmf & 0xF0) >> 4;
if ($cinfo > 7) {
- user_error("CINFO above 7 is not allowed ($cinfo)");
+ throw new RuntimeException("CINFO above 7 is not allowed ($cinfo)");
}
$windowSize = 1 << ($cinfo + 8);
$flg = ord($payload[1]);
//$fcheck = $flg && 0x0F;
if ((($cmf << 8) | $flg) % 31) {
- user_error('fcheck failed');
+ throw new RuntimeException('fcheck failed');
}
$fdict = boolval($flg & 0x20);
$flevel = ($flg & 0xC0) >> 6;
@@ -3930,7 +3931,7 @@ class SSH2
$packet .= $this->encrypt && $this->encrypt->usesNonce() ? $this->encrypt->getTag() : $hmac;
$start = microtime(true);
- $sent = @fputs($this->fsock, $packet);
+ $sent = @fwrite($this->fsock, $packet);
$stop = microtime(true);
if (defined('NET_SSH2_LOGGING')) {
@@ -3976,17 +3977,9 @@ class SSH2
/**
* Logs data packet helper
*
- * @param int $constant
- * @param string $message_number
- * @param string $message
- * @param array &$message_number_log
- * @param array &$message_log
- * @param int &$log_size
* @param resource &$realtime_log_file
- * @param bool &$realtime_log_wrap
- * @param int &$realtime_log_size
*/
- protected function append_log_helper(int $constant, string $message_number, string $message, array &$message_number_log, array &$message_log, int &$log_size, &$realtime_log_file, bool &$realtime_log_wrap, int &$realtime_log_size)
+ protected function append_log_helper(int $constant, string $message_number, string $message, array &$message_number_log, array &$message_log, int &$log_size, &$realtime_log_file, bool &$realtime_log_wrap, int &$realtime_log_size): void
{
// remove the byte identifying the message type from all but the first two messages (ie. the identification strings)
if (strlen($message_number) > 2) {
@@ -4056,7 +4049,7 @@ class SSH2
$realtime_log_size = strlen($entry);
$realtime_log_wrap = true;
}
- fputs($realtime_log_file, $entry);
+ fwrite($realtime_log_file, $entry);
}
}
@@ -4195,9 +4188,7 @@ class SSH2
$output .= str_pad(dechex($j), 7, '0', STR_PAD_LEFT) . '0 ';
}
$fragment = Strings::shift($current_log, $this->log_short_width);
- $hex = substr(preg_replace_callback('#.#s', function ($matches) {
- return $this->log_boundary . str_pad(dechex(ord($matches[0])), 2, '0', STR_PAD_LEFT);
- }, $fragment), strlen($this->log_boundary));
+ $hex = substr(preg_replace_callback('#.#s', fn ($matches) => $this->log_boundary . str_pad(dechex(ord($matches[0])), 2, '0', STR_PAD_LEFT), $fragment), strlen($this->log_boundary));
// replace non ASCII printable characters with dots
// http://en.wikipedia.org/wiki/ASCII#ASCII_printable_characters
// also replace < with a . since < messes up the output on web browsers
diff --git a/phpseclib/System/SSH/Agent.php b/phpseclib/System/SSH/Agent.php
index 20a93d99..954fdd56 100644
--- a/phpseclib/System/SSH/Agent.php
+++ b/phpseclib/System/SSH/Agent.php
@@ -36,7 +36,6 @@ namespace phpseclib3\System\SSH;
use phpseclib3\Common\Functions\Strings;
use phpseclib3\Crypt\PublicKeyLoader;
-use phpseclib3\Crypt\RSA;
use phpseclib3\Exception\BadConfigurationException;
use phpseclib3\Net\SSH2;
use phpseclib3\System\SSH\Agent\Identity;
@@ -152,7 +151,7 @@ class Agent
}
$packet = pack('NC', 1, self::SSH_AGENTC_REQUEST_IDENTITIES);
- if (strlen($packet) != fputs($this->fsock, $packet)) {
+ if (strlen($packet) != fwrite($this->fsock, $packet)) {
throw new \RuntimeException('Connection closed while requesting identities');
}
diff --git a/phpseclib/System/SSH/Agent/Identity.php b/phpseclib/System/SSH/Agent/Identity.php
index c3920196..0bb770cd 100644
--- a/phpseclib/System/SSH/Agent/Identity.php
+++ b/phpseclib/System/SSH/Agent/Identity.php
@@ -264,7 +264,7 @@ class Identity implements PrivateKey
$this->flags
);
$packet = Strings::packSSH2('s', $packet);
- if (strlen($packet) != fputs($this->fsock, $packet)) {
+ if (strlen($packet) != fwrite($this->fsock, $packet)) {
throw new \RuntimeException('Connection closed during signing');
}
diff --git a/tests/Functional/Net/SFTPStreamTest.php b/tests/Functional/Net/SFTPStreamTest.php
index c219f53d..d38ce4ea 100644
--- a/tests/Functional/Net/SFTPStreamTest.php
+++ b/tests/Functional/Net/SFTPStreamTest.php
@@ -40,7 +40,7 @@ class SFTPStreamTest extends SFTPTestCase
'sftp' => ['session' => $this->sftp],
]);
$fp = fopen($this->buildUrl('te#st.txt'), 'wb', false, $context);
- fputs($fp, 'zzzz');
+ fwrite($fp, 'zzzz');
fclose($fp);
$this->assertContains('te#st.txt', $this->sftp->nlist());
diff --git a/tests/Functional/Net/SFTPUserStoryTest.php b/tests/Functional/Net/SFTPUserStoryTest.php
index e69fc61b..6f440a84 100644
--- a/tests/Functional/Net/SFTPUserStoryTest.php
+++ b/tests/Functional/Net/SFTPUserStoryTest.php
@@ -268,7 +268,7 @@ class SFTPUserStoryTest extends PhpseclibFunctionalTestCase
public function testChModOnFile($sftp)
{
$this->assertNotFalse(
- $sftp->chmod(0755, 'file1.txt'),
+ $sftp->chmod(0o755, 'file1.txt'),
'Failed asserting that chmod() was successful.'
);
@@ -717,12 +717,12 @@ class SFTPUserStoryTest extends PhpseclibFunctionalTestCase
*/
public function testReadableWritable($sftp)
{
- $sftp->chmod(0000, 'offset.txt');
+ $sftp->chmod(0, 'offset.txt');
$this->assertFalse($sftp->is_writable('offset.txt'));
$this->assertFalse($sftp->is_writeable('offset.txt'));
$this->assertFalse($sftp->is_readable('offset.txt'));
- $sftp->chmod(0777, 'offset.txt');
+ $sftp->chmod(0o777, 'offset.txt');
$this->assertTrue($sftp->is_writable('offset.txt'));
$this->assertTrue($sftp->is_writeable('offset.txt'));
$this->assertTrue($sftp->is_readable('offset.txt'));
diff --git a/tests/PhpseclibTestCase.php b/tests/PhpseclibTestCase.php
index 4c273100..0418c7d2 100644
--- a/tests/PhpseclibTestCase.php
+++ b/tests/PhpseclibTestCase.php
@@ -82,7 +82,7 @@ abstract class PhpseclibTestCase extends TestCase
protected static function getVar($obj, $var)
{
- $reflection = new \ReflectionClass(get_class($obj));
+ $reflection = new \ReflectionClass($obj::class);
$prop = $reflection->getProperty($var);
$prop->setAccessible(true);
return $prop->getValue($obj);
@@ -90,7 +90,7 @@ abstract class PhpseclibTestCase extends TestCase
public static function callFunc($obj, $func, $params = [])
{
- $reflection = new \ReflectionClass(get_class($obj));
+ $reflection = new \ReflectionClass($obj::class);
$method = $reflection->getMethod($func);
$method->setAccessible(true);
return $method->invokeArgs($obj, $params);
diff --git a/tests/PsalmBaselineTest.php b/tests/PsalmBaselineTest.php
index ec33f61b..c12045c4 100644
--- a/tests/PsalmBaselineTest.php
+++ b/tests/PsalmBaselineTest.php
@@ -34,7 +34,7 @@ class PsalmBaselineTest extends TestCase
/** @var array{level: int, type: string, tag: string, attributes: array{OCCURRENCES?: int}} $element */
foreach ($values as $element) {
if ($element['level'] === 3 && ($element['type'] === 'open' || $element['type'] === 'complete')) {
- $errorCounts[$element['tag']] = $errorCounts[$element['tag']] ?? 0;
+ $errorCounts[$element['tag']] ??= 0;
$occurrences = $element['attributes']['OCCURRENCES'] ?? 1;
$errorCounts[$element['tag']] += $occurrences;
}
diff --git a/tests/Unit/Crypt/AES/TestCase.php b/tests/Unit/Crypt/AES/TestCase.php
index 98013461..6a984aaa 100644
--- a/tests/Unit/Crypt/AES/TestCase.php
+++ b/tests/Unit/Crypt/AES/TestCase.php
@@ -178,9 +178,7 @@ abstract class TestCase extends PhpseclibTestCase
*/
public function continuousBufferBatteryCombosWithoutSingleCombos(): array
{
- return array_filter($this->continuousBufferBatteryCombos(), function (array $continuousBufferBatteryCombo) {
- return count($continuousBufferBatteryCombo[2]) > 1;
- });
+ return array_filter($this->continuousBufferBatteryCombos(), fn (array $continuousBufferBatteryCombo) => count($continuousBufferBatteryCombo[2]) > 1);
}
/**
diff --git a/tests/Unit/Crypt/ChaCha20Test.php b/tests/Unit/Crypt/ChaCha20Test.php
index 56244092..357de9f5 100644
--- a/tests/Unit/Crypt/ChaCha20Test.php
+++ b/tests/Unit/Crypt/ChaCha20Test.php
@@ -100,7 +100,7 @@ class ChaCha20Test extends PhpseclibTestCase
$c = new ChaCha20();
$c->setPoly1305Key($key);
- $r = new \ReflectionClass(get_class($c));
+ $r = new \ReflectionClass($c::class);
// this unit test is testing Poly1305 independent of ChaCha20, which phpseclib doesn't
// really support, hence this hackish approach
$m = $r->getMethod('poly1305');
@@ -128,7 +128,7 @@ class ChaCha20Test extends PhpseclibTestCase
$c->setKey($key);
$c->setNonce($nonce);
- $r = new \ReflectionClass(get_class($c));
+ $r = new \ReflectionClass($c::class);
$m = $r->getMethod('createPoly1305Key');
$m->setAccessible(true);
$result = $m->invoke($c);
diff --git a/tests/Unit/Crypt/EC/KeyTest.php b/tests/Unit/Crypt/EC/KeyTest.php
index b36700a6..f6689608 100644
--- a/tests/Unit/Crypt/EC/KeyTest.php
+++ b/tests/Unit/Crypt/EC/KeyTest.php
@@ -568,7 +568,7 @@ MIIEDwIBADATBgcqhkjOPQIBBggqhkjOPQMBBwSCA/MwggPvAgEBBIID6P//////
$this->assertSameNL($raw, $key->toString('MontgomeryPrivate'));
}
- public function testOpenSSHEncryptedCreation()
+ public function testOpenSSHEncryptedCreation(): void
{
$key = EC::createKey('Ed25519');
$key = $key->withPassword('test')->toString('OpenSSH');