summaryrefslogtreecommitdiffhomepage
path: root/dbrandom.c
diff options
context:
space:
mode:
authorMatt Johnston <matt@ucc.asn.au>2015-02-10 21:46:19 +0800
committerMatt Johnston <matt@ucc.asn.au>2015-02-10 21:46:19 +0800
commitc44a78a2e66b666696a944a389c00b1cf0fa49ca (patch)
tree40edf0fdbc11eae88e4bf2eba3d4be53be086b41 /dbrandom.c
parentb6685bf806b1cf58f194d56261b29db0f235d33b (diff)
Tighten validation of DH values. Odds of x==0 being generated are
improbable, roughly 2**-1023 Regression in 0.49
Diffstat (limited to 'dbrandom.c')
-rw-r--r--dbrandom.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/dbrandom.c b/dbrandom.c
index e2f55c2..cf280f4 100644
--- a/dbrandom.c
+++ b/dbrandom.c
@@ -306,7 +306,7 @@ void gen_random_mpint(mp_int *max, mp_int *rand) {
/* 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);
}