aboutsummaryrefslogtreecommitdiffstats
path: root/src/math/bigint
diff options
context:
space:
mode:
authorlloyd <[email protected]>2012-02-20 17:09:46 +0000
committerlloyd <[email protected]>2012-02-20 17:09:46 +0000
commit8c2dc1a6c3bf352a56622d569dc855ca8d6ab5e0 (patch)
tree6f50627e2e73c2b1fc1295dde8b19c4f169de46d /src/math/bigint
parent24c1546324995da70c51137ad138c3bb997a37b9 (diff)
parente943fc67962b6e4dc2c7c64707dc2cf062728520 (diff)
propagate from branch 'net.randombit.botan.tls-state-machine' (head 0ceb9cde62a2b3614901ae85a53546d9fc641326)
to branch 'net.randombit.botan.cxx11' (head 777e65950ef3706a82e5df20dcca7fcc999ca533)
Diffstat (limited to 'src/math/bigint')
-rw-r--r--src/math/bigint/big_code.cpp4
-rw-r--r--src/math/bigint/bigint.cpp11
-rw-r--r--src/math/bigint/bigint.h29
3 files changed, 32 insertions, 12 deletions
diff --git a/src/math/bigint/big_code.cpp b/src/math/bigint/big_code.cpp
index 75a310a7c..28614c9f1 100644
--- a/src/math/bigint/big_code.cpp
+++ b/src/math/bigint/big_code.cpp
@@ -111,7 +111,9 @@ BigInt BigInt::decode(const byte buf[], size_t length, Base base)
if(length % 2)
{
// Handle lack of leading 0
- const char buf0_with_leading_0[2] = { '0', buf[0] };
+ const char buf0_with_leading_0[2] =
+ { '0', static_cast<char>(buf[0]) };
+
binary = hex_decode(buf0_with_leading_0, 2);
binary += hex_decode(reinterpret_cast<const char*>(&buf[1]),
diff --git a/src/math/bigint/bigint.cpp b/src/math/bigint/bigint.cpp
index e2e062f2d..e2bbe7f5a 100644
--- a/src/math/bigint/bigint.cpp
+++ b/src/math/bigint/bigint.cpp
@@ -40,7 +40,7 @@ BigInt::BigInt(Sign s, size_t size)
}
/*
-* Construct a BigInt from a "raw" BigInt
+* Copy constructor
*/
BigInt::BigInt(const BigInt& b)
{
@@ -101,15 +101,6 @@ BigInt::BigInt(RandomNumberGenerator& rng, size_t bits)
}
/*
-* Swap this BigInt with another
-*/
-void BigInt::swap(BigInt& other)
- {
- reg.swap(other.reg);
- std::swap(signedness, other.signedness);
- }
-
-/*
* Grow the internal storage
*/
void BigInt::grow_reg(size_t n)
diff --git a/src/math/bigint/bigint.h b/src/math/bigint/bigint.h
index 87c7cb766..57aa84528 100644
--- a/src/math/bigint/bigint.h
+++ b/src/math/bigint/bigint.h
@@ -438,7 +438,11 @@ class BOTAN_DLL BigInt
* Swap this value with another
* @param other BigInt to swap values with
*/
- void swap(BigInt& other);
+ void swap(BigInt& other)
+ {
+ reg.swap(other.reg);
+ std::swap(signedness, other.signedness);
+ }
/**
* Create empty BigInt
@@ -500,6 +504,29 @@ class BOTAN_DLL BigInt
*/
BigInt(NumberType type, size_t n);
+ /**
+ * Move constructor
+ */
+ BigInt(BigInt&& other)
+ {
+ this->swap(other);
+ }
+
+ /**
+ * Move assignment
+ */
+ BigInt& operator=(BigInt&& other)
+ {
+ if(this != &other)
+ this->swap(other);
+
+ return (*this);
+ }
+
+ /**
+ * Copy assignment
+ */
+ BigInt& operator=(const BigInt&) = default;
private:
SecureVector<word> reg;
Sign signedness;