aboutsummaryrefslogtreecommitdiffstats
path: root/src/stream
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/stream
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/stream')
-rw-r--r--src/stream/arc4/arc4.cpp4
-rw-r--r--src/stream/ctr/ctr.cpp6
-rw-r--r--src/stream/ofb/ofb.cpp4
-rw-r--r--src/stream/salsa20/salsa20.cpp4
-rw-r--r--src/stream/turing/turing.cpp10
-rw-r--r--src/stream/wid_wake/wid_wake.cpp8
6 files changed, 18 insertions, 18 deletions
diff --git a/src/stream/arc4/arc4.cpp b/src/stream/arc4/arc4.cpp
index 1c89379ba..a3a2f9a65 100644
--- a/src/stream/arc4/arc4.cpp
+++ b/src/stream/arc4/arc4.cpp
@@ -89,8 +89,8 @@ std::string ARC4::name() const
*/
void ARC4::clear()
{
- state.clear();
- buffer.clear();
+ zeroise(state);
+ zeroise(buffer);
position = X = Y = 0;
}
diff --git a/src/stream/ctr/ctr.cpp b/src/stream/ctr/ctr.cpp
index 8a24cd4d0..cd1b1b7fb 100644
--- a/src/stream/ctr/ctr.cpp
+++ b/src/stream/ctr/ctr.cpp
@@ -40,8 +40,8 @@ CTR_BE::~CTR_BE()
void CTR_BE::clear()
{
permutation->clear();
- buffer.clear();
- counter.clear();
+ zeroise(buffer);
+ zeroise(counter);
position = 0;
}
@@ -91,7 +91,7 @@ void CTR_BE::set_iv(const byte iv[], u32bit iv_len)
const u32bit BLOCK_SIZE = permutation->BLOCK_SIZE;
- counter.clear();
+ zeroise(counter);
counter.copy(0, iv, iv_len);
diff --git a/src/stream/ofb/ofb.cpp b/src/stream/ofb/ofb.cpp
index cfa035a4f..332673153 100644
--- a/src/stream/ofb/ofb.cpp
+++ b/src/stream/ofb/ofb.cpp
@@ -38,7 +38,7 @@ OFB::~OFB()
void OFB::clear()
{
permutation->clear();
- buffer.clear();
+ zeroise(buffer);
position = 0;
}
@@ -87,7 +87,7 @@ void OFB::set_iv(const byte iv[], u32bit iv_len)
if(!valid_iv_length(iv_len))
throw Invalid_IV_Length(name(), iv_len);
- buffer.clear();
+ zeroise(buffer);
buffer.copy(0, iv, iv_len);
permutation->encrypt(buffer);
diff --git a/src/stream/salsa20/salsa20.cpp b/src/stream/salsa20/salsa20.cpp
index a38e6e305..c52e305d1 100644
--- a/src/stream/salsa20/salsa20.cpp
+++ b/src/stream/salsa20/salsa20.cpp
@@ -232,8 +232,8 @@ std::string Salsa20::name() const
*/
void Salsa20::clear()
{
- state.clear();
- buffer.clear();
+ zeroise(state);
+ zeroise(buffer);
position = 0;
}
diff --git a/src/stream/turing/turing.cpp b/src/stream/turing/turing.cpp
index 159c262fd..bfb2166d8 100644
--- a/src/stream/turing/turing.cpp
+++ b/src/stream/turing/turing.cpp
@@ -300,12 +300,12 @@ void Turing::set_iv(const byte iv[], u32bit length)
*/
void Turing::clear()
{
- S0.clear();
- S1.clear();
- S2.clear();
- S3.clear();
+ zeroise(S0);
+ zeroise(S1);
+ zeroise(S2);
+ zeroise(S3);
- buffer.clear();
+ zeroise(buffer);
position = 0;
}
diff --git a/src/stream/wid_wake/wid_wake.cpp b/src/stream/wid_wake/wid_wake.cpp
index 225ccf9a6..f5897f1cc 100644
--- a/src/stream/wid_wake/wid_wake.cpp
+++ b/src/stream/wid_wake/wid_wake.cpp
@@ -139,10 +139,10 @@ void WiderWake_41_BE::set_iv(const byte iv[], u32bit length)
void WiderWake_41_BE::clear()
{
position = 0;
- t_key.clear();
- state.clear();
- T.clear();
- buffer.clear();
+ zeroise(t_key);
+ zeroise(state);
+ zeroise(T);
+ zeroise(buffer);
}
}