comparison 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
comparison
equal deleted inserted replaced
1012:ffd2359564b0 1013:a1e79ffa5862
304 304
305 bytes_to_mp(rand, randbuf, len); 305 bytes_to_mp(rand, randbuf, len);
306 306
307 /* keep regenerating until we get one satisfying 307 /* keep regenerating until we get one satisfying
308 * 0 < rand < max */ 308 * 0 < rand < max */
309 } while (mp_cmp(rand, max) != MP_LT); 309 } while (!(mp_cmp(rand, max) == MP_LT && mp_cmp_d(rand, 0) == MP_GT));
310 m_burn(randbuf, len); 310 m_burn(randbuf, len);
311 m_free(randbuf); 311 m_free(randbuf);
312 } 312 }