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
*
* @param string $cert
* @param array|string $cert
* @param int $mode
* @return mixed
*/
@ -1694,7 +1694,7 @@ class X509
* @param bool $withType optional
* @return mixed
*/
public function getDNProp($propName, $dn = null, $withType = false)
public function getDNProp($propName, array $dn = null, $withType = false)
{
if (!isset($dn)) {
$dn = $this->dn;
@ -1799,7 +1799,7 @@ class X509
* @param array $dn optional
* @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)) {
$dn = isset($this->currentCert['tbsCertList']) ? $this->currentCert['tbsCertList']['issuer'] : $this->dn;
@ -2241,7 +2241,7 @@ class X509
* @param int $format optional
* @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'])) {
return false;
@ -2350,7 +2350,7 @@ class X509
* @param int $format optional
* @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'])) {
return false;
@ -2453,7 +2453,7 @@ class X509
* @param int $format optional
* @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'])) {
return false;
@ -2531,11 +2531,9 @@ class X509
* $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.
*
* @param \phpseclib3\File\X509 $issuer
* @param \phpseclib3\File\X509 $subject
* @return mixed
*/
public function sign($issuer, $subject)
public function sign(X509 $issuer, X509 $subject)
{
if (!is_object($issuer->privateKey) || empty($issuer->dn)) {
return false;
@ -2841,11 +2839,9 @@ class X509
*
* $issuer's private key needs to be loaded.
*
* @param \phpseclib3\File\X509 $issuer
* @param \phpseclib3\File\X509 $crl
* @return mixed
*/
public function signCRL($issuer, $crl)
public function signCRL(X509 $issuer, X509 $crl)
{
if (!is_object($issuer->privateKey) || empty($issuer->dn)) {
return false;
@ -3097,7 +3093,7 @@ class X509
* @param string $path
* @return boolean
*/
private function isSubArrayValid($root, $path)
private function isSubArrayValid(array $root, $path)
{
if (!is_array($root)) {
return false;
@ -3133,7 +3129,7 @@ class X509
* @param bool $create optional
* @return array|false
*/
private function &subArrayUnchecked(&$root, $path, $create = false)
private function &subArrayUnchecked(array &$root, $path, $create = false)
{
$false = false;
@ -3160,7 +3156,7 @@ class X509
* @param bool $create optional
* @return array|false
*/
private function &subArray(&$root, $path, $create = false)
private function &subArray(array &$root = null, $path, $create = false)
{
$false = false;
@ -3195,7 +3191,7 @@ class X509
* @param bool $create optional
* @return array|false
*/
private function &extensions(&$root, $path = null, $create = false)
private function &extensions(array &$root = null, $path = null, $create = false)
{
if (!isset($root)) {
$root = $this->currentCert;
@ -3282,7 +3278,7 @@ class X509
* @param string $path optional
* @return mixed
*/
private function getExtensionHelper($id, $cert = null, $path = null)
private function getExtensionHelper($id, array $cert = null, $path = null)
{
$extensions = $this->extensions($cert, $path);
@ -3306,7 +3302,7 @@ class X509
* @param string $path optional
* @return array
*/
private function getExtensionsHelper($cert = null, $path = null)
private function getExtensionsHelper(array $cert = null, $path = null)
{
$exts = $this->extensions($cert, $path);
$extensions = [];
@ -3376,7 +3372,7 @@ class X509
* @param string $path
* @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);
}
@ -3388,7 +3384,7 @@ class X509
* @param string $path optional
* @return array
*/
public function getExtensions($cert = null, $path = null)
public function getExtensions(array $cert = null, $path = null)
{
return $this->getExtensionsHelper($cert, $path);
}
@ -3464,7 +3460,7 @@ class X509
* @param array $csr optional
* @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)) {
$csr = $this->currentCert;
@ -3503,7 +3499,7 @@ class X509
* @param array $csr optional
* @return array
*/
public function getAttributes($csr = null)
public function getAttributes(array $csr = null)
{
if (empty($csr)) {
$csr = $this->currentCert;
@ -3761,7 +3757,7 @@ class X509
* @param bool $create optional
* @return int|false
*/
private function revokedCertificate(&$rclist, $serial, $create = false)
private function revokedCertificate(array &$rclist, $serial, $create = false)
{
$serial = new BigInteger($serial);
@ -3850,7 +3846,7 @@ class X509
* @param array $crl optional
* @return array|bool
*/
public function listRevoked($crl = null)
public function listRevoked(array $crl = null)
{
if (!isset($crl)) {
$crl = $this->currentCert;
@ -3899,7 +3895,7 @@ class X509
* @param array $crl optional
* @return mixed
*/
public function getRevokedCertificateExtension($serial, $id, $crl = null)
public function getRevokedCertificateExtension($serial, $id, array $crl = null)
{
if (!isset($crl)) {
$crl = $this->currentCert;
@ -3921,7 +3917,7 @@ class X509
* @param array $crl optional
* @return array|bool
*/
public function getRevokedCertificateExtensions($serial, $crl = null)
public function getRevokedCertificateExtensions($serial, array $crl = null)
{
if (!isset($crl)) {
$crl = $this->currentCert;

View File

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

View File

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

View File

@ -2402,7 +2402,7 @@ class SSH2
* @return bool
* @throws \RuntimeException on connection error
*/
private function keyboard_interactive_process(...$responses)
private function keyboard_interactive_process(array ...$responses)
{
if (strlen($this->last_interactive_response)) {
$response = $this->last_interactive_response;
@ -4376,7 +4376,7 @@ class SSH2
* @param array $message_number_log
* @return string
*/
protected function format_log($message_log, $message_number_log)
protected function format_log(array $message_log, array $message_number_log)
{
$output = '';
for ($i = 0; $i < count($message_log); $i++) {
@ -4427,7 +4427,7 @@ class SSH2
* @param array $array2
* @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) {
if (in_array($value, $array2)) {

View File

@ -36,6 +36,7 @@ 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;
/**
@ -215,7 +216,7 @@ class Agent
* @param \phpseclib3\Net\SSH2 $ssh
* @return bool
*/
private function request_forwarding($ssh)
private function request_forwarding(SSH2 $ssh)
{
if (!$ssh->requestAgentForwarding()) {
return false;
@ -235,7 +236,7 @@ class Agent
*
* @param \phpseclib3\Net\SSH2 $ssh
*/
public function registerChannelOpen($ssh)
public function registerChannelOpen(SSH2 $ssh)
{
if ($this->forward_status == self::FORWARD_REQUEST) {
$this->request_forwarding($ssh);

View File

@ -108,7 +108,7 @@ class Identity implements PrivateKey
*
* @param \phpseclib3\Crypt\Common\PublicKey $key
*/
public function withPublicKey($key)
public function withPublicKey(PublicKey $key)
{
if ($key instanceof EC) {
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()
{
$num = $this->getInstance(50);