diff options
author | lloyd <[email protected]> | 2008-10-26 03:07:18 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2008-10-26 03:07:18 +0000 |
commit | a8ee54d459a42d98fdfe1e9ff4f0c011c2f41e10 (patch) | |
tree | 576d871ed243508e5458456d12ea99d240e8339c /checks | |
parent | b1344477a80c7410da9ce05dd3343c04d24f8095 (diff) |
Move rng.{cpp,h} from core to rng/ topdir
Add a new class AutoSeeded_RNG that is a RandomNumberGenerator that wraps
up the logic formerly in RandomNumberGenerator::make_rng. make_rng in
fact now just returns a new AutoSeeded_RNG object.
AutoSeeded_RNG is a bit more convenient because
- No need to use auto_ptr
- No need to dereference (same syntax everywhere - it's an underestimated
advantage imo)
Also move the code from timer/timer_base to timer/
Diffstat (limited to 'checks')
-rw-r--r-- | checks/check.cpp | 40 |
1 files changed, 19 insertions, 21 deletions
diff --git a/checks/check.cpp b/checks/check.cpp index 2105640f8..36762786a 100644 --- a/checks/check.cpp +++ b/checks/check.cpp @@ -140,12 +140,11 @@ int main(int argc, char* argv[]) const bool html = opts.is_set("html"); - std::auto_ptr<RandomNumberGenerator> rng( - RandomNumberGenerator::make_rng()); + AutoSeeded_RNG rng; if(opts.is_set("benchmark")) { - benchmark("All", *rng, html, seconds); + benchmark("All", rng, html, seconds); } else if(opts.is_set("bench-algo")) { @@ -155,9 +154,9 @@ int main(int argc, char* argv[]) for(u32bit j = 0; j != algs.size(); j++) { const std::string alg = algs[j]; - u32bit found = bench_algo(alg, *rng, seconds); + u32bit found = bench_algo(alg, rng, seconds); if(!found) // maybe it's a PK algorithm - bench_pk(*rng, alg, html, seconds); + bench_pk(rng, alg, html, seconds); } } else if(opts.is_set("bench-type")) @@ -165,19 +164,19 @@ int main(int argc, char* argv[]) const std::string type = opts.value("bench-type"); if(type == "all") - benchmark("All", *rng, html, seconds); + benchmark("All", rng, html, seconds); else if(type == "block") - benchmark("Block Cipher", *rng, html, seconds); + benchmark("Block Cipher", rng, html, seconds); else if(type == "stream") - benchmark("Stream Cipher", *rng, html, seconds); + benchmark("Stream Cipher", rng, html, seconds); else if(type == "hash") - benchmark("Hash", *rng, html, seconds); + benchmark("Hash", rng, html, seconds); else if(type == "mac") - benchmark("MAC", *rng, html, seconds); + benchmark("MAC", rng, html, seconds); else if(type == "rng") - benchmark("RNG", *rng, html, seconds); + benchmark("RNG", rng, html, seconds); else if(type == "pk") - bench_pk(*rng, "All", html, seconds); + bench_pk(rng, "All", html, seconds); else std::cerr << "Unknown --bench-type " << type << "\n"; } @@ -204,15 +203,14 @@ int run_test_suite() u32bit errors = 0; try { - std::auto_ptr<RandomNumberGenerator> rng( - RandomNumberGenerator::make_rng()); - - errors += do_validation_tests(VALIDATION_FILE, *rng); - errors += do_validation_tests(EXPECTED_FAIL_FILE, *rng, false); - errors += do_bigint_tests(BIGINT_VALIDATION_FILE, *rng); - errors += do_gfpmath_tests(*rng); - errors += do_pk_validation_tests(PK_VALIDATION_FILE, *rng); - //errors += do_cvc_tests(*rng); + AutoSeeded_RNG rng; + + errors += do_validation_tests(VALIDATION_FILE, rng); + errors += do_validation_tests(EXPECTED_FAIL_FILE, rng, false); + errors += do_bigint_tests(BIGINT_VALIDATION_FILE, rng); + errors += do_gfpmath_tests(rng); + errors += do_pk_validation_tests(PK_VALIDATION_FILE, rng); + //errors += do_cvc_tests(rng); } catch(Botan::Exception& e) { |