1
0
mirror of https://github.com/danog/phpseclib.git synced 2024-12-13 09:37:37 +01:00

SSH2: build supported cipher list off of files that are present

This commit is contained in:
terrafrost 2013-06-20 20:51:50 -05:00
parent 2edc9fc0a9
commit adf8afd4eb

View File

@ -942,7 +942,9 @@ class Net_SSH2 {
'ssh-dss' // REQUIRED sign Raw DSS Key
);
static $encryption_algorithms = array(
static $encryption_algorithms = false;
if ($encryption_algorithms === false) {
$encryption_algorithms = array(
// from <http://tools.ietf.org/html/rfc4345#section-4>:
'arcfour256',
'arcfour128',
@ -978,6 +980,33 @@ class Net_SSH2 {
'none' // OPTIONAL no encryption; NOT RECOMMENDED
);
if (!file_exists('Crypt/AES.php')) {
$encryption_algorithms = array_diff(
$encryption_algorithms,
array('aes128-ctr', 'aes192-ctr', 'aes256-ctr', 'aes128-cbc', 'aes192-cbc', 'aes256-cbc')
);
}
if (!file_exists('Crypt/Twofish.php')) {
$encryption_algorithms = array_diff(
$encryption_algorithms,
array('twofish128-ctr', 'twofish192-ctr', 'twofish256-ctr', 'twofish128-cbc', 'twofish192-cbc', 'twofish256-cbc', 'twofish-cbc')
);
}
if (!file_exists('Crypt/Blowfish.php')) {
$encryption_algorithms = array_diff(
$encryption_algorithms,
array('blowfish-ctr', 'blowfish-cbc')
);
}
if (!file_exists('Crypt/TripleDES.php')) {
$encryption_algorithms = array_diff(
$encryption_algorithms,
array('3des-ctr', '3des-cbc')
);
}
$encryption_algorithms = array_values($encryption_algorithms);
}
static $mac_algorithms = array(
'hmac-sha1-96', // RECOMMENDED first 96 bits of HMAC-SHA1 (digest length = 12, key length = 20)
'hmac-sha1', // REQUIRED HMAC-SHA1 (digest length = key length = 20)