diff options
author | lloyd <[email protected]> | 2010-02-25 23:07:38 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2010-02-25 23:07:38 +0000 |
commit | 5fec937bd0c72858d6cf2f09b58b219294c7d5cc (patch) | |
tree | 811714c0663199782b07b8f20a328eeeeff9e768 /src/math | |
parent | 08647db8877585a783797c8db22dc76233b200f0 (diff) | |
parent | 3e95540b28f3d828c4578381c318545f6ad49589 (diff) |
propagate from branch 'net.randombit.botan' (head c1db52e38b60afbc6549af5222d6e10b1b9730dd)
to branch 'net.randombit.botan.c++0x' (head e56dfbfe6bffbd5b4e52b115549d885c5fd04586)
Diffstat (limited to 'src/math')
-rw-r--r-- | src/math/bigint/bigint.cpp | 21 | ||||
-rw-r--r-- | src/math/bigint/bigint.h | 19 | ||||
-rw-r--r-- | src/math/numbertheory/dsa_gen.cpp | 8 | ||||
-rw-r--r-- | src/math/numbertheory/make_prm.cpp | 4 | ||||
-rw-r--r-- | src/math/numbertheory/numthry.cpp | 2 |
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 b136b6d25..3eb01cd42 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) @@ -85,7 +85,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 }, |