diff options
author | lloyd <[email protected]> | 2008-06-20 10:49:31 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2008-06-20 10:49:31 +0000 |
commit | 850af952f95a3115e509ebd0aa6689a1d2e9c810 (patch) | |
tree | f8933b074f00ddd1fdba746e9cc1d3ad5d96e9c8 /src/if_algo.cpp | |
parent | a2700f470482680d4f99b3b519af0a1ccfd53bfd (diff) |
Pass RNG& to IF (RSA/RW) load hooks
Diffstat (limited to 'src/if_algo.cpp')
-rw-r--r-- | src/if_algo.cpp | 32 |
1 files changed, 18 insertions, 14 deletions
diff --git a/src/if_algo.cpp b/src/if_algo.cpp index 209c51c46..2bd508c86 100644 --- a/src/if_algo.cpp +++ b/src/if_algo.cpp @@ -62,15 +62,17 @@ X509_Decoder* IF_Scheme_PublicKey::x509_decoder() .verify_end() .end_cons(); - key->X509_load_hook(); + key->X509_load_hook(rng); } - IF_Scheme_Decoder(IF_Scheme_PublicKey* k) : key(k) {} + IF_Scheme_Decoder(IF_Scheme_PublicKey* k, RandomNumberGenerator& r) : + key(k), rng(r) {} private: IF_Scheme_PublicKey* key; + RandomNumberGenerator& rng; }; - return new IF_Scheme_Decoder(this); + return new IF_Scheme_Decoder(this, global_state().prng_reference()); } /************************************************* @@ -142,43 +144,45 @@ PKCS8_Decoder* IF_Scheme_PrivateKey::pkcs8_decoder() if(version != 0) throw Decoding_Error("Unknown PKCS #1 key format version"); - key->PKCS8_load_hook(); + key->PKCS8_load_hook(rng); } - IF_Scheme_Decoder(IF_Scheme_PrivateKey* k) : key(k) {} + IF_Scheme_Decoder(IF_Scheme_PrivateKey* k, RandomNumberGenerator& r) : + key(k), rng(r) {} private: IF_Scheme_PrivateKey* key; + RandomNumberGenerator& rng; }; - return new IF_Scheme_Decoder(this); + return new IF_Scheme_Decoder(this, global_state().prng_reference()); } /************************************************* * Algorithm Specific X.509 Initialization Code * *************************************************/ -void IF_Scheme_PublicKey::X509_load_hook() +void IF_Scheme_PublicKey::X509_load_hook(RandomNumberGenerator& rng) { - core = IF_Core(global_state().prng_reference(), e, n); - load_check(global_state().prng_reference()); + core = IF_Core(rng, e, n); + load_check(rng); } /************************************************* * Algorithm Specific PKCS #8 Initialization Code * *************************************************/ -void IF_Scheme_PrivateKey::PKCS8_load_hook(bool generated) +void IF_Scheme_PrivateKey::PKCS8_load_hook(RandomNumberGenerator& rng, + bool generated) { if(n == 0) n = p * q; if(d1 == 0) d1 = d % (p - 1); if(d2 == 0) d2 = d % (q - 1); if(c == 0) c = inverse_mod(q, p); - core = IF_Core(global_state().prng_reference(), - e, n, d, p, q, d1, d2, c); + core = IF_Core(rng, e, n, d, p, q, d1, d2, c); if(generated) - gen_check(global_state().prng_reference()); + gen_check(rng); else - load_check(global_state().prng_reference()); + load_check(rng); } /************************************************* |