aboutsummaryrefslogtreecommitdiffstats
path: root/doc
diff options
context:
space:
mode:
authorlloyd <[email protected]>2010-03-09 02:53:56 +0000
committerlloyd <[email protected]>2010-03-09 02:53:56 +0000
commitcdcd3a9aba28cefcccb64f91fb56d3847f6c9130 (patch)
tree6f4efd137aad848e698f9f4fc48a8bc9145fea12 /doc
parent4a9afbb99bb73e43bcb3a30379d6a2dd59dae76a (diff)
parent3c15bd259f0921f1fa08ec91ee3cf2621c64a02d (diff)
propagate from branch 'net.randombit.botan' (head 9932d4d63417f7fcc199ada244cbaa6c1c32d9c1)
to branch 'net.randombit.botan.c++0x' (head f4a385a376311edc62ef506c72cc56f69e6efd5a)
Diffstat (limited to 'doc')
-rw-r--r--doc/examples/GNUmakefile4
-rw-r--r--doc/examples/asn1.cpp4
-rw-r--r--doc/examples/bench.cpp44
-rw-r--r--doc/examples/ca.cpp11
-rw-r--r--doc/examples/gen_certs.cpp10
-rw-r--r--doc/examples/rsa_manykey.cpp2
6 files changed, 33 insertions, 42 deletions
diff --git a/doc/examples/GNUmakefile b/doc/examples/GNUmakefile
index 44fcfeea5..a96e8d65d 100644
--- a/doc/examples/GNUmakefile
+++ b/doc/examples/GNUmakefile
@@ -1,8 +1,8 @@
BOTAN_CONFIG = botan-config
-CXX = g++
-CFLAGS = -O2 -ansi -W -Wall -I../../build/include
+CXX = g++-4.5-20091112
+CFLAGS = -O2 -ansi -std=c++0x -W -Wall -I../../build/include
LIBS = -L../.. -lbotan
SRCS=$(wildcard *.cpp)
diff --git a/doc/examples/asn1.cpp b/doc/examples/asn1.cpp
index b0a6aa104..11e283a64 100644
--- a/doc/examples/asn1.cpp
+++ b/doc/examples/asn1.cpp
@@ -121,7 +121,7 @@ void decode(BER_Decoder& decoder, u32bit level)
if((class_tag & APPLICATION) || (class_tag & CONTEXT_SPECIFIC) ||
(class_tag & PRIVATE))
{
- name = "cons [" + to_string(type_tag) + "]";
+ name = "cons [" + std::to_string(type_tag) + "]";
if(class_tag & APPLICATION)
name += " appl";
@@ -148,7 +148,7 @@ void decode(BER_Decoder& decoder, u32bit level)
Pipe pipe(((not_text) ? new Hex_Encoder : 0));
pipe.process_msg(bits);
- emit("[" + to_string(type_tag) + "]", level, length,
+ emit("[" + std::to_string(type_tag) + "]", level, length,
pipe.read_all_as_string());
}
else if(type_tag == OBJECT_ID)
diff --git a/doc/examples/bench.cpp b/doc/examples/bench.cpp
index 3bcfbf5f3..7054d8563 100644
--- a/doc/examples/bench.cpp
+++ b/doc/examples/bench.cpp
@@ -68,41 +68,29 @@ const std::string algos[] = {
"",
};
-void benchmark_algo(const std::string& algo,
- RandomNumberGenerator& rng)
+int main()
{
- u32bit milliseconds = 3000;
- Algorithm_Factory& af = global_state().algorithm_factory();
+ LibraryInitializer init;
- std::map<std::string, double> speeds =
- algorithm_benchmark(algo, milliseconds, rng, af);
+ u32bit milliseconds = 1000;
+ AutoSeeded_RNG rng;
- std::cout << algo << ":";
+ Algorithm_Factory& af = global_state().algorithm_factory();
- for(std::map<std::string, double>::const_iterator i = speeds.begin();
- i != speeds.end(); ++i)
+ for(u32bit i = 0; algos[i] != ""; ++i)
{
- std::cout << " " << i->second << " [" << i->first << "]";
- }
- std::cout << "\n";
- }
+ std::string algo = algos[i];
-}
+ std::map<std::string, double> speeds =
+ algorithm_benchmark(algos[i], milliseconds, rng, af);
-int main(int argc, char* argv[])
- {
- LibraryInitializer init;
-
- AutoSeeded_RNG rng;
+ std::cout << algo << ":";
- if(argc == 1) // no args, benchmark everything
- {
- for(u32bit i = 0; algos[i] != ""; ++i)
- benchmark_algo(algos[i], rng);
- }
- else
- {
- for(int i = 1; argv[i]; ++i)
- benchmark_algo(argv[i], rng);
+ for(std::map<std::string, double>::const_iterator i = speeds.begin();
+ i != speeds.end(); ++i)
+ {
+ std::cout << " " << i->second << " [" << i->first << "]";
+ }
+ std::cout << "\n";
}
}
diff --git a/doc/examples/ca.cpp b/doc/examples/ca.cpp
index 8dd3e981f..25a3b5a03 100644
--- a/doc/examples/ca.cpp
+++ b/doc/examples/ca.cpp
@@ -17,11 +17,11 @@
#include <botan/botan.h>
#include <botan/x509_ca.h>
-#include <botan/time.h>
using namespace Botan;
#include <iostream>
#include <memory>
+#include <chrono>
int main(int argc, char* argv[])
{
@@ -58,8 +58,13 @@ int main(int argc, char* argv[])
// (this example should be extended to show how)
// now sign the request
- X509_Time start_time(system_time());
- X509_Time end_time(system_time() + 365 * 60 * 60 * 24);
+ auto now = std::chrono::system_clock::now();
+
+ X509_Time start_time(now);
+
+ typedef std::chrono::duration<int, std::ratio<31556926>> years;
+
+ X509_Time end_time(now + years(1));
X509_Certificate new_cert = ca.sign_request(req, rng,
start_time, end_time);
diff --git a/doc/examples/gen_certs.cpp b/doc/examples/gen_certs.cpp
index f8c9fe124..73d667edb 100644
--- a/doc/examples/gen_certs.cpp
+++ b/doc/examples/gen_certs.cpp
@@ -11,9 +11,9 @@
#include <botan/botan.h>
#include <botan/rsa.h>
-#include <botan/time.h>
#include <botan/x509self.h>
#include <botan/x509_ca.h>
+#include <chrono>
using namespace Botan;
@@ -79,16 +79,14 @@ void save_pair(const std::string& name,
key_out.close();
}
-}
+typedef std::chrono::duration<int, std::ratio<31556926>> years;
int main()
{
- const u32bit seconds_in_a_year = 31556926;
-
- const u32bit current_time = system_time();
+ auto current_time = std::chrono::system_clock::now();
X509_Time now = X509_Time(current_time);
- X509_Time later = X509_Time(current_time + 4*seconds_in_a_year);
+ X509_Time later = X509_Time(current_time + years(4));
LibraryInitializer init;
diff --git a/doc/examples/rsa_manykey.cpp b/doc/examples/rsa_manykey.cpp
index e6a511753..c282e7882 100644
--- a/doc/examples/rsa_manykey.cpp
+++ b/doc/examples/rsa_manykey.cpp
@@ -31,7 +31,7 @@ int main()
RSA_PrivateKey key(rng, j);
- std::ofstream priv(("rsa/" + to_string(j) + ".pem").c_str());
+ std::ofstream priv(("rsa/" + std::to_string(j) + ".pem").c_str());
priv << PKCS8::PEM_encode(key);
priv.close();