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 /doc/examples/pkcs10.cpp | |
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 'doc/examples/pkcs10.cpp')
-rw-r--r-- | doc/examples/pkcs10.cpp | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/doc/examples/pkcs10.cpp b/doc/examples/pkcs10.cpp index 3983d5891..18390da7c 100644 --- a/doc/examples/pkcs10.cpp +++ b/doc/examples/pkcs10.cpp @@ -8,6 +8,7 @@ Written by Jack Lloyd ([email protected]), April 7, 2003 This file is in the public domain */ #include <botan/init.h> +#include <botan/auto_rng.h> #include <botan/x509self.h> #include <botan/rsa.h> #include <botan/dsa.h> @@ -28,16 +29,15 @@ int main(int argc, char* argv[]) try { - std::auto_ptr<RandomNumberGenerator> rng( - RandomNumberGenerator::make_rng()); + AutoSeeded_RNG rng; - RSA_PrivateKey priv_key(*rng, 1024); + RSA_PrivateKey priv_key(rng, 1024); // If you want a DSA key instead of RSA, comment out the above line and // uncomment this one: //DSA_PrivateKey priv_key(DL_Group("dsa/jce/1024")); std::ofstream key_file("private.pem"); - key_file << PKCS8::PEM_encode(priv_key, *rng, argv[1]); + key_file << PKCS8::PEM_encode(priv_key, rng, argv[1]); X509_Cert_Options opts; @@ -57,7 +57,7 @@ int main(int argc, char* argv[]) opts.xmpp = "[email protected]"; - PKCS10_Request req = X509::create_cert_req(opts, priv_key, *rng); + PKCS10_Request req = X509::create_cert_req(opts, priv_key, rng); std::ofstream req_file("req.pem"); req_file << req.PEM_encode(); |