aboutsummaryrefslogtreecommitdiffstats
path: root/src/math
diff options
context:
space:
mode:
authorlloyd <[email protected]>2010-03-09 02:53:56 +0000
committerlloyd <[email protected]>2010-03-09 02:53:56 +0000
commitcdcd3a9aba28cefcccb64f91fb56d3847f6c9130 (patch)
tree6f4efd137aad848e698f9f4fc48a8bc9145fea12 /src/math
parent4a9afbb99bb73e43bcb3a30379d6a2dd59dae76a (diff)
parent3c15bd259f0921f1fa08ec91ee3cf2621c64a02d (diff)
propagate from branch 'net.randombit.botan' (head 9932d4d63417f7fcc199ada244cbaa6c1c32d9c1)
to branch 'net.randombit.botan.c++0x' (head f4a385a376311edc62ef506c72cc56f69e6efd5a)
Diffstat (limited to 'src/math')
-rw-r--r--src/math/bigint/bigint.cpp21
-rw-r--r--src/math/bigint/bigint.h19
-rw-r--r--src/math/numbertheory/dsa_gen.cpp8
-rw-r--r--src/math/numbertheory/make_prm.cpp4
-rw-r--r--src/math/numbertheory/numthry.cpp2
5 files changed, 43 insertions, 11 deletions
diff --git a/src/math/bigint/bigint.cpp b/src/math/bigint/bigint.cpp
index 09ac2a75d..b92cd359e 100644
--- a/src/math/bigint/bigint.cpp
+++ b/src/math/bigint/bigint.cpp
@@ -40,7 +40,7 @@ BigInt::BigInt(Sign s, u32bit size)
}
/*
-* Construct a BigInt from a "raw" BigInt
+* Copy constructor
*/
BigInt::BigInt(const BigInt& b)
{
@@ -100,6 +100,25 @@ BigInt::BigInt(RandomNumberGenerator& rng, u32bit bits)
randomize(rng, bits);
}
+/**
+* Move constructor
+*/
+BigInt::BigInt(BigInt&& other)
+ {
+ std::swap(*this, other);
+ }
+
+/**
+* Move assignment
+*/
+BigInt& BigInt::operator=(BigInt&& other)
+ {
+ if(this != &other)
+ std::swap(*this, other);
+
+ return (*this);
+ }
+
/*
* Swap this BigInt with another
*/
diff --git a/src/math/bigint/bigint.h b/src/math/bigint/bigint.h
index 55ccf7aae..2612850c3 100644
--- a/src/math/bigint/bigint.h
+++ b/src/math/bigint/bigint.h
@@ -425,10 +425,14 @@ class BOTAN_DLL BigInt
BigInt(u64bit n);
/**
- * Copy-Constructor: clone given BigInt
- * @param bigint the BigInt to clone
+ * Copy constructor
*/
- BigInt(const BigInt& bigint);
+ BigInt(const BigInt& other);
+
+ /**
+ * Assignment operator
+ */
+ BigInt& operator=(const BigInt&) = default;
/**
* Create BigInt from a string.
@@ -471,6 +475,15 @@ class BOTAN_DLL BigInt
*/
BigInt(NumberType type, u32bit n);
+ /**
+ * Move constructor
+ */
+ BigInt(BigInt&& other);
+
+ /**
+ * Move assignment
+ */
+ BigInt& operator=(BigInt&& other);
private:
SecureVector<word> reg;
Sign signedness;
diff --git a/src/math/numbertheory/dsa_gen.cpp b/src/math/numbertheory/dsa_gen.cpp
index 83646e50e..39a7cf5fa 100644
--- a/src/math/numbertheory/dsa_gen.cpp
+++ b/src/math/numbertheory/dsa_gen.cpp
@@ -47,15 +47,15 @@ bool generate_dsa_primes(RandomNumberGenerator& rng,
if(!fips186_3_valid_size(pbits, qbits))
throw Invalid_Argument(
"FIPS 186-3 does not allow DSA domain parameters of " +
- to_string(pbits) + "/" + to_string(qbits) + " bits long");
+ std::to_string(pbits) + "/" + std::to_string(qbits) + " bits long");
if(seed_c.size() * 8 < qbits)
throw Invalid_Argument(
- "Generating a DSA parameter set with a " + to_string(qbits) +
+ "Generating a DSA parameter set with a " + std::to_string(qbits) +
"long q requires a seed at least as many bits long");
- std::auto_ptr<HashFunction> hash(
- af.make_hash_function("SHA-" + to_string(qbits)));
+ std::unique_ptr<HashFunction> hash(
+ af.make_hash_function("SHA-" + std::to_string(qbits)));
const u32bit HASH_SIZE = hash->OUTPUT_LENGTH;
diff --git a/src/math/numbertheory/make_prm.cpp b/src/math/numbertheory/make_prm.cpp
index 61d42634a..23b8cf549 100644
--- a/src/math/numbertheory/make_prm.cpp
+++ b/src/math/numbertheory/make_prm.cpp
@@ -20,7 +20,7 @@ BigInt random_prime(RandomNumberGenerator& rng,
{
if(bits <= 1)
throw Invalid_Argument("random_prime: Can't make a prime of " +
- to_string(bits) + " bits");
+ std::to_string(bits) + " bits");
else if(bits == 2)
return ((rng.next_byte() % 2) ? 2 : 3);
else if(bits == 3)
@@ -88,7 +88,7 @@ BigInt random_safe_prime(RandomNumberGenerator& rng, u32bit bits)
{
if(bits <= 64)
throw Invalid_Argument("random_safe_prime: Can't make a prime of " +
- to_string(bits) + " bits");
+ std::to_string(bits) + " bits");
BigInt p;
do
diff --git a/src/math/numbertheory/numthry.cpp b/src/math/numbertheory/numthry.cpp
index e4c52323e..f79fdec2b 100644
--- a/src/math/numbertheory/numthry.cpp
+++ b/src/math/numbertheory/numthry.cpp
@@ -77,7 +77,7 @@ u32bit miller_rabin_test_iterations(u32bit bits, bool verify)
{
struct mapping { u32bit bits; u32bit verify_iter; u32bit check_iter; };
- static const mapping tests[] = {
+ const mapping tests[] = {
{ 50, 55, 25 },
{ 100, 38, 22 },
{ 160, 32, 18 },