From 59a7b1166b666a4e5b76313e72790700c2ffaaed Mon Sep 17 00:00:00 2001 From: terrafrost Date: Mon, 24 Feb 2020 19:20:00 -0600 Subject: [PATCH] SSH2: use RFC8332 auth even if host key algo isn't RSA --- phpseclib/Net/SSH2.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/phpseclib/Net/SSH2.php b/phpseclib/Net/SSH2.php index 75a17717..2da90962 100644 --- a/phpseclib/Net/SSH2.php +++ b/phpseclib/Net/SSH2.php @@ -2398,7 +2398,12 @@ class SSH2 if ($publickey instanceof RSA) { $privatekey = $privatekey->withPadding(RSA::SIGNATURE_PKCS1); - switch ($this->signature_format) { + $algos = ['rsa-sha2-256', 'rsa-sha2-512', 'ssh-rsa']; + if (isset($this->preferred['hostkey'])) { + $algos = array_intersect($this->preferred['hostkey'] , $algos); + } + $algo = self::array_intersect_first($algos, $this->server_host_key_algorithms); + switch ($algo) { case 'rsa-sha2-512': $hash = 'sha512'; $signatureType = 'rsa-sha2-512';