diff options
author | lloyd <[email protected]> | 2010-09-14 01:16:32 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2010-09-14 01:16:32 +0000 |
commit | ae59295ea945fdcc482df2233409a5f878fa20c7 (patch) | |
tree | 768c30635a17847dccb6db6f36fa3b033adc37bf /src/block/blowfish | |
parent | 548f48611760346fa2e47efd5c0865eff831946a (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/blowfish')
-rw-r--r-- | src/block/blowfish/blowfish.cpp | 6 | ||||
-rw-r--r-- | src/block/blowfish/blowfish.h | 6 |
2 files changed, 7 insertions, 5 deletions
diff --git a/src/block/blowfish/blowfish.cpp b/src/block/blowfish/blowfish.cpp index 6e4ad5b28..91d25884d 100644 --- a/src/block/blowfish/blowfish.cpp +++ b/src/block/blowfish/blowfish.cpp @@ -131,8 +131,10 @@ void Blowfish::generate_sbox(MemoryRegion<u32bit>& box, */ void Blowfish::clear() { - P.copy(P_INIT, 18); - S.copy(S_INIT, 1024); + std::copy(P_INIT, P_INIT + 18, P.begin()); + std::copy(S_INIT, S_INIT + 1024, S.begin()); + //P.copy(P_INIT, 18); + //S.copy(S_INIT, 1024); } } diff --git a/src/block/blowfish/blowfish.h b/src/block/blowfish/blowfish.h index 88122aed8..0b4df50ad 100644 --- a/src/block/blowfish/blowfish.h +++ b/src/block/blowfish/blowfish.h @@ -25,7 +25,7 @@ class BOTAN_DLL Blowfish : public BlockCipher std::string name() const { return "Blowfish"; } BlockCipher* clone() const { return new Blowfish; } - Blowfish() : BlockCipher(8, 1, 56) {} + Blowfish() : BlockCipher(8, 1, 56), S(1024), P(18) {} private: void key_schedule(const byte[], u32bit); void generate_sbox(MemoryRegion<u32bit>& box, @@ -34,8 +34,8 @@ class BOTAN_DLL Blowfish : public BlockCipher static const u32bit P_INIT[18]; static const u32bit S_INIT[1024]; - SecureVector<u32bit, 1024> S; - SecureVector<u32bit, 18> P; + SecureVector<u32bit> S; + SecureVector<u32bit> P; }; } |