aboutsummaryrefslogtreecommitdiffstats
path: root/doc/examples/rsa_manykey.cpp
diff options
context:
space:
mode:
authorlloyd <[email protected]>2011-04-08 14:57:49 +0000
committerlloyd <[email protected]>2011-04-08 14:57:49 +0000
commitfc62f7f284387a180e42402e8706965a666efba7 (patch)
tree9abe74c670993c111bd3a5bf5fb568767f9e75be /doc/examples/rsa_manykey.cpp
parent438f3eb73e494fcab82b239452d712bec06f48c9 (diff)
More pubkey doc updates
Diffstat (limited to 'doc/examples/rsa_manykey.cpp')
-rw-r--r--doc/examples/rsa_manykey.cpp42
1 files changed, 42 insertions, 0 deletions
diff --git a/doc/examples/rsa_manykey.cpp b/doc/examples/rsa_manykey.cpp
new file mode 100644
index 000000000..e6a511753
--- /dev/null
+++ b/doc/examples/rsa_manykey.cpp
@@ -0,0 +1,42 @@
+/*
+* (C) 2009 Jack Lloyd
+*
+* Distributed under the terms of the Botan license
+*/
+
+/*
+Generate a whole sequence of keys (for benchmarking)
+*/
+
+#include <iostream>
+#include <fstream>
+#include <string>
+#include <cstdlib>
+#include <memory>
+
+#include <botan/botan.h>
+#include <botan/rsa.h>
+#include <botan/parsing.h>
+using namespace Botan;
+
+int main()
+ {
+ Botan::LibraryInitializer init;
+
+ AutoSeeded_RNG rng;
+
+ for(u32bit j = 512; j <= 8192; j += 256)
+ {
+ std::cout << j << "...";
+
+ RSA_PrivateKey key(rng, j);
+
+ std::ofstream priv(("rsa/" + to_string(j) + ".pem").c_str());
+ priv << PKCS8::PEM_encode(key);
+ priv.close();
+
+ std::cout << " done" << std::endl;
+ }
+
+ return 0;
+ }