From 69e8cc40848b95a644fb952c73788e825c1683ba Mon Sep 17 00:00:00 2001
From: lloyd <lloyd@randombit.net>
Date: Wed, 16 Sep 2009 15:56:55 +0000
Subject: Use <chrono> in the runtime benchmarking code instead of the local
 timers.

---
 src/benchmark/benchmark.cpp | 76 +++++++++++++++++++++++++++------------------
 src/benchmark/benchmark.h   | 26 +---------------
 src/benchmark/info.txt      |  1 -
 3 files changed, 47 insertions(+), 56 deletions(-)

(limited to 'src/benchmark')

diff --git a/src/benchmark/benchmark.cpp b/src/benchmark/benchmark.cpp
index 3bbc1f883..ff7519c09 100644
--- a/src/benchmark/benchmark.cpp
+++ b/src/benchmark/benchmark.cpp
@@ -1,6 +1,6 @@
 /**
 * Runtime benchmarking
-* (C) 2008 Jack Lloyd
+* (C) 2008-2009 Jack Lloyd
 *
 * Distributed under the terms of the Botan license
 */
@@ -13,31 +13,40 @@
 #include <botan/mac.h>
 #include <botan/util.h>
 #include <memory>
+#include <vector>
+#include <chrono>
 
 namespace Botan {
 
 namespace {
 
+typedef std::chrono::high_resolution_clock benchmark_clock;
+
 /**
 * Benchmark BufferedComputation (hash or MAC)
 */
 std::pair<u64bit, u64bit> bench_buf_comp(BufferedComputation* buf_comp,
-                                         Timer& timer,
                                          u64bit nanoseconds_max,
                                          const byte buf[], u32bit buf_len)
    {
-   const u64bit start = timer.clock();
-   u64bit nanoseconds_used = 0;
    u64bit reps = 0;
 
-   while(nanoseconds_used < nanoseconds_max)
+   std::chrono::nanoseconds max_time(nanoseconds_max);
+   std::chrono::nanoseconds time_used(0);
+
+   auto start = benchmark_clock::now();
+
+   while(time_used < max_time)
       {
       buf_comp->update(buf, buf_len);
       ++reps;
-      nanoseconds_used = timer.clock() - start;
+      time_used = benchmark_clock::now() - start;
       }
 
-   return std::make_pair(reps * buf_len, nanoseconds_used);
+   u64bit ns_taken =
+      std::chrono::duration_cast<std::chrono::nanoseconds>(time_used).count();
+
+   return std::make_pair(reps * buf_len, ns_taken);
    }
 
 /**
@@ -45,26 +54,30 @@ std::pair<u64bit, u64bit> bench_buf_comp(BufferedComputation* buf_comp,
 */
 std::pair<u64bit, u64bit>
 bench_block_cipher(BlockCipher* block_cipher,
-                   Timer& timer,
                    u64bit nanoseconds_max,
                    byte buf[], u32bit buf_len)
    {
-   const u64bit start = timer.clock();
-   u64bit nanoseconds_used = 0;
+   const u32bit in_blocks = buf_len / block_cipher->BLOCK_SIZE;
+
    u64bit reps = 0;
 
-   const u32bit in_blocks = buf_len / block_cipher->BLOCK_SIZE;
+   std::chrono::nanoseconds max_time(nanoseconds_max);
+   std::chrono::nanoseconds time_used(0);
 
-   while(nanoseconds_used < nanoseconds_max)
+   auto start = benchmark_clock::now();
+
+   while(time_used < max_time)
       {
       block_cipher->encrypt_n(buf, buf, in_blocks);
-
       ++reps;
-      nanoseconds_used = timer.clock() - start;
+      time_used = benchmark_clock::now() - start;
       }
 
+   u64bit ns_taken =
+      std::chrono::duration_cast<std::chrono::nanoseconds>(time_used).count();
+
    return std::make_pair(reps * in_blocks * block_cipher->BLOCK_SIZE,
-                         nanoseconds_used);
+                         ns_taken);
    }
 
 /**
@@ -72,33 +85,38 @@ bench_block_cipher(BlockCipher* block_cipher,
 */
 std::pair<u64bit, u64bit>
 bench_stream_cipher(StreamCipher* stream_cipher,
-                    Timer& timer,
                     u64bit nanoseconds_max,
                     byte buf[], u32bit buf_len)
    {
-   const u64bit start = timer.clock();
-   u64bit nanoseconds_used = 0;
    u64bit reps = 0;
 
-   while(nanoseconds_used < nanoseconds_max)
+   std::chrono::nanoseconds max_time(nanoseconds_max);
+   std::chrono::nanoseconds time_used(0);
+
+   auto start = benchmark_clock::now();
+
+   while(time_used < max_time)
       {
       stream_cipher->encrypt(buf, buf_len);
       ++reps;
-      nanoseconds_used = timer.clock() - start;
+      time_used = benchmark_clock::now() - start;
       }
 
-   return std::make_pair(reps * buf_len, nanoseconds_used);
+   u64bit ns_taken =
+      std::chrono::duration_cast<std::chrono::nanoseconds>(time_used).count();
+
+   return std::make_pair(reps * buf_len, ns_taken);
    }
 
 /**
 * Benchmark hash
 */
 std::pair<u64bit, u64bit>
-bench_hash(HashFunction* hash, Timer& timer,
+bench_hash(HashFunction* hash,
            u64bit nanoseconds_max,
            const byte buf[], u32bit buf_len)
    {
-   return bench_buf_comp(hash, timer, nanoseconds_max, buf, buf_len);
+   return bench_buf_comp(hash, nanoseconds_max, buf, buf_len);
    }
 
 /**
@@ -106,12 +124,11 @@ bench_hash(HashFunction* hash, Timer& timer,
 */
 std::pair<u64bit, u64bit>
 bench_mac(MessageAuthenticationCode* mac,
-          Timer& timer,
           u64bit nanoseconds_max,
           const byte buf[], u32bit buf_len)
    {
    mac->set_key(buf, mac->MAXIMUM_KEYLENGTH);
-   return bench_buf_comp(mac, timer, nanoseconds_max, buf, buf_len);
+   return bench_buf_comp(mac, nanoseconds_max, buf, buf_len);
    }
 
 }
@@ -119,7 +136,6 @@ bench_mac(MessageAuthenticationCode* mac,
 std::map<std::string, double>
 algorithm_benchmark(const std::string& name,
                     u32bit milliseconds,
-                    Timer& timer,
                     RandomNumberGenerator& rng,
                     Algorithm_Factory& af)
    {
@@ -145,7 +161,7 @@ algorithm_benchmark(const std::string& name,
             af.prototype_block_cipher(name, provider))
          {
          std::auto_ptr<BlockCipher> block_cipher(proto->clone());
-         results = bench_block_cipher(block_cipher.get(), timer,
+         results = bench_block_cipher(block_cipher.get(),
                                       ns_per_provider,
                                       &buf[0], buf.size());
          }
@@ -153,7 +169,7 @@ algorithm_benchmark(const std::string& name,
                  af.prototype_stream_cipher(name, provider))
          {
          std::auto_ptr<StreamCipher> stream_cipher(proto->clone());
-         results = bench_stream_cipher(stream_cipher.get(), timer,
+         results = bench_stream_cipher(stream_cipher.get(),
                                        ns_per_provider,
                                        &buf[0], buf.size());
          }
@@ -161,14 +177,14 @@ algorithm_benchmark(const std::string& name,
                  af.prototype_hash_function(name, provider))
          {
          std::auto_ptr<HashFunction> hash(proto->clone());
-         results = bench_hash(hash.get(), timer, ns_per_provider,
+         results = bench_hash(hash.get(), ns_per_provider,
                               &buf[0], buf.size());
          }
       else if(const MessageAuthenticationCode* proto =
                  af.prototype_mac(name, provider))
          {
          std::auto_ptr<MessageAuthenticationCode> mac(proto->clone());
-         results = bench_mac(mac.get(), timer, ns_per_provider,
+         results = bench_mac(mac.get(), ns_per_provider,
                              &buf[0], buf.size());
          }
 
diff --git a/src/benchmark/benchmark.h b/src/benchmark/benchmark.h
index 272cfdfa2..a9c3fc01e 100644
--- a/src/benchmark/benchmark.h
+++ b/src/benchmark/benchmark.h
@@ -1,6 +1,6 @@
 /**
 * Runtime benchmarking
-* (C) 2008 Jack Lloyd
+* (C) 2008-2009 Jack Lloyd
 *
 * Distributed under the terms of the Botan license
 */
@@ -9,35 +9,12 @@
 #define BOTAN_RUNTIME_BENCHMARK_H__
 
 #include <botan/algo_factory.h>
-#include <botan/timer.h>
 #include <botan/rng.h>
 #include <map>
 #include <string>
 
-/**
-* Choose some sort of default timer implementation to use, since some
-* (like hardware tick counters and current Win32 timer) are not
-* reliable for benchmarking.
-*/
-#if defined(BOTAN_HAS_TIMER_POSIX)
-  #include <botan/tm_posix.h>
-#elif defined(BOTAN_HAS_TIMER_UNIX)
-  #include <botan/tm_unix.h>
-#endif
-
 namespace Botan {
 
-#if defined(BOTAN_HAS_TIMER_POSIX)
-  typedef POSIX_Timer Default_Benchmark_Timer;
-#elif defined(BOTAN_HAS_TIMER_UNIX)
-  typedef Unix_Timer Default_Benchmark_Timer;
-#else
-   /* I have not had good success using clock(), the results seem
-    * pretty bogus, but as a last resort it works.
-    */
-  typedef ANSI_Clock_Timer Default_Benchmark_Timer;
-#endif
-
 /**
 * Algorithm benchmark
 * @param name the name of the algorithm to test (cipher, hash, or MAC)
@@ -50,7 +27,6 @@ namespace Botan {
 std::map<std::string, double>
 algorithm_benchmark(const std::string& name,
                     u32bit milliseconds,
-                    Timer& timer,
                     RandomNumberGenerator& rng,
                     Algorithm_Factory& af);
 
diff --git a/src/benchmark/info.txt b/src/benchmark/info.txt
index 0fbcdb2de..03d5aac50 100644
--- a/src/benchmark/info.txt
+++ b/src/benchmark/info.txt
@@ -17,5 +17,4 @@ hash
 mac
 rng
 stream
-timer
 </requires>
-- 
cgit v1.2.3


From ac0ec9b832a337c91cb451e0b8d12b77fa27a20c Mon Sep 17 00:00:00 2001
From: lloyd <lloyd@randombit.net>
Date: Tue, 9 Mar 2010 04:14:30 +0000
Subject: Various updates: unique_ptr, using chrono, merge fixups, etc

---
 checks/pk_bench.cpp         |  4 ++--
 src/benchmark/benchmark.cpp |  8 ++++----
 src/cert/cvc/cvc_self.cpp   | 15 +++++++++++----
 src/cms/cms_dalg.cpp        |  2 +-
 src/cms/cms_ealg.cpp        |  4 ++--
 src/constructs/tss/tss.cpp  |  2 +-
 src/pubkey/blinding.cpp     |  6 ++++--
 src/ssl/cert_ver.cpp        |  2 +-
 src/ssl/s_kex.cpp           |  2 +-
 src/wrap/python/core.cpp    |  2 +-
 src/wrap/python/filter.cpp  | 14 +++++++-------
 src/wrap/python/rsa.cpp     |  8 ++++----
 12 files changed, 39 insertions(+), 30 deletions(-)

(limited to 'src/benchmark')

diff --git a/checks/pk_bench.cpp b/checks/pk_bench.cpp
index a180778a6..c6f411379 100644
--- a/checks/pk_bench.cpp
+++ b/checks/pk_bench.cpp
@@ -374,7 +374,7 @@ void benchmark_gost_3410(RandomNumberGenerator& rng,
       if(hashbits == 521)
          hashbits = 512;
 
-      const std::string padding = "EMSA1(SHA-" + to_string(hashbits) + ")";
+      const std::string padding = "EMSA1(SHA-" + std::to_string(hashbits) + ")";
 
       Timer keygen_timer("keygen");
       Timer verify_timer(padding + " verify");
@@ -394,7 +394,7 @@ void benchmark_gost_3410(RandomNumberGenerator& rng,
                            sig_timer, rng, 1000, seconds);
          }
 
-      const std::string nm = "GOST-34.10-" + to_string(pbits);
+      const std::string nm = "GOST-34.10-" + std::to_string(pbits);
 
       report.report(nm, keygen_timer);
       report.report(nm, verify_timer);
diff --git a/src/benchmark/benchmark.cpp b/src/benchmark/benchmark.cpp
index 7a78461c2..348882b2a 100644
--- a/src/benchmark/benchmark.cpp
+++ b/src/benchmark/benchmark.cpp
@@ -162,7 +162,7 @@ algorithm_benchmark(const std::string& name,
       if(const BlockCipher* proto =
             af.prototype_block_cipher(name, provider))
          {
-         std::auto_ptr<BlockCipher> block_cipher(proto->clone());
+         std::unique_ptr<BlockCipher> block_cipher(proto->clone());
          results = bench_block_cipher(block_cipher.get(),
                                       ns_per_provider,
                                       &buf[0], buf.size());
@@ -170,7 +170,7 @@ algorithm_benchmark(const std::string& name,
       else if(const StreamCipher* proto =
                  af.prototype_stream_cipher(name, provider))
          {
-         std::auto_ptr<StreamCipher> stream_cipher(proto->clone());
+         std::unique_ptr<StreamCipher> stream_cipher(proto->clone());
          results = bench_stream_cipher(stream_cipher.get(),
                                        ns_per_provider,
                                        &buf[0], buf.size());
@@ -178,14 +178,14 @@ algorithm_benchmark(const std::string& name,
       else if(const HashFunction* proto =
                  af.prototype_hash_function(name, provider))
          {
-         std::auto_ptr<HashFunction> hash(proto->clone());
+         std::unique_ptr<HashFunction> hash(proto->clone());
          results = bench_hash(hash.get(), ns_per_provider,
                               &buf[0], buf.size());
          }
       else if(const MessageAuthenticationCode* proto =
                  af.prototype_mac(name, provider))
          {
-         std::auto_ptr<MessageAuthenticationCode> mac(proto->clone());
+         std::unique_ptr<MessageAuthenticationCode> mac(proto->clone());
          results = bench_mac(mac.get(), ns_per_provider,
                              &buf[0], buf.size());
          }
diff --git a/src/cert/cvc/cvc_self.cpp b/src/cert/cvc/cvc_self.cpp
index 0c765347f..9489ede85 100644
--- a/src/cert/cvc/cvc_self.cpp
+++ b/src/cert/cvc/cvc_self.cpp
@@ -168,7 +168,8 @@ EAC1_1_ADO create_ado_req(Private_Key const& key,
    PK_Signer signer(*priv_key, padding_and_hash);
    SecureVector<byte> tbs_bits = req.BER_encode();
    tbs_bits.append(DER_Encoder().encode(car).get_contents());
-   MemoryVector<byte> signed_cert = EAC1_1_ADO::make_signed(*signer.get(), tbs_bits, rng);
+   MemoryVector<byte> signed_cert = EAC1_1_ADO::make_signed(signer,
+                                                            tbs_bits, rng);
 
    DataSource_Memory source(signed_cert);
    return EAC1_1_ADO(source);
@@ -229,7 +230,7 @@ EAC1_1_CVC link_cvca(EAC1_1_CVC const& signer,
    AlgorithmIdentifier sig_algo = signer.signature_algorithm();
    std::string padding_and_hash = padding_and_hash_from_oid(sig_algo.oid);
    PK_Signer pk_signer(*priv_key, padding_and_hash);
-   std::auto_ptr<Public_Key> pk = signee.subject_public_key();
+   std::unique_ptr<Public_Key> pk = signee.subject_public_key();
    ECDSA_PublicKey* subj_pk = dynamic_cast<ECDSA_PublicKey*>(pk.get());
    subj_pk->set_parameter_encoding(EC_DOMPAR_ENC_EXPLICIT);
 
@@ -259,11 +260,17 @@ EAC1_1_CVC sign_request(EAC1_1_CVC const& signer_cert,
       throw Invalid_Argument("CVC_EAC::create_self_signed_cert(): unsupported key type");
       }
    std::string chr_str = signee.get_chr().value();
-   chr_str += to_string(seqnr, seqnr_len);
+
+   std::string seqnr_string = std::to_string(seqnr);
+
+   while(seqnr_string.size() < seqnr_len)
+      seqnr_string = '0' + seqnr_string;
+
+   chr_str += seqnr_string;
    ASN1_Chr chr(chr_str);
    std::string padding_and_hash = padding_and_hash_from_oid(signee.signature_algorithm().oid);
    PK_Signer pk_signer(*priv_key, padding_and_hash);
-   std::auto_ptr<Public_Key> pk = signee.subject_public_key();
+   std::unique_ptr<Public_Key> pk = signee.subject_public_key();
    ECDSA_PublicKey*  subj_pk = dynamic_cast<ECDSA_PublicKey*>(pk.get());
    std::unique_ptr<Public_Key> signer_pk = signer_cert.subject_public_key();
 
diff --git a/src/cms/cms_dalg.cpp b/src/cms/cms_dalg.cpp
index 2a380b596..f727f2a3f 100644
--- a/src/cms/cms_dalg.cpp
+++ b/src/cms/cms_dalg.cpp
@@ -29,7 +29,7 @@ SecureVector<byte> hash_of(const SecureVector<byte>& content,
 
    Algorithm_Factory& af = global_state().algorithm_factory();
 
-   std::auto_ptr<HashFunction> hash_fn(af.make_hash_function(hash_name));
+   std::unique_ptr<HashFunction> hash_fn(af.make_hash_function(hash_name));
    return hash_fn->process(content);
    }
 
diff --git a/src/cms/cms_ealg.cpp b/src/cms/cms_ealg.cpp
index 3ddf8a39e..b910b89d2 100644
--- a/src/cms/cms_ealg.cpp
+++ b/src/cms/cms_ealg.cpp
@@ -58,7 +58,7 @@ SecureVector<byte> hash_of(const SecureVector<byte>& content,
                            const std::string& hash_name)
    {
    Algorithm_Factory& af = global_state().algorithm_factory();
-   std::auto_ptr<HashFunction> hash_fn(af.make_hash_function(hash_name));
+   std::unique_ptr<HashFunction> hash_fn(af.make_hash_function(hash_name));
    return hash_fn->process(content);
    }
 
@@ -97,7 +97,7 @@ void CMS_Encoder::encrypt(RandomNumberGenerator& rng,
    {
    const std::string cipher = choose_algo(user_cipher, "TripleDES");
 
-   std::auto_ptr<Public_Key> key(to.subject_public_key());
+   std::unique_ptr<Public_Key> key(to.subject_public_key());
    const std::string algo = key->algo_name();
 
    Key_Constraints constraints = to.constraints();
diff --git a/src/constructs/tss/tss.cpp b/src/constructs/tss/tss.cpp
index 0782a27d1..101640f96 100644
--- a/src/constructs/tss/tss.cpp
+++ b/src/constructs/tss/tss.cpp
@@ -209,7 +209,7 @@ RTSS_Share::reconstruct(const std::vector<RTSS_Share>& shares)
 
    byte hash_id = shares[0].contents[16];
 
-   std::auto_ptr<HashFunction> hash(get_rtss_hash_by_id(hash_id));
+   std::unique_ptr<HashFunction> hash(get_rtss_hash_by_id(hash_id));
 
    if(shares[0].size() != secret_len + hash->OUTPUT_LENGTH + RTSS_HEADER_SIZE + 1)
       throw Decoding_Error("Bad RTSS length field in header");
diff --git a/src/pubkey/blinding.cpp b/src/pubkey/blinding.cpp
index 819d0dd20..8da50249f 100644
--- a/src/pubkey/blinding.cpp
+++ b/src/pubkey/blinding.cpp
@@ -32,7 +32,7 @@ BigInt Blinder::choose_nonce(const BigInt& x, const BigInt& mod)
    {
    Algorithm_Factory& af = global_state().algorithm_factory();
 
-   std::auto_ptr<HashFunction> hash(af.make_hash_function("SHA-512"));
+   std::unique_ptr<HashFunction> hash(af.make_hash_function("SHA-512"));
 
    u64bit ns_clock = get_nanoseconds_clock();
    for(size_t i = 0; i != sizeof(ns_clock); ++i)
@@ -41,7 +41,9 @@ BigInt Blinder::choose_nonce(const BigInt& x, const BigInt& mod)
    hash->update(BigInt::encode(x));
    hash->update(BigInt::encode(mod));
 
-   u64bit timestamp = system_time();
+   auto timestamp = std::chrono::system_clock::to_time_t(
+      std::chrono::system_clock::now());
+
    for(size_t i = 0; i != sizeof(timestamp); ++i)
       hash->update(get_byte(i, timestamp));
 
diff --git a/src/ssl/cert_ver.cpp b/src/ssl/cert_ver.cpp
index 7e17dbfab..0bf6c85be 100644
--- a/src/ssl/cert_ver.cpp
+++ b/src/ssl/cert_ver.cpp
@@ -80,7 +80,7 @@ bool Certificate_Verify::verify(const X509_Certificate& cert,
    {
    // FIXME: duplicate of Server_Key_Exchange::verify
 
-   std::auto_ptr<Public_Key> key(cert.subject_public_key());
+   std::unique_ptr<Public_Key> key(cert.subject_public_key());
 
    std::string padding = "";
    Signature_Format format = IEEE_1363;
diff --git a/src/ssl/s_kex.cpp b/src/ssl/s_kex.cpp
index 94b17cb7e..3223adc5b 100644
--- a/src/ssl/s_kex.cpp
+++ b/src/ssl/s_kex.cpp
@@ -157,7 +157,7 @@ bool Server_Key_Exchange::verify(const X509_Certificate& cert,
                                  const MemoryRegion<byte>& s_random) const
    {
 
-   std::auto_ptr<Public_Key> key(cert.subject_public_key());
+   std::unique_ptr<Public_Key> key(cert.subject_public_key());
 
    std::string padding = "";
    Signature_Format format = IEEE_1363;
diff --git a/src/wrap/python/core.cpp b/src/wrap/python/core.cpp
index b1be3b71f..67e17c4d5 100644
--- a/src/wrap/python/core.cpp
+++ b/src/wrap/python/core.cpp
@@ -178,7 +178,7 @@ std::string python_kdf2(const std::string& param,
                         const std::string& masterkey,
                         u32bit outputlength)
    {
-   std::auto_ptr<KDF> kdf(get_kdf("KDF2(SHA-1)"));
+   std::unique_ptr<KDF> kdf(get_kdf("KDF2(SHA-1)"));
 
    return make_string(
       kdf->derive_key(outputlength,
diff --git a/src/wrap/python/filter.cpp b/src/wrap/python/filter.cpp
index 48a3f84eb..0076f0c49 100644
--- a/src/wrap/python/filter.cpp
+++ b/src/wrap/python/filter.cpp
@@ -109,19 +109,19 @@ Filter* make_filter4(const std::string& name,
       name);
    }
 
-void append_filter(Pipe& pipe, std::auto_ptr<Filter> filter)
+void append_filter(Pipe& pipe, std::unique_ptr<Filter> filter)
    {
    pipe.append(filter.get());
    filter.release();
    }
 
-void prepend_filter(Pipe& pipe, std::auto_ptr<Filter> filter)
+void prepend_filter(Pipe& pipe, std::unique_ptr<Filter> filter)
    {
    pipe.prepend(filter.get());
    filter.release();
    }
 
-void do_send(std::auto_ptr<FilterWrapper> filter, const std::string& data)
+void do_send(std::unique_ptr<FilterWrapper> filter, const std::string& data)
    {
    printf("Sending %s to %p\n", data.c_str(), filter.get());
    filter->send_str(data);
@@ -131,7 +131,7 @@ BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(rallas_ovls, read_all_as_string, 0, 1)
 
 void export_filters()
    {
-   class_<Filter, std::auto_ptr<Filter>, boost::noncopyable>
+   class_<Filter, std::unique_ptr<Filter>, boost::noncopyable>
       ("__Internal_FilterObj", no_init);
 
    def("make_filter", make_filter1,
@@ -145,7 +145,7 @@ void export_filters()
 
    // This might not work - Pipe will delete the filter, but Python
    // might have allocated the space with malloc() or who-knows-what -> bad
-   class_<FilterWrapper, std::auto_ptr<FilterWrapper>,
+   class_<FilterWrapper, std::unique_ptr<FilterWrapper>,
           bases<Filter>, boost::noncopyable>
       ("FilterObj")
       .def("write", pure_virtual(&Py_Filter::write_str))
@@ -153,8 +153,8 @@ void export_filters()
       .def("start_msg", &Filter::start_msg, &FilterWrapper::default_start_msg)
       .def("end_msg", &Filter::end_msg, &FilterWrapper::default_end_msg);
 
-   implicitly_convertible<std::auto_ptr<FilterWrapper>,
-                          std::auto_ptr<Filter> >();
+   implicitly_convertible<std::unique_ptr<FilterWrapper>,
+                          std::unique_ptr<Filter> >();
 
    void (Pipe::*pipe_write_str)(const std::string&) = &Pipe::write;
    void (Pipe::*pipe_process_str)(const std::string&) = &Pipe::process_msg;
diff --git a/src/wrap/python/rsa.cpp b/src/wrap/python/rsa.cpp
index 900c3f93d..41d9bd4d1 100644
--- a/src/wrap/python/rsa.cpp
+++ b/src/wrap/python/rsa.cpp
@@ -55,7 +55,7 @@ class Py_RSA_PrivateKey
 std::string Py_RSA_PrivateKey::decrypt(const std::string& in,
                                        const std::string& padding)
    {
-   std::auto_ptr<PK_Decryptor> enc(get_pk_decryptor(*rsa_key, padding));
+   std::unique_ptr<PK_Decryptor> enc(get_pk_decryptor(*rsa_key, padding));
 
    const byte* in_bytes = reinterpret_cast<const byte*>(in.data());
 
@@ -66,7 +66,7 @@ std::string Py_RSA_PrivateKey::sign(const std::string& in,
                                     const std::string& padding,
                                     Python_RandomNumberGenerator& rng)
    {
-   std::auto_ptr<PK_Signer> sign(get_pk_signer(*rsa_key, padding));
+   std::unique_ptr<PK_Signer> sign(get_pk_signer(*rsa_key, padding));
    const byte* in_bytes = reinterpret_cast<const byte*>(in.data());
    sign->update(in_bytes, in.size());
    return make_string(sign->signature(rng.get_underlying_rng()));
@@ -144,7 +144,7 @@ std::string Py_RSA_PublicKey::encrypt(const std::string& in,
                                       const std::string& padding,
                                       Python_RandomNumberGenerator& rng)
    {
-   std::auto_ptr<PK_Encryptor> enc(get_pk_encryptor(*rsa_key, padding));
+   std::unique_ptr<PK_Encryptor> enc(get_pk_encryptor(*rsa_key, padding));
 
    const byte* in_bytes = reinterpret_cast<const byte*>(in.data());
 
@@ -156,7 +156,7 @@ bool Py_RSA_PublicKey::verify(const std::string& in,
                               const std::string& signature,
                               const std::string& padding)
    {
-   std::auto_ptr<PK_Verifier> ver(get_pk_verifier(*rsa_key, padding));
+   std::unique_ptr<PK_Verifier> ver(get_pk_verifier(*rsa_key, padding));
 
    const byte* in_bytes = reinterpret_cast<const byte*>(in.data());
    const byte* sig_bytes = reinterpret_cast<const byte*>(signature.data());
-- 
cgit v1.2.3