diff svr-runopts.c @ 1659:d32bcb5c557d

Add Ed25519 support (#91) * Add support for Ed25519 as a public key type Ed25519 is a elliptic curve signature scheme that offers better security than ECDSA and DSA and good performance. It may be used for both user and host keys. OpenSSH key import and fuzzer are not supported yet. Initially inspired by Peter Szabo. * Add curve25519 and ed25519 fuzzers * Add import and export of Ed25519 keys
author Vladislav Grishenko <themiron@users.noreply.github.com>
date Wed, 11 Mar 2020 21:09:45 +0500
parents cc0fc5131c5c
children 4b4cfc92c5b7
line wrap: on
line diff
--- a/svr-runopts.c	Fri Oct 18 23:48:16 2019 +0800
+++ b/svr-runopts.c	Wed Mar 11 21:09:45 2020 +0500
@@ -57,6 +57,9 @@
 #if DROPBEAR_ECDSA
 					"		- ecdsa %s\n"
 #endif
+#if DROPBEAR_ED25519
+					"		- ed25519 %s\n"
+#endif
 #if DROPBEAR_DELAY_HOSTKEY
 					"-R		Create hostkeys as required\n" 
 #endif
@@ -117,6 +120,9 @@
 #if DROPBEAR_ECDSA
 					ECDSA_PRIV_FILENAME,
 #endif
+#if DROPBEAR_ED25519
+					ED25519_PRIV_FILENAME,
+#endif
 					MAX_AUTH_TRIES,
 					DROPBEAR_MAX_PORTS, DROPBEAR_DEFPORT, DROPBEAR_PIDFILE,
 					DEFAULT_RECV_WINDOW, DEFAULT_KEEPALIVE, DEFAULT_IDLE_TIMEOUT);
@@ -538,6 +544,13 @@
 	}
 #endif
 #endif /* DROPBEAR_ECDSA */
+
+#if DROPBEAR_ED25519
+	if (type == DROPBEAR_SIGNKEY_ED25519) {
+		loadhostkey_helper("ed25519", (void**)&read_key->ed25519key, (void**)&svr_opts.hostkey->ed25519key, fatal_duplicate);
+	}
+#endif
+
 	sign_key_free(read_key);
 	TRACE(("leave loadhostkey"))
 }
@@ -579,6 +592,9 @@
 #if DROPBEAR_ECDSA
 		loadhostkey(ECDSA_PRIV_FILENAME, 0);
 #endif
+#if DROPBEAR_ED25519
+		loadhostkey(ED25519_PRIV_FILENAME, 0);
+#endif
 	}
 
 #if DROPBEAR_RSA
@@ -642,6 +658,14 @@
 #endif
 #endif /* DROPBEAR_ECDSA */
 
+#if DROPBEAR_ED25519
+	if (!svr_opts.delay_hostkey && !svr_opts.hostkey->ed25519key) {
+		disablekey(DROPBEAR_SIGNKEY_ED25519);
+	} else {
+		any_keys = 1;
+	}
+#endif
+
 	if (!any_keys) {
 		dropbear_exit("No hostkeys available. 'dropbear -R' may be useful or run dropbearkey.");
 	}