Merge pull request #759 from bantu/ssh2-function-key_exchange-no-static

[2.0] SSH2: Remove all static variables as loadable classes may change at runtime.

* bantu/ssh2-function-key_exchange-no-static:
  SSH2: Remove all static variables as loadable classes may change at runtime.
This commit is contained in:
Andreas Fischer 2015-08-13 14:25:21 -04:00
commit f29805e394

View File

@ -1147,7 +1147,7 @@ class SSH2
*/ */
function _key_exchange($kexinit_payload_server) function _key_exchange($kexinit_payload_server)
{ {
static $kex_algorithms = array( $kex_algorithms = array(
// Elliptic Curve Diffie-Hellman Key Agreement (ECDH) using // Elliptic Curve Diffie-Hellman Key Agreement (ECDH) using
// Curve25519. See doc/curve25519-sha256@libssh.org.txt in the // Curve25519. See doc/curve25519-sha256@libssh.org.txt in the
// libssh repository for more information. // libssh repository for more information.
@ -1167,13 +1167,11 @@ class SSH2
); );
} }
static $server_host_key_algorithms = array( $server_host_key_algorithms = array(
'ssh-rsa', // RECOMMENDED sign Raw RSA Key 'ssh-rsa', // RECOMMENDED sign Raw RSA Key
'ssh-dss' // REQUIRED sign Raw DSS Key 'ssh-dss' // REQUIRED sign Raw DSS Key
); );
static $encryption_algorithms = false;
if ($encryption_algorithms === false) {
$encryption_algorithms = array( $encryption_algorithms = array(
// from <http://tools.ietf.org/html/rfc4345#section-4>: // from <http://tools.ietf.org/html/rfc4345#section-4>:
'arcfour256', 'arcfour256',
@ -1250,7 +1248,6 @@ class SSH2
); );
} }
$encryption_algorithms = array_values($encryption_algorithms); $encryption_algorithms = array_values($encryption_algorithms);
}
$mac_algorithms = array( $mac_algorithms = array(
// from <http://www.ietf.org/rfc/rfc6668.txt>: // from <http://www.ietf.org/rfc/rfc6668.txt>:
@ -1263,7 +1260,7 @@ class SSH2
//'none' // OPTIONAL no MAC; NOT RECOMMENDED //'none' // OPTIONAL no MAC; NOT RECOMMENDED
); );
static $compression_algorithms = array( $compression_algorithms = array(
'none' // REQUIRED no compression 'none' // REQUIRED no compression
//'zlib' // OPTIONAL ZLIB (LZ77) compression //'zlib' // OPTIONAL ZLIB (LZ77) compression
); );
@ -1277,17 +1274,11 @@ class SSH2
)); ));
} }
static $str_kex_algorithms, $str_server_host_key_algorithms,
$encryption_algorithms_server_to_client, $mac_algorithms_server_to_client, $compression_algorithms_server_to_client,
$encryption_algorithms_client_to_server, $mac_algorithms_client_to_server, $compression_algorithms_client_to_server;
if (empty($str_kex_algorithms)) {
$str_kex_algorithms = implode(',', $kex_algorithms); $str_kex_algorithms = implode(',', $kex_algorithms);
$str_server_host_key_algorithms = implode(',', $server_host_key_algorithms); $str_server_host_key_algorithms = implode(',', $server_host_key_algorithms);
$encryption_algorithms_server_to_client = $encryption_algorithms_client_to_server = implode(',', $encryption_algorithms); $encryption_algorithms_server_to_client = $encryption_algorithms_client_to_server = implode(',', $encryption_algorithms);
$mac_algorithms_server_to_client = $mac_algorithms_client_to_server = implode(',', $mac_algorithms); $mac_algorithms_server_to_client = $mac_algorithms_client_to_server = implode(',', $mac_algorithms);
$compression_algorithms_server_to_client = $compression_algorithms_client_to_server = implode(',', $compression_algorithms); $compression_algorithms_server_to_client = $compression_algorithms_client_to_server = implode(',', $compression_algorithms);
}
$client_cookie = Random::string(16); $client_cookie = Random::string(16);