changeset 1418:92717c0fec39

check p and q lengths
author Matt Johnston <matt@ucc.asn.au>
date Fri, 16 Jun 2017 22:35:18 +0800
parents 33d90d219e03
children 7672b13c5367
files dss.c dss.h
diffstat 2 files changed, 12 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/dss.c	Fri Jun 23 21:31:25 2017 +0800
+++ b/dss.c	Fri Jun 16 22:35:18 2017 +0800
@@ -61,8 +61,15 @@
 		goto out;
 	}
 
-	if (mp_count_bits(key->p) < MIN_DSS_KEYLEN) {
-		dropbear_log(LOG_WARNING, "DSS key too short");
+	if (mp_count_bits(key->p) < DSS_P_BITS) {
+		dropbear_log(LOG_WARNING, "Bad DSS p");
+		TRACE(("leave buf_get_dss_pub_key: short key"))
+		ret = DROPBEAR_FAILURE;
+		goto out;
+	}
+
+	if (mp_count_bits(key->q) < DSS_Q_BITS) {
+		dropbear_log(LOG_WARNING, "Bad DSS q");
 		TRACE(("leave buf_get_dss_pub_key: short key"))
 		ret = DROPBEAR_FAILURE;
 		goto out;
--- a/dss.h	Fri Jun 23 21:31:25 2017 +0800
+++ b/dss.h	Fri Jun 16 22:35:18 2017 +0800
@@ -41,6 +41,9 @@
 
 } dropbear_dss_key;
 
+#define DSS_P_BITS 1024
+#define DSS_Q_BITS 160
+
 void buf_put_dss_sign(buffer* buf, dropbear_dss_key *key, buffer *data_buf);
 #if DROPBEAR_SIGNKEY_VERIFY
 int buf_dss_verify(buffer* buf, dropbear_dss_key *key, buffer *data_buf);