aboutsummaryrefslogtreecommitdiffstats
path: root/doc
diff options
context:
space:
mode:
authorlloyd <[email protected]>2009-12-21 13:53:40 +0000
committerlloyd <[email protected]>2009-12-21 13:53:40 +0000
commit93e8fd697d009dfef3b994a77936cbf88d2d2ba3 (patch)
treee31140bd8a9f4de3fa0a4705dce389acf50197a0 /doc
parent75f32d61c6a78e4e63cfadd084730f20b5896493 (diff)
parent1d595f8976483078c292e365bde3949c9de26332 (diff)
propagate from branch 'net.randombit.botan' (head 14c1d4dc8696d2705a70ec3d2403e01d2ca95265)
to branch 'net.randombit.botan.c++0x' (head c567fa7310ba082a837562092728c4b4b882bf82)
Diffstat (limited to 'doc')
-rw-r--r--doc/examples/GNUmakefile4
-rw-r--r--doc/examples/asn1.cpp4
-rw-r--r--doc/examples/bench.cpp42
-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, 34 insertions, 39 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 95757ec19..141d4d5b4 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 6a15df7c0..7d53e0557 100644
--- a/doc/examples/bench.cpp
+++ b/doc/examples/bench.cpp
@@ -60,39 +60,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];
-int main(int argc, char* argv[])
- {
- LibraryInitializer init;
+ std::map<std::string, double> speeds =
+ algorithm_benchmark(algos[i], milliseconds, rng, af);
- 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 f5eccdde9..8ca6228c2 100644
--- a/doc/examples/ca.cpp
+++ b/doc/examples/ca.cpp
@@ -15,11 +15,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[])
{
@@ -56,8 +56,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 8490a167e..5f943ff3a 100644
--- a/doc/examples/gen_certs.cpp
+++ b/doc/examples/gen_certs.cpp
@@ -5,9 +5,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;
@@ -71,14 +71,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 4122bc8ef..cf810749a 100644
--- a/doc/examples/rsa_manykey.cpp
+++ b/doc/examples/rsa_manykey.cpp
@@ -25,7 +25,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();