diff dropbearkey.c @ 841:d4ce5269a439 ecc

Fix specifying a keysize for key generation, fix key name arguments
author Matt Johnston <matt@ucc.asn.au>
date Fri, 01 Nov 2013 00:13:09 +0800
parents 5128e525c8fa
children b298bb438625
line wrap: on
line diff
--- a/dropbearkey.c	Thu Oct 31 22:49:15 2013 +0800
+++ b/dropbearkey.c	Fri Nov 01 00:13:09 2013 +0800
@@ -185,7 +185,24 @@
 		exit(EXIT_FAILURE);
 	}
 
-	keytype = signkey_type_from_name(typetext, strlen(typetext));
+#ifdef DROPBEAR_RSA
+	if (strcmp(typetext, "rsa") == 0)
+	{
+		keytype = DROPBEAR_SIGNKEY_RSA;
+	}
+#endif
+#ifdef DROPBEAR_DSS
+	if (strcmp(typetext, "dss") == 0)
+	{
+		keytype = DROPBEAR_SIGNKEY_DSS;
+	}
+#endif
+#ifdef DROPBEAR_ECDSA
+	if (strcmp(typetext, "ecdsa") == 0)
+	{
+		keytype = DROPBEAR_SIGNKEY_ECDSA_KEYGEN;
+	}
+#endif
 
 	if (keytype == DROPBEAR_SIGNKEY_NONE) {
 		fprintf(stderr, "Unknown key type '%s'\n", typetext);
@@ -221,10 +238,13 @@
 				(void)0; /* quiet, compiler. ecdsa handles checks itself */
         }
 
+    } else {
+    	/* default key size */
+
         switch (keytype) {
 #ifdef DROPBEAR_RSA
             case DROPBEAR_SIGNKEY_RSA:
-                bits = RSA_DEFAULT_SIZE;
+				bits = RSA_DEFAULT_SIZE;
                 break;
 #endif
 #ifdef DROPBEAR_DSS
@@ -269,7 +289,7 @@
 			{
 				ecc_key *ecckey = gen_ecdsa_priv_key(bits);
 				keytype = ecdsa_signkey_type(ecckey);
-				*signkey_ecc_key_ptr(key, keytype) = ecckey;
+				*signkey_key_ptr(key, keytype) = ecckey;
 			}
 			break;
 #endif
@@ -299,7 +319,7 @@
 
 	buffer *buf = NULL;
 	sign_key *key = NULL;
-	int keytype;
+	enum signkey_type keytype;
 	int ret;
 	int err = DROPBEAR_FAILURE;