aboutsummaryrefslogtreecommitdiffstats
path: root/doc
diff options
context:
space:
mode:
authorlloyd <[email protected]>2008-09-18 13:59:24 +0000
committerlloyd <[email protected]>2008-09-18 13:59:24 +0000
commit71b3fe8ee01d1910d2c4e6e1ff6bdacf08957729 (patch)
treec42752b3c317c96e37aa8d0e0ca45ba10355f6c2 /doc
parentaf31e045e19379518a925c7be0705016a4a3f9dc (diff)
Create a RNG object, update for new interface for DSA paramater generation
Diffstat (limited to 'doc')
-rw-r--r--doc/examples/pqg_gen.cpp21
1 files changed, 15 insertions, 6 deletions
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 <string>
#include <vector>
#include <map>
+#include <memory>
#include <botan/botan.h>
#include <botan/look_pk.h>
#include <botan/dsa.h>
#include <botan/numthry.h>
+#include <botan/dl_group.h>
using namespace Botan;
-bool check(std::map<std::string, std::string>);
+bool check(RandomNumberGenerator& rng,
+ std::map<std::string, std::string>);
int main()
{
try {
LibraryInitializer init("use_engines");
+ std::auto_ptr<RandomNumberGenerator> 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<std::string, std::string> inputs)
+bool check(RandomNumberGenerator& rng,
+ std::map<std::string, std::string> inputs)
{
BigInt p("0x"+inputs["P"]),
q("0x"+inputs["Q"]),
@@ -80,7 +87,7 @@ bool check(std::map<std::string, std::string> 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<std::string, std::string> 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;