aboutsummaryrefslogtreecommitdiffstats
path: root/src/math/bigint
diff options
context:
space:
mode:
authorlloyd <[email protected]>2010-09-07 23:40:31 +0000
committerlloyd <[email protected]>2010-09-07 23:40:31 +0000
commit197f7cd4f744ae8246832343dc514296632554b2 (patch)
tree63963dfab01e29ce32be4c1d43e62506d9f0246d /src/math/bigint
parent5f83d344e49a6d62cd8989d9fb8f8ca80ed48fc1 (diff)
Big, invasive but mostly automated change, with a further attempt at
harmonising MemoryRegion with std::vector: The MemoryRegion::clear() function would zeroise the buffer, but keep the memory allocated and the size unchanged. This is very different from STL's clear(), which is basically the equivalent to what is called destroy() in MemoryRegion. So to be able to replace MemoryRegion with a std::vector, we have to rename destroy() to clear() and we have to expose the current functionality of clear() in some other way, since vector doesn't support this operation. Do so by adding a global function named zeroise() which takes a MemoryRegion which is zeroed. Remove clear() to ensure all callers are updated.
Diffstat (limited to 'src/math/bigint')
-rw-r--r--src/math/bigint/big_ops2.cpp6
-rw-r--r--src/math/bigint/bigint.cpp2
-rw-r--r--src/math/bigint/bigint.h2
3 files changed, 5 insertions, 5 deletions
diff --git a/src/math/bigint/big_ops2.cpp b/src/math/bigint/big_ops2.cpp
index cc50c26e5..193c00e32 100644
--- a/src/math/bigint/big_ops2.cpp
+++ b/src/math/bigint/big_ops2.cpp
@@ -37,7 +37,7 @@ BigInt& BigInt::operator+=(const BigInt& y)
}
else if(relative_size == 0)
{
- get_reg().clear();
+ zeroise(reg);
set_sign(Positive);
}
else if(relative_size > 0)
@@ -72,7 +72,7 @@ BigInt& BigInt::operator-=(const BigInt& y)
{
if(sign() == y.sign())
{
- get_reg().clear();
+ clear();
set_sign(Positive);
}
else
@@ -99,7 +99,7 @@ BigInt& BigInt::operator*=(const BigInt& y)
if(x_sw == 0 || y_sw == 0)
{
- get_reg().clear();
+ clear();
set_sign(Positive);
}
else if(x_sw == 1 && y_sw)
diff --git a/src/math/bigint/bigint.cpp b/src/math/bigint/bigint.cpp
index 1ae8be130..2ac387a97 100644
--- a/src/math/bigint/bigint.cpp
+++ b/src/math/bigint/bigint.cpp
@@ -348,7 +348,7 @@ void BigInt::binary_decode(const byte buf[], u32bit length)
{
const u32bit WORD_BYTES = sizeof(word);
- reg.clear();
+ clear();
reg.resize(round_up<u32bit>((length / WORD_BYTES) + 1, 8));
for(u32bit j = 0; j != length / WORD_BYTES; ++j)
diff --git a/src/math/bigint/bigint.h b/src/math/bigint/bigint.h
index 64bf20068..9ce71aeca 100644
--- a/src/math/bigint/bigint.h
+++ b/src/math/bigint/bigint.h
@@ -140,7 +140,7 @@ class BOTAN_DLL BigInt
/**
* Zeroize the BigInt
*/
- void clear() { get_reg().clear(); }
+ void clear() { zeroise(reg); }
/**
* Compare this to another BigInt