more backporting

This commit is contained in:
terrafrost 2022-06-23 00:46:12 -05:00
parent 5f137d60ec
commit 250f1a5b51
7 changed files with 31 additions and 37 deletions

View File

@ -430,7 +430,7 @@ class X509
* *
* Returns an associative array describing the X.509 cert or a false if the cert failed to load * Returns an associative array describing the X.509 cert or a false if the cert failed to load
* *
* @param string $cert * @param array|string $cert
* @param int $mode * @param int $mode
* @return mixed * @return mixed
*/ */
@ -1694,7 +1694,7 @@ class X509
* @param bool $withType optional * @param bool $withType optional
* @return mixed * @return mixed
*/ */
public function getDNProp($propName, $dn = null, $withType = false) public function getDNProp($propName, array $dn = null, $withType = false)
{ {
if (!isset($dn)) { if (!isset($dn)) {
$dn = $this->dn; $dn = $this->dn;
@ -1799,7 +1799,7 @@ class X509
* @param array $dn optional * @param array $dn optional
* @return array|bool|string * @return array|bool|string
*/ */
public function getDN($format = self::DN_ARRAY, $dn = null) public function getDN($format = self::DN_ARRAY, array $dn = null)
{ {
if (!isset($dn)) { if (!isset($dn)) {
$dn = isset($this->currentCert['tbsCertList']) ? $this->currentCert['tbsCertList']['issuer'] : $this->dn; $dn = isset($this->currentCert['tbsCertList']) ? $this->currentCert['tbsCertList']['issuer'] : $this->dn;
@ -2241,7 +2241,7 @@ class X509
* @param int $format optional * @param int $format optional
* @return string * @return string
*/ */
public function saveCSR($csr, $format = self::FORMAT_PEM) public function saveCSR(array $csr, $format = self::FORMAT_PEM)
{ {
if (!is_array($csr) || !isset($csr['certificationRequestInfo'])) { if (!is_array($csr) || !isset($csr['certificationRequestInfo'])) {
return false; return false;
@ -2350,7 +2350,7 @@ class X509
* @param int $format optional * @param int $format optional
* @return string * @return string
*/ */
public function saveSPKAC($spkac, $format = self::FORMAT_PEM) public function saveSPKAC(array $spkac, $format = self::FORMAT_PEM)
{ {
if (!is_array($spkac) || !isset($spkac['publicKeyAndChallenge'])) { if (!is_array($spkac) || !isset($spkac['publicKeyAndChallenge'])) {
return false; return false;
@ -2453,7 +2453,7 @@ class X509
* @param int $format optional * @param int $format optional
* @return string * @return string
*/ */
public function saveCRL($crl, $format = self::FORMAT_PEM) public function saveCRL(array $crl, $format = self::FORMAT_PEM)
{ {
if (!is_array($crl) || !isset($crl['tbsCertList'])) { if (!is_array($crl) || !isset($crl['tbsCertList'])) {
return false; return false;
@ -2531,11 +2531,9 @@ class X509
* $subject can be either an existing X.509 cert (if you want to resign it), * $subject can be either an existing X.509 cert (if you want to resign it),
* a CSR or something with the DN and public key explicitly set. * a CSR or something with the DN and public key explicitly set.
* *
* @param \phpseclib3\File\X509 $issuer
* @param \phpseclib3\File\X509 $subject
* @return mixed * @return mixed
*/ */
public function sign($issuer, $subject) public function sign(X509 $issuer, X509 $subject)
{ {
if (!is_object($issuer->privateKey) || empty($issuer->dn)) { if (!is_object($issuer->privateKey) || empty($issuer->dn)) {
return false; return false;
@ -2841,11 +2839,9 @@ class X509
* *
* $issuer's private key needs to be loaded. * $issuer's private key needs to be loaded.
* *
* @param \phpseclib3\File\X509 $issuer
* @param \phpseclib3\File\X509 $crl
* @return mixed * @return mixed
*/ */
public function signCRL($issuer, $crl) public function signCRL(X509 $issuer, X509 $crl)
{ {
if (!is_object($issuer->privateKey) || empty($issuer->dn)) { if (!is_object($issuer->privateKey) || empty($issuer->dn)) {
return false; return false;
@ -3097,7 +3093,7 @@ class X509
* @param string $path * @param string $path
* @return boolean * @return boolean
*/ */
private function isSubArrayValid($root, $path) private function isSubArrayValid(array $root, $path)
{ {
if (!is_array($root)) { if (!is_array($root)) {
return false; return false;
@ -3133,7 +3129,7 @@ class X509
* @param bool $create optional * @param bool $create optional
* @return array|false * @return array|false
*/ */
private function &subArrayUnchecked(&$root, $path, $create = false) private function &subArrayUnchecked(array &$root, $path, $create = false)
{ {
$false = false; $false = false;
@ -3160,7 +3156,7 @@ class X509
* @param bool $create optional * @param bool $create optional
* @return array|false * @return array|false
*/ */
private function &subArray(&$root, $path, $create = false) private function &subArray(array &$root = null, $path, $create = false)
{ {
$false = false; $false = false;
@ -3195,7 +3191,7 @@ class X509
* @param bool $create optional * @param bool $create optional
* @return array|false * @return array|false
*/ */
private function &extensions(&$root, $path = null, $create = false) private function &extensions(array &$root = null, $path = null, $create = false)
{ {
if (!isset($root)) { if (!isset($root)) {
$root = $this->currentCert; $root = $this->currentCert;
@ -3282,7 +3278,7 @@ class X509
* @param string $path optional * @param string $path optional
* @return mixed * @return mixed
*/ */
private function getExtensionHelper($id, $cert = null, $path = null) private function getExtensionHelper($id, array $cert = null, $path = null)
{ {
$extensions = $this->extensions($cert, $path); $extensions = $this->extensions($cert, $path);
@ -3306,7 +3302,7 @@ class X509
* @param string $path optional * @param string $path optional
* @return array * @return array
*/ */
private function getExtensionsHelper($cert = null, $path = null) private function getExtensionsHelper(array $cert = null, $path = null)
{ {
$exts = $this->extensions($cert, $path); $exts = $this->extensions($cert, $path);
$extensions = []; $extensions = [];
@ -3376,7 +3372,7 @@ class X509
* @param string $path * @param string $path
* @return mixed * @return mixed
*/ */
public function getExtension($id, $cert = null, $path = null) public function getExtension($id, array $cert = null, $path = null)
{ {
return $this->getExtensionHelper($id, $cert, $path); return $this->getExtensionHelper($id, $cert, $path);
} }
@ -3388,7 +3384,7 @@ class X509
* @param string $path optional * @param string $path optional
* @return array * @return array
*/ */
public function getExtensions($cert = null, $path = null) public function getExtensions(array $cert = null, $path = null)
{ {
return $this->getExtensionsHelper($cert, $path); return $this->getExtensionsHelper($cert, $path);
} }
@ -3464,7 +3460,7 @@ class X509
* @param array $csr optional * @param array $csr optional
* @return mixed * @return mixed
*/ */
public function getAttribute($id, $disposition = self::ATTR_ALL, $csr = null) public function getAttribute($id, $disposition = self::ATTR_ALL, array $csr = null)
{ {
if (empty($csr)) { if (empty($csr)) {
$csr = $this->currentCert; $csr = $this->currentCert;
@ -3503,7 +3499,7 @@ class X509
* @param array $csr optional * @param array $csr optional
* @return array * @return array
*/ */
public function getAttributes($csr = null) public function getAttributes(array $csr = null)
{ {
if (empty($csr)) { if (empty($csr)) {
$csr = $this->currentCert; $csr = $this->currentCert;
@ -3761,7 +3757,7 @@ class X509
* @param bool $create optional * @param bool $create optional
* @return int|false * @return int|false
*/ */
private function revokedCertificate(&$rclist, $serial, $create = false) private function revokedCertificate(array &$rclist, $serial, $create = false)
{ {
$serial = new BigInteger($serial); $serial = new BigInteger($serial);
@ -3850,7 +3846,7 @@ class X509
* @param array $crl optional * @param array $crl optional
* @return array|bool * @return array|bool
*/ */
public function listRevoked($crl = null) public function listRevoked(array $crl = null)
{ {
if (!isset($crl)) { if (!isset($crl)) {
$crl = $this->currentCert; $crl = $this->currentCert;
@ -3899,7 +3895,7 @@ class X509
* @param array $crl optional * @param array $crl optional
* @return mixed * @return mixed
*/ */
public function getRevokedCertificateExtension($serial, $id, $crl = null) public function getRevokedCertificateExtension($serial, $id, array $crl = null)
{ {
if (!isset($crl)) { if (!isset($crl)) {
$crl = $this->currentCert; $crl = $this->currentCert;
@ -3921,7 +3917,7 @@ class X509
* @param array $crl optional * @param array $crl optional
* @return array|bool * @return array|bool
*/ */
public function getRevokedCertificateExtensions($serial, $crl = null) public function getRevokedCertificateExtensions($serial, array $crl = null)
{ {
if (!isset($crl)) { if (!isset($crl)) {
$crl = $this->currentCert; $crl = $this->currentCert;

View File

@ -1150,7 +1150,7 @@ class SFTP extends SSH2
* @param array $b * @param array $b
* @return int * @return int
*/ */
private function comparator($a, $b) private function comparator(array $a, array $b)
{ {
switch (true) { switch (true) {
case $a['filename'] === '.' || $b['filename'] === '.': case $a['filename'] === '.' || $b['filename'] === '.':

View File

@ -734,7 +734,7 @@ class Stream
* @param array $arguments * @param array $arguments
* @return mixed * @return mixed
*/ */
public function __call($name, $arguments) public function __call($name, array $arguments)
{ {
if (defined('NET_SFTP_STREAM_LOGGING')) { if (defined('NET_SFTP_STREAM_LOGGING')) {
echo $name . '('; echo $name . '(';

View File

@ -2402,7 +2402,7 @@ class SSH2
* @return bool * @return bool
* @throws \RuntimeException on connection error * @throws \RuntimeException on connection error
*/ */
private function keyboard_interactive_process(...$responses) private function keyboard_interactive_process(array ...$responses)
{ {
if (strlen($this->last_interactive_response)) { if (strlen($this->last_interactive_response)) {
$response = $this->last_interactive_response; $response = $this->last_interactive_response;
@ -4376,7 +4376,7 @@ class SSH2
* @param array $message_number_log * @param array $message_number_log
* @return string * @return string
*/ */
protected function format_log($message_log, $message_number_log) protected function format_log(array $message_log, array $message_number_log)
{ {
$output = ''; $output = '';
for ($i = 0; $i < count($message_log); $i++) { for ($i = 0; $i < count($message_log); $i++) {
@ -4427,7 +4427,7 @@ class SSH2
* @param array $array2 * @param array $array2
* @return mixed False if intersection is empty, else intersected value. * @return mixed False if intersection is empty, else intersected value.
*/ */
private static function array_intersect_first($array1, $array2) private static function array_intersect_first(array $array1, array $array2)
{ {
foreach ($array1 as $value) { foreach ($array1 as $value) {
if (in_array($value, $array2)) { if (in_array($value, $array2)) {

View File

@ -36,6 +36,7 @@ use phpseclib3\Common\Functions\Strings;
use phpseclib3\Crypt\PublicKeyLoader; use phpseclib3\Crypt\PublicKeyLoader;
use phpseclib3\Crypt\RSA; use phpseclib3\Crypt\RSA;
use phpseclib3\Exception\BadConfigurationException; use phpseclib3\Exception\BadConfigurationException;
use phpseclib3\Net\SSH2;
use phpseclib3\System\SSH\Agent\Identity; use phpseclib3\System\SSH\Agent\Identity;
/** /**
@ -215,7 +216,7 @@ class Agent
* @param \phpseclib3\Net\SSH2 $ssh * @param \phpseclib3\Net\SSH2 $ssh
* @return bool * @return bool
*/ */
private function request_forwarding($ssh) private function request_forwarding(SSH2 $ssh)
{ {
if (!$ssh->requestAgentForwarding()) { if (!$ssh->requestAgentForwarding()) {
return false; return false;
@ -235,7 +236,7 @@ class Agent
* *
* @param \phpseclib3\Net\SSH2 $ssh * @param \phpseclib3\Net\SSH2 $ssh
*/ */
public function registerChannelOpen($ssh) public function registerChannelOpen(SSH2 $ssh)
{ {
if ($this->forward_status == self::FORWARD_REQUEST) { if ($this->forward_status == self::FORWARD_REQUEST) {
$this->request_forwarding($ssh); $this->request_forwarding($ssh);

View File

@ -108,7 +108,7 @@ class Identity implements PrivateKey
* *
* @param \phpseclib3\Crypt\Common\PublicKey $key * @param \phpseclib3\Crypt\Common\PublicKey $key
*/ */
public function withPublicKey($key) public function withPublicKey(PublicKey $key)
{ {
if ($key instanceof EC) { if ($key instanceof EC) {
if (is_array($key->getCurve()) || !isset(self::$curveAliases[$key->getCurve()])) { if (is_array($key->getCurve()) || !isset(self::$curveAliases[$key->getCurve()])) {

View File

@ -382,9 +382,6 @@ abstract class TestCase extends PhpseclibTestCase
); );
} }
/**
* @requires PHP 5.6
*/
public function testDebugInfo() public function testDebugInfo()
{ {
$num = $this->getInstance(50); $num = $this->getInstance(50);