mirror of
https://github.com/phpseclib/phpseclib.git
synced 2024-12-30 12:50:38 +00:00
Merge branch 'master' of https://github.com/phpseclib/phpseclib
This commit is contained in:
commit
a6acafa36c
@ -165,13 +165,12 @@ abstract class Strings
|
|||||||
/**
|
/**
|
||||||
* Create SSH2-style string
|
* Create SSH2-style string
|
||||||
*
|
*
|
||||||
* @param mixed $input..
|
* @param $elements[]
|
||||||
* @access public
|
* @access public
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public static function packSSH2()
|
public static function packSSH2(...$elements)
|
||||||
{
|
{
|
||||||
$elements = func_get_args();
|
|
||||||
$format = $elements[0];
|
$format = $elements[0];
|
||||||
array_shift($elements);
|
array_shift($elements);
|
||||||
if (strlen($format) != count($elements)) {
|
if (strlen($format) != count($elements)) {
|
||||||
|
@ -650,12 +650,13 @@ abstract class SymmetricKey
|
|||||||
* @see Crypt/Hash.php
|
* @see Crypt/Hash.php
|
||||||
* @param string $password
|
* @param string $password
|
||||||
* @param string $method
|
* @param string $method
|
||||||
|
* @param $func_args[]
|
||||||
* @throws \LengthException if pbkdf1 is being used and the derived key length exceeds the hash length
|
* @throws \LengthException if pbkdf1 is being used and the derived key length exceeds the hash length
|
||||||
* @return bool
|
* @return bool
|
||||||
* @access public
|
* @access public
|
||||||
* @internal Could, but not must, extend by the child Crypt_* class
|
* @internal Could, but not must, extend by the child Crypt_* class
|
||||||
*/
|
*/
|
||||||
public function setPassword($password, $method = 'pbkdf2')
|
public function setPassword($password, $method = 'pbkdf2', ...$func_args)
|
||||||
{
|
{
|
||||||
$key = '';
|
$key = '';
|
||||||
|
|
||||||
@ -664,23 +665,21 @@ abstract class SymmetricKey
|
|||||||
case 'pkcs12': // from https://tools.ietf.org/html/rfc7292#appendix-B.2
|
case 'pkcs12': // from https://tools.ietf.org/html/rfc7292#appendix-B.2
|
||||||
case 'pbkdf1':
|
case 'pbkdf1':
|
||||||
case 'pbkdf2':
|
case 'pbkdf2':
|
||||||
$func_args = func_get_args();
|
|
||||||
|
|
||||||
// Hash function
|
// Hash function
|
||||||
$hash = isset($func_args[2]) ? strtolower($func_args[2]) : 'sha1';
|
$hash = isset($func_args[0]) ? strtolower($func_args[0]) : 'sha1';
|
||||||
$hashObj = new Hash();
|
$hashObj = new Hash();
|
||||||
$hashObj->setHash($hash);
|
$hashObj->setHash($hash);
|
||||||
|
|
||||||
// WPA and WPA2 use the SSID as the salt
|
// WPA and WPA2 use the SSID as the salt
|
||||||
$salt = isset($func_args[3]) ? $func_args[3] : $this->password_default_salt;
|
$salt = isset($func_args[1]) ? $func_args[1] : $this->password_default_salt;
|
||||||
|
|
||||||
// RFC2898#section-4.2 uses 1,000 iterations by default
|
// RFC2898#section-4.2 uses 1,000 iterations by default
|
||||||
// WPA and WPA2 use 4,096.
|
// WPA and WPA2 use 4,096.
|
||||||
$count = isset($func_args[4]) ? $func_args[4] : 1000;
|
$count = isset($func_args[2]) ? $func_args[2] : 1000;
|
||||||
|
|
||||||
// Keylength
|
// Keylength
|
||||||
if (isset($func_args[5])) {
|
if (isset($func_args[3])) {
|
||||||
$dkLen = $func_args[5];
|
$dkLen = $func_args[3];
|
||||||
} else {
|
} else {
|
||||||
$key_length = $this->explicit_key_length !== false ? $this->explicit_key_length : $this->key_length;
|
$key_length = $this->explicit_key_length !== false ? $this->explicit_key_length : $this->key_length;
|
||||||
$dkLen = $method == 'pbkdf1' ? 2 * $key_length : $key_length;
|
$dkLen = $method == 'pbkdf1' ? 2 * $key_length : $key_length;
|
||||||
|
@ -182,14 +182,14 @@ class DSA extends AsymmetricKey
|
|||||||
* - 'privatekey': The private key.
|
* - 'privatekey': The private key.
|
||||||
* - 'publickey': The public key.
|
* - 'publickey': The public key.
|
||||||
*
|
*
|
||||||
|
* @param $args[]
|
||||||
* @access public
|
* @access public
|
||||||
* @return array|DSA
|
* @return array|DSA
|
||||||
*/
|
*/
|
||||||
static function createKey()
|
static function createKey(...$args)
|
||||||
{
|
{
|
||||||
self::initialize_static_variables();
|
self::initialize_static_variables();
|
||||||
|
|
||||||
$args = func_get_args();
|
|
||||||
if (count($args) == 2 && is_int($args[0]) && is_int($args[1])) {
|
if (count($args) == 2 && is_int($args[0]) && is_int($args[1])) {
|
||||||
$private = self::createParameters($args[0], $args[1]);
|
$private = self::createParameters($args[0], $args[1]);
|
||||||
} else if (count($args) == 1 && $args[0] instanceof DSA) {
|
} else if (count($args) == 1 && $args[0] instanceof DSA) {
|
||||||
|
@ -3478,12 +3478,13 @@ class X509
|
|||||||
/**
|
/**
|
||||||
* Set the domain name's which the cert is to be valid for
|
* Set the domain name's which the cert is to be valid for
|
||||||
*
|
*
|
||||||
|
* @param $domains[]
|
||||||
* @access public
|
* @access public
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function setDomain()
|
public function setDomain(...$domains)
|
||||||
{
|
{
|
||||||
$this->domains = func_get_args();
|
$this->domains = $domains;
|
||||||
$this->removeDNProp('id-at-commonName');
|
$this->removeDNProp('id-at-commonName');
|
||||||
$this->setDNProp('id-at-commonName', $this->domains[0]);
|
$this->setDNProp('id-at-commonName', $this->domains[0]);
|
||||||
}
|
}
|
||||||
@ -3492,11 +3493,11 @@ class X509
|
|||||||
* Set the IP Addresses's which the cert is to be valid for
|
* Set the IP Addresses's which the cert is to be valid for
|
||||||
*
|
*
|
||||||
* @access public
|
* @access public
|
||||||
* @param string $ipAddress optional
|
* @param $ipAddresses[] optional
|
||||||
*/
|
*/
|
||||||
public function setIPAddress()
|
public function setIPAddress(...$ipAddresses)
|
||||||
{
|
{
|
||||||
$this->ipAddresses = func_get_args();
|
$this->ipAddresses = $ipAddresses;
|
||||||
/*
|
/*
|
||||||
if (!isset($this->domains)) {
|
if (!isset($this->domains)) {
|
||||||
$this->removeDNProp('id-at-commonName');
|
$this->removeDNProp('id-at-commonName');
|
||||||
|
@ -398,15 +398,14 @@ class SFTP extends SSH2
|
|||||||
* Login
|
* Login
|
||||||
*
|
*
|
||||||
* @param string $username
|
* @param string $username
|
||||||
* @param string $password
|
* @param $args[] string password
|
||||||
* @throws \UnexpectedValueException on receipt of unexpected packets
|
* @throws \UnexpectedValueException on receipt of unexpected packets
|
||||||
* @return bool
|
* @return bool
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
public function login($username)
|
public function login($username, ...$args)
|
||||||
{
|
{
|
||||||
$args = func_get_args();
|
if (!$this->sublogin($username, ...$args)) {
|
||||||
if (!call_user_func_array([&$this, 'sublogin'], $args)) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1071,12 +1070,12 @@ class SFTP extends SSH2
|
|||||||
* $sftp->setListOrder();
|
* $sftp->setListOrder();
|
||||||
* Don't do any sort of sorting
|
* Don't do any sort of sorting
|
||||||
*
|
*
|
||||||
|
* @param $args[]
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
public function setListOrder()
|
public function setListOrder(...$args)
|
||||||
{
|
{
|
||||||
$this->sortOptions = [];
|
$this->sortOptions = [];
|
||||||
$args = func_get_args();
|
|
||||||
if (empty($args)) {
|
if (empty($args)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1359,12 +1359,11 @@ class SSH1
|
|||||||
* named constants from it, using the value as the name of the constant and the index as the value of the constant.
|
* named constants from it, using the value as the name of the constant and the index as the value of the constant.
|
||||||
* If any of the constants that would be defined already exists, none of the constants will be defined.
|
* If any of the constants that would be defined already exists, none of the constants will be defined.
|
||||||
*
|
*
|
||||||
* @param array $array
|
* @param $args[]
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
private function define_array()
|
private function define_array(...$args)
|
||||||
{
|
{
|
||||||
$args = func_get_args();
|
|
||||||
foreach ($args as $arg) {
|
foreach ($args as $arg) {
|
||||||
foreach ($arg as $key => $value) {
|
foreach ($arg as $key => $value) {
|
||||||
if (!defined($value)) {
|
if (!defined($value)) {
|
||||||
|
@ -2098,29 +2098,26 @@ class SSH2
|
|||||||
* The $password parameter can be a plaintext password, a \phpseclib\Crypt\RSA object or an array
|
* The $password parameter can be a plaintext password, a \phpseclib\Crypt\RSA object or an array
|
||||||
*
|
*
|
||||||
* @param string $username
|
* @param string $username
|
||||||
* @param mixed $password
|
* @param $args[] param mixed $password
|
||||||
* @param mixed $...
|
|
||||||
* @return bool
|
* @return bool
|
||||||
* @see self::_login()
|
* @see self::_login()
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
public function login($username)
|
public function login($username, ...$args)
|
||||||
{
|
{
|
||||||
$args = func_get_args();
|
return $this->sublogin($username, ...$args);
|
||||||
return call_user_func_array([&$this, 'sublogin'], $args);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Login Helper
|
* Login Helper
|
||||||
*
|
*
|
||||||
* @param string $username
|
* @param string $username
|
||||||
* @param mixed $password
|
* @param $args[] param mixed $password
|
||||||
* @param mixed $...
|
|
||||||
* @return bool
|
* @return bool
|
||||||
* @see self::_login_helper()
|
* @see self::_login_helper()
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
protected function sublogin($username)
|
protected function sublogin($username, ...$args)
|
||||||
{
|
{
|
||||||
if (!($this->bitmap & self::MASK_CONSTRUCTOR)) {
|
if (!($this->bitmap & self::MASK_CONSTRUCTOR)) {
|
||||||
if (!$this->connect()) {
|
if (!$this->connect()) {
|
||||||
@ -2128,7 +2125,6 @@ class SSH2
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$args = array_slice(func_get_args(), 1);
|
|
||||||
if (empty($args)) {
|
if (empty($args)) {
|
||||||
return $this->login_helper($username);
|
return $this->login_helper($username);
|
||||||
}
|
}
|
||||||
@ -2375,15 +2371,13 @@ class SSH2
|
|||||||
/**
|
/**
|
||||||
* Handle the keyboard-interactive requests / responses.
|
* Handle the keyboard-interactive requests / responses.
|
||||||
*
|
*
|
||||||
* @param string $responses...
|
* @param $responses[]
|
||||||
* @return bool
|
* @return bool
|
||||||
* @throws \RuntimeException on connection error
|
* @throws \RuntimeException on connection error
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
private function keyboard_interactive_process()
|
private function keyboard_interactive_process(...$responses)
|
||||||
{
|
{
|
||||||
$responses = func_get_args();
|
|
||||||
|
|
||||||
if (strlen($this->last_interactive_response)) {
|
if (strlen($this->last_interactive_response)) {
|
||||||
$response = $this->last_interactive_response;
|
$response = $this->last_interactive_response;
|
||||||
} else {
|
} else {
|
||||||
@ -4058,12 +4052,11 @@ class SSH2
|
|||||||
* named constants from it, using the value as the name of the constant and the index as the value of the constant.
|
* named constants from it, using the value as the name of the constant and the index as the value of the constant.
|
||||||
* If any of the constants that would be defined already exists, none of the constants will be defined.
|
* If any of the constants that would be defined already exists, none of the constants will be defined.
|
||||||
*
|
*
|
||||||
* @param array $array
|
* @param $args[]
|
||||||
* @access protected
|
* @access protected
|
||||||
*/
|
*/
|
||||||
protected function define_array()
|
protected function define_array(...$args)
|
||||||
{
|
{
|
||||||
$args = func_get_args();
|
|
||||||
foreach ($args as $arg) {
|
foreach ($args as $arg) {
|
||||||
foreach ($arg as $key => $value) {
|
foreach ($arg as $key => $value) {
|
||||||
if (!defined($value)) {
|
if (!defined($value)) {
|
||||||
|
Loading…
Reference in New Issue
Block a user