diff svr-authpubkey.c @ 1675:ae41624c2198

split signkey_type and signature_type for RSA sha1 vs sha256
author Matt Johnston <matt@ucc.asn.au>
date Sun, 17 May 2020 23:58:31 +0800
parents ba6fc7afe1c5
children 064f5be2fc45
line wrap: on
line diff
--- a/svr-authpubkey.c	Mon Apr 06 23:18:26 2020 +0800
+++ b/svr-authpubkey.c	Sun May 17 23:58:31 2020 +0800
@@ -92,7 +92,8 @@
 	buffer * signbuf = NULL;
 	sign_key * key = NULL;
 	char* fp = NULL;
-	enum signkey_type sigtype, keytype;
+	enum signature_type sigtype;
+	enum signkey_type keytype;
     int auth_failure = 1;
 
 	TRACE(("enter pubkeyauth"))
@@ -102,10 +103,6 @@
 	testkey = (buf_getbool(ses.payload) == 0);
 
 	sigalgo = buf_getstring(ses.payload, &sigalgolen);
-	sigtype = signature_type_from_name(sigalgo, sigalgolen);
-	keytype = signkey_type_from_signature(sigtype);
-	keyalgo = signkey_name_from_type(keytype, &keyalgolen);
-
 	keybloblen = buf_getint(ses.payload);
 	keyblob = buf_getptr(ses.payload, keybloblen);
 
@@ -117,6 +114,16 @@
 		send_msg_userauth_failure(0, 0);
 		goto out;
 	}
+
+	sigtype = signature_type_from_name(sigalgo, sigalgolen);
+	if (sigtype == DROPBEAR_SIGNATURE_NONE) {
+		send_msg_userauth_failure(0, 0);
+		goto out;
+	}
+
+	keytype = signkey_type_from_signature(sigtype);
+	keyalgo = signkey_name_from_type(keytype, &keyalgolen);
+
 #if DROPBEAR_PLUGIN
         if (svr_ses.plugin_instance != NULL) {
             char *options_buf;