Commit ed7b20e72d0710f329fcfd05001c0c57d424aa09

Miguel Arroz 2020-12-21T17:26:34

Add support for additional hostkey types. Specifically: ECDSA_256, ECDSA_384, ECDSA_521 and ED25519.

diff --git a/include/git2/cert.h b/include/git2/cert.h
index 07ae8c9..f111b13 100644
--- a/include/git2/cert.h
+++ b/include/git2/cert.h
@@ -91,6 +91,14 @@ typedef enum {
 	GIT_CERT_SSH_RAW_TYPE_RSA = 1,
 	/** The raw key is a DSS key. */
 	GIT_CERT_SSH_RAW_TYPE_DSS = 2,
+	/** The raw key is a ECDSA 256 key. */
+	GIT_CERT_SSH_RAW_TYPE_KEY_ECDSA_256 = 3,
+	/** The raw key is a ECDSA 384 key. */
+	GIT_CERT_SSH_RAW_TYPE_KEY_ECDSA_384 = 4,
+	/** The raw key is a ECDSA 521 key. */
+	GIT_CERT_SSH_RAW_TYPE_KEY_ECDSA_521 = 5,
+	/** The raw key is a ED25519 key. */
+	GIT_CERT_SSH_RAW_TYPE_KEY_ED25519 = 6
 } git_cert_ssh_raw_type_t;
 
 /**
diff --git a/src/transports/ssh.c b/src/transports/ssh.c
index c33c08a..3827424 100644
--- a/src/transports/ssh.c
+++ b/src/transports/ssh.c
@@ -580,6 +580,18 @@ post_extract:
 				case LIBSSH2_HOSTKEY_TYPE_DSS:
 					cert.raw_type = GIT_CERT_SSH_RAW_TYPE_DSS;
 					break;
+				case LIBSSH2_HOSTKEY_TYPE_ECDSA_256:
+					cert.raw_type = GIT_CERT_SSH_RAW_TYPE_KEY_ECDSA_256;
+					break;
+				case LIBSSH2_HOSTKEY_TYPE_ECDSA_384:
+					cert.raw_type = GIT_CERT_SSH_RAW_TYPE_KEY_ECDSA_384;
+					break;
+				case LIBSSH2_KNOWNHOST_KEY_ECDSA_521:
+					cert.raw_type = GIT_CERT_SSH_RAW_TYPE_KEY_ECDSA_521;
+					break;
+				case LIBSSH2_HOSTKEY_TYPE_ED25519:
+					cert.raw_type = GIT_CERT_SSH_RAW_TYPE_KEY_ED25519;
+					break;
 				default:
 					cert.raw_type = GIT_CERT_SSH_RAW_TYPE_UNKNOWN;
 			}