diff options
author | lloyd <[email protected]> | 2010-03-21 23:30:14 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2010-03-21 23:30:14 +0000 |
commit | f8a77dd91e8b3aed644c2c206ff9b8822fb3ae02 (patch) | |
tree | 315cbc118a8ba2afda674154e7c65e8900a00cb8 /src/math | |
parent | 572c106e868821da13447ca7349523ef4a90ec2c (diff) | |
parent | 634f3d27f7faad1dc558821382f71ecc2194637d (diff) |
propagate from branch 'net.randombit.botan' (head 96d0a1885774b624812fd143d541c8bcda319217)
to branch 'net.randombit.botan.c++0x' (head e14368ab9d7976f3e111c6bc0adf24eebeb7c114)
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 0bb51fd20..3756da51f 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 535c22976..42b670d69 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 59a5c2635..897b0d6ba 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 010a523ff..0cd3a61e5 100644 --- a/src/math/numbertheory/numthry.cpp +++ b/src/math/numbertheory/numthry.cpp @@ -77,7 +77,7 @@ u32bit miller_rabin_test_iterations(u32bit bits, u32bit level) { 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 }, |