Mercurial > dropbear
diff dbrandom.c @ 1013:a1e79ffa5862
Tighten validation of DH values. Odds of x==0 being generated are
improbable, roughly 2**-1023
Regression in 0.49
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Tue, 10 Feb 2015 21:46:19 +0800 |
parents | 220f55d540ae |
children | a9e4d66ffb2c |
line wrap: on
line diff
--- a/dbrandom.c Wed Feb 04 22:12:06 2015 +0800 +++ b/dbrandom.c Tue Feb 10 21:46:19 2015 +0800 @@ -306,7 +306,7 @@ /* keep regenerating until we get one satisfying * 0 < rand < max */ - } while (mp_cmp(rand, max) != MP_LT); + } while (!(mp_cmp(rand, max) == MP_LT && mp_cmp_d(rand, 0) == MP_GT)); m_burn(randbuf, len); m_free(randbuf); }