changeset 1413:79582b52a791 fuzz

check p and q lengths
author Matt Johnston <matt@ucc.asn.au>
date Fri, 16 Jun 2017 22:35:18 +0800
parents 798854f62430
children 9236e7120c3e
files dss.c dss.h
diffstat 2 files changed, 13 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/dss.c	Wed Jun 14 23:31:42 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;
@@ -94,7 +101,7 @@
 	m_mp_alloc_init_multi(&key->x, NULL);
 	ret = buf_getmpint(buf, key->x);
 	if (ret == DROPBEAR_FAILURE) {
-		m_mp_free_multi(&key->x);
+		m_mp_free_multi(&key->x, NULL);
 	}
 
 	return ret;
--- a/dss.h	Wed Jun 14 23:31:42 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);