aboutsummaryrefslogtreecommitdiffstats
path: root/src/stream/arc4/arc4.cpp
diff options
context:
space:
mode:
authorlloyd <[email protected]>2012-05-25 02:11:10 +0000
committerlloyd <[email protected]>2012-05-25 02:11:10 +0000
commit113f4035f41cf3152832e1753d28b79a7ea811a4 (patch)
tree1e2071c1f7786972d268b727f52ee33225ad68d4 /src/stream/arc4/arc4.cpp
parentee42784fee56c48f72ecf03d7b93765dac35edf5 (diff)
For block and stream ciphers, don't set the size of the key vectors
until we are actually setting a key. This avoids the problem of prototype objects consuming not just memory but the precious few bytes of mlock'able memory that we're given by Linux. Use clear_mem instead of a loop in BigInt::mask_bits If OS2ECP encounters an invalid format type, include what type it was in the exception message.
Diffstat (limited to 'src/stream/arc4/arc4.cpp')
-rw-r--r--src/stream/arc4/arc4.cpp16
1 files changed, 7 insertions, 9 deletions
diff --git a/src/stream/arc4/arc4.cpp b/src/stream/arc4/arc4.cpp
index a25b68185..13eb6ff9e 100644
--- a/src/stream/arc4/arc4.cpp
+++ b/src/stream/arc4/arc4.cpp
@@ -61,7 +61,10 @@ void ARC4::generate()
*/
void ARC4::key_schedule(const byte key[], size_t length)
{
- clear();
+ state.resize(256);
+ buffer.resize(DEFAULT_BUFFERSIZE);
+
+ position = X = Y = 0;
for(size_t i = 0; i != 256; ++i)
state[i] = static_cast<byte>(i);
@@ -93,19 +96,14 @@ std::string ARC4::name() const
*/
void ARC4::clear()
{
- zeroise(state);
- zeroise(buffer);
+ state.clear();
+ buffer.clear();
position = X = Y = 0;
}
/*
* ARC4 Constructor
*/
-ARC4::ARC4(size_t s) : SKIP(s),
- state(256),
- buffer(DEFAULT_BUFFERSIZE)
- {
- clear();
- }
+ARC4::ARC4(size_t s) : SKIP(s) {}
}