aboutsummaryrefslogtreecommitdiffstats
path: root/doc
diff options
context:
space:
mode:
authorlloyd <[email protected]>2011-06-17 16:03:16 +0000
committerlloyd <[email protected]>2011-06-17 16:03:16 +0000
commit41a11496d5594d8ea5c7879804a540f482033644 (patch)
treec99fbbc1691ae8b3593aa73a007f0658b72f0354 /doc
parent9fd0362d65435adf377ed1e4b85f010737b7def0 (diff)
parent6aac9723c9c286b5486e970e496daf7d01d83f4b (diff)
propagate from branch 'net.randombit.botan' (head 5dc30d88afdeec4896b5065f9260e66d52b1a730)
to branch 'net.randombit.botan.cxx11' (head 8d42792537db92fab3136f5696ee1eba3e73fa76)
Diffstat (limited to 'doc')
-rw-r--r--doc/examples/GNUmakefile4
-rw-r--r--doc/examples/asn1.cpp4
-rw-r--r--doc/examples/bench.cpp40
-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, 31 insertions, 40 deletions
diff --git a/doc/examples/GNUmakefile b/doc/examples/GNUmakefile
index a5da47a7c..6238512dc 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-1.10
SRCS=$(wildcard *.cpp)
diff --git a/doc/examples/asn1.cpp b/doc/examples/asn1.cpp
index 95e5b2627..866e57d75 100644
--- a/doc/examples/asn1.cpp
+++ b/doc/examples/asn1.cpp
@@ -97,7 +97,7 @@ void decode(BER_Decoder& decoder, size_t 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";
@@ -124,7 +124,7 @@ void decode(BER_Decoder& decoder, size_t 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 20e6ec40b..884bc2ecc 100644
--- a/doc/examples/bench.cpp
+++ b/doc/examples/bench.cpp
@@ -67,41 +67,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, af, rng, milliseconds, 16*1024);
- 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 7a3e6daf9..6fd2eb15b 100644
--- a/doc/examples/ca.cpp
+++ b/doc/examples/ca.cpp
@@ -1,10 +1,10 @@
#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[])
{
@@ -41,8 +41,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();