aboutsummaryrefslogtreecommitdiffstats
path: root/src/block/mars
diff options
context:
space:
mode:
authorlloyd <lloyd@randombit.net>2010-09-14 01:16:32 +0000
committerlloyd <lloyd@randombit.net>2010-09-14 01:16:32 +0000
commitae59295ea945fdcc482df2233409a5f878fa20c7 (patch)
tree768c30635a17847dccb6db6f36fa3b033adc37bf /src/block/mars
parent548f48611760346fa2e47efd5c0865eff831946a (diff)
Completely remove the second parameter to SecureVector which specifies
the initial/default length of the array, update all users to instead pass the value to the constructor. This is a old vestigal thing from a class (SecureBuffer) that used this compile-time constant in order to store the values in an array. However this was changed way back in 2002 to use the same allocator hooks as the rest of the containers, so the only advantage to using the length field was that the initial length was set and didn't have to be set in the constructor which was midly convenient. However this directly conflicts with the desire to be able to (eventually) use std::vector with a custom allocator, since of course vector doesn't support this. Fortunately almost all of the uses are in classes which have only a single constructor, so there is little to no duplication by instead initializing the size in the constructor.
Diffstat (limited to 'src/block/mars')
-rw-r--r--src/block/mars/mars.cpp3
-rw-r--r--src/block/mars/mars.h4
2 files changed, 4 insertions, 3 deletions
diff --git a/src/block/mars/mars.cpp b/src/block/mars/mars.cpp
index 57a224fac..71cef3ee8 100644
--- a/src/block/mars/mars.cpp
+++ b/src/block/mars/mars.cpp
@@ -320,9 +320,10 @@ void MARS::decrypt_n(const byte in[], byte out[], u32bit blocks) const
*/
void MARS::key_schedule(const byte key[], u32bit length)
{
- SecureVector<u32bit, 15> T;
+ SecureVector<u32bit> T(15);
for(u32bit j = 0; j != length / 4; ++j)
T[j] = load_le<u32bit>(key, j);
+
T[length / 4] = length / 4;
for(u32bit j = 0; j != 4; ++j)
diff --git a/src/block/mars/mars.h b/src/block/mars/mars.h
index 37501fff1..84a9a21f7 100644
--- a/src/block/mars/mars.h
+++ b/src/block/mars/mars.h
@@ -25,11 +25,11 @@ class BOTAN_DLL MARS : public BlockCipher
std::string name() const { return "MARS"; }
BlockCipher* clone() const { return new MARS; }
- MARS() : BlockCipher(16, 16, 32, 4) {}
+ MARS() : BlockCipher(16, 16, 32, 4), EK(40) {}
private:
void key_schedule(const byte[], u32bit);
- SecureVector<u32bit, 40> EK;
+ SecureVector<u32bit> EK;
};
}