From 509d9b5b9f539cebaaa905437ba58b5a80a4d4a4 Mon Sep 17 00:00:00 2001 From: Bastian Germann Date: Sun, 28 Mar 2021 23:10:21 +0200 Subject: [PATCH] rpc: libssh2: Enable EC host keys libssh2 has ECDSA and ED25519 support beginning with v1.9.0. libvirt cannot make use of those because it will handle them as unknown key types. Add support for those host key types. Signed-off-by: Bastian Germann Reviewed-by: Neal Gompa Reviewed-by: Michal Privoznik --- src/rpc/virnetsshsession.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/rpc/virnetsshsession.c b/src/rpc/virnetsshsession.c index 07110446d8..f2862979c9 100644 --- a/src/rpc/virnetsshsession.c +++ b/src/rpc/virnetsshsession.c @@ -388,7 +388,21 @@ virNetSSHCheckHostKey(virNetSSHSession *sess) case LIBSSH2_HOSTKEY_TYPE_DSS: keyType = LIBSSH2_KNOWNHOST_KEY_SSHDSS; break; - +#ifdef LIBSSH2_HOSTKEY_TYPE_ED25519 + /* defs from libssh2 v1.9.0 or later */ + case LIBSSH2_HOSTKEY_TYPE_ECDSA_256: + keyType = LIBSSH2_KNOWNHOST_KEY_ECDSA_256; + break; + case LIBSSH2_HOSTKEY_TYPE_ECDSA_384: + keyType = LIBSSH2_KNOWNHOST_KEY_ECDSA_384; + break; + case LIBSSH2_HOSTKEY_TYPE_ECDSA_521: + keyType = LIBSSH2_KNOWNHOST_KEY_ECDSA_521; + break; + case LIBSSH2_HOSTKEY_TYPE_ED25519: + keyType = LIBSSH2_KNOWNHOST_KEY_ED25519; + break; +#endif case LIBSSH2_HOSTKEY_TYPE_UNKNOWN: default: virReportError(VIR_ERR_SSH, "%s",