aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/algo_factory/algo_cache.h16
-rw-r--r--src/algo_factory/algo_factory.cpp11
-rw-r--r--src/algo_factory/algo_factory.h5
-rw-r--r--src/algo_factory/info.txt1
-rw-r--r--src/alloc/alloc_mmap/mmap_mem.h1
-rw-r--r--src/alloc/mem_pool/info.txt4
-rw-r--r--src/alloc/mem_pool/mem_pool.cpp9
-rw-r--r--src/alloc/mem_pool/mem_pool.h6
-rw-r--r--src/alloc/system_alloc/defalloc.h2
-rw-r--r--src/asn1/asn1_dn.cpp70
-rw-r--r--src/build-data/cc/gcc4
-rw-r--r--src/cert/cvc/cvc_ado.cpp10
-rw-r--r--src/cert/cvc/cvc_ado.h4
-rw-r--r--src/cert/cvc/cvc_ca.cpp4
-rw-r--r--src/cert/cvc/cvc_ca.h2
-rw-r--r--src/cert/cvc/cvc_cert.cpp6
-rw-r--r--src/cert/cvc/cvc_cert.h2
-rw-r--r--src/cert/cvc/cvc_gen_cert.h12
-rw-r--r--src/cert/cvc/cvc_req.cpp6
-rw-r--r--src/cert/cvc/cvc_req.h2
-rw-r--r--src/cert/cvc/cvc_self.cpp47
-rw-r--r--src/cert/cvc/eac_obj.h10
-rw-r--r--src/cert/cvc/ecdsa_sig.cpp2
-rw-r--r--src/cert/cvc/freestore.h11
-rw-r--r--src/cert/x509/x509_ca.cpp4
-rw-r--r--src/cert/x509/x509_obj.cpp2
-rw-r--r--src/cert/x509/x509self.cpp4
-rw-r--r--src/cert/x509/x509stor.cpp4
-rw-r--r--src/hash/par_hash/par_hash.cpp41
-rw-r--r--src/libstate/info.txt2
-rw-r--r--src/libstate/init.cpp35
-rw-r--r--src/libstate/libstate.cpp96
-rw-r--r--src/libstate/libstate.h21
-rw-r--r--src/libstate/scan_name.cpp1
-rw-r--r--src/math/gfpmath/curve_gfp.cpp28
-rw-r--r--src/math/gfpmath/curve_gfp.h16
-rw-r--r--src/math/gfpmath/gfp_element.cpp6
-rw-r--r--src/math/gfpmath/gfp_element.h17
-rw-r--r--src/math/gfpmath/point_gfp.cpp16
-rw-r--r--src/math/gfpmath/point_gfp.h10
-rw-r--r--src/math/numbertheory/dsa_gen.cpp2
-rw-r--r--src/mutex/info.txt9
-rw-r--r--src/mutex/mutex.h56
-rw-r--r--src/mutex/noop_mutex/info.txt10
-rw-r--r--src/mutex/noop_mutex/mux_noop.cpp50
-rw-r--r--src/mutex/noop_mutex/mux_noop.h26
-rw-r--r--src/mutex/pthreads/info.txt30
-rw-r--r--src/mutex/pthreads/mux_pthr.cpp58
-rw-r--r--src/mutex/pthreads/mux_pthr.h26
-rw-r--r--src/mutex/qt_mutex/info.txt18
-rw-r--r--src/mutex/qt_mutex/mux_qt.cpp35
-rw-r--r--src/mutex/qt_mutex/mux_qt.h27
-rw-r--r--src/mutex/win32_crit_section/info.txt17
-rw-r--r--src/mutex/win32_crit_section/mux_win32.cpp34
-rw-r--r--src/mutex/win32_crit_section/mux_win32.h26
-rw-r--r--src/pubkey/ec_dompar/ec_dompar.cpp2
-rw-r--r--src/pubkey/ecc_key/ecc_key.cpp2
-rw-r--r--src/pubkey/ecc_key/ecc_key.h4
-rw-r--r--src/pubkey/ecdsa/ecdsa.cpp11
-rw-r--r--src/pubkey/eckaeg/eckaeg.cpp4
-rw-r--r--src/pubkey/eckaeg/eckaeg.h2
-rw-r--r--src/pubkey/keypair/keypair.cpp8
-rw-r--r--src/pubkey/pk_codecs/pkcs8.cpp10
-rw-r--r--src/pubkey/pk_codecs/x509_key.cpp6
-rw-r--r--src/utils/parsing.cpp36
-rw-r--r--src/utils/stl_util.h16
66 files changed, 266 insertions, 809 deletions
diff --git a/src/algo_factory/algo_cache.h b/src/algo_factory/algo_cache.h
index 17ea9964a..97e14f85a 100644
--- a/src/algo_factory/algo_cache.h
+++ b/src/algo_factory/algo_cache.h
@@ -5,8 +5,9 @@
#ifndef BOTAN_ALGORITHM_CACHE_TEMPLATE_H__
#define BOTAN_ALGORITHM_CACHE_TEMPLATE_H__
-#include <botan/mutex.h>
+#include <botan/types.h>
#include <botan/stl_util.h>
+#include <mutex>
#include <string>
#include <vector>
#include <map>
@@ -47,7 +48,6 @@ class Algorithm_Cache
*/
std::vector<std::string> providers_of(const std::string& algo_name);
- Algorithm_Cache(Mutex* m) : mutex(m) {}
~Algorithm_Cache();
private:
typedef typename std::map<std::string, std::map<std::string, T*> >::iterator
@@ -57,7 +57,7 @@ class Algorithm_Cache
algorithms_iterator find_algorithm(const std::string& algo_spec);
- Mutex* mutex;
+ std::mutex mutex;
std::map<std::string, std::string> aliases;
std::map<std::string, std::string> pref_providers;
std::map<std::string, std::map<std::string, T*> > algorithms;
@@ -93,7 +93,7 @@ template<typename T>
const T* Algorithm_Cache<T>::get(const std::string& algo_spec,
const std::string& requested_provider)
{
- Mutex_Holder lock(mutex);
+ std::lock_guard<std::mutex> lock(mutex);
algorithms_iterator algo = find_algorithm(algo_spec);
if(algo == algorithms.end()) // algo not found at all (no providers)
@@ -145,7 +145,7 @@ void Algorithm_Cache<T>::add(T* algo,
if(!algo)
return;
- Mutex_Holder lock(mutex);
+ std::lock_guard<std::mutex> lock(mutex);
delete algorithms[algo->name()][provider];
algorithms[algo->name()][provider] = algo;
@@ -163,7 +163,7 @@ void Algorithm_Cache<T>::add(T* algo,
template<typename T> std::vector<std::string>
Algorithm_Cache<T>::providers_of(const std::string& algo_name)
{
- Mutex_Holder lock(mutex);
+ std::lock_guard<std::mutex> lock(mutex);
std::vector<std::string> providers;
@@ -190,7 +190,7 @@ template<typename T>
void Algorithm_Cache<T>::set_preferred_provider(const std::string& algo_spec,
const std::string& provider)
{
- Mutex_Holder lock(mutex);
+ std::lock_guard<std::mutex> lock(mutex);
pref_providers[algo_spec] = provider;
}
@@ -215,8 +215,6 @@ Algorithm_Cache<T>::~Algorithm_Cache()
++algo;
}
-
- delete mutex;
}
}
diff --git a/src/algo_factory/algo_factory.cpp b/src/algo_factory/algo_factory.cpp
index 3523b19d4..e891dc5cd 100644
--- a/src/algo_factory/algo_factory.cpp
+++ b/src/algo_factory/algo_factory.cpp
@@ -80,15 +80,14 @@ const T* factory_prototype(const std::string& algo_spec,
/**
* Setup caches
*/
-Algorithm_Factory::Algorithm_Factory(const std::vector<Engine*>& engines_in,
- Mutex_Factory& mf)
+Algorithm_Factory::Algorithm_Factory(const std::vector<Engine*>& engines_in)
{
engines = engines_in;
- block_cipher_cache = new Algorithm_Cache<BlockCipher>(mf.make());
- stream_cipher_cache = new Algorithm_Cache<StreamCipher>(mf.make());
- hash_cache = new Algorithm_Cache<HashFunction>(mf.make());
- mac_cache = new Algorithm_Cache<MessageAuthenticationCode>(mf.make());
+ block_cipher_cache = new Algorithm_Cache<BlockCipher>();
+ stream_cipher_cache = new Algorithm_Cache<StreamCipher>();
+ hash_cache = new Algorithm_Cache<HashFunction>();
+ mac_cache = new Algorithm_Cache<MessageAuthenticationCode>();
}
/**
diff --git a/src/algo_factory/algo_factory.h b/src/algo_factory/algo_factory.h
index 73e592013..1f4b577ee 100644
--- a/src/algo_factory/algo_factory.h
+++ b/src/algo_factory/algo_factory.h
@@ -8,7 +8,7 @@
#ifndef BOTAN_ALGORITHM_FACTORY_H__
#define BOTAN_ALGORITHM_FACTORY_H__
-#include <botan/mutex.h>
+#include <botan/types.h>
#include <string>
#include <vector>
@@ -37,8 +37,7 @@ class BOTAN_DLL Algorithm_Factory
* @param engines_in the list of engines to use
* @param mf a mutex factory
*/
- Algorithm_Factory(const std::vector<Engine*>& engines_in,
- Mutex_Factory& mf);
+ Algorithm_Factory(const std::vector<Engine*>& engines_in);
/**
* Destructor
diff --git a/src/algo_factory/info.txt b/src/algo_factory/info.txt
index dfc42230a..fc248523d 100644
--- a/src/algo_factory/info.txt
+++ b/src/algo_factory/info.txt
@@ -16,6 +16,5 @@ block
engine
hash
mac
-mutex
stream
</requires>
diff --git a/src/alloc/alloc_mmap/mmap_mem.h b/src/alloc/alloc_mmap/mmap_mem.h
index bef166a16..30e6d9ebb 100644
--- a/src/alloc/alloc_mmap/mmap_mem.h
+++ b/src/alloc/alloc_mmap/mmap_mem.h
@@ -18,7 +18,6 @@ namespace Botan {
class BOTAN_DLL MemoryMapping_Allocator : public Pooling_Allocator
{
public:
- MemoryMapping_Allocator(Mutex* m) : Pooling_Allocator(m) {}
std::string type() const { return "mmap"; }
private:
void* alloc_block(u32bit);
diff --git a/src/alloc/mem_pool/info.txt b/src/alloc/mem_pool/info.txt
index 0a762ccc4..b1c7a091f 100644
--- a/src/alloc/mem_pool/info.txt
+++ b/src/alloc/mem_pool/info.txt
@@ -6,7 +6,3 @@ load_on auto
mem_pool.cpp
mem_pool.h
</add>
-
-<requires>
-mutex
-</requires>
diff --git a/src/alloc/mem_pool/mem_pool.cpp b/src/alloc/mem_pool/mem_pool.cpp
index 38e0c3285..a3858add6 100644
--- a/src/alloc/mem_pool/mem_pool.cpp
+++ b/src/alloc/mem_pool/mem_pool.cpp
@@ -109,7 +109,7 @@ void Pooling_Allocator::Memory_Block::free(void* ptr, u32bit blocks) throw()
/*
* Pooling_Allocator Constructor
*/
-Pooling_Allocator::Pooling_Allocator(Mutex* m) : mutex(m)
+Pooling_Allocator::Pooling_Allocator()
{
last_used = blocks.begin();
}
@@ -119,7 +119,6 @@ Pooling_Allocator::Pooling_Allocator(Mutex* m) : mutex(m)
*/
Pooling_Allocator::~Pooling_Allocator()
{
- delete mutex;
if(blocks.size())
throw Invalid_State("Pooling_Allocator: Never released memory");
}
@@ -129,7 +128,7 @@ Pooling_Allocator::~Pooling_Allocator()
*/
void Pooling_Allocator::destroy()
{
- Mutex_Holder lock(mutex);
+ std::lock_guard<std::mutex> lock(mutex);
blocks.clear();
@@ -146,7 +145,7 @@ void* Pooling_Allocator::allocate(u32bit n)
const u32bit BITMAP_SIZE = Memory_Block::bitmap_size();
const u32bit BLOCK_SIZE = Memory_Block::block_size();
- Mutex_Holder lock(mutex);
+ std::lock_guard<std::mutex> lock(mutex);
if(n <= BITMAP_SIZE * BLOCK_SIZE)
{
@@ -183,7 +182,7 @@ void Pooling_Allocator::deallocate(void* ptr, u32bit n)
if(ptr == 0 && n == 0)
return;
- Mutex_Holder lock(mutex);
+ std::lock_guard<std::mutex> lock(mutex);
if(n > BITMAP_SIZE * BLOCK_SIZE)
dealloc_block(ptr, n);
diff --git a/src/alloc/mem_pool/mem_pool.h b/src/alloc/mem_pool/mem_pool.h
index a57800972..871f135bd 100644
--- a/src/alloc/mem_pool/mem_pool.h
+++ b/src/alloc/mem_pool/mem_pool.h
@@ -10,7 +10,7 @@
#include <botan/allocate.h>
#include <botan/exceptn.h>
-#include <botan/mutex.h>
+#include <mutex>
#include <utility>
#include <vector>
@@ -27,7 +27,7 @@ class BOTAN_DLL Pooling_Allocator : public Allocator
void destroy();
- Pooling_Allocator(Mutex*);
+ Pooling_Allocator();
~Pooling_Allocator();
private:
void get_more_core(u32bit);
@@ -66,7 +66,7 @@ class BOTAN_DLL Pooling_Allocator : public Allocator
std::vector<Memory_Block> blocks;
std::vector<Memory_Block>::iterator last_used;
std::vector<std::pair<void*, u32bit> > allocated;
- Mutex* mutex;
+ std::mutex mutex;
};
}
diff --git a/src/alloc/system_alloc/defalloc.h b/src/alloc/system_alloc/defalloc.h
index 627e8df70..ed2682ec0 100644
--- a/src/alloc/system_alloc/defalloc.h
+++ b/src/alloc/system_alloc/defalloc.h
@@ -30,8 +30,6 @@ class BOTAN_DLL Malloc_Allocator : public Allocator
class BOTAN_DLL Locking_Allocator : public Pooling_Allocator
{
public:
- Locking_Allocator(Mutex* m) : Pooling_Allocator(m) {}
-
std::string type() const { return "locking"; }
private:
void* alloc_block(u32bit);
diff --git a/src/asn1/asn1_dn.cpp b/src/asn1/asn1_dn.cpp
index c5a132d85..dd5bc94dc 100644
--- a/src/asn1/asn1_dn.cpp
+++ b/src/asn1/asn1_dn.cpp
@@ -26,9 +26,8 @@ X509_DN::X509_DN()
*/
X509_DN::X509_DN(const std::multimap<OID, std::string>& args)
{
- std::multimap<OID, std::string>::const_iterator j;
- for(j = args.begin(); j != args.end(); ++j)
- add_attribute(j->first, j->second);
+ for(auto i = args.begin(); i != args.end(); ++i)
+ add_attribute(i->first, i->second);
}
/*
@@ -36,9 +35,8 @@ X509_DN::X509_DN(const std::multimap<OID, std::string>& args)
*/
X509_DN::X509_DN(const std::multimap<std::string, std::string>& args)
{
- std::multimap<std::string, std::string>::const_iterator j;
- for(j = args.begin(); j != args.end(); ++j)
- add_attribute(OIDS::lookup(j->first), j->second);
+ for(auto i = args.begin(); i != args.end(); ++i)
+ add_attribute(OIDS::lookup(i->first), i->second);
}
/*
@@ -59,11 +57,9 @@ void X509_DN::add_attribute(const OID& oid, const std::string& str)
if(str == "")
return;
- typedef std::multimap<OID, ASN1_String>::iterator rdn_iter;
-
- std::pair<rdn_iter, rdn_iter> range = dn_info.equal_range(oid);
- for(rdn_iter j = range.first; j != range.second; ++j)
- if(j->second.value() == str)
+ auto range = dn_info.equal_range(oid);
+ for(auto i = range.first; i != range.second; ++i)
+ if(i->second.value() == str)
return;
multimap_insert(dn_info, oid, ASN1_String(str));
@@ -75,11 +71,9 @@ void X509_DN::add_attribute(const OID& oid, const std::string& str)
*/
std::multimap<OID, std::string> X509_DN::get_attributes() const
{
- typedef std::multimap<OID, ASN1_String>::const_iterator rdn_iter;
-
std::multimap<OID, std::string> retval;
- for(rdn_iter j = dn_info.begin(); j != dn_info.end(); ++j)
- multimap_insert(retval, j->first, j->second.value());
+ for(auto i = dn_info.begin(); i != dn_info.end(); ++i)
+ multimap_insert(retval, i->first, i->second.value());
return retval;
}
@@ -88,11 +82,9 @@ std::multimap<OID, std::string> X509_DN::get_attributes() const
*/
std::multimap<std::string, std::string> X509_DN::contents() const
{
- typedef std::multimap<OID, ASN1_String>::const_iterator rdn_iter;
-
std::multimap<std::string, std::string> retval;
- for(rdn_iter j = dn_info.begin(); j != dn_info.end(); ++j)
- multimap_insert(retval, OIDS::lookup(j->first), j->second.value());
+ for(auto i = dn_info.begin(); i != dn_info.end(); ++i)
+ multimap_insert(retval, OIDS::lookup(i->first), i->second.value());
return retval;
}
@@ -101,14 +93,13 @@ std::multimap<std::string, std::string> X509_DN::contents() const
*/
std::vector<std::string> X509_DN::get_attribute(const std::string& attr) const
{
- typedef std::multimap<OID, ASN1_String>::const_iterator rdn_iter;
-
const OID oid = OIDS::lookup(deref_info_field(attr));
- std::pair<rdn_iter, rdn_iter> range = dn_info.equal_range(oid);
+
+ auto range = dn_info.equal_range(oid);
std::vector<std::string> values;
- for(rdn_iter j = range.first; j != range.second; ++j)
- values.push_back(j->second.value());
+ for(auto i = range.first; i != range.second; ++i)
+ values.push_back(i->second.value());
return values;
}
@@ -171,15 +162,13 @@ std::string X509_DN::deref_info_field(const std::string& info)
*/
bool operator==(const X509_DN& dn1, const X509_DN& dn2)
{
- typedef std::multimap<OID, std::string>::const_iterator rdn_iter;
-
- std::multimap<OID, std::string> attr1 = dn1.get_attributes();
- std::multimap<OID, std::string> attr2 = dn2.get_attributes();
+ auto attr1 = dn1.get_attributes();
+ auto attr2 = dn2.get_attributes();
if(attr1.size() != attr2.size()) return false;
- rdn_iter p1 = attr1.begin();
- rdn_iter p2 = attr2.begin();
+ auto p1 = attr1.begin();
+ auto p2 = attr2.begin();
while(true)
{
@@ -209,18 +198,15 @@ bool operator!=(const X509_DN& dn1, const X509_DN& dn2)
*/
bool operator<(const X509_DN& dn1, const X509_DN& dn2)
{
- typedef std::multimap<OID, std::string>::const_iterator rdn_iter;
-
- std::multimap<OID, std::string> attr1 = dn1.get_attributes();
- std::multimap<OID, std::string> attr2 = dn2.get_attributes();
+ auto attr1 = dn1.get_attributes();
+ auto attr2 = dn2.get_attributes();
if(attr1.size() < attr2.size()) return true;
if(attr1.size() > attr2.size()) return false;
- for(rdn_iter p1 = attr1.begin(); p1 != attr1.end(); ++p1)
+ for(auto p1 = attr1.begin(); p1 != attr1.end(); ++p1)
{
- std::multimap<OID, std::string>::const_iterator p2;
- p2 = attr2.find(p1->first);
+ auto p2 = attr2.find(p1->first);
if(p2 == attr2.end()) return false;
if(p1->second > p2->second) return false;
if(p1->second < p2->second) return true;
@@ -238,8 +224,6 @@ void do_ava(DER_Encoder& encoder,
ASN1_Tag string_type, const std::string& oid_str,
bool must_exist = false)
{
- typedef std::multimap<OID, std::string>::const_iterator rdn_iter;
-
const OID oid = OIDS::lookup(oid_str);
const bool exists = (dn_info.find(oid) != dn_info.end());
@@ -247,14 +231,14 @@ void do_ava(DER_Encoder& encoder,
throw Encoding_Error("X509_DN: No entry for " + oid_str);
if(!exists) return;
- std::pair<rdn_iter, rdn_iter> range = dn_info.equal_range(oid);
+ auto range = dn_info.equal_range(oid);
- for(rdn_iter j = range.first; j != range.second; ++j)
+ for(auto i = range.first; i != range.second; ++i)
{
encoder.start_cons(SET)
.start_cons(SEQUENCE)
.encode(oid)
- .encode(ASN1_String(j->second, string_type))
+ .encode(ASN1_String(i->second, string_type))
.end_cons()
.end_cons();
}
@@ -267,7 +251,7 @@ void do_ava(DER_Encoder& encoder,
*/
void X509_DN::encode_into(DER_Encoder& der) const
{
- std::multimap<OID, std::string> dn_info = get_attributes();
+ auto dn_info = get_attributes();
der.start_cons(SEQUENCE);
diff --git a/src/build-data/cc/gcc b/src/build-data/cc/gcc
index 978ed6d58..23671efce 100644
--- a/src/build-data/cc/gcc
+++ b/src/build-data/cc/gcc
@@ -1,6 +1,6 @@
realname "GNU C++"
-binary_name "g++"
+binary_name "g++-4.4.1"
compiler_has_tr1 yes
@@ -10,7 +10,7 @@ add_include_dir_option "-I"
add_lib_dir_option "-L"
add_lib_option "-l"
-lang_flags "-D_REENTRANT -ansi -Wno-long-long"
+lang_flags "-D_REENTRANT -ansi -Wno-long-long -std=c++0x"
warning_flags "-W -Wall"
#warning_flags "-Wextra -Wall -Wstrict-aliasing -Wstrict-overflow=5 -Wcast-align -Wmissing-declarations -Wno-unused-parameter"
diff --git a/src/cert/cvc/cvc_ado.cpp b/src/cert/cvc/cvc_ado.cpp
index 6e1484e90..47c972c72 100644
--- a/src/cert/cvc/cvc_ado.cpp
+++ b/src/cert/cvc/cvc_ado.cpp
@@ -12,7 +12,7 @@
namespace Botan {
-EAC1_1_ADO::EAC1_1_ADO(std::tr1::shared_ptr<DataSource> in)
+EAC1_1_ADO::EAC1_1_ADO(std::shared_ptr<DataSource> in)
{
init(in);
do_decode();
@@ -20,7 +20,7 @@ EAC1_1_ADO::EAC1_1_ADO(std::tr1::shared_ptr<DataSource> in)
EAC1_1_ADO::EAC1_1_ADO(const std::string& in)
{
- std::tr1::shared_ptr<DataSource> stream(new DataSource_Stream(in, true));
+ std::shared_ptr<DataSource> stream(new DataSource_Stream(in, true));
init(stream);
do_decode();
}
@@ -41,18 +41,18 @@ void EAC1_1_ADO::force_decode()
.end_cons()
.get_contents();
- std::tr1::shared_ptr<DataSource> req_source(new DataSource_Memory(req_bits));
+ std::shared_ptr<DataSource> req_source(new DataSource_Memory(req_bits));
m_req = EAC1_1_Req(req_source);
sig_algo = m_req.sig_algo;
}
MemoryVector<byte> EAC1_1_ADO::make_signed(
- std::auto_ptr<PK_Signer> signer,
+ PK_Signer& signer,
const MemoryRegion<byte>& tbs_bits,
RandomNumberGenerator& rng)
{
SecureVector<byte> concat_sig =
- EAC1_1_obj<EAC1_1_ADO>::make_signature(signer.get(), tbs_bits, rng);
+ EAC1_1_obj<EAC1_1_ADO>::make_signature(signer, tbs_bits, rng);
assert(concat_sig.size() % 2 == 0);
MemoryVector<byte> result = DER_Encoder()
.start_cons(ASN1_Tag(7), APPLICATION)
diff --git a/src/cert/cvc/cvc_ado.h b/src/cert/cvc/cvc_ado.h
index 2c4f3ce70..dbb4a3f47 100644
--- a/src/cert/cvc/cvc_ado.h
+++ b/src/cert/cvc/cvc_ado.h
@@ -39,7 +39,7 @@ class BOTAN_DLL EAC1_1_ADO : public EAC1_1_obj<EAC1_1_ADO>
* Construct a CVC ADO request from a data source
* @param source the data source
*/
- EAC1_1_ADO(std::tr1::shared_ptr<DataSource> source);
+ EAC1_1_ADO(std::shared_ptr<DataSource> source);
/**
* Create a signed CVC ADO request from to be signed (TBS) data
@@ -47,7 +47,7 @@ class BOTAN_DLL EAC1_1_ADO : public EAC1_1_obj<EAC1_1_ADO>
* @param tbs_bits the TBS data to sign
*/
static MemoryVector<byte> make_signed(
- std::auto_ptr<PK_Signer> signer,
+ PK_Signer& signer,
const MemoryRegion<byte>& tbs_bits,
RandomNumberGenerator& rng);
diff --git a/src/cert/cvc/cvc_ca.cpp b/src/cert/cvc/cvc_ca.cpp
index 638d3f984..20cea9104 100644
--- a/src/cert/cvc/cvc_ca.cpp
+++ b/src/cert/cvc/cvc_ca.cpp
@@ -5,7 +5,7 @@
#include <botan/oids.h>
namespace Botan {
-EAC1_1_CVC EAC1_1_CVC_CA::make_cert(std::auto_ptr<PK_Signer> signer,
+EAC1_1_CVC EAC1_1_CVC_CA::make_cert(PK_Signer& signer,
MemoryRegion<byte> const& public_key,
ASN1_Car const& car,
ASN1_Chr const& chr,
@@ -38,7 +38,7 @@ EAC1_1_CVC EAC1_1_CVC_CA::make_cert(std::auto_ptr<PK_Signer> signer,
EAC1_1_CVC::build_cert_body(tbs),
rng);
- std::tr1::shared_ptr<DataSource> source(new DataSource_Memory(signed_cert));
+ std::shared_ptr<DataSource> source(new DataSource_Memory(signed_cert));
return EAC1_1_CVC(source);
}
diff --git a/src/cert/cvc/cvc_ca.h b/src/cert/cvc/cvc_ca.h
index 3ec307bb3..87699808f 100644
--- a/src/cert/cvc/cvc_ca.h
+++ b/src/cert/cvc/cvc_ca.h
@@ -36,7 +36,7 @@ class BOTAN_DLL EAC1_1_CVC_CA
* @param ced the CED to appear in the certificate
* @param ced the CEX to appear in the certificate
*/
- static EAC1_1_CVC make_cert(std::auto_ptr<PK_Signer> signer,
+ static EAC1_1_CVC make_cert(PK_Signer& signer,
MemoryRegion<byte> const& public_key,
ASN1_Car const& car,
ASN1_Chr const& chr,
diff --git a/src/cert/cvc/cvc_cert.cpp b/src/cert/cvc/cvc_cert.cpp
index d2be12df8..5c2e28c39 100644
--- a/src/cert/cvc/cvc_cert.cpp
+++ b/src/cert/cvc/cvc_cert.cpp
@@ -61,7 +61,7 @@ void EAC1_1_CVC::force_decode()
// FIXME: PK algos have no notion of EAC encoder/decoder currently
#if 0
ECDSA_PublicKey tmp_pk;
- std::auto_ptr<EAC1_1_CVC_Decoder> dec = tmp_pk.cvc_eac1_1_decoder();
+ std::unique_ptr<EAC1_1_CVC_Decoder> dec = tmp_pk.cvc_eac1_1_decoder();
sig_algo = dec->public_key(enc_pk);
@@ -78,7 +78,7 @@ void EAC1_1_CVC::force_decode()
/*
* CVC Certificate Constructor
*/
-EAC1_1_CVC::EAC1_1_CVC(std::tr1::shared_ptr<DataSource>& in)
+EAC1_1_CVC::EAC1_1_CVC(std::shared_ptr<DataSource>& in)
{
init(in);
self_signed = false;
@@ -87,7 +87,7 @@ EAC1_1_CVC::EAC1_1_CVC(std::tr1::shared_ptr<DataSource>& in)
EAC1_1_CVC::EAC1_1_CVC(const std::string& in)
{
- std::tr1::shared_ptr<DataSource> stream(new DataSource_Stream(in, true));
+ std::shared_ptr<DataSource> stream(new DataSource_Stream(in, true));
init(stream);
self_signed = false;
do_decode();
diff --git a/src/cert/cvc/cvc_cert.h b/src/cert/cvc/cvc_cert.h
index 17671d332..0bc162c0c 100644
--- a/src/cert/cvc/cvc_cert.h
+++ b/src/cert/cvc/cvc_cert.h
@@ -59,7 +59,7 @@ class BOTAN_DLL EAC1_1_CVC : public EAC1_1_gen_CVC<EAC1_1_CVC>//Signed_Object
* Construct a CVC from a data source
* @param source the data source
*/
- EAC1_1_CVC(std::tr1::shared_ptr<DataSource>& source);
+ EAC1_1_CVC(std::shared_ptr<DataSource>& source);
/**
* Construct a CVC from a file
diff --git a/src/cert/cvc/cvc_gen_cert.h b/src/cert/cvc/cvc_gen_cert.h
index 4a788026c..8620cd89a 100644
--- a/src/cert/cvc/cvc_gen_cert.h
+++ b/src/cert/cvc/cvc_gen_cert.h
@@ -33,7 +33,7 @@ class BOTAN_DLL EAC1_1_gen_CVC : public EAC1_1_obj<Derived> // CRTP continuation
* Get this certificates public key.
* @result this certificates public key
*/
- std::auto_ptr<Public_Key> subject_public_key() const;
+ std::unique_ptr<Public_Key> subject_public_key() const;
/**
* Find out whether this object is self signed.
@@ -75,7 +75,7 @@ class BOTAN_DLL EAC1_1_gen_CVC : public EAC1_1_obj<Derived> // CRTP continuation
* @result the DER encoded signed generalized CVC object
*/
static MemoryVector<byte> make_signed(
- std::auto_ptr<PK_Signer> signer,
+ PK_Signer& signer,
const MemoryRegion<byte>& tbs_bits,
RandomNumberGenerator& rng);
virtual ~EAC1_1_gen_CVC<Derived>()
@@ -103,11 +103,11 @@ template<typename Derived> bool EAC1_1_gen_CVC<Derived>::is_self_signed() const
}
template<typename Derived> MemoryVector<byte> EAC1_1_gen_CVC<Derived>::make_signed(
- std::auto_ptr<PK_Signer> signer,
+ PK_Signer& signer,
const MemoryRegion<byte>& tbs_bits,
RandomNumberGenerator& rng) // static
{
- SecureVector<byte> concat_sig = EAC1_1_obj<Derived>::make_signature(signer.get(), tbs_bits, rng);
+ SecureVector<byte> concat_sig = EAC1_1_obj<Derived>::make_signature(signer, tbs_bits, rng);
assert(concat_sig.size() % 2 == 0);
return DER_Encoder()
.start_cons(ASN1_Tag(33), APPLICATION)
@@ -117,9 +117,9 @@ template<typename Derived> MemoryVector<byte> EAC1_1_gen_CVC<Derived>::make_sign
.get_contents();
}
-template<typename Derived> std::auto_ptr<Public_Key> EAC1_1_gen_CVC<Derived>::subject_public_key() const
+template<typename Derived> std::unique_ptr<Public_Key> EAC1_1_gen_CVC<Derived>::subject_public_key() const
{
- return std::auto_ptr<Public_Key>(new ECDSA_PublicKey(m_pk));
+ return std::unique_ptr<Public_Key>(new ECDSA_PublicKey(m_pk));
}
template<typename Derived> SecureVector<byte> EAC1_1_gen_CVC<Derived>::build_cert_body(MemoryRegion<byte> const& tbs)
diff --git a/src/cert/cvc/cvc_req.cpp b/src/cert/cvc/cvc_req.cpp
index 70a44bacd..aa29d8ee6 100644
--- a/src/cert/cvc/cvc_req.cpp
+++ b/src/cert/cvc/cvc_req.cpp
@@ -44,13 +44,13 @@ void EAC1_1_Req::force_decode()
// FIXME: No EAC support in ECDSA
#if 0
ECDSA_PublicKey tmp_pk;
- std::auto_ptr<EAC1_1_CVC_Decoder> dec = tmp_pk.cvc_eac1_1_decoder();
+ std::unique_ptr<EAC1_1_CVC_Decoder> dec = tmp_pk.cvc_eac1_1_decoder();
sig_algo = dec->public_key(enc_pk);
m_pk = tmp_pk;
#endif
}
-EAC1_1_Req::EAC1_1_Req(std::tr1::shared_ptr<DataSource> in)
+EAC1_1_Req::EAC1_1_Req(std::shared_ptr<DataSource> in)
{
init(in);
self_signed = true;
@@ -59,7 +59,7 @@ EAC1_1_Req::EAC1_1_Req(std::tr1::shared_ptr<DataSource> in)
EAC1_1_Req::EAC1_1_Req(const std::string& in)
{
- std::tr1::shared_ptr<DataSource> stream(new DataSource_Stream(in, true));
+ std::shared_ptr<DataSource> stream(new DataSource_Stream(in, true));
init(stream);
self_signed = true;
do_decode();
diff --git a/src/cert/cvc/cvc_req.h b/src/cert/cvc/cvc_req.h
index 8599f539d..4999c332f 100644
--- a/src/cert/cvc/cvc_req.h
+++ b/src/cert/cvc/cvc_req.h
@@ -36,7 +36,7 @@ class BOTAN_DLL EAC1_1_Req : public EAC1_1_gen_CVC<EAC1_1_Req>
* Construct a CVC request from a data source.
* @param source the data source
*/
- EAC1_1_Req(std::tr1::shared_ptr<DataSource> source);
+ EAC1_1_Req(std::shared_ptr<DataSource> source);
/**
* Construct a CVC request from a DER encoded CVC reqeust file.
diff --git a/src/cert/cvc/cvc_self.cpp b/src/cert/cvc/cvc_self.cpp
index 91ea38724..6a81c40ec 100644
--- a/src/cert/cvc/cvc_self.cpp
+++ b/src/cert/cvc/cvc_self.cpp
@@ -84,16 +84,18 @@ EAC1_1_CVC create_self_signed_cert(Private_Key const& key,
sig_algo.oid = OIDS::lookup(priv_key->algo_name() + "/" + padding_and_hash);
sig_algo = AlgorithmIdentifier(sig_algo.oid, AlgorithmIdentifier::USE_NULL_PARAM);
- std::auto_ptr<Botan::PK_Signer> signer(get_pk_signer(*priv_key, padding_and_hash));
+ std::unique_ptr<Botan::PK_Signer> signer(get_pk_signer(*priv_key, padding_and_hash));
#if 0 // FIXME
- std::auto_ptr<EAC1_1_CVC_Encoder> enc(priv_key->cvc_eac1_1_encoder());
+ std::unique_ptr<EAC1_1_CVC_Encoder> enc(priv_key->cvc_eac1_1_encoder());
MemoryVector<byte> enc_public_key = enc->public_key(sig_algo);
#else
MemoryVector<byte> enc_public_key;
#endif
- return EAC1_1_CVC_CA::make_cert(signer, enc_public_key, opt.car, chr, opt.holder_auth_templ, opt.ced, opt.cex, rng);
+ return EAC1_1_CVC_CA::make_cert(*signer.get(), enc_public_key,
+ opt.car, chr, opt.holder_auth_templ,
+ opt.ced, opt.cex, rng);
}
@@ -113,10 +115,10 @@ EAC1_1_Req create_cvc_req(Private_Key const& key,
sig_algo.oid = OIDS::lookup(priv_key->algo_name() + "/" + padding_and_hash);
sig_algo = AlgorithmIdentifier(sig_algo.oid, AlgorithmIdentifier::USE_NULL_PARAM);
- std::auto_ptr<Botan::PK_Signer> signer(get_pk_signer(*priv_key, padding_and_hash));
+ std::unique_ptr<Botan::PK_Signer> signer(get_pk_signer(*priv_key, padding_and_hash));
#if 0 // FIXME
- std::auto_ptr<EAC1_1_CVC_Encoder> enc(priv_key->cvc_eac1_1_encoder());
+ std::unique_ptr<EAC1_1_CVC_Encoder> enc(priv_key->cvc_eac1_1_encoder());
MemoryVector<byte> enc_public_key = enc->public_key(sig_algo);
#else
MemoryVector<byte> enc_public_key;
@@ -130,8 +132,11 @@ EAC1_1_Req create_cvc_req(Private_Key const& key,
.encode(chr)
.get_contents();
- MemoryVector<byte> signed_cert = EAC1_1_gen_CVC<EAC1_1_Req>::make_signed(signer, EAC1_1_gen_CVC<EAC1_1_Req>::build_cert_body(tbs), rng);
- std::tr1::shared_ptr<DataSource> source(new DataSource_Memory(signed_cert));
+ MemoryVector<byte> signed_cert =
+ EAC1_1_gen_CVC<EAC1_1_Req>::make_signed(*signer.get(),
+ EAC1_1_gen_CVC<EAC1_1_Req>::build_cert_body(tbs), rng);
+
+ std::shared_ptr<DataSource> source(new DataSource_Memory(signed_cert));
return EAC1_1_Req(source);
}
@@ -146,12 +151,16 @@ EAC1_1_ADO create_ado_req(Private_Key const& key,
{
throw Invalid_Argument("CVC_EAC::create_self_signed_cert(): unsupported key type");
}
+
std::string padding_and_hash = padding_and_hash_from_oid(req.signature_algorithm().oid);
- std::auto_ptr<Botan::PK_Signer> signer(get_pk_signer(*priv_key, padding_and_hash));
+
+ std::unique_ptr<Botan::PK_Signer> signer(get_pk_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, tbs_bits, rng);
- std::tr1::shared_ptr<DataSource> source(new DataSource_Memory(signed_cert));
+
+ MemoryVector<byte> signed_cert = EAC1_1_ADO::make_signed(*signer.get(), tbs_bits, rng);
+ std::shared_ptr<DataSource> source(new DataSource_Memory(signed_cert));
return EAC1_1_ADO(source);
}
@@ -210,19 +219,19 @@ 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);
- std::auto_ptr<Botan::PK_Signer> pk_signer(get_pk_signer(*priv_key, padding_and_hash));
- std::auto_ptr<Public_Key> pk = signee.subject_public_key();
+ std::unique_ptr<Botan::PK_Signer> pk_signer(get_pk_signer(*priv_key, padding_and_hash));
+ 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(ENC_EXPLICIT);
#if 0 // FIXME
- std::auto_ptr<EAC1_1_CVC_Encoder> enc(subj_pk->cvc_eac1_1_encoder());
+ std::unique_ptr<EAC1_1_CVC_Encoder> enc(subj_pk->cvc_eac1_1_encoder());
MemoryVector<byte> enc_public_key = enc->public_key(sig_algo);
#else
MemoryVector<byte> enc_public_key;
#endif
- return EAC1_1_CVC_CA::make_cert(pk_signer, enc_public_key,
+ return EAC1_1_CVC_CA::make_cert(*pk_signer.get(), enc_public_key,
signer.get_car(),
signee.get_chr(),
signer.get_chat_value(),
@@ -250,10 +259,10 @@ EAC1_1_CVC sign_request(EAC1_1_CVC const& signer_cert,
chr_str.append(fixed_len_seqnr(seqnr, seqnr_len));
ASN1_Chr chr(chr_str);
std::string padding_and_hash = padding_and_hash_from_oid(signee.signature_algorithm().oid);
- std::auto_ptr<Botan::PK_Signer> pk_signer(get_pk_signer(*priv_key, padding_and_hash));
- std::auto_ptr<Public_Key> pk = signee.subject_public_key();
+ std::unique_ptr<Botan::PK_Signer> pk_signer(get_pk_signer(*priv_key, padding_and_hash));
+ std::unique_ptr<Public_Key> pk = signee.subject_public_key();
ECDSA_PublicKey* subj_pk = dynamic_cast<ECDSA_PublicKey*>(pk.get());
- std::auto_ptr<Public_Key> signer_pk = signer_cert.subject_public_key();
+ std::unique_ptr<Public_Key> signer_pk = signer_cert.subject_public_key();
// for the case that the domain parameters are not set...
// (we use those from the signer because they must fit)
@@ -262,7 +271,7 @@ EAC1_1_CVC sign_request(EAC1_1_CVC const& signer_cert,
subj_pk->set_parameter_encoding(ENC_IMPLICITCA);
#if 0 // FIXME
- std::auto_ptr<EAC1_1_CVC_Encoder> enc(subj_pk->cvc_eac1_1_encoder());
+ std::unique_ptr<EAC1_1_CVC_Encoder> enc(subj_pk->cvc_eac1_1_encoder());
MemoryVector<byte> enc_public_key = enc->public_key(sig_algo);
#else
MemoryVector<byte> enc_public_key;
@@ -298,7 +307,7 @@ EAC1_1_CVC sign_request(EAC1_1_CVC const& signer_cert,
throw Invalid_Argument("sign_request(): encountered illegal value for CHAT");
// (IS cannot sign certificates)
}
- return EAC1_1_CVC_CA::make_cert(pk_signer, enc_public_key,
+ return EAC1_1_CVC_CA::make_cert(*pk_signer.get(), enc_public_key,
ASN1_Car(signer_cert.get_chr().iso_8859()),
chr,
chat_val,
diff --git a/src/cert/cvc/eac_obj.h b/src/cert/cvc/eac_obj.h
index 04afd7e59..b41b78b2c 100644
--- a/src/cert/cvc/eac_obj.h
+++ b/src/cert/cvc/eac_obj.h
@@ -54,7 +54,7 @@ class BOTAN_DLL EAC1_1_obj : public EAC_Signed_Object
protected:
void init(SharedPtrConverter<DataSource> in);
- static SecureVector<byte> make_signature(PK_Signer* signer,
+ static SecureVector<byte> make_signature(PK_Signer& signer,
const MemoryRegion<byte>& tbs_bits,
RandomNumberGenerator& rng);
@@ -68,12 +68,12 @@ template<typename Derived> SecureVector<byte> EAC1_1_obj<Derived>::get_concat_si
}
template<typename Derived> SecureVector<byte>
-EAC1_1_obj<Derived>::make_signature(PK_Signer* signer,
+EAC1_1_obj<Derived>::make_signature(PK_Signer& signer,
const MemoryRegion<byte>& tbs_bits,
RandomNumberGenerator& rng)
{
// this is the signature as a der sequence
- SecureVector<byte> seq_sig = signer->sign_message(tbs_bits, rng);
+ SecureVector<byte> seq_sig = signer.sign_message(tbs_bits, rng);
ECDSA_Signature sig(decode_seq(seq_sig));
SecureVector<byte> concat_sig(sig.get_concatenation());
@@ -112,12 +112,12 @@ bool EAC1_1_obj<Derived>::check_signature(Public_Key& pub_key) const
if(!dynamic_cast<PK_Verifying_wo_MR_Key*>(&pub_key))
return false;
- std::auto_ptr<ECDSA_Signature_Encoder> enc(new ECDSA_Signature_Encoder(&m_sig));
+ std::unique_ptr<ECDSA_Signature_Encoder> enc(new ECDSA_Signature_Encoder(&m_sig));
SecureVector<byte> seq_sig = enc->signature_bits();
SecureVector<byte> to_sign = tbs_data();
PK_Verifying_wo_MR_Key& sig_key = dynamic_cast<PK_Verifying_wo_MR_Key&>(pub_key);
- std::auto_ptr<PK_Verifier> verifier(get_pk_verifier(sig_key, padding, format));
+ std::unique_ptr<PK_Verifier> verifier(get_pk_verifier(sig_key, padding, format));
return verifier->verify_message(to_sign, seq_sig);
}
catch(...)
diff --git a/src/cert/cvc/ecdsa_sig.cpp b/src/cert/cvc/ecdsa_sig.cpp
index c33a4550a..1a60f7aa8 100644
--- a/src/cert/cvc/ecdsa_sig.cpp
+++ b/src/cert/cvc/ecdsa_sig.cpp
@@ -41,7 +41,7 @@ ECDSA_Signature const decode_seq(MemoryRegion<byte> const& seq)
{
ECDSA_Signature sig;
- std::auto_ptr<ECDSA_Signature_Decoder> dec(new ECDSA_Signature_Decoder(&sig));
+ std::unique_ptr<ECDSA_Signature_Decoder> dec(new ECDSA_Signature_Decoder(&sig));
dec->signature_bits(seq);
return sig;
}
diff --git a/src/cert/cvc/freestore.h b/src/cert/cvc/freestore.h
index f95afa802..a6f779c78 100644
--- a/src/cert/cvc/freestore.h
+++ b/src/cert/cvc/freestore.h
@@ -7,14 +7,7 @@
#define BOTAN_FREESTORE_H__
#include <botan/build.h>
-
-#if defined(BOTAN_USE_STD_TR1)
- #include <tr1/memory>
-#elif defined(BOTAN_USE_BOOST_TR1)
- #include <boost/tr1/memory.hpp>
-#else
- #error "Please choose a TR1 implementation in build.h"
-#endif
+#include <memory>
namespace Botan {
@@ -30,7 +23,7 @@ template<typename T>
class BOTAN_DLL SharedPtrConverter
{
public:
- typedef std::tr1::shared_ptr<T> SharedPtr;
+ typedef std::shared_ptr<T> SharedPtr;
/**
* Construct a null pointer equivalent object.
diff --git a/src/cert/x509/x509_ca.cpp b/src/cert/x509/x509_ca.cpp
index 41e314724..05cdce411 100644
--- a/src/cert/x509/x509_ca.cpp
+++ b/src/cert/x509/x509_ca.cpp
@@ -51,7 +51,7 @@ X509_Certificate X509_CA::sign_request(const PKCS10_Request& req,
constraints = Key_Constraints(KEY_CERT_SIGN | CRL_SIGN);
else
{
- std::auto_ptr<Public_Key> key(req.subject_public_key());
+ std::unique_ptr<Public_Key> key(req.subject_public_key());
constraints = X509::find_constraints(*key, req.constraints());
}
@@ -269,7 +269,7 @@ PK_Signer* choose_sig_format(const Private_Key& key,
sig_algo.oid = OIDS::lookup(algo_name + "/" + padding);
- std::auto_ptr<X509_Encoder> encoding(key.x509_encoder());
+ std::unique_ptr<X509_Encoder> encoding(key.x509_encoder());
if(!encoding.get())
throw Encoding_Error("Key " + algo_name + " does not support "
"X.509 encoding");
diff --git a/src/cert/x509/x509_obj.cpp b/src/cert/x509/x509_obj.cpp
index 31b4a309f..95a1c1cca 100644
--- a/src/cert/x509/x509_obj.cpp
+++ b/src/cert/x509/x509_obj.cpp
@@ -168,7 +168,7 @@ bool X509_Object::check_signature(Public_Key& pub_key) const
Signature_Format format =
(pub_key.message_parts() >= 2) ? DER_SEQUENCE : IEEE_1363;
- std::auto_ptr<PK_Verifier> verifier;
+ std::unique_ptr<PK_Verifier> verifier;
if(dynamic_cast<PK_Verifying_with_MR_Key*>(&pub_key))
{
diff --git a/src/cert/x509/x509self.cpp b/src/cert/x509/x509self.cpp
index 8afb22a7e..598d6a418 100644
--- a/src/cert/x509/x509self.cpp
+++ b/src/cert/x509/x509self.cpp
@@ -72,7 +72,7 @@ X509_Certificate create_self_signed_cert(const X509_Cert_Options& opts,
AlternativeName subject_alt;
MemoryVector<byte> pub_key = shared_setup(opts, key);
- std::auto_ptr<PK_Signer> signer(choose_sig_format(key, sig_algo));
+ std::unique_ptr<PK_Signer> signer(choose_sig_format(key, sig_algo));
load_info(opts, subject_dn, subject_alt);
Key_Constraints constraints;
@@ -110,7 +110,7 @@ PKCS10_Request create_cert_req(const X509_Cert_Options& opts,
AlternativeName subject_alt;
MemoryVector<byte> pub_key = shared_setup(opts, key);
- std::auto_ptr<PK_Signer> signer(choose_sig_format(key, sig_algo));
+ std::unique_ptr<PK_Signer> signer(choose_sig_format(key, sig_algo));
load_info(opts, subject_dn, subject_alt);
const u32bit PKCS10_VERSION = 0;
diff --git a/src/cert/x509/x509stor.cpp b/src/cert/x509/x509stor.cpp
index cb61bc2d2..f91da890b 100644
--- a/src/cert/x509/x509stor.cpp
+++ b/src/cert/x509/x509stor.cpp
@@ -380,8 +380,8 @@ X509_Code X509_Store::check_sig(const Cert_Info& cert_info,
*/
X509_Code X509_Store::check_sig(const X509_Object& object, Public_Key* key)
{
- std::auto_ptr<Public_Key> pub_key(key);
- std::auto_ptr<PK_Verifier> verifier;
+ std::unique_ptr<Public_Key> pub_key(key);
+ std::unique_ptr<PK_Verifier> verifier;
try {
std::vector<std::string> sig_info =
diff --git a/src/hash/par_hash/par_hash.cpp b/src/hash/par_hash/par_hash.cpp
index 4b0c7c466..789238647 100644
--- a/src/hash/par_hash/par_hash.cpp
+++ b/src/hash/par_hash/par_hash.cpp
@@ -1,6 +1,6 @@
/*
* Parallel
-* (C) 1999-2007 Jack Lloyd
+* (C) 1999-2009 Jack Lloyd
*
* Distributed under the terms of the Botan license
*/
@@ -18,8 +18,8 @@ u32bit sum_of_hash_lengths(const std::vector<HashFunction*>& hashes)
{
u32bit sum = 0;
- for(u32bit j = 0; j != hashes.size(); ++j)
- sum += hashes[j]->OUTPUT_LENGTH;
+ for(auto hash = hashes.begin(); hash != hashes.end(); ++hash)
+ sum += (*hash)->OUTPUT_LENGTH;
return sum;
}
@@ -31,20 +31,21 @@ u32bit sum_of_hash_lengths(const std::vector<HashFunction*>& hashes)
*/
void Parallel::add_data(const byte input[], u32bit length)
{
- for(u32bit j = 0; j != hashes.size(); ++j)
- hashes[j]->update(input, length);
+ for(auto hash = hashes.begin(); hash != hashes.end(); ++hash)
+ (*hash)->update(input, length);
}
/*
* Finalize the hash
*/
-void Parallel::final_result(byte hash[])
+void Parallel::final_result(byte out[])
{
u32bit offset = 0;
- for(u32bit j = 0; j != hashes.size(); ++j)
+
+ for(auto hash = hashes.begin(); hash != hashes.end(); ++hash)
{
- hashes[j]->final(hash + offset);
- offset += hashes[j]->OUTPUT_LENGTH;
+ (*hash)->final(out + offset);
+ offset += (*hash)->OUTPUT_LENGTH;
}
}
@@ -54,12 +55,14 @@ void Parallel::final_result(byte hash[])
std::string Parallel::name() const
{
std::string hash_names;
- for(u32bit j = 0; j != hashes.size(); ++j)
+
+ for(auto hash = hashes.begin(); hash != hashes.end(); ++hash)
{
- if(j)
+ if(hash != hashes.begin())
hash_names += ',';
- hash_names += hashes[j]->name();
+ hash_names += (*hash)->name();
}
+
return "Parallel(" + hash_names + ")";
}
@@ -69,8 +72,10 @@ std::string Parallel::name() const
HashFunction* Parallel::clone() const
{
std::vector<HashFunction*> hash_copies;
- for(u32bit j = 0; j != hashes.size(); ++j)
- hash_copies.push_back(hashes[j]->clone());
+
+ for(auto hash = hashes.begin(); hash != hashes.end(); ++hash)
+ hash_copies.push_back((*hash)->clone());
+
return new Parallel(hash_copies);
}
@@ -79,8 +84,8 @@ HashFunction* Parallel::clone() const
*/
void Parallel::clear() throw()
{
- for(u32bit j = 0; j != hashes.size(); ++j)
- hashes[j]->clear();
+ for(auto hash = hashes.begin(); hash != hashes.end(); ++hash)
+ (*hash)->clear();
}
/*
@@ -96,8 +101,8 @@ Parallel::Parallel(const std::vector<HashFunction*>& hash_in) :
*/
Parallel::~Parallel()
{
- for(u32bit j = 0; j != hashes.size(); ++j)
- delete hashes[j];
+ for(auto hash = hashes.begin(); hash != hashes.end(); ++hash)
+ delete (*hash);
}
}
diff --git a/src/libstate/info.txt b/src/libstate/info.txt
index 6eaa2f70b..fcf386e6d 100644
--- a/src/libstate/info.txt
+++ b/src/libstate/info.txt
@@ -34,8 +34,6 @@ hash
kdf
mac
mode_pad
-mutex
-noop_mutex
pk_pad
pubkey
rng
diff --git a/src/libstate/init.cpp b/src/libstate/init.cpp
index b908de6c7..0d9a2420c 100644
--- a/src/libstate/init.cpp
+++ b/src/libstate/init.cpp
@@ -1,12 +1,11 @@
/**
* Default Initialization Function
-* (C) 1999-2007 Jack Lloyd
+* (C) 1999-2009 Jack Lloyd
*
* Distributed under the terms of the Botan license
*/
#include <botan/init.h>
-#include <botan/parsing.h>
#include <botan/libstate.h>
namespace Botan {
@@ -14,36 +13,8 @@ namespace Botan {
/*
* Library Initialization
*/
-void LibraryInitializer::initialize(const std::string& arg_string)
+void LibraryInitializer::initialize(const std::string&)
{
- bool thread_safe = false;
-
- const std::vector<std::string> arg_list = split_on(arg_string, ' ');
- for(u32bit j = 0; j != arg_list.size(); ++j)
- {
- if(arg_list[j].size() == 0)
- continue;
-
- std::string name, value;
-
- if(arg_list[j].find('=') == std::string::npos)
- {
- name = arg_list[j];
- value = "true";
- }
- else
- {
- std::vector<std::string> name_and_value = split_on(arg_list[j], '=');
- name = name_and_value[0];
- value = name_and_value[1];
- }
-
- bool is_on =
- (value == "1" || value == "true" || value == "yes" || value == "on");
-
- if(name == "thread_safe")
- thread_safe = is_on;
- }
try
{
@@ -55,7 +26,7 @@ void LibraryInitializer::initialize(const std::string& arg_string)
*/
set_global_state(new Library_State);
- global_state().initialize(thread_safe);
+ global_state().initialize();
}
catch(...)
{
diff --git a/src/libstate/libstate.cpp b/src/libstate/libstate.cpp
index 20e736868..fea0c942a 100644
--- a/src/libstate/libstate.cpp
+++ b/src/libstate/libstate.cpp
@@ -9,21 +9,11 @@
#include <botan/init.h>
#include <botan/engine.h>
#include <botan/stl_util.h>
-#include <botan/mutex.h>
-#include <botan/mux_noop.h>
#include <botan/charset.h>
#include <botan/defalloc.h>
#include <botan/def_eng.h>
#include <algorithm>
-#if defined(BOTAN_HAS_MUTEX_PTHREAD)
- #include <botan/mux_pthr.h>
-#elif defined(BOTAN_HAS_MUTEX_WIN32)
- #include <botan/mux_win32.h>
-#elif defined(BOTAN_HAS_MUTEX_QT)
- #include <botan/mux_qt.h>
-#endif
-
#if defined(BOTAN_HAS_ALLOC_MMAP)
#include <botan/mmap_mem.h>
#endif
@@ -86,25 +76,17 @@ void set_global_state(Library_State* new_state)
*/
Library_State* swap_global_state(Library_State* new_state)
{
- Library_State* old_state = global_lib_state;
+ auto old_state = global_lib_state;
global_lib_state = new_state;
return old_state;
}
/*
-* Get a new mutex object
-*/
-Mutex* Library_State::get_mutex() const
- {
- return mutex_factory->make();
- }
-
-/*
* Get an allocator by its name
*/
-Allocator* Library_State::get_allocator(const std::string& type) const
+Allocator* Library_State::get_allocator(const std::string& type)
{
- Mutex_Holder lock(allocator_lock);
+ std::lock_guard<std::mutex> lock(allocator_lock);
if(type != "")
return search_map<std::string, Allocator*>(alloc_factory, type, 0);
@@ -128,7 +110,7 @@ Allocator* Library_State::get_allocator(const std::string& type) const
*/
void Library_State::add_allocator(Allocator* allocator)
{
- Mutex_Holder lock(allocator_lock);
+ std::lock_guard<std::mutex> lock(allocator_lock);
allocator->init();
@@ -141,11 +123,11 @@ void Library_State::add_allocator(Allocator* allocator)
*/
void Library_State::set_default_allocator(const std::string& type)
{
- Mutex_Holder lock(allocator_lock);
-
if(type == "")
return;
+ std::lock_guard<std::mutex> lock(allocator_lock);
+
this->set("conf", "base/default_allocator", type);
cached_default_allocator = 0;
}
@@ -154,9 +136,9 @@ void Library_State::set_default_allocator(const std::string& type)
* Get a configuration value
*/
std::string Library_State::get(const std::string& section,
- const std::string& key) const
+ const std::string& key)
{
- Mutex_Holder lock(config_lock);
+ std::lock_guard<std::mutex> lock(config_lock);
return search_map<std::string, std::string>(config,
section + "/" + key, "");
@@ -166,9 +148,9 @@ std::string Library_State::get(const std::string& section,
* See if a particular option has been set
*/
bool Library_State::is_set(const std::string& section,
- const std::string& key) const
+ const std::string& key)
{
- Mutex_Holder lock(config_lock);
+ std::lock_guard<std::mutex> lock(config_lock);
return search_map(config, section + "/" + key, false, true);
}
@@ -179,7 +161,7 @@ bool Library_State::is_set(const std::string& section,
void Library_State::set(const std::string& section, const std::string& key,
const std::string& value, bool overwrite)
{
- Mutex_Holder lock(config_lock);
+ std::lock_guard<std::mutex> lock(config_lock);
std::string full_key = section + "/" + key;
@@ -201,7 +183,7 @@ void Library_State::add_alias(const std::string& key, const std::string& value)
/*
* Dereference an alias to a fixed name
*/
-std::string Library_State::deref_alias(const std::string& key) const
+std::string Library_State::deref_alias(const std::string& key)
{
std::string result = key;
while(is_set("alias", result))
@@ -221,7 +203,7 @@ void Library_State::set_option(const std::string& key,
/*
* Get an option value
*/
-std::string Library_State::option(const std::string& key) const
+std::string Library_State::option(const std::string& key)
{
return get("conf", key);
}
@@ -239,69 +221,50 @@ Algorithm_Factory& Library_State::algorithm_factory()
/*
* Load a set of modules
*/
-void Library_State::initialize(bool thread_safe)
+void Library_State::initialize()
{
- if(mutex_factory)
+ if(m_algorithm_factory)
throw Invalid_State("Library_State has already been initialized");
- if(!thread_safe)
- {
- mutex_factory = new Noop_Mutex_Factory;
- }
- else
- {
-#if defined(BOTAN_HAS_MUTEX_PTHREAD)
- mutex_factory = new Pthread_Mutex_Factory;
-#elif defined(BOTAN_HAS_MUTEX_WIN32)
- mutex_factory = new Win32_Mutex_Factory;
-#elif defined(BOTAN_HAS_MUTEX_QT)
- mutex_factory Qt_Mutex_Factory;
-#else
- throw Invalid_State("Could not find a thread-safe mutex object to use");
-#endif
- }
-
- allocator_lock = mutex_factory->make();
- config_lock = mutex_factory->make();
-
cached_default_allocator = 0;
add_allocator(new Malloc_Allocator);
- add_allocator(new Locking_Allocator(mutex_factory->make()));
+ add_allocator(new Locking_Allocator);
#if defined(BOTAN_HAS_ALLOC_MMAP)
- add_allocator(new MemoryMapping_Allocator(mutex_factory->make()));
+ add_allocator(new MemoryMapping_Allocator);
#endif
set_default_allocator("locking");
load_default_config();
- std::vector<Engine*> engines;
+ std::vector<Engine*> engines = {
#if defined(BOTAN_HAS_ENGINE_GNU_MP)
- engines.push_back(new GMP_Engine);
+ new GMP_Engine,
#endif
#if defined(BOTAN_HAS_ENGINE_OPENSSL)
- engines.push_back(new OpenSSL_Engine);
+ new OpenSSL_Engine,
#endif
#if defined(BOTAN_HAS_ENGINE_SSE2_ASSEMBLER)
- engines.push_back(new SSE2_Assembler_Engine);
+ new SSE2_Assembler_Engine,
#endif
#if defined(BOTAN_HAS_ENGINE_AMD64_ASSEMBLER)
- engines.push_back(new AMD64_Assembler_Engine);
+ new AMD64_Assembler_Engine,
#endif
#if defined(BOTAN_HAS_ENGINE_IA32_ASSEMBLER)
- engines.push_back(new IA32_Assembler_Engine);
+ new IA32_Assembler_Engine,
#endif
- engines.push_back(new Default_Engine);
+ new Default_Engine
+ };
- m_algorithm_factory = new Algorithm_Factory(engines, *mutex_factory);
+ m_algorithm_factory = new Algorithm_Factory(engines);
}
/*
@@ -309,8 +272,6 @@ void Library_State::initialize(bool thread_safe)
*/
Library_State::Library_State()
{
- mutex_factory = 0;
- allocator_lock = config_lock = 0;
cached_default_allocator = 0;
m_algorithm_factory = 0;
}
@@ -321,6 +282,7 @@ Library_State::Library_State()
Library_State::~Library_State()
{
delete m_algorithm_factory;
+ m_algorithm_factory = 0;
cached_default_allocator = 0;
@@ -329,10 +291,6 @@ Library_State::~Library_State()
allocators[j]->destroy();
delete allocators[j];
}
-
- delete allocator_lock;
- delete mutex_factory;
- delete config_lock;
}
}
diff --git a/src/libstate/libstate.h b/src/libstate/libstate.h
index a0421953e..91fd58dff 100644
--- a/src/libstate/libstate.h
+++ b/src/libstate/libstate.h
@@ -12,6 +12,7 @@
#include <botan/allocate.h>
#include <botan/algo_factory.h>
+#include <mutex>
#include <string>
#include <vector>
#include <map>
@@ -27,11 +28,11 @@ class BOTAN_DLL Library_State
Library_State();
~Library_State();
- void initialize(bool thread_safe);
+ void initialize();
Algorithm_Factory& algorithm_factory();
- Allocator* get_allocator(const std::string& = "") const;
+ Allocator* get_allocator(const std::string& = "");
void add_allocator(Allocator*);
void set_default_allocator(const std::string&);
@@ -42,7 +43,7 @@ class BOTAN_DLL Library_State
* @result the value of the parameter
*/
std::string get(const std::string& section,
- const std::string& key) const;
+ const std::string& key);
/**
* Check whether a certain parameter is set
@@ -52,7 +53,7 @@ class BOTAN_DLL Library_State
* @result true if the parameters value is set,
* false otherwise
*/
- bool is_set(const std::string& section, const std::string& key) const;
+ bool is_set(const std::string& section, const std::string& key);
/**
* Set a configuration parameter.
@@ -70,7 +71,7 @@ class BOTAN_DLL Library_State
* referred to as option).
* @param key the desired keys name
*/
- std::string option(const std::string& key) const;
+ std::string option(const std::string& key);
/**
* Set an option.
@@ -91,21 +92,17 @@ class BOTAN_DLL Library_State
* @param alias the alias to resolve.
* @return what the alias stands for
*/
- std::string deref_alias(const std::string&) const;
-
- class Mutex* get_mutex() const;
+ std::string deref_alias(const std::string&);
private:
void load_default_config();
Library_State(const Library_State&) {}
Library_State& operator=(const Library_State&) { return (*this); }
- class Mutex_Factory* mutex_factory;
-
+ std::mutex config_lock;
std::map<std::string, std::string> config;
- class Mutex* config_lock;
- class Mutex* allocator_lock;
+ std::mutex allocator_lock;
std::map<std::string, Allocator*> alloc_factory;
mutable Allocator* cached_default_allocator;
std::vector<Allocator*> allocators;
diff --git a/src/libstate/scan_name.cpp b/src/libstate/scan_name.cpp
index 88992d66e..889ef7367 100644
--- a/src/libstate/scan_name.cpp
+++ b/src/libstate/scan_name.cpp
@@ -8,6 +8,7 @@
#include <botan/scan_name.h>
#include <botan/parsing.h>
#include <botan/libstate.h>
+#include <botan/exceptn.h>
#include <stdexcept>
namespace Botan {
diff --git a/src/math/gfpmath/curve_gfp.cpp b/src/math/gfpmath/curve_gfp.cpp
index e12ade081..7536318d9 100644
--- a/src/math/gfpmath/curve_gfp.cpp
+++ b/src/math/gfpmath/curve_gfp.cpp
@@ -14,7 +14,7 @@
namespace Botan {
-void CurveGFp::set_shrd_mod(const std::tr1::shared_ptr<GFpModulus> mod)
+void CurveGFp::set_shrd_mod(const std::shared_ptr<GFpModulus> mod)
{
mp_mod = mod;
mA.turn_off_sp_red_mul();// m.m. is not needed, must be trf. back
@@ -34,7 +34,7 @@ CurveGFp::CurveGFp(const GFpElement& a, const GFpElement& b,
{
throw Invalid_Argument("could not construct curve: moduli of arguments differ");
}
- std::tr1::shared_ptr<GFpModulus> p_mod = std::tr1::shared_ptr<GFpModulus>(new GFpModulus(p));
+ std::shared_ptr<GFpModulus> p_mod = std::shared_ptr<GFpModulus>(new GFpModulus(p));
// the above is the creation of the GFpModuls object which will be shared point-wide
// (in the context of a point of course)
set_shrd_mod(p_mod);
@@ -44,21 +44,21 @@ CurveGFp::CurveGFp(const CurveGFp& other)
: mA(other.get_a()),
mB(other.get_b())
{
- mp_mod = std::tr1::shared_ptr<GFpModulus>(new GFpModulus(*other.mp_mod));
+ mp_mod = std::shared_ptr<GFpModulus>(new GFpModulus(*other.mp_mod));
assert(mp_mod->p_equal_to(mA.get_p()));
assert(mp_mod->p_equal_to(mB.get_p()));
set_shrd_mod(mp_mod);
if(other.mp_mres_a.get())
{
- mp_mres_a = std::tr1::shared_ptr<GFpElement>(new GFpElement(*other.mp_mres_a));
+ mp_mres_a = std::shared_ptr<GFpElement>(new GFpElement(*other.mp_mres_a));
}
if(other.mp_mres_b.get())
{
- mp_mres_b = std::tr1::shared_ptr<GFpElement>(new GFpElement(*other.mp_mres_b));
+ mp_mres_b = std::shared_ptr<GFpElement>(new GFpElement(*other.mp_mres_b));
}
if(other.mp_mres_one.get())
{
- mp_mres_one = std::tr1::shared_ptr<GFpElement>(new GFpElement(*other.mp_mres_one));
+ mp_mres_one = std::shared_ptr<GFpElement>(new GFpElement(*other.mp_mres_one));
}
}
@@ -72,21 +72,21 @@ const CurveGFp& CurveGFp::operator=(const CurveGFp& other)
mA.swap(a_tmp);
mB.swap(b_tmp);
- std::tr1::shared_ptr<GFpModulus> p_mod = std::tr1::shared_ptr<GFpModulus>(new GFpModulus(*other.mp_mod));
+ std::shared_ptr<GFpModulus> p_mod = std::shared_ptr<GFpModulus>(new GFpModulus(*other.mp_mod));
set_shrd_mod(p_mod);
// exception safety note: no problem if we have a throw from here on...
if(other.mp_mres_a.get())
{
- mp_mres_a = std::tr1::shared_ptr<GFpElement>(new GFpElement(*other.mp_mres_a));
+ mp_mres_a = std::shared_ptr<GFpElement>(new GFpElement(*other.mp_mres_a));
}
if(other.mp_mres_b.get())
{
- mp_mres_b = std::tr1::shared_ptr<GFpElement>(new GFpElement(*other.mp_mres_b));
+ mp_mres_b = std::shared_ptr<GFpElement>(new GFpElement(*other.mp_mres_b));
}
if(other.mp_mres_one.get())
{
- mp_mres_one = std::tr1::shared_ptr<GFpElement>(new GFpElement(*other.mp_mres_one));
+ mp_mres_one = std::shared_ptr<GFpElement>(new GFpElement(*other.mp_mres_one));
}
return *this;
}
@@ -123,7 +123,7 @@ GFpElement const CurveGFp::get_mres_a() const
{
if(mp_mres_a.get() == 0)
{
- mp_mres_a = std::tr1::shared_ptr<GFpElement>(new GFpElement(mA));
+ mp_mres_a = std::shared_ptr<GFpElement>(new GFpElement(mA));
mp_mres_a->turn_on_sp_red_mul();
mp_mres_a->get_mres();
}
@@ -134,18 +134,18 @@ GFpElement const CurveGFp::get_mres_b() const
{
if(mp_mres_b.get() == 0)
{
- mp_mres_b = std::tr1::shared_ptr<GFpElement>(new GFpElement(mB));
+ mp_mres_b = std::shared_ptr<GFpElement>(new GFpElement(mB));
mp_mres_b->turn_on_sp_red_mul();
mp_mres_b->get_mres();
}
return GFpElement(*mp_mres_b);
}
-std::tr1::shared_ptr<GFpElement const> const CurveGFp::get_mres_one() const
+std::shared_ptr<GFpElement const> const CurveGFp::get_mres_one() const
{
if(mp_mres_one.get() == 0)
{
- mp_mres_one = std::tr1::shared_ptr<GFpElement>(new GFpElement(mp_mod->get_p(), 1));
+ mp_mres_one = std::shared_ptr<GFpElement>(new GFpElement(mp_mod->get_p(), 1));
mp_mres_one->turn_on_sp_red_mul();
mp_mres_one->get_mres();
}
diff --git a/src/math/gfpmath/curve_gfp.h b/src/math/gfpmath/curve_gfp.h
index 81cf6ce51..eab8a57da 100644
--- a/src/math/gfpmath/curve_gfp.h
+++ b/src/math/gfpmath/curve_gfp.h
@@ -57,7 +57,7 @@ class BOTAN_DLL CurveGFp
* @param mod a shared pointer to a GFpModulus object suitable for
* *this.
*/
- void set_shrd_mod(const std::tr1::shared_ptr<GFpModulus> mod);
+ void set_shrd_mod(const std::shared_ptr<GFpModulus> mod);
// getters
@@ -99,14 +99,14 @@ class BOTAN_DLL CurveGFp
* function.
* @result the GFpElement 1, transformed to its m-residue
*/
- std::tr1::shared_ptr<GFpElement const> const get_mres_one() const;
+ std::shared_ptr<GFpElement const> const get_mres_one() const;
/**
* Get prime modulus of the field of the curve
* @result prime modulus of the field of the curve
*/
BigInt const get_p() const;
- /*inline std::tr1::shared_ptr<BigInt> const get_ptr_p() const
+ /*inline std::shared_ptr<BigInt> const get_ptr_p() const
{
return mp_p;
}*/
@@ -119,7 +119,7 @@ class BOTAN_DLL CurveGFp
* Do NOT spread pointers to a GFpModulus over different threads!
* @result a shared pointer to a GFpModulus object
*/
- inline std::tr1::shared_ptr<GFpModulus> const get_ptr_mod() const
+ inline std::shared_ptr<GFpModulus> const get_ptr_mod() const
{
return mp_mod;
}
@@ -131,12 +131,12 @@ class BOTAN_DLL CurveGFp
void swap(CurveGFp& other);
private:
- std::tr1::shared_ptr<GFpModulus> mp_mod;
+ std::shared_ptr<GFpModulus> mp_mod;
GFpElement mA;
GFpElement mB;
- mutable std::tr1::shared_ptr<GFpElement> mp_mres_a;
- mutable std::tr1::shared_ptr<GFpElement> mp_mres_b;
- mutable std::tr1::shared_ptr<GFpElement> mp_mres_one;
+ mutable std::shared_ptr<GFpElement> mp_mres_a;
+ mutable std::shared_ptr<GFpElement> mp_mres_b;
+ mutable std::shared_ptr<GFpElement> mp_mres_one;
};
// relational operators
diff --git a/src/math/gfpmath/gfp_element.cpp b/src/math/gfpmath/gfp_element.cpp
index b71809301..932ec274e 100644
--- a/src/math/gfpmath/gfp_element.cpp
+++ b/src/math/gfpmath/gfp_element.cpp
@@ -174,13 +174,13 @@ GFpElement::GFpElement(const BigInt& p, const BigInt& value, bool use_montgm)
m_is_trf(false)
{
assert(mp_mod.get() == 0);
- mp_mod = std::tr1::shared_ptr<GFpModulus>(new GFpModulus(p));
+ mp_mod = std::shared_ptr<GFpModulus>(new GFpModulus(p));
assert(mp_mod->m_p_dash == 0);
if(m_use_montgm)
ensure_montgm_precomp();
}
-GFpElement::GFpElement(std::tr1::shared_ptr<GFpModulus> const mod, const BigInt& value, bool use_montgm)
+GFpElement::GFpElement(std::shared_ptr<GFpModulus> const mod, const BigInt& value, bool use_montgm)
: mp_mod(),
m_value(value % mod->m_p),
m_use_montgm(use_montgm),
@@ -247,7 +247,7 @@ void GFpElement::ensure_montgm_precomp() const
}
-void GFpElement::set_shrd_mod(std::tr1::shared_ptr<GFpModulus> const p_mod)
+void GFpElement::set_shrd_mod(std::shared_ptr<GFpModulus> const p_mod)
{
mp_mod = p_mod;
}
diff --git a/src/math/gfpmath/gfp_element.h b/src/math/gfpmath/gfp_element.h
index 4e0ee985b..d9e60f41d 100644
--- a/src/math/gfpmath/gfp_element.h
+++ b/src/math/gfpmath/gfp_element.h
@@ -15,14 +15,7 @@
#include <botan/bigint.h>
#include <botan/gfp_modulus.h>
#include <iosfwd>
-
-#if defined(BOTAN_USE_STD_TR1)
- #include <tr1/memory>
-#elif defined(BOTAN_USE_BOOST_TR1)
- #include <boost/tr1/memory.hpp>
-#else
- #error "Please choose a TR1 implementation in build.h"
-#endif
+#include <memory>
namespace Botan {
@@ -40,7 +33,7 @@ struct Illegal_Transformation : public Exception
class BOTAN_DLL GFpElement
{
private:
- std::tr1::shared_ptr<GFpModulus> mp_mod;
+ std::shared_ptr<GFpModulus> mp_mod;
mutable BigInt m_value; // ordinary residue or m-residue respectively
mutable BigInt workspace;
@@ -79,7 +72,7 @@ class BOTAN_DLL GFpElement
* @param value the element value
* @param use_montgm whether this object will use Montgomery multiplication
*/
- explicit GFpElement(std::tr1::shared_ptr<GFpModulus> const mod,
+ explicit GFpElement(std::shared_ptr<GFpModulus> const mod,
const BigInt& value, bool use_mongm = false);
/**
@@ -190,7 +183,7 @@ class BOTAN_DLL GFpElement
* the shared GFpModulus objects!
* @result the shared pointer to the GFpModulus of *this
*/
- inline std::tr1::shared_ptr<GFpModulus> const get_ptr_mod() const
+ inline std::shared_ptr<GFpModulus> const get_ptr_mod() const
{
return mp_mod;
}
@@ -203,7 +196,7 @@ class BOTAN_DLL GFpElement
* the shared GFpModulus objects!
* @param mod a shared pointer to a GFpModulus that will be held in *this
*/
- void set_shrd_mod(std::tr1::shared_ptr<GFpModulus> const mod);
+ void set_shrd_mod(std::shared_ptr<GFpModulus> const mod);
/**
* Tells whether this GFpElement is currently transformed to it´ m-residue,
diff --git a/src/math/gfpmath/point_gfp.cpp b/src/math/gfpmath/point_gfp.cpp
index 9139c3ef9..c997ac525 100644
--- a/src/math/gfpmath/point_gfp.cpp
+++ b/src/math/gfpmath/point_gfp.cpp
@@ -109,7 +109,7 @@ const PointGFp& PointGFp::assign_within_same_curve(PointGFp const& other)
return *this;
}
-void PointGFp::set_shrd_mod(std::tr1::shared_ptr<GFpModulus> p_mod)
+void PointGFp::set_shrd_mod(std::shared_ptr<GFpModulus> p_mod)
{
mX.set_shrd_mod(p_mod);
mY.set_shrd_mod(p_mod);
@@ -133,7 +133,7 @@ void PointGFp::ensure_worksp() const
}
}
- mp_worksp_gfp_el = std::tr1::shared_ptr<std::vector<GFpElement> >(new std::vector<GFpElement>);
+ mp_worksp_gfp_el = std::shared_ptr<std::vector<GFpElement> >(new std::vector<GFpElement>);
mp_worksp_gfp_el->reserve(9);
for (u32bit i=0; i<GFPEL_WKSP_SIZE; i++)
{
@@ -337,8 +337,8 @@ PointGFp& PointGFp::mult_this_secure(const BigInt& scalar,
// use montgomery mult. in this operation
this->turn_on_sp_red_mul();
- std::tr1::shared_ptr<PointGFp> H(new PointGFp(this->mC));
- std::tr1::shared_ptr<PointGFp> tmp; // used for AADA
+ std::shared_ptr<PointGFp> H(new PointGFp(this->mC));
+ std::shared_ptr<PointGFp> tmp; // used for AADA
PointGFp P(*this);
BigInt m(scalar);
@@ -477,15 +477,15 @@ PointGFp& PointGFp::operator*=(const BigInt& scalar)
return *this;
}
-inline std::tr1::shared_ptr<PointGFp> PointGFp::mult_loop(int l,
+inline std::shared_ptr<PointGFp> PointGFp::mult_loop(int l,
const BigInt& m,
- std::tr1::shared_ptr<PointGFp> H,
- std::tr1::shared_ptr<PointGFp> tmp,
+ std::shared_ptr<PointGFp> H,
+ std::shared_ptr<PointGFp> tmp,
const PointGFp& P)
{
//assert(l >= (int)m.bits()- 1);
tmp = H;
- std::tr1::shared_ptr<PointGFp> to_add(new PointGFp(P)); // we just need some point
+ std::shared_ptr<PointGFp> to_add(new PointGFp(P)); // we just need some point
// so that we can use op=
// inside the loop
for (int i=l; i >=0; i--)
diff --git a/src/math/gfpmath/point_gfp.h b/src/math/gfpmath/point_gfp.h
index 771605efc..b001bbbad 100644
--- a/src/math/gfpmath/point_gfp.h
+++ b/src/math/gfpmath/point_gfp.h
@@ -234,7 +234,7 @@ class BOTAN_DLL PointGFp
* @param mod a shared pointer to a GFpModulus that will
* be held in the members *this
*/
- void set_shrd_mod(std::tr1::shared_ptr<GFpModulus> p_mod);
+ void set_shrd_mod(std::shared_ptr<GFpModulus> p_mod);
static GFpElement decompress(bool yMod2, GFpElement const& x, const CurveGFp& curve);
@@ -242,9 +242,9 @@ class BOTAN_DLL PointGFp
static const u32bit GFPEL_WKSP_SIZE = 9;
void ensure_worksp() const;
- inline std::tr1::shared_ptr<PointGFp> mult_loop(int l, const BigInt& m,
- std::tr1::shared_ptr<PointGFp> H,
- std::tr1::shared_ptr<PointGFp> tmp,
+ inline std::shared_ptr<PointGFp> mult_loop(int l, const BigInt& m,
+ std::shared_ptr<PointGFp> H,
+ std::shared_ptr<PointGFp> tmp,
const PointGFp& P);
CurveGFp mC;
@@ -257,7 +257,7 @@ class BOTAN_DLL PointGFp
mutable bool mZpow2_set;
mutable bool mZpow3_set;
mutable bool mAZpow4_set;
- mutable std::tr1::shared_ptr<std::vector<GFpElement> > mp_worksp_gfp_el;
+ mutable std::shared_ptr<std::vector<GFpElement> > mp_worksp_gfp_el;
};
diff --git a/src/math/numbertheory/dsa_gen.cpp b/src/math/numbertheory/dsa_gen.cpp
index 83646e50e..d5f6dc792 100644
--- a/src/math/numbertheory/dsa_gen.cpp
+++ b/src/math/numbertheory/dsa_gen.cpp
@@ -54,7 +54,7 @@ bool generate_dsa_primes(RandomNumberGenerator& rng,
"Generating a DSA parameter set with a " + to_string(qbits) +
"long q requires a seed at least as many bits long");
- std::auto_ptr<HashFunction> hash(
+ std::unique_ptr<HashFunction> hash(
af.make_hash_function("SHA-" + to_string(qbits)));
const u32bit HASH_SIZE = hash->OUTPUT_LENGTH;
diff --git a/src/mutex/info.txt b/src/mutex/info.txt
deleted file mode 100644
index ff79bf753..000000000
--- a/src/mutex/info.txt
+++ /dev/null
@@ -1,9 +0,0 @@
-realname "Mutex Wrappers"
-
-define MUTEX_WRAPPERS
-
-load_on auto
-
-<add>
-mutex.h
-</add>
diff --git a/src/mutex/mutex.h b/src/mutex/mutex.h
deleted file mode 100644
index a04ff83c9..000000000
--- a/src/mutex/mutex.h
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
-* Mutex
-* (C) 1999-2007 Jack Lloyd
-*
-* Distributed under the terms of the Botan license
-*/
-
-#ifndef BOTAN_MUTEX_H__
-#define BOTAN_MUTEX_H__
-
-#include <botan/exceptn.h>
-
-namespace Botan {
-
-/*
-* Mutex Base Class
-*/
-class BOTAN_DLL Mutex
- {
- public:
- virtual void lock() = 0;
- virtual void unlock() = 0;
- virtual ~Mutex() {}
- };
-
-/*
-* Mutex Factory
-*/
-class BOTAN_DLL Mutex_Factory
- {
- public:
- virtual Mutex* make() = 0;
- virtual ~Mutex_Factory() {}
- };
-
-/*
-* Mutex Holding Class
-*/
-class BOTAN_DLL Mutex_Holder
- {
- public:
- Mutex_Holder(Mutex* m) : mux(m)
- {
- if(!mux)
- throw Invalid_Argument("Mutex_Holder: Argument was NULL");
- mux->lock();
- }
-
- ~Mutex_Holder() { mux->unlock(); }
- private:
- Mutex* mux;
- };
-
-}
-
-#endif
diff --git a/src/mutex/noop_mutex/info.txt b/src/mutex/noop_mutex/info.txt
deleted file mode 100644
index 1f49f5e1c..000000000
--- a/src/mutex/noop_mutex/info.txt
+++ /dev/null
@@ -1,10 +0,0 @@
-realname "No-Op Mutex"
-
-load_on auto
-
-define MUTEX_NOOP
-
-<add>
-mux_noop.cpp
-mux_noop.h
-</add>
diff --git a/src/mutex/noop_mutex/mux_noop.cpp b/src/mutex/noop_mutex/mux_noop.cpp
deleted file mode 100644
index 5c45084fe..000000000
--- a/src/mutex/noop_mutex/mux_noop.cpp
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
-* No-Op Mutex Factory
-* (C) 1999-2007 Jack Lloyd
-*
-* Distributed under the terms of the Botan license
-*/
-
-#include <botan/mux_noop.h>
-
-namespace Botan {
-
-/*
-* No-Op Mutex Factory
-*/
-Mutex* Noop_Mutex_Factory::make()
- {
- class Noop_Mutex : public Mutex
- {
- public:
- class Mutex_State_Error : public Internal_Error
- {
- public:
- Mutex_State_Error(const std::string& where) :
- Internal_Error("Noop_Mutex::" + where + ": " +
- "Mutex is already " + where + "ed") {}
- };
-
- void lock()
- {
- if(locked)
- throw Mutex_State_Error("lock");
- locked = true;
- }
-
- void unlock()
- {
- if(!locked)
- throw Mutex_State_Error("unlock");
- locked = false;
- }
-
- Noop_Mutex() { locked = false; }
- private:
- bool locked;
- };
-
- return new Noop_Mutex;
- }
-
-}
diff --git a/src/mutex/noop_mutex/mux_noop.h b/src/mutex/noop_mutex/mux_noop.h
deleted file mode 100644
index 94201cb7c..000000000
--- a/src/mutex/noop_mutex/mux_noop.h
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
-* No-Op Mutex Factory
-* (C) 1999-2007 Jack Lloyd
-*
-* Distributed under the terms of the Botan license
-*/
-
-#ifndef BOTAN_NOOP_MUTEX_FACTORY_H__
-#define BOTAN_NOOP_MUTEX_FACTORY_H__
-
-#include <botan/mutex.h>
-
-namespace Botan {
-
-/*
-* No-Op Mutex Factory
-*/
-class BOTAN_DLL Noop_Mutex_Factory : public Mutex_Factory
- {
- public:
- Mutex* make();
- };
-
-}
-
-#endif
diff --git a/src/mutex/pthreads/info.txt b/src/mutex/pthreads/info.txt
deleted file mode 100644
index f135dea48..000000000
--- a/src/mutex/pthreads/info.txt
+++ /dev/null
@@ -1,30 +0,0 @@
-realname "Pthread Mutex"
-
-define MUTEX_PTHREAD
-
-load_on auto
-
-<add>
-mux_pthr.cpp
-mux_pthr.h
-</add>
-
-<libs>
-all!qnx,freebsd,dragonfly,openbsd,netbsd -> pthread
-</libs>
-
-<os>
-aix
-cygwin
-darwin
-freebsd
-dragonfly
-hpux
-irix
-linux
-netbsd
-openbsd
-qnx
-solaris
-tru64
-</os>
diff --git a/src/mutex/pthreads/mux_pthr.cpp b/src/mutex/pthreads/mux_pthr.cpp
deleted file mode 100644
index 9f1d9816e..000000000
--- a/src/mutex/pthreads/mux_pthr.cpp
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
-* Pthread Mutex
-* (C) 1999-2007 Jack Lloyd
-*
-* Distributed under the terms of the Botan license
-*/
-
-#include <botan/mux_pthr.h>
-#include <botan/exceptn.h>
-
-#ifndef _POSIX_C_SOURCE
- #define _POSIX_C_SOURCE 199506
-#endif
-
-#include <pthread.h>
-
-namespace Botan {
-
-/*
-* Pthread Mutex Factory
-*/
-Mutex* Pthread_Mutex_Factory::make()
- {
-
- class Pthread_Mutex : public Mutex
- {
- public:
- void lock()
- {
- if(pthread_mutex_lock(&mutex) != 0)
- throw Exception("Pthread_Mutex::lock: Error occured");
- }
-
- void unlock()
- {
- if(pthread_mutex_unlock(&mutex) != 0)
- throw Exception("Pthread_Mutex::unlock: Error occured");
- }
-
- Pthread_Mutex()
- {
- if(pthread_mutex_init(&mutex, 0) != 0)
- throw Exception("Pthread_Mutex: initialization failed");
- }
-
- ~Pthread_Mutex()
- {
- if(pthread_mutex_destroy(&mutex) != 0)
- throw Invalid_State("~Pthread_Mutex: mutex is still locked");
- }
- private:
- pthread_mutex_t mutex;
- };
-
- return new Pthread_Mutex();
- }
-
-}
diff --git a/src/mutex/pthreads/mux_pthr.h b/src/mutex/pthreads/mux_pthr.h
deleted file mode 100644
index 118853947..000000000
--- a/src/mutex/pthreads/mux_pthr.h
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
-* Pthread Mutex
-* (C) 1999-2007 Jack Lloyd
-*
-* Distributed under the terms of the Botan license
-*/
-
-#ifndef BOTAN_MUTEX_PTHREAD_H__
-#define BOTAN_MUTEX_PTHREAD_H__
-
-#include <botan/mutex.h>
-
-namespace Botan {
-
-/*
-* Pthread Mutex Factory
-*/
-class BOTAN_DLL Pthread_Mutex_Factory : public Mutex_Factory
- {
- public:
- Mutex* make();
- };
-
-}
-
-#endif
diff --git a/src/mutex/qt_mutex/info.txt b/src/mutex/qt_mutex/info.txt
deleted file mode 100644
index a21108c79..000000000
--- a/src/mutex/qt_mutex/info.txt
+++ /dev/null
@@ -1,18 +0,0 @@
-realname "Qt Mutex"
-
-define MUTEX_QT
-
-note "You'll probably have to add -I/-L flags to the Makefile to find Qt"
-
-load_on request
-
-<add>
-mux_qt.cpp
-mux_qt.h
-</add>
-
-# I think we want to always use qt-mt, not qt -- not much point in supporting
-# mutexes in a single threaded application, after all.
-<libs>
-all -> qt-mt
-</libs>
diff --git a/src/mutex/qt_mutex/mux_qt.cpp b/src/mutex/qt_mutex/mux_qt.cpp
deleted file mode 100644
index 0f670c8b4..000000000
--- a/src/mutex/qt_mutex/mux_qt.cpp
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
-* Qt Thread Mutex
-* (C) 2004-2007 Justin Karneges
-* 2004-2007 Jack Lloyd
-*
-* Distributed under the terms of the Botan license
-*/
-
-#include <botan/mux_qt.h>
-#include <qmutex.h>
-
-#if !defined(QT_THREAD_SUPPORT)
- #error Your version of Qt does not support threads or mutexes
-#endif
-
-namespace Botan {
-
-/*
-* Qt Mutex Factory
-*/
-Mutex* Qt_Mutex_Factory::make()
- {
- class Qt_Mutex : public Mutex
- {
- public:
- void lock() { mutex.lock(); }
- void unlock() { mutex.unlock(); }
- private:
- QMutex mutex;
- };
-
- return new Qt_Mutex();
- }
-
-}
diff --git a/src/mutex/qt_mutex/mux_qt.h b/src/mutex/qt_mutex/mux_qt.h
deleted file mode 100644
index 5aed77f4b..000000000
--- a/src/mutex/qt_mutex/mux_qt.h
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
-* Qt Mutex
-* (C) 2004-2007 Justin Karneges
-* 2004-2007 Jack Lloyd
-*
-* Distributed under the terms of the Botan license
-*/
-
-#ifndef BOTAN_MUTEX_QT_H__
-#define BOTAN_MUTEX_QT_H__
-
-#include <botan/mutex.h>
-
-namespace Botan {
-
-/*
-* Qt Mutex
-*/
-class BOTAN_DLL Qt_Mutex_Factory : public Mutex_Factory
- {
- public:
- Mutex* make();
- };
-
-}
-
-#endif
diff --git a/src/mutex/win32_crit_section/info.txt b/src/mutex/win32_crit_section/info.txt
deleted file mode 100644
index a2d339c3b..000000000
--- a/src/mutex/win32_crit_section/info.txt
+++ /dev/null
@@ -1,17 +0,0 @@
-realname "Win32 Mutex"
-
-define MUTEX_WIN32
-modset win32
-
-load_on auto
-
-<add>
-mux_win32.cpp
-mux_win32.h
-</add>
-
-<os>
-cygwin
-windows
-mingw
-</os>
diff --git a/src/mutex/win32_crit_section/mux_win32.cpp b/src/mutex/win32_crit_section/mux_win32.cpp
deleted file mode 100644
index 2a967892b..000000000
--- a/src/mutex/win32_crit_section/mux_win32.cpp
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
-* Win32 Mutex
-* (C) 2006 Luca Piccarreta
-* 2006-2007 Jack Lloyd
-*
-* Distributed under the terms of the Botan license
-*/
-
-#include <botan/mux_win32.h>
-#include <windows.h>
-
-namespace Botan {
-
-/*
-* Win32 Mutex Factory
-*/
-Mutex* Win32_Mutex_Factory::make()
- {
- class Win32_Mutex : public Mutex
- {
- public:
- void lock() { EnterCriticalSection(&mutex); }
- void unlock() { LeaveCriticalSection(&mutex); }
-
- Win32_Mutex() { InitializeCriticalSection(&mutex); }
- ~Win32_Mutex() { DeleteCriticalSection(&mutex); }
- private:
- CRITICAL_SECTION mutex;
- };
-
- return new Win32_Mutex();
- }
-
-}
diff --git a/src/mutex/win32_crit_section/mux_win32.h b/src/mutex/win32_crit_section/mux_win32.h
deleted file mode 100644
index a91850e71..000000000
--- a/src/mutex/win32_crit_section/mux_win32.h
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
-* Win32 Mutex
-* (C) 2006 Luca Piccarreta
-* 2006-2007 Jack Lloyd
-*
-* Distributed under the terms of the Botan license
-*/
-
-#ifndef BOTAN_MUTEX_WIN32_H__
-#define BOTAN_MUTEX_WIN32_H__
-
-#include <botan/mutex.h>
-
-namespace Botan {
-
-/*
-* Win32 Mutex Factory
-*/
-class BOTAN_DLL Win32_Mutex_Factory : public Mutex_Factory
- {
- public:
- Mutex* make();
- };
-}
-
-#endif
diff --git a/src/pubkey/ec_dompar/ec_dompar.cpp b/src/pubkey/ec_dompar/ec_dompar.cpp
index 6cfcc0619..c4634877e 100644
--- a/src/pubkey/ec_dompar/ec_dompar.cpp
+++ b/src/pubkey/ec_dompar/ec_dompar.cpp
@@ -545,7 +545,7 @@ EC_Domain_Params decode_ber_ec_dompar(SecureVector<byte> const& encoded)
BER_Decoder dec(encoded);
BER_Object obj = dec.get_next_object();
ASN1_Tag tag = obj.type_tag;
- std::auto_ptr<EC_Domain_Params> p_result;
+ std::unique_ptr<EC_Domain_Params> p_result;
if(tag == OBJECT_ID)
{
diff --git a/src/pubkey/ecc_key/ecc_key.cpp b/src/pubkey/ecc_key/ecc_key.cpp
index 615efecf1..6c7d02c74 100644
--- a/src/pubkey/ecc_key/ecc_key.cpp
+++ b/src/pubkey/ecc_key/ecc_key.cpp
@@ -166,7 +166,7 @@ void EC_PrivateKey::generate_private_key(RandomNumberGenerator& rng)
BigInt tmp_private_value(0);
tmp_private_value = BigInt::random_integer(rng, 1, mp_dom_pars->get_order());
- mp_public_point = std::auto_ptr<PointGFp>( new PointGFp (mp_dom_pars->get_base_point()));
+ mp_public_point = std::unique_ptr<PointGFp>( new PointGFp (mp_dom_pars->get_base_point()));
mp_public_point->mult_this_secure(tmp_private_value,
mp_dom_pars->get_order(),
mp_dom_pars->get_order()-1);
diff --git a/src/pubkey/ecc_key/ecc_key.h b/src/pubkey/ecc_key/ecc_key.h
index 0ca9a0e75..9d5f57d9f 100644
--- a/src/pubkey/ecc_key/ecc_key.h
+++ b/src/pubkey/ecc_key/ecc_key.h
@@ -103,8 +103,8 @@ class BOTAN_DLL EC_PublicKey : public virtual Public_Key
SecureVector<byte> m_enc_public_point; // stores the public point
- std::auto_ptr<EC_Domain_Params> mp_dom_pars;
- std::auto_ptr<PointGFp> mp_public_point;
+ std::unique_ptr<EC_Domain_Params> mp_dom_pars;
+ std::unique_ptr<PointGFp> mp_public_point;
EC_dompar_enc m_param_enc;
};
diff --git a/src/pubkey/ecdsa/ecdsa.cpp b/src/pubkey/ecdsa/ecdsa.cpp
index 9640c6397..3e3bbf38a 100644
--- a/src/pubkey/ecdsa/ecdsa.cpp
+++ b/src/pubkey/ecdsa/ecdsa.cpp
@@ -20,7 +20,7 @@ namespace Botan {
ECDSA_PrivateKey::ECDSA_PrivateKey(RandomNumberGenerator& rng,
const EC_Domain_Params& dom_pars)
{
- mp_dom_pars = std::auto_ptr<EC_Domain_Params>(new EC_Domain_Params(dom_pars));
+ mp_dom_pars = std::unique_ptr<EC_Domain_Params>(new EC_Domain_Params(dom_pars));
generate_private_key(rng);
try
@@ -68,11 +68,10 @@ void ECDSA_PublicKey::set_domain_parameters(const EC_Domain_Params& dom_pars)
throw Invalid_State("EC_PublicKey::set_domain_parameters(): point does not lie on provided curve");
}
- std::auto_ptr<EC_Domain_Params> p_tmp_pars(new EC_Domain_Params(dom_pars));
- ECDSA_Core tmp_ecdsa_core(*p_tmp_pars, BigInt(0), tmp_pp);
+ mp_dom_pars.reset(new EC_Domain_Params(dom_pars));
+ ECDSA_Core tmp_ecdsa_core(*mp_dom_pars, BigInt(0), tmp_pp);
mp_public_point.reset(new PointGFp(tmp_pp));
m_ecdsa_core = tmp_ecdsa_core;
- mp_dom_pars = p_tmp_pars;
}
void ECDSA_PublicKey::set_all_values(const ECDSA_PublicKey& other)
@@ -131,8 +130,8 @@ bool ECDSA_PublicKey::verify(const byte message[],
ECDSA_PublicKey::ECDSA_PublicKey(const EC_Domain_Params& dom_par,
const PointGFp& public_point)
{
- mp_dom_pars = std::auto_ptr<EC_Domain_Params>(new EC_Domain_Params(dom_par));
- mp_public_point = std::auto_ptr<PointGFp>(new PointGFp(public_point));
+ mp_dom_pars = std::unique_ptr<EC_Domain_Params>(new EC_Domain_Params(dom_par));
+ mp_public_point = std::unique_ptr<PointGFp>(new PointGFp(public_point));
m_param_enc = ENC_EXPLICIT;
m_ecdsa_core = ECDSA_Core(*mp_dom_pars, BigInt(0), *mp_public_point);
}
diff --git a/src/pubkey/eckaeg/eckaeg.cpp b/src/pubkey/eckaeg/eckaeg.cpp
index b8ff75d89..5787f062d 100644
--- a/src/pubkey/eckaeg/eckaeg.cpp
+++ b/src/pubkey/eckaeg/eckaeg.cpp
@@ -63,8 +63,8 @@ void ECKAEG_PublicKey::X509_load_hook()
ECKAEG_PublicKey::ECKAEG_PublicKey(EC_Domain_Params const& dom_par, PointGFp const& public_point)
{
- mp_dom_pars = std::auto_ptr<EC_Domain_Params>(new EC_Domain_Params(dom_par));
- mp_public_point = std::auto_ptr<PointGFp>(new PointGFp(public_point));
+ mp_dom_pars = std::unique_ptr<EC_Domain_Params>(new EC_Domain_Params(dom_par));
+ mp_public_point = std::unique_ptr<PointGFp>(new PointGFp(public_point));
if(mp_public_point->get_curve() != mp_dom_pars->get_curve())
{
throw Invalid_Argument("ECKAEG_PublicKey(): curve of arg. point and curve of arg. domain parameters are different");
diff --git a/src/pubkey/eckaeg/eckaeg.h b/src/pubkey/eckaeg/eckaeg.h
index 31b65740c..053a40e4f 100644
--- a/src/pubkey/eckaeg/eckaeg.h
+++ b/src/pubkey/eckaeg/eckaeg.h
@@ -89,7 +89,7 @@ class BOTAN_DLL ECKAEG_PrivateKey : public ECKAEG_PublicKey,
ECKAEG_PrivateKey(RandomNumberGenerator& rng,
const EC_Domain_Params& dom_pars)
{
- mp_dom_pars = std::auto_ptr<EC_Domain_Params>(new EC_Domain_Params(dom_pars));
+ mp_dom_pars = std::unique_ptr<EC_Domain_Params>(new EC_Domain_Params(dom_pars));
generate_private_key(rng);
mp_public_point->check_invariants();
m_eckaeg_core = ECKAEG_Core(*mp_dom_pars, m_private_value, *mp_public_point);
diff --git a/src/pubkey/keypair/keypair.cpp b/src/pubkey/keypair/keypair.cpp
index 486577fc5..7eaa33395 100644
--- a/src/pubkey/keypair/keypair.cpp
+++ b/src/pubkey/keypair/keypair.cpp
@@ -22,8 +22,8 @@ void check_key(RandomNumberGenerator& rng,
if(encryptor->maximum_input_size() == 0)
return;
- std::auto_ptr<PK_Encryptor> enc(encryptor);
- std::auto_ptr<PK_Decryptor> dec(decryptor);
+ std::unique_ptr<PK_Encryptor> enc(encryptor);
+ std::unique_ptr<PK_Decryptor> dec(decryptor);
SecureVector<byte> message(enc->maximum_input_size() - 1);
rng.randomize(message, message.size());
@@ -43,8 +43,8 @@ void check_key(RandomNumberGenerator& rng,
void check_key(RandomNumberGenerator& rng,
PK_Signer* signer, PK_Verifier* verifier)
{
- std::auto_ptr<PK_Signer> sig(signer);
- std::auto_ptr<PK_Verifier> ver(verifier);
+ std::unique_ptr<PK_Signer> sig(signer);
+ std::unique_ptr<PK_Verifier> ver(verifier);
SecureVector<byte> message(16);
rng.randomize(message, message.size());
diff --git a/src/pubkey/pk_codecs/pkcs8.cpp b/src/pubkey/pk_codecs/pkcs8.cpp
index 8a464ecfe..87f05da92 100644
--- a/src/pubkey/pk_codecs/pkcs8.cpp
+++ b/src/pubkey/pk_codecs/pkcs8.cpp
@@ -89,7 +89,7 @@ SecureVector<byte> PKCS8_decode(DataSource& source, const User_Interface& ui,
if(is_encrypted)
{
DataSource_Memory params(pbe_alg_id.parameters);
- std::auto_ptr<PBE> pbe(get_pbe(pbe_alg_id.oid, params));
+ std::unique_ptr<PBE> pbe(get_pbe(pbe_alg_id.oid, params));
User_Interface::UI_Result result = User_Interface::OK;
const std::string passphrase =
@@ -138,7 +138,7 @@ SecureVector<byte> PKCS8_decode(DataSource& source, const User_Interface& ui,
*/
void encode(const Private_Key& key, Pipe& pipe, X509_Encoding encoding)
{
- std::auto_ptr<PKCS8_Encoder> encoder(key.pkcs8_encoder());
+ std::unique_ptr<PKCS8_Encoder> encoder(key.pkcs8_encoder());
if(!encoder.get())
throw Encoding_Error("PKCS8::encode: Key does not support encoding");
@@ -175,7 +175,7 @@ void encrypt_key(const Private_Key& key,
encode(key, raw_key, RAW_BER);
raw_key.end_msg();
- std::auto_ptr<PBE> pbe(get_pbe(((pbe_algo != "") ? pbe_algo : DEFAULT_PBE)));
+ std::unique_ptr<PBE> pbe(get_pbe(((pbe_algo != "") ? pbe_algo : DEFAULT_PBE)));
pbe->new_params(rng);
pbe->set_key(pass);
@@ -244,13 +244,13 @@ Private_Key* load_key(DataSource& source,
throw PKCS8_Exception("Unknown algorithm OID: " +
alg_id.oid.as_string());
- std::auto_ptr<Private_Key> key(get_private_key(alg_name));
+ std::unique_ptr<Private_Key> key(get_private_key(alg_name));
if(!key.get())
throw PKCS8_Exception("Unknown PK algorithm/OID: " + alg_name + ", " +
alg_id.oid.as_string());
- std::auto_ptr<PKCS8_Decoder> decoder(key->pkcs8_decoder(rng));
+ std::unique_ptr<PKCS8_Decoder> decoder(key->pkcs8_decoder(rng));
if(!decoder.get())
throw Decoding_Error("Key does not support PKCS #8 decoding");
diff --git a/src/pubkey/pk_codecs/x509_key.cpp b/src/pubkey/pk_codecs/x509_key.cpp
index 455e627f3..f1fc59410 100644
--- a/src/pubkey/pk_codecs/x509_key.cpp
+++ b/src/pubkey/pk_codecs/x509_key.cpp
@@ -24,7 +24,7 @@ namespace X509 {
*/
void encode(const Public_Key& key, Pipe& pipe, X509_Encoding encoding)
{
- std::auto_ptr<X509_Encoder> encoder(key.x509_encoder());
+ std::unique_ptr<X509_Encoder> encoder(key.x509_encoder());
if(!encoder.get())
throw Encoding_Error("X509::encode: Key does not support encoding");
@@ -94,12 +94,12 @@ Public_Key* load_key(DataSource& source)
throw Decoding_Error("Unknown algorithm OID: " +
alg_id.oid.as_string());
- std::auto_ptr<Public_Key> key_obj(get_public_key(alg_name));
+ std::unique_ptr<Public_Key> key_obj(get_public_key(alg_name));
if(!key_obj.get())
throw Decoding_Error("Unknown PK algorithm/OID: " + alg_name + ", " +
alg_id.oid.as_string());
- std::auto_ptr<X509_Decoder> decoder(key_obj->x509_decoder());
+ std::unique_ptr<X509_Decoder> decoder(key_obj->x509_decoder());
if(!decoder.get())
throw Decoding_Error("Key does not support X.509 decoding");
diff --git a/src/utils/parsing.cpp b/src/utils/parsing.cpp
index bdb9e79dc..556e2f65c 100644
--- a/src/utils/parsing.cpp
+++ b/src/utils/parsing.cpp
@@ -19,11 +19,11 @@ u32bit to_u32bit(const std::string& number)
{
u32bit n = 0;
- for(std::string::const_iterator j = number.begin(); j != number.end(); ++j)
+ for(auto i = number.begin(); i != number.end(); ++i)
{
const u32bit OVERFLOW_MARK = 0xFFFFFFFF / 10;
- byte digit = Charset::char2digit(*j);
+ byte digit = Charset::char2digit(*i);
if((n > OVERFLOW_MARK) || (n == OVERFLOW_MARK && digit > 5))
throw Decoding_Error("to_u32bit: Integer overflow");
@@ -103,15 +103,15 @@ std::vector<std::string> parse_algorithm_name(const std::string& namex)
elems.push_back(name.substr(0, name.find('(')));
name = name.substr(name.find('('));
- for(std::string::const_iterator j = name.begin(); j != name.end(); ++j)
+ for(auto i = name.begin(); i != name.end(); ++i)
{
- char c = *j;
+ char c = *i;
if(c == '(')
++level;
if(c == ')')
{
- if(level == 1 && j == name.end() - 1)
+ if(level == 1 && i == name.end() - 1)
{
if(elems.size() == 1)
elems.push_back(substring.substr(1));
@@ -120,7 +120,7 @@ std::vector<std::string> parse_algorithm_name(const std::string& namex)
return elems;
}
- if(level == 0 || (level == 1 && j != name.end() - 1))
+ if(level == 0 || (level == 1 && i != name.end() - 1))
throw Invalid_Algorithm_Name(namex);
--level;
}
@@ -152,16 +152,16 @@ std::vector<std::string> split_on(const std::string& str, char delim)
if(str == "") return elems;
std::string substr;
- for(std::string::const_iterator j = str.begin(); j != str.end(); ++j)
+ for(auto i = str.begin(); i != str.end(); ++i)
{
- if(*j == delim)
+ if(*i == delim)
{
if(substr != "")
elems.push_back(substr);
substr.clear();
}
else
- substr += *j;
+ substr += *i;
}
if(substr == "")
@@ -179,9 +179,9 @@ std::vector<u32bit> parse_asn1_oid(const std::string& oid)
std::string substring;
std::vector<u32bit> oid_elems;
- for(std::string::const_iterator j = oid.begin(); j != oid.end(); ++j)
+ for(auto i = oid.begin(); i != oid.end(); ++i)
{
- char c = *j;
+ char c = *i;
if(c == '.')
{
@@ -209,8 +209,8 @@ std::vector<u32bit> parse_asn1_oid(const std::string& oid)
*/
bool x500_name_cmp(const std::string& name1, const std::string& name2)
{
- std::string::const_iterator p1 = name1.begin();
- std::string::const_iterator p2 = name2.begin();
+ auto p1 = name1.begin();
+ auto p2 = name2.begin();
while((p1 != name1.end()) && Charset::is_space(*p1)) ++p1;
while((p2 != name2.end()) && Charset::is_space(*p2)) ++p2;
@@ -255,9 +255,9 @@ u32bit string_to_ipv4(const std::string& str)
u32bit ip = 0;
- for(size_t j = 0; j != parts.size(); j++)
+ for(auto part = parts.begin(); part != parts.end(); ++part)
{
- u32bit octet = to_u32bit(parts[j]);
+ u32bit octet = to_u32bit(*part);
if(octet > 255)
throw Decoding_Error("Invalid IP string " + str);
@@ -275,11 +275,11 @@ std::string ipv4_to_string(u32bit ip)
{
std::string str;
- for(size_t j = 0; j != sizeof(ip); j++)
+ for(size_t i = 0; i != sizeof(ip); i++)
{
- if(j)
+ if(i)
str += ".";
- str += to_string(get_byte(j, ip));
+ str += to_string(get_byte(i, ip));
}
return str;
diff --git a/src/utils/stl_util.h b/src/utils/stl_util.h
index 18c8b149b..fc4d4effe 100644
--- a/src/utils/stl_util.h
+++ b/src/utils/stl_util.h
@@ -13,22 +13,6 @@
namespace Botan {
/*
-* Copy-on-Predicate Algorithm
-*/
-template<typename InputIterator, typename OutputIterator, typename Predicate>
-OutputIterator copy_if(InputIterator current, InputIterator end,
- OutputIterator dest, Predicate copy_p)
- {
- while(current != end)
- {
- if(copy_p(*current))
- *dest++ = *current;
- ++current;
- }
- return dest;
- }
-
-/*
* Searching through a std::map
*/
template<typename K, typename V>