Merge branch '3.0'

This commit is contained in:
terrafrost 2023-11-22 12:45:05 -06:00
commit c6f25ccde3

View File

@ -330,14 +330,6 @@ class SSH2
*/
private array|false $languages_client_to_server = false;
/**
* Server Signature Algorithms
*
* @link https://www.rfc-editor.org/rfc/rfc8308.html#section-3.1
* @var array|false
*/
private $server_sig_algs = false;
/**
* Preferred Algorithms
*
@ -2070,7 +2062,7 @@ class SSH2
for ($i = 0; $i < $nr_extensions; $i++) {
[$extension_name, $extension_value] = Strings::unpackSSH2('ss', $response);
if ($extension_name == 'server-sig-algs') {
$this->server_sig_algs = explode(',', $extension_value);
$this->supported_private_key_algorithms = explode(',', $extension_value);
}
}
@ -2342,9 +2334,7 @@ class SSH2
if ($publickey instanceof RSA) {
$privatekey = $privatekey->withPadding(RSA::SIGNATURE_PKCS1);
$algos = ['rsa-sha2-256', 'rsa-sha2-512', 'ssh-rsa'];
if ($this->server_sig_algs) {
$algos = array_intersect($algos, $this->server_sig_algs);
} elseif (isset($this->preferred['hostkey'])) {
if (isset($this->preferred['hostkey'])) {
$algos = array_intersect($algos, $this->preferred['hostkey']);
}
$algo = self::array_intersect_first($algos, $this->supported_private_key_algorithms);