From be4c408997cf182d974c33b1c62d7f6605c55f3e Mon Sep 17 00:00:00 2001 From: lloyd Date: Sat, 24 May 2008 19:14:00 +0000 Subject: Remove random_integer() and replace it with a BigInt constructor taking a RandomNumberGenerator reference. Update all callers. --- src/pk_core.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'src/pk_core.cpp') diff --git a/src/pk_core.cpp b/src/pk_core.cpp index 6d02c1cd3..daee59273 100644 --- a/src/pk_core.cpp +++ b/src/pk_core.cpp @@ -31,7 +31,8 @@ IF_Core::IF_Core(RandomNumberGenerator& rng, if(d != 0) { - BigInt k = random_integer(rng, std::min(n.bits()-1, BLINDING_BITS)); + BigInt k(rng, std::min(n.bits()-1, BLINDING_BITS)); + if(k != 0) blinder = Blinder(power_mod(k, e, n), inverse_mod(k, n), n); } @@ -182,8 +183,9 @@ ELG_Core::ELG_Core(const DL_Group& group, const BigInt& y, const BigInt& x) const BigInt& p = group.get_p(); p_bytes = p.bytes(); - BigInt k = random_integer(global_state().prng_reference(), - std::min(p.bits()-1, BLINDING_BITS)); + BigInt k(global_state().prng_reference(), + std::min(p.bits()-1, BLINDING_BITS)); + if(k != 0) blinder = Blinder(k, power_mod(k, x, p), p); } @@ -245,8 +247,10 @@ DH_Core::DH_Core(const DL_Group& group, const BigInt& x) op = Engine_Core::dh_op(group, x); const BigInt& p = group.get_p(); - BigInt k = random_integer(global_state().prng_reference(), - std::min(p.bits()-1, BLINDING_BITS)); + + BigInt k(global_state().prng_reference(), + std::min(p.bits()-1, BLINDING_BITS)); + if(k != 0) blinder = Blinder(k, power_mod(inverse_mod(k, p), x, p), p); } -- cgit v1.2.3