aboutsummaryrefslogtreecommitdiffstats
path: root/src/stream/salsa20/salsa20.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/salsa20/salsa20.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/salsa20/salsa20.cpp')
-rw-r--r--src/stream/salsa20/salsa20.cpp9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/stream/salsa20/salsa20.cpp b/src/stream/salsa20/salsa20.cpp
index 65ee3d758..a7d1b2622 100644
--- a/src/stream/salsa20/salsa20.cpp
+++ b/src/stream/salsa20/salsa20.cpp
@@ -134,7 +134,8 @@ void Salsa20::key_schedule(const byte key[], size_t length)
static const u32bit SIGMA[] =
{ 0x61707865, 0x3320646e, 0x79622d32, 0x6b206574 };
- clear();
+ state.resize(16);
+ buffer.resize(64);
if(length == 16)
{
@@ -167,6 +168,8 @@ void Salsa20::key_schedule(const byte key[], size_t length)
state[15] = SIGMA[3];
}
+ position = 0;
+
const byte ZERO[8] = { 0 };
set_iv(ZERO, sizeof(ZERO));
}
@@ -232,8 +235,8 @@ std::string Salsa20::name() const
*/
void Salsa20::clear()
{
- zeroise(state);
- zeroise(buffer);
+ state.clear();
+ buffer.clear();
position = 0;
}