aboutsummaryrefslogtreecommitdiffstats
path: root/doc
diff options
context:
space:
mode:
authorlloyd <[email protected]>2010-05-19 14:06:59 +0000
committerlloyd <[email protected]>2010-05-19 14:06:59 +0000
commit2295ef9e8d97065ad2920f5039878728e52a144f (patch)
tree8776271409e706f5d2695d6ec05f8fbd3680e4ef /doc
parent4cace3ee04ae9a20a57b1fa11447a1917f0f155d (diff)
parentb724994a7385e4ddd2e4e0684383302271ea2bf9 (diff)
propagate from branch 'net.randombit.botan' (head 66b216669d7ac91303378281d760236153955ae4)
to branch 'net.randombit.botan.c++0x' (head b911a76971563afcde85935a44a43248a3f5b4a6)
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();