mirror of
https://github.com/phpseclib/phpseclib.git
synced 2024-11-11 08:10:58 +00:00
rm call_user_func() calls
This commit is contained in:
parent
d37dffdb81
commit
ceff4cfbbc
@ -442,7 +442,7 @@ abstract class PKCS8 extends PKCS
|
|||||||
if (isset($keyLength)) {
|
if (isset($keyLength)) {
|
||||||
$params[] = (int) $keyLength->toString();
|
$params[] = (int) $keyLength->toString();
|
||||||
}
|
}
|
||||||
call_user_func_array([$cipher, 'setPassword'], $params);
|
$cipher->setPassword(...$params);
|
||||||
$key = $cipher->decrypt($decrypted['encryptedData']);
|
$key = $cipher->decrypt($decrypted['encryptedData']);
|
||||||
$decoded = ASN1::decodeBER($key);
|
$decoded = ASN1::decodeBER($key);
|
||||||
if (empty($decoded)) {
|
if (empty($decoded)) {
|
||||||
|
@ -93,7 +93,7 @@ class Hash
|
|||||||
* @var string
|
* @var string
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
private $hash;
|
private $algo;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Key
|
* Key
|
||||||
@ -268,9 +268,9 @@ class Hash
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->computedKey = is_array($this->hash) ?
|
$this->computedKey = is_array($this->algo) ?
|
||||||
call_user_func($this->hash, $this->key) :
|
call_user_func($this->algo, $this->key) :
|
||||||
hash($this->hash, $this->key, true);
|
hash($this->algo, $this->key, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -302,7 +302,7 @@ class Hash
|
|||||||
case 'umac-128':
|
case 'umac-128':
|
||||||
$this->blockSize = 128;
|
$this->blockSize = 128;
|
||||||
$this->length = abs(substr($hash, -3)) >> 3;
|
$this->length = abs(substr($hash, -3)) >> 3;
|
||||||
$this->hash = 'umac';
|
$this->algo = 'umac';
|
||||||
return;
|
return;
|
||||||
case 'md2-96':
|
case 'md2-96':
|
||||||
case 'md5-96':
|
case 'md5-96':
|
||||||
@ -439,7 +439,7 @@ class Hash
|
|||||||
$this->opad = str_repeat(chr(0x5C), $b);
|
$this->opad = str_repeat(chr(0x5C), $b);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->hash = $hash;
|
$this->algo = $hash;
|
||||||
|
|
||||||
$this->computeKey();
|
$this->computeKey();
|
||||||
}
|
}
|
||||||
@ -785,7 +785,8 @@ class Hash
|
|||||||
*/
|
*/
|
||||||
public function hash($text)
|
public function hash($text)
|
||||||
{
|
{
|
||||||
if ($this->hash == 'umac') {
|
$algo = $this->algo;
|
||||||
|
if ($algo == 'umac') {
|
||||||
if ($this->recomputeAESKey) {
|
if ($this->recomputeAESKey) {
|
||||||
if (!is_string($this->nonce)) {
|
if (!is_string($this->nonce)) {
|
||||||
throw new InsufficientSetupException('No nonce has been set');
|
throw new InsufficientSetupException('No nonce has been set');
|
||||||
@ -837,9 +838,9 @@ class Hash
|
|||||||
return $hashedmessage ^ $this->pad;
|
return $hashedmessage ^ $this->pad;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_array($this->hash)) {
|
if (is_array($algo)) {
|
||||||
if (empty($this->key) || !is_string($this->key)) {
|
if (empty($this->key) || !is_string($this->key)) {
|
||||||
return substr(call_user_func($this->hash, $text, ...array_values($this->parameters)), 0, $this->length);
|
return substr($algo($text, ...array_values($this->parameters)), 0, $this->length);
|
||||||
}
|
}
|
||||||
|
|
||||||
// SHA3 HMACs are discussed at https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.202.pdf#page=30
|
// SHA3 HMACs are discussed at https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.202.pdf#page=30
|
||||||
@ -847,17 +848,17 @@ class Hash
|
|||||||
$key = str_pad($this->computedKey, $b, chr(0));
|
$key = str_pad($this->computedKey, $b, chr(0));
|
||||||
$temp = $this->ipad ^ $key;
|
$temp = $this->ipad ^ $key;
|
||||||
$temp .= $text;
|
$temp .= $text;
|
||||||
$temp = substr(call_user_func($this->hash, $temp, ...array_values($this->parameters)), 0, $this->length);
|
$temp = substr($algo($temp, ...array_values($this->parameters)), 0, $this->length);
|
||||||
$output = $this->opad ^ $key;
|
$output = $this->opad ^ $key;
|
||||||
$output.= $temp;
|
$output.= $temp;
|
||||||
$output = call_user_func($this->hash, $output, ...array_values($this->parameters));
|
$output = $algo($output, ...array_values($this->parameters));
|
||||||
|
|
||||||
return substr($output, 0, $this->length);
|
return substr($output, 0, $this->length);
|
||||||
}
|
}
|
||||||
|
|
||||||
$output = !empty($this->key) || is_string($this->key) ?
|
$output = !empty($this->key) || is_string($this->key) ?
|
||||||
hash_hmac($this->hash, $text, $this->computedKey, true) :
|
hash_hmac($algo, $text, $this->computedKey, true) :
|
||||||
hash($this->hash, $text, true);
|
hash($algo, $text, true);
|
||||||
|
|
||||||
return strlen($output) > $this->length
|
return strlen($output) > $this->length
|
||||||
? substr($output, 0, $this->length)
|
? substr($output, 0, $this->length)
|
||||||
|
@ -393,7 +393,7 @@ class RC2 extends BlockCipher
|
|||||||
$l[0] = self::$invpitable[$l[0]];
|
$l[0] = self::$invpitable[$l[0]];
|
||||||
array_unshift($l, 'C*');
|
array_unshift($l, 'C*');
|
||||||
|
|
||||||
$this->key = call_user_func_array('pack', $l);
|
$this->key = pack(...$l);
|
||||||
$this->key_length = strlen($this->key);
|
$this->key_length = strlen($this->key);
|
||||||
$this->changed = $this->nonIVChanged = true;
|
$this->changed = $this->nonIVChanged = true;
|
||||||
$this->setEngine();
|
$this->setEngine();
|
||||||
|
@ -553,7 +553,7 @@ abstract class ASN1
|
|||||||
}
|
}
|
||||||
if (isset($value)) {
|
if (isset($value)) {
|
||||||
if (isset($special[$key])) {
|
if (isset($special[$key])) {
|
||||||
$value = call_user_func($special[$key], $value);
|
$value = $special[$key]($value);
|
||||||
}
|
}
|
||||||
return [$key => $value];
|
return [$key => $value];
|
||||||
}
|
}
|
||||||
@ -637,7 +637,7 @@ abstract class ASN1
|
|||||||
if ($maymatch) {
|
if ($maymatch) {
|
||||||
// Got the match: use it.
|
// Got the match: use it.
|
||||||
if (isset($special[$key])) {
|
if (isset($special[$key])) {
|
||||||
$candidate = call_user_func($special[$key], $candidate);
|
$candidate = $special[$key]($candidate);
|
||||||
}
|
}
|
||||||
$map[$key] = $candidate;
|
$map[$key] = $candidate;
|
||||||
$i++;
|
$i++;
|
||||||
@ -722,7 +722,7 @@ abstract class ASN1
|
|||||||
|
|
||||||
// Got the match: use it.
|
// Got the match: use it.
|
||||||
if (isset($special[$key])) {
|
if (isset($special[$key])) {
|
||||||
$candidate = call_user_func($special[$key], $candidate);
|
$candidate = $special[$key]($candidate);
|
||||||
}
|
}
|
||||||
$map[$key] = $candidate;
|
$map[$key] = $candidate;
|
||||||
break;
|
break;
|
||||||
@ -881,7 +881,7 @@ abstract class ASN1
|
|||||||
|
|
||||||
if (isset($idx)) {
|
if (isset($idx)) {
|
||||||
if (isset($special[$idx])) {
|
if (isset($special[$idx])) {
|
||||||
$source = call_user_func($special[$idx], $source);
|
$source = $special[$idx]($source);
|
||||||
}
|
}
|
||||||
self::$location[] = $idx;
|
self::$location[] = $idx;
|
||||||
}
|
}
|
||||||
|
@ -1941,7 +1941,7 @@ class SFTP extends SSH2
|
|||||||
$i = $j = 0;
|
$i = $j = 0;
|
||||||
while ($dataCallback || ($size === 0 || $sent < $size)) {
|
while ($dataCallback || ($size === 0 || $sent < $size)) {
|
||||||
if ($dataCallback) {
|
if ($dataCallback) {
|
||||||
$temp = call_user_func($dataCallback, $sftp_packet_size);
|
$temp = $dataCallback($sftp_packet_size);
|
||||||
if (is_null($temp)) {
|
if (is_null($temp)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -1962,7 +1962,7 @@ class SFTP extends SSH2
|
|||||||
}
|
}
|
||||||
$sent+= strlen($temp);
|
$sent+= strlen($temp);
|
||||||
if (is_callable($progressCallback)) {
|
if (is_callable($progressCallback)) {
|
||||||
call_user_func($progressCallback, $sent);
|
$progressCallback($sent);
|
||||||
}
|
}
|
||||||
|
|
||||||
$i++;
|
$i++;
|
||||||
@ -2137,7 +2137,7 @@ class SFTP extends SSH2
|
|||||||
$packet = null;
|
$packet = null;
|
||||||
$read+= $packet_size;
|
$read+= $packet_size;
|
||||||
if (is_callable($progressCallback)) {
|
if (is_callable($progressCallback)) {
|
||||||
call_user_func($progressCallback, $read);
|
$progressCallback($read);
|
||||||
}
|
}
|
||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
|
@ -789,6 +789,6 @@ class Stream
|
|||||||
if (!method_exists($this, $name)) {
|
if (!method_exists($this, $name)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return call_user_func_array([$this, $name], $arguments);
|
return $this->$name(...$arguments);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2675,7 +2675,7 @@ class SSH2
|
|||||||
return false;
|
return false;
|
||||||
default:
|
default:
|
||||||
if (is_callable($callback)) {
|
if (is_callable($callback)) {
|
||||||
if (call_user_func($callback, $temp) === true) {
|
if ($callback($temp) === true) {
|
||||||
$this->close_channel(self::CHANNEL_EXEC);
|
$this->close_channel(self::CHANNEL_EXEC);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user