diff options
Diffstat (limited to 'src/hash')
-rw-r--r-- | src/hash/bmw/bmw_512.h | 7 | ||||
-rw-r--r-- | src/hash/gost_3411/gost_3411.cpp | 9 | ||||
-rw-r--r-- | src/hash/gost_3411/gost_3411.h | 4 | ||||
-rw-r--r-- | src/hash/has160/has160.h | 7 | ||||
-rw-r--r-- | src/hash/md2/md2.h | 7 | ||||
-rw-r--r-- | src/hash/md4/md4.h | 7 | ||||
-rw-r--r-- | src/hash/md5/md5.h | 7 | ||||
-rw-r--r-- | src/hash/rmd128/rmd128.h | 7 | ||||
-rw-r--r-- | src/hash/rmd160/rmd160.h | 7 | ||||
-rw-r--r-- | src/hash/sha1/sha160.cpp | 4 | ||||
-rw-r--r-- | src/hash/sha1/sha160.h | 2 | ||||
-rw-r--r-- | src/hash/sha2/sha2_32.h | 14 | ||||
-rw-r--r-- | src/hash/sha2/sha2_64.h | 13 | ||||
-rw-r--r-- | src/hash/skein/skein_512.cpp | 6 | ||||
-rw-r--r-- | src/hash/skein/skein_512.h | 6 | ||||
-rw-r--r-- | src/hash/tiger/tiger.cpp | 5 | ||||
-rw-r--r-- | src/hash/tiger/tiger.h | 3 | ||||
-rw-r--r-- | src/hash/whirlpool/whrlpool.h | 7 |
18 files changed, 69 insertions, 53 deletions
diff --git a/src/hash/bmw/bmw_512.h b/src/hash/bmw/bmw_512.h index d3c9c03c6..b1eaa6874 100644 --- a/src/hash/bmw/bmw_512.h +++ b/src/hash/bmw/bmw_512.h @@ -21,13 +21,14 @@ class BOTAN_DLL BMW_512 : public MDx_HashFunction void clear(); std::string name() const { return "BMW512"; } HashFunction* clone() const { return new BMW_512; } - BMW_512() : MDx_HashFunction(64, 128, false, true) { clear(); } + + BMW_512() : MDx_HashFunction(64, 128, false, true), H(16), M(16), Q(32) + { clear(); } private: void compress_n(const byte input[], u32bit blocks); void copy_out(byte output[]); - SecureVector<u64bit, 16> H, M; - SecureVector<u64bit, 32> Q; + SecureVector<u64bit> H, M, Q; }; } diff --git a/src/hash/gost_3411/gost_3411.cpp b/src/hash/gost_3411/gost_3411.cpp index ad874fe8a..ee43514d5 100644 --- a/src/hash/gost_3411/gost_3411.cpp +++ b/src/hash/gost_3411/gost_3411.cpp @@ -17,7 +17,10 @@ namespace Botan { */ GOST_34_11::GOST_34_11() : HashFunction(32, 32), - cipher(GOST_28147_89_Params("R3411_CryptoPro")) + cipher(GOST_28147_89_Params("R3411_CryptoPro")), + buffer(32), + sum(32), + hash(32) { count = 0; position = 0; @@ -223,11 +226,11 @@ void GOST_34_11::final_result(byte out[]) compress_n(buffer, 1); } - SecureVector<byte, 32> length_buf; + SecureVector<byte> length_buf(32); const u64bit bit_count = count * 8; store_le(bit_count, length_buf); - SecureVector<byte, 32> sum_buf(sum); + SecureVector<byte> sum_buf = sum; compress_n(length_buf, 1); compress_n(sum_buf, 1); diff --git a/src/hash/gost_3411/gost_3411.h b/src/hash/gost_3411/gost_3411.h index 04417d6fd..5d26e8557 100644 --- a/src/hash/gost_3411/gost_3411.h +++ b/src/hash/gost_3411/gost_3411.h @@ -31,9 +31,7 @@ class BOTAN_DLL GOST_34_11 : public HashFunction void final_result(byte[]); GOST_28147_89 cipher; - SecureVector<byte, 32> buffer; - SecureVector<byte, 32> sum; - SecureVector<byte, 32> hash; + SecureVector<byte> buffer, sum, hash; u64bit count; u32bit position; }; diff --git a/src/hash/has160/has160.h b/src/hash/has160/has160.h index a82e4c579..7cff320b8 100644 --- a/src/hash/has160/has160.h +++ b/src/hash/has160/has160.h @@ -22,13 +22,14 @@ class BOTAN_DLL HAS_160 : public MDx_HashFunction void clear(); std::string name() const { return "HAS-160"; } HashFunction* clone() const { return new HAS_160; } - HAS_160() : MDx_HashFunction(20, 64, false, true) { clear(); } + + HAS_160() : MDx_HashFunction(20, 64, false, true), X(20), digest(5) + { clear(); } private: void compress_n(const byte[], u32bit blocks); void copy_out(byte[]); - SecureVector<u32bit, 20> X; - SecureVector<u32bit, 5> digest; + SecureVector<u32bit> X, digest; }; } diff --git a/src/hash/md2/md2.h b/src/hash/md2/md2.h index 9d39d8913..b25d5f410 100644 --- a/src/hash/md2/md2.h +++ b/src/hash/md2/md2.h @@ -21,14 +21,15 @@ class BOTAN_DLL MD2 : public HashFunction void clear(); std::string name() const { return "MD2"; } HashFunction* clone() const { return new MD2; } - MD2() : HashFunction(16, 16) { clear(); } + + MD2() : HashFunction(16, 16), X(48), checksum(16), buffer(16) + { clear(); } private: void add_data(const byte[], u32bit); void hash(const byte[]); void final_result(byte[]); - SecureVector<byte, 48> X; - SecureVector<byte, 16> checksum, buffer; + SecureVector<byte> X, checksum, buffer; u32bit position; }; diff --git a/src/hash/md4/md4.h b/src/hash/md4/md4.h index 44d60406a..44081e635 100644 --- a/src/hash/md4/md4.h +++ b/src/hash/md4/md4.h @@ -21,13 +21,14 @@ class BOTAN_DLL MD4 : public MDx_HashFunction void clear(); std::string name() const { return "MD4"; } HashFunction* clone() const { return new MD4; } - MD4() : MDx_HashFunction(16, 64, false, true) { clear(); } + + MD4() : MDx_HashFunction(16, 64, false, true), M(16), digest(4) + { clear(); } protected: void compress_n(const byte input[], u32bit blocks); void copy_out(byte[]); - SecureVector<u32bit, 16> M; - SecureVector<u32bit, 4> digest; + SecureVector<u32bit> M, digest; }; } diff --git a/src/hash/md5/md5.h b/src/hash/md5/md5.h index d0706ab4b..732ec026d 100644 --- a/src/hash/md5/md5.h +++ b/src/hash/md5/md5.h @@ -21,13 +21,14 @@ class BOTAN_DLL MD5 : public MDx_HashFunction void clear(); std::string name() const { return "MD5"; } HashFunction* clone() const { return new MD5; } - MD5() : MDx_HashFunction(16, 64, false, true) { clear(); } + + MD5() : MDx_HashFunction(16, 64, false, true), M(16), digest(4) + { clear(); } protected: void compress_n(const byte[], u32bit blocks); void copy_out(byte[]); - SecureVector<u32bit, 16> M; - SecureVector<u32bit, 4> digest; + SecureVector<u32bit> M, digest; }; } diff --git a/src/hash/rmd128/rmd128.h b/src/hash/rmd128/rmd128.h index c7c7f4580..23272c622 100644 --- a/src/hash/rmd128/rmd128.h +++ b/src/hash/rmd128/rmd128.h @@ -21,13 +21,14 @@ class BOTAN_DLL RIPEMD_128 : public MDx_HashFunction void clear(); std::string name() const { return "RIPEMD-128"; } HashFunction* clone() const { return new RIPEMD_128; } - RIPEMD_128() : MDx_HashFunction(16, 64, false, true) { clear(); } + + RIPEMD_128() : MDx_HashFunction(16, 64, false, true), M(16), digest(4) + { clear(); } private: void compress_n(const byte[], u32bit blocks); void copy_out(byte[]); - SecureVector<u32bit, 16> M; - SecureVector<u32bit, 4> digest; + SecureVector<u32bit> M, digest; }; } diff --git a/src/hash/rmd160/rmd160.h b/src/hash/rmd160/rmd160.h index 0b6e847f0..09c995628 100644 --- a/src/hash/rmd160/rmd160.h +++ b/src/hash/rmd160/rmd160.h @@ -21,13 +21,14 @@ class BOTAN_DLL RIPEMD_160 : public MDx_HashFunction void clear(); std::string name() const { return "RIPEMD-160"; } HashFunction* clone() const { return new RIPEMD_160; } - RIPEMD_160() : MDx_HashFunction(20, 64, false, true) { clear(); } + + RIPEMD_160() : MDx_HashFunction(20, 64, false, true), M(16), digest(5) + { clear(); } private: void compress_n(const byte[], u32bit blocks); void copy_out(byte[]); - SecureVector<u32bit, 16> M; - SecureVector<u32bit, 5> digest; + SecureVector<u32bit> M, digest; }; } diff --git a/src/hash/sha1/sha160.cpp b/src/hash/sha1/sha160.cpp index 0b3d7c346..79348a371 100644 --- a/src/hash/sha1/sha160.cpp +++ b/src/hash/sha1/sha160.cpp @@ -156,7 +156,7 @@ void SHA_160::clear() * SHA_160 Constructor */ SHA_160::SHA_160() : - MDx_HashFunction(20, 64, true, true), W(80) + MDx_HashFunction(20, 64, true, true), digest(5), W(80) { clear(); } @@ -165,7 +165,7 @@ SHA_160::SHA_160() : * SHA_160 Constructor */ SHA_160::SHA_160(u32bit W_size) : - MDx_HashFunction(20, 64, true, true), W(W_size) + MDx_HashFunction(20, 64, true, true), digest(5), W(W_size) { clear(); } diff --git a/src/hash/sha1/sha160.h b/src/hash/sha1/sha160.h index c66831a1e..690aea1d5 100644 --- a/src/hash/sha1/sha160.h +++ b/src/hash/sha1/sha160.h @@ -35,7 +35,7 @@ class BOTAN_DLL SHA_160 : public MDx_HashFunction void compress_n(const byte[], u32bit blocks); void copy_out(byte[]); - SecureVector<u32bit, 5> digest; + SecureVector<u32bit> digest; SecureVector<u32bit> W; }; diff --git a/src/hash/sha2/sha2_32.h b/src/hash/sha2/sha2_32.h index 71f0cff4b..a3e3a6f19 100644 --- a/src/hash/sha2/sha2_32.h +++ b/src/hash/sha2/sha2_32.h @@ -22,13 +22,14 @@ class BOTAN_DLL SHA_224 : public MDx_HashFunction void clear(); std::string name() const { return "SHA-224"; } HashFunction* clone() const { return new SHA_224; } - SHA_224() : MDx_HashFunction(28, 64, true, true) { clear(); } + + SHA_224() : MDx_HashFunction(28, 64, true, true), W(64), digest(8) + { clear(); } private: void compress_n(const byte[], u32bit blocks); void copy_out(byte[]); - SecureVector<u32bit, 64> W; - SecureVector<u32bit, 8> digest; + SecureVector<u32bit> W, digest; }; /** @@ -40,13 +41,14 @@ class BOTAN_DLL SHA_256 : public MDx_HashFunction void clear(); std::string name() const { return "SHA-256"; } HashFunction* clone() const { return new SHA_256; } - SHA_256() : MDx_HashFunction(32, 64, true, true) { clear(); } + + SHA_256() : MDx_HashFunction(32, 64, true, true), W(64), digest(8) + { clear(); } private: void compress_n(const byte[], u32bit blocks); void copy_out(byte[]); - SecureVector<u32bit, 64> W; - SecureVector<u32bit, 8> digest; + SecureVector<u32bit> W, digest; }; } diff --git a/src/hash/sha2/sha2_64.h b/src/hash/sha2/sha2_64.h index e8112595e..726712221 100644 --- a/src/hash/sha2/sha2_64.h +++ b/src/hash/sha2/sha2_64.h @@ -21,13 +21,14 @@ class BOTAN_DLL SHA_384 : public MDx_HashFunction void clear(); std::string name() const { return "SHA-384"; } HashFunction* clone() const { return new SHA_384; } - SHA_384() : MDx_HashFunction(48, 128, true, true, 16) { clear(); } + + SHA_384() : MDx_HashFunction(48, 128, true, true, 16), W(80), digest(8) + { clear(); } private: void compress_n(const byte[], u32bit blocks); void copy_out(byte[]); - SecureVector<u64bit, 80> W; - SecureVector<u64bit, 8> digest; + SecureVector<u64bit> W, digest; }; /** @@ -39,13 +40,13 @@ class BOTAN_DLL SHA_512 : public MDx_HashFunction void clear(); std::string name() const { return "SHA-512"; } HashFunction* clone() const { return new SHA_512; } - SHA_512() : MDx_HashFunction(64, 128, true, true, 16) { clear(); } + SHA_512() : MDx_HashFunction(64, 128, true, true, 16), W(80), digest(8) + { clear(); } private: void compress_n(const byte[], u32bit blocks); void copy_out(byte[]); - SecureVector<u64bit, 80> W; - SecureVector<u64bit, 8> digest; + SecureVector<u64bit> W, digest; }; } diff --git a/src/hash/skein/skein_512.cpp b/src/hash/skein/skein_512.cpp index 5aa49ab7a..a3aff52ab 100644 --- a/src/hash/skein/skein_512.cpp +++ b/src/hash/skein/skein_512.cpp @@ -170,12 +170,12 @@ Skein_512::Skein_512(u32bit arg_output_bits, const std::string& arg_personalization) : HashFunction(arg_output_bits / 8, 64), personalization(arg_personalization), - output_bits(arg_output_bits) + output_bits(arg_output_bits), + H(9), T(3), buffer(64), buf_pos(0) { if(output_bits == 0 || output_bits % 8 != 0) throw Invalid_Argument("Bad output bits size for Skein-512"); - buf_pos = 0; initial_block(H, T, output_bits, personalization); } @@ -239,7 +239,7 @@ void Skein_512::final_result(byte out[]) u32bit out_bytes = output_bits / 8; - SecureVector<u64bit, 9> H_out; + SecureVector<u64bit> H_out(9); while(out_bytes) { diff --git a/src/hash/skein/skein_512.h b/src/hash/skein/skein_512.h index 5d17fa564..811b633eb 100644 --- a/src/hash/skein/skein_512.h +++ b/src/hash/skein/skein_512.h @@ -37,10 +37,10 @@ class BOTAN_DLL Skein_512 : public HashFunction std::string personalization; u32bit output_bits; - SecureVector<u64bit, 9> H; - SecureVector<u64bit, 3> T; - SecureVector<byte, 64> buffer; + SecureVector<u64bit> H; + SecureVector<u64bit> T; + SecureVector<byte> buffer; u32bit buf_pos; }; diff --git a/src/hash/tiger/tiger.cpp b/src/hash/tiger/tiger.cpp index d931324e0..9d3e2cbe4 100644 --- a/src/hash/tiger/tiger.cpp +++ b/src/hash/tiger/tiger.cpp @@ -167,7 +167,10 @@ std::string Tiger::name() const * Tiger Constructor */ Tiger::Tiger(u32bit hashlen, u32bit pass) : - MDx_HashFunction(hashlen, 64, false, false), PASS(pass) + MDx_HashFunction(hashlen, 64, false, false), + X(8), + digest(3), + PASS(pass) { if(OUTPUT_LENGTH != 16 && OUTPUT_LENGTH != 20 && OUTPUT_LENGTH != 24) throw Invalid_Argument("Tiger: Illegal hash output size: " + diff --git a/src/hash/tiger/tiger.h b/src/hash/tiger/tiger.h index 94665b902..4b8a99344 100644 --- a/src/hash/tiger/tiger.h +++ b/src/hash/tiger/tiger.h @@ -44,8 +44,7 @@ class BOTAN_DLL Tiger : public MDx_HashFunction static const u64bit SBOX3[256]; static const u64bit SBOX4[256]; - SecureVector<u64bit, 8> X; - SecureVector<u64bit, 3> digest; + SecureVector<u64bit> X, digest; const u32bit PASS; }; diff --git a/src/hash/whirlpool/whrlpool.h b/src/hash/whirlpool/whrlpool.h index e28053d4f..98be0b480 100644 --- a/src/hash/whirlpool/whrlpool.h +++ b/src/hash/whirlpool/whrlpool.h @@ -21,7 +21,9 @@ class BOTAN_DLL Whirlpool : public MDx_HashFunction void clear(); std::string name() const { return "Whirlpool"; } HashFunction* clone() const { return new Whirlpool; } - Whirlpool() : MDx_HashFunction(64, 64, true, true, 32) { clear(); } + + Whirlpool() : MDx_HashFunction(64, 64, true, true, 32), M(8), digest(8) + { clear(); } private: void compress_n(const byte[], u32bit blocks); void copy_out(byte[]); @@ -34,7 +36,8 @@ class BOTAN_DLL Whirlpool : public MDx_HashFunction static const u64bit C5[256]; static const u64bit C6[256]; static const u64bit C7[256]; - SecureVector<u64bit, 8> M, digest; + + SecureVector<u64bit> M, digest; }; } |