From 71b3fe8ee01d1910d2c4e6e1ff6bdacf08957729 Mon Sep 17 00:00:00 2001 From: lloyd Date: Thu, 18 Sep 2008 13:59:24 +0000 Subject: Create a RNG object, update for new interface for DSA paramater generation --- doc/examples/pqg_gen.cpp | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) (limited to 'doc') diff --git a/doc/examples/pqg_gen.cpp b/doc/examples/pqg_gen.cpp index 96852a81c..328dc785e 100644 --- a/doc/examples/pqg_gen.cpp +++ b/doc/examples/pqg_gen.cpp @@ -3,20 +3,26 @@ #include #include #include +#include #include #include #include #include +#include using namespace Botan; -bool check(std::map); +bool check(RandomNumberGenerator& rng, + std::map); int main() { try { LibraryInitializer init("use_engines"); + std::auto_ptr rng( + RandomNumberGenerator::make_rng()); + std::ifstream in("PQGGen.rsp"); if(!in) throw Exception("Can't open response file"); @@ -45,7 +51,7 @@ int main() if(name == "H") { - bool result = check(inputs); + bool result = check(*rng, inputs); std::cout << "." << std::flush; if(result == false) { @@ -71,7 +77,8 @@ int main() return 0; } -bool check(std::map inputs) +bool check(RandomNumberGenerator& rng, + std::map inputs) { BigInt p("0x"+inputs["P"]), q("0x"+inputs["Q"]), @@ -80,7 +87,7 @@ bool check(std::map inputs) if(h < 1 || h >= p-1) return false; - u32bit c = to_u32bit(inputs["c"]); + //u32bit c = to_u32bit(inputs["c"]); Pipe pipe(new Hex_Decoder); pipe.process_msg(inputs["Seed"]); @@ -88,8 +95,10 @@ bool check(std::map inputs) BigInt our_p, our_q; - bool found = generate_dsa_primes(our_p, our_q, seed, seed.size(), - p.bits(), 0); + u32bit qbits = (p.bits() <= 1024) ? 160 : 256; + + bool found = DL_Group::generate_dsa_primes(rng, our_p, our_q, + p.bits(), qbits, seed); if(!found) /* bad seed */ return false; -- cgit v1.2.3