1
0
mirror of https://github.com/danog/phpseclib.git synced 2024-12-04 18:48:24 +01:00

Merge branch '2.0' into 3.0

This commit is contained in:
terrafrost 2020-07-31 21:27:38 -05:00
commit 92a67a03aa

View File

@ -924,7 +924,7 @@ class SSH2
* @var int * @var int
* @access private * @access private
*/ */
private $crypto_engine = false; private static $crypto_engine = false;
/** /**
* A System_SSH_Agent for use in the SSH2 Agent Forwarding scenario * A System_SSH_Agent for use in the SSH2 Agent Forwarding scenario
@ -1114,9 +1114,9 @@ class SSH2
* @param int $engine * @param int $engine
* @access public * @access public
*/ */
public function setCryptoEngine($engine) public static function setCryptoEngine($engine)
{ {
$this->crypto_engine = $engine; self::$crypto_engine = $engine;
} }
/** /**
@ -1710,8 +1710,8 @@ class SSH2
$this->encrypt = self::encryption_algorithm_to_crypt_instance($encrypt); $this->encrypt = self::encryption_algorithm_to_crypt_instance($encrypt);
if ($this->encrypt) { if ($this->encrypt) {
if ($this->crypto_engine) { if (self::$crypto_engine) {
$this->encrypt->setPreferredEngine($this->crypto_engine); $this->encrypt->setPreferredEngine(self::$crypto_engine);
} }
if ($this->encrypt->getBlockLengthInBytes()) { if ($this->encrypt->getBlockLengthInBytes()) {
$this->encrypt_block_size = $this->encrypt->getBlockLengthInBytes(); $this->encrypt_block_size = $this->encrypt->getBlockLengthInBytes();
@ -1754,8 +1754,8 @@ class SSH2
$this->decrypt = self::encryption_algorithm_to_crypt_instance($decrypt); $this->decrypt = self::encryption_algorithm_to_crypt_instance($decrypt);
if ($this->decrypt) { if ($this->decrypt) {
if ($this->crypto_engine) { if (self::$crypto_engine) {
$this->decrypt->setPreferredEngine($this->crypto_engine); $this->decrypt->setPreferredEngine(self::$crypto_engine);
} }
if ($this->decrypt->getBlockLengthInBytes()) { if ($this->decrypt->getBlockLengthInBytes()) {
$this->decrypt_block_size = $this->decrypt->getBlockLengthInBytes(); $this->decrypt_block_size = $this->decrypt->getBlockLengthInBytes();
@ -4430,6 +4430,9 @@ class SSH2
//'none' // OPTIONAL no encryption; NOT RECOMMENDED //'none' // OPTIONAL no encryption; NOT RECOMMENDED
]; ];
if (self::$crypto_engine) {
$engines = [self::$crypto_engine];
} else {
$engines = [ $engines = [
'libsodium', 'libsodium',
'OpenSSL (GCM)', 'OpenSSL (GCM)',
@ -4438,8 +4441,10 @@ class SSH2
'Eval', 'Eval',
'PHP' 'PHP'
]; ];
}
$ciphers = []; $ciphers = [];
foreach ($engines as $engine) { foreach ($engines as $engine) {
foreach ($algos as $algo) { foreach ($algos as $algo) {
$obj = self::encryption_algorithm_to_crypt_instance($algo); $obj = self::encryption_algorithm_to_crypt_instance($algo);