aboutsummaryrefslogtreecommitdiffstats
path: root/src/block/mars
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/block/mars
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/block/mars')
-rw-r--r--src/block/mars/mars.cpp2
-rw-r--r--src/block/mars/mars.h4
2 files changed, 3 insertions, 3 deletions
diff --git a/src/block/mars/mars.cpp b/src/block/mars/mars.cpp
index 64ece83ab..5badc40cc 100644
--- a/src/block/mars/mars.cpp
+++ b/src/block/mars/mars.cpp
@@ -326,6 +326,8 @@ void MARS::key_schedule(const byte key[], size_t length)
T[length / 4] = static_cast<u32bit>(length) / 4;
+ EK.resize(40);
+
for(u32bit i = 0; i != 4; ++i)
{
T[ 0] ^= rotate_left(T[ 8] ^ T[13], 3) ^ (i );
diff --git a/src/block/mars/mars.h b/src/block/mars/mars.h
index fc732ae10..488ea1b83 100644
--- a/src/block/mars/mars.h
+++ b/src/block/mars/mars.h
@@ -21,11 +21,9 @@ class BOTAN_DLL MARS : public Block_Cipher_Fixed_Params<16, 16, 32, 4>
void encrypt_n(const byte in[], byte out[], size_t blocks) const;
void decrypt_n(const byte in[], byte out[], size_t blocks) const;
- void clear() { zeroise(EK); }
+ void clear() { EK.clear(); }
std::string name() const { return "MARS"; }
BlockCipher* clone() const { return new MARS; }
-
- MARS() : EK(40) {}
private:
void key_schedule(const byte[], size_t);