# HG changeset patch # User Matt Johnston # Date 1497623718 -28800 # Node ID 79582b52a791cb4ad59e8392ebc34f1844b0c841 # Parent 798854f624300bb34c148bb1d9f80a7f32fe6410 check p and q lengths diff -r 798854f62430 -r 79582b52a791 dss.c --- 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; diff -r 798854f62430 -r 79582b52a791 dss.h --- 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);