diff options
author | lloyd <[email protected]> | 2008-05-24 19:06:45 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2008-05-24 19:06:45 +0000 |
commit | 117ee205ea987df26945e28373a66716fee06876 (patch) | |
tree | a3a61a34cbab8f7b9f129a4b51c8fa6a7d4f706b | |
parent | df8691c753ad17d364c868f9b34a56a1f52bb9cf (diff) |
Pass an RNG reference to IF_Core
-rw-r--r-- | include/pk_core.h | 4 | ||||
-rw-r--r-- | src/if_algo.cpp | 5 | ||||
-rw-r--r-- | src/pk_core.cpp | 6 |
3 files changed, 9 insertions, 6 deletions
diff --git a/include/pk_core.h b/include/pk_core.h index 3f4ebda57..e4d50a685 100644 --- a/include/pk_core.h +++ b/include/pk_core.h @@ -26,7 +26,9 @@ class BOTAN_DLL IF_Core IF_Core() { op = 0; } IF_Core(const IF_Core&); - IF_Core(const BigInt&, const BigInt&, + + IF_Core(RandomNumberGenerator& rng, + const BigInt&, const BigInt&, const BigInt& = 0, const BigInt& = 0, const BigInt& = 0, const BigInt& = 0, const BigInt& = 0, const BigInt& = 0); ~IF_Core() { delete op; } diff --git a/src/if_algo.cpp b/src/if_algo.cpp index 4e64e82ae..209c51c46 100644 --- a/src/if_algo.cpp +++ b/src/if_algo.cpp @@ -158,7 +158,7 @@ PKCS8_Decoder* IF_Scheme_PrivateKey::pkcs8_decoder() *************************************************/ void IF_Scheme_PublicKey::X509_load_hook() { - core = IF_Core(e, n); + core = IF_Core(global_state().prng_reference(), e, n); load_check(global_state().prng_reference()); } @@ -172,7 +172,8 @@ void IF_Scheme_PrivateKey::PKCS8_load_hook(bool generated) if(d2 == 0) d2 = d % (q - 1); if(c == 0) c = inverse_mod(q, p); - core = IF_Core(e, n, d, p, q, d1, d2, c); + core = IF_Core(global_state().prng_reference(), + e, n, d, p, q, d1, d2, c); if(generated) gen_check(global_state().prng_reference()); diff --git a/src/pk_core.cpp b/src/pk_core.cpp index 4c76716f2..6d02c1cd3 100644 --- a/src/pk_core.cpp +++ b/src/pk_core.cpp @@ -22,7 +22,8 @@ const u32bit BLINDING_BITS = BOTAN_PRIVATE_KEY_OP_BLINDING_BITS; /************************************************* * IF_Core Constructor * *************************************************/ -IF_Core::IF_Core(const BigInt& e, const BigInt& n, const BigInt& d, +IF_Core::IF_Core(RandomNumberGenerator& rng, + const BigInt& e, const BigInt& n, const BigInt& d, const BigInt& p, const BigInt& q, const BigInt& d1, const BigInt& d2, const BigInt& c) { @@ -30,8 +31,7 @@ IF_Core::IF_Core(const BigInt& e, const BigInt& n, const BigInt& d, if(d != 0) { - BigInt k = random_integer(global_state().prng_reference(), - std::min(n.bits()-1, BLINDING_BITS)); + BigInt k = random_integer(rng, std::min(n.bits()-1, BLINDING_BITS)); if(k != 0) blinder = Blinder(power_mod(k, e, n), inverse_mod(k, n), n); } |