aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorlloyd <[email protected]>2010-10-29 13:51:27 +0000
committerlloyd <[email protected]>2010-10-29 13:51:27 +0000
commit633175a57a03ed9bf5a5e3577bfc26068c62b688 (patch)
tree086eb3a931d39fb35f8a3896a25a5cb38736a696 /src
parentdf0dfeb904485bacb8034d0468b4498130939acc (diff)
Remove BufferedComputation::OUTPUT_LENGTH
Diffstat (limited to 'src')
-rw-r--r--src/checksum/adler32/adler32.h7
-rw-r--r--src/checksum/crc24/crc24.h7
-rw-r--r--src/checksum/crc32/crc32.h7
-rw-r--r--src/hash/bmw/bmw_512.h6
-rw-r--r--src/hash/comb4p/comb4p.cpp1
-rw-r--r--src/hash/comb4p/comb4p.h5
-rw-r--r--src/hash/gost_3411/gost_3411.cpp1
-rw-r--r--src/hash/gost_3411/gost_3411.h5
-rw-r--r--src/hash/has160/has160.h6
-rw-r--r--src/hash/hash.h10
-rw-r--r--src/hash/md2/md2.h7
-rw-r--r--src/hash/md4/md4.h6
-rw-r--r--src/hash/md5/md5.h6
-rw-r--r--src/hash/mdx_hash/mdx_hash.cpp8
-rw-r--r--src/hash/mdx_hash/mdx_hash.h3
-rw-r--r--src/hash/par_hash/par_hash.cpp30
-rw-r--r--src/hash/par_hash/par_hash.h2
-rw-r--r--src/hash/rmd128/rmd128.h6
-rw-r--r--src/hash/rmd160/rmd160.h6
-rw-r--r--src/hash/sha1/sha160.cpp18
-rw-r--r--src/hash/sha1/sha160.h15
-rw-r--r--src/hash/sha2_32/sha2_32.h12
-rw-r--r--src/hash/sha2_64/sha2_64.h13
-rw-r--r--src/hash/skein/skein_512.cpp1
-rw-r--r--src/hash/skein/skein_512.h1
-rw-r--r--src/hash/tiger/tiger.cpp16
-rw-r--r--src/hash/tiger/tiger.h8
-rw-r--r--src/hash/whirlpool/whrlpool.h6
-rw-r--r--src/mac/cbc_mac/cbc_mac.cpp1
-rw-r--r--src/mac/cbc_mac/cbc_mac.h3
-rw-r--r--src/mac/cmac/cmac.cpp4
-rw-r--r--src/mac/cmac/cmac.h4
-rw-r--r--src/mac/hmac/hmac.cpp4
-rw-r--r--src/mac/hmac/hmac.h2
-rw-r--r--src/mac/mac.h9
-rw-r--r--src/mac/ssl3mac/ssl3_mac.cpp4
-rw-r--r--src/mac/ssl3mac/ssl3_mac.h4
-rw-r--r--src/mac/x919_mac/x919_mac.cpp1
-rw-r--r--src/mac/x919_mac/x919_mac.h1
-rw-r--r--src/utils/buf_comp/buf_comp.h15
40 files changed, 134 insertions, 137 deletions
diff --git a/src/checksum/adler32/adler32.h b/src/checksum/adler32/adler32.h
index 3a2441ad3..dc2872ca1 100644
--- a/src/checksum/adler32/adler32.h
+++ b/src/checksum/adler32/adler32.h
@@ -18,10 +18,13 @@ namespace Botan {
class BOTAN_DLL Adler32 : public HashFunction
{
public:
- void clear() { S1 = 1; S2 = 0; }
std::string name() const { return "Adler32"; }
+ size_t output_length() const { return 4; }
HashFunction* clone() const { return new Adler32; }
- Adler32() : HashFunction(4) { clear(); }
+
+ void clear() { S1 = 1; S2 = 0; }
+
+ Adler32() { clear(); }
~Adler32() { clear(); }
private:
void add_data(const byte[], size_t);
diff --git a/src/checksum/crc24/crc24.h b/src/checksum/crc24/crc24.h
index f9786dfa4..b5faebcee 100644
--- a/src/checksum/crc24/crc24.h
+++ b/src/checksum/crc24/crc24.h
@@ -18,10 +18,13 @@ namespace Botan {
class BOTAN_DLL CRC24 : public HashFunction
{
public:
- void clear() { crc = 0xB704CE; }
std::string name() const { return "CRC24"; }
+ size_t output_length() const { return 3; }
HashFunction* clone() const { return new CRC24; }
- CRC24() : HashFunction(3) { clear(); }
+
+ void clear() { crc = 0xB704CE; }
+
+ CRC24() { clear(); }
~CRC24() { clear(); }
private:
void add_data(const byte[], size_t);
diff --git a/src/checksum/crc32/crc32.h b/src/checksum/crc32/crc32.h
index aa8c366e5..dec3d0449 100644
--- a/src/checksum/crc32/crc32.h
+++ b/src/checksum/crc32/crc32.h
@@ -18,10 +18,13 @@ namespace Botan {
class BOTAN_DLL CRC32 : public HashFunction
{
public:
- void clear() { crc = 0xFFFFFFFF; }
std::string name() const { return "CRC32"; }
+ size_t output_length() const { return 4; }
HashFunction* clone() const { return new CRC32; }
- CRC32() : HashFunction(4) { clear(); }
+
+ void clear() { crc = 0xFFFFFFFF; }
+
+ CRC32() { clear(); }
~CRC32() { clear(); }
private:
void add_data(const byte[], size_t);
diff --git a/src/hash/bmw/bmw_512.h b/src/hash/bmw/bmw_512.h
index aa527c142..474b607bb 100644
--- a/src/hash/bmw/bmw_512.h
+++ b/src/hash/bmw/bmw_512.h
@@ -18,11 +18,13 @@ namespace Botan {
class BOTAN_DLL BMW_512 : public MDx_HashFunction
{
public:
- void clear();
std::string name() const { return "BMW512"; }
+ size_t output_length() const { return 64; }
HashFunction* clone() const { return new BMW_512; }
- BMW_512() : MDx_HashFunction(64, 128, false, true), H(16), M(16), Q(32)
+ void clear();
+
+ BMW_512() : MDx_HashFunction(128, false, true), H(16), M(16), Q(32)
{ clear(); }
private:
void compress_n(const byte input[], size_t blocks);
diff --git a/src/hash/comb4p/comb4p.cpp b/src/hash/comb4p/comb4p.cpp
index 19e23879f..1ea64a5cb 100644
--- a/src/hash/comb4p/comb4p.cpp
+++ b/src/hash/comb4p/comb4p.cpp
@@ -35,7 +35,6 @@ void comb4p_round(MemoryRegion<byte>& out,
}
Comb4P::Comb4P(HashFunction* h1, HashFunction* h2) :
- HashFunction(h1->output_length() + h2->output_length()),
hash1(h1), hash2(h2)
{
if(hash1->name() == hash2->name())
diff --git a/src/hash/comb4p/comb4p.h b/src/hash/comb4p/comb4p.h
index 67547f979..73e06c379 100644
--- a/src/hash/comb4p/comb4p.h
+++ b/src/hash/comb4p/comb4p.h
@@ -29,6 +29,11 @@ class BOTAN_DLL Comb4P : public HashFunction
size_t hash_block_size() const;
+ size_t output_length() const
+ {
+ return hash1->output_length() + hash2->output_length();
+ }
+
HashFunction* clone() const
{
return new Comb4P(hash1->clone(), hash2->clone());
diff --git a/src/hash/gost_3411/gost_3411.cpp b/src/hash/gost_3411/gost_3411.cpp
index fd47ba2c7..075f26889 100644
--- a/src/hash/gost_3411/gost_3411.cpp
+++ b/src/hash/gost_3411/gost_3411.cpp
@@ -16,7 +16,6 @@ namespace Botan {
* GOST 34.11 Constructor
*/
GOST_34_11::GOST_34_11() :
- HashFunction(32),
cipher(GOST_28147_89_Params("R3411_CryptoPro")),
buffer(32),
sum(32),
diff --git a/src/hash/gost_3411/gost_3411.h b/src/hash/gost_3411/gost_3411.h
index 64ea0f40c..fbbcb7a89 100644
--- a/src/hash/gost_3411/gost_3411.h
+++ b/src/hash/gost_3411/gost_3411.h
@@ -19,11 +19,12 @@ namespace Botan {
class BOTAN_DLL GOST_34_11 : public HashFunction
{
public:
- void clear();
std::string name() const { return "GOST-R-34.11-94" ; }
+ size_t output_length() const { return 32; }
+ size_t hash_block_size() const { return 32; }
HashFunction* clone() const { return new GOST_34_11; }
- size_t hash_block_size() const { return 32; }
+ void clear();
GOST_34_11();
private:
diff --git a/src/hash/has160/has160.h b/src/hash/has160/has160.h
index 83ed5ab56..d32361601 100644
--- a/src/hash/has160/has160.h
+++ b/src/hash/has160/has160.h
@@ -19,11 +19,13 @@ namespace Botan {
class BOTAN_DLL HAS_160 : public MDx_HashFunction
{
public:
- void clear();
std::string name() const { return "HAS-160"; }
+ size_t output_length() const { return 20; }
HashFunction* clone() const { return new HAS_160; }
- HAS_160() : MDx_HashFunction(20, 64, false, true), X(20), digest(5)
+ void clear();
+
+ HAS_160() : MDx_HashFunction(64, false, true), X(20), digest(5)
{ clear(); }
private:
void compress_n(const byte[], size_t blocks);
diff --git a/src/hash/hash.h b/src/hash/hash.h
index 881e23817..af411fb87 100644
--- a/src/hash/hash.h
+++ b/src/hash/hash.h
@@ -14,20 +14,12 @@
namespace Botan {
/**
-* This class represents hash function (message digest) objects.
+* This class represents hash function (message digest) objects
*/
class BOTAN_DLL HashFunction : public BufferedComputation
{
public:
/**
- * @param hash_len the output length
- * @param block_len the internal block size (if applicable)
- */
- HashFunction(size_t hash_len) : BufferedComputation(hash_len) {}
-
- virtual ~HashFunction() {}
-
- /**
* Get a new object representing the same algorithm as *this
*/
virtual HashFunction* clone() const = 0;
diff --git a/src/hash/md2/md2.h b/src/hash/md2/md2.h
index 84f213811..84e0323f7 100644
--- a/src/hash/md2/md2.h
+++ b/src/hash/md2/md2.h
@@ -18,13 +18,14 @@ namespace Botan {
class BOTAN_DLL MD2 : public HashFunction
{
public:
- void clear();
std::string name() const { return "MD2"; }
+ size_t output_length() const { return 16; }
+ size_t hash_block_size() const { return 16; }
HashFunction* clone() const { return new MD2; }
- size_t hash_block_size() const { return 16; }
+ void clear();
- MD2() : HashFunction(16), X(48), checksum(16), buffer(16)
+ MD2() : X(48), checksum(16), buffer(16)
{ clear(); }
private:
void add_data(const byte[], size_t);
diff --git a/src/hash/md4/md4.h b/src/hash/md4/md4.h
index 07467fdfc..182954834 100644
--- a/src/hash/md4/md4.h
+++ b/src/hash/md4/md4.h
@@ -18,11 +18,13 @@ namespace Botan {
class BOTAN_DLL MD4 : public MDx_HashFunction
{
public:
- void clear();
std::string name() const { return "MD4"; }
+ size_t output_length() const { return 16; }
HashFunction* clone() const { return new MD4; }
- MD4() : MDx_HashFunction(16, 64, false, true), M(16), digest(4)
+ void clear();
+
+ MD4() : MDx_HashFunction(64, false, true), M(16), digest(4)
{ clear(); }
protected:
void compress_n(const byte input[], size_t blocks);
diff --git a/src/hash/md5/md5.h b/src/hash/md5/md5.h
index f79a3ec65..b54beeec4 100644
--- a/src/hash/md5/md5.h
+++ b/src/hash/md5/md5.h
@@ -18,11 +18,13 @@ namespace Botan {
class BOTAN_DLL MD5 : public MDx_HashFunction
{
public:
- void clear();
std::string name() const { return "MD5"; }
+ size_t output_length() const { return 16; }
HashFunction* clone() const { return new MD5; }
- MD5() : MDx_HashFunction(16, 64, false, true), M(16), digest(4)
+ void clear();
+
+ MD5() : MDx_HashFunction(64, false, true), M(16), digest(4)
{ clear(); }
protected:
void compress_n(const byte[], size_t blocks);
diff --git a/src/hash/mdx_hash/mdx_hash.cpp b/src/hash/mdx_hash/mdx_hash.cpp
index f82c971f8..7bfcf6592 100644
--- a/src/hash/mdx_hash/mdx_hash.cpp
+++ b/src/hash/mdx_hash/mdx_hash.cpp
@@ -14,19 +14,15 @@ namespace Botan {
/*
* MDx_HashFunction Constructor
*/
-MDx_HashFunction::MDx_HashFunction(size_t hash_len,
- size_t block_len,
+MDx_HashFunction::MDx_HashFunction(size_t block_len,
bool byte_end,
bool bit_end,
size_t cnt_size) :
- HashFunction(hash_len),
buffer(block_len),
BIG_BYTE_ENDIAN(byte_end),
BIG_BIT_ENDIAN(bit_end),
COUNT_SIZE(cnt_size)
{
- if(COUNT_SIZE >= output_length() || COUNT_SIZE >= hash_block_size())
- throw Invalid_Argument("MDx_HashFunction: COUNT_SIZE is too big");
count = position = 0;
}
@@ -98,6 +94,8 @@ void MDx_HashFunction::write_count(byte out[])
{
if(COUNT_SIZE < 8)
throw Invalid_State("MDx_HashFunction::write_count: COUNT_SIZE < 8");
+ if(COUNT_SIZE >= output_length() || COUNT_SIZE >= hash_block_size())
+ throw Invalid_Argument("MDx_HashFunction: COUNT_SIZE is too big");
const u64bit bit_count = count * 8;
diff --git a/src/hash/mdx_hash/mdx_hash.h b/src/hash/mdx_hash/mdx_hash.h
index d1260180e..0dfc16b31 100644
--- a/src/hash/mdx_hash/mdx_hash.h
+++ b/src/hash/mdx_hash/mdx_hash.h
@@ -25,8 +25,7 @@ class BOTAN_DLL MDx_HashFunction : public HashFunction
* @param big_bit_endian specifies if the hash uses big-endian bits
* @param counter_size specifies the size of the counter var in bytes
*/
- MDx_HashFunction(size_t hash_length,
- size_t block_length,
+ MDx_HashFunction(size_t block_length,
bool big_byte_endian,
bool big_bit_endian,
size_t counter_size = 8);
diff --git a/src/hash/par_hash/par_hash.cpp b/src/hash/par_hash/par_hash.cpp
index aef5f8247..328be6a11 100644
--- a/src/hash/par_hash/par_hash.cpp
+++ b/src/hash/par_hash/par_hash.cpp
@@ -9,23 +9,6 @@
namespace Botan {
-namespace {
-
-/*
-* Return the sum of the hash sizes
-*/
-size_t sum_of_hash_lengths(const std::vector<HashFunction*>& hashes)
- {
- size_t sum = 0;
-
- for(size_t i = 0; i != hashes.size(); ++i)
- sum += hashes[i]->output_length();
-
- return sum;
- }
-
-}
-
/*
* Update the hash
*/
@@ -49,6 +32,17 @@ void Parallel::final_result(byte hash[])
}
/*
+* Return output size
+*/
+size_t Parallel::output_length() const
+ {
+ size_t sum = 0;
+ for(size_t i = 0; i != hashes.size(); ++i)
+ sum += hashes[i]->output_length();
+ return sum;
+ }
+
+/*
* Return the name of this type
*/
std::string Parallel::name() const
@@ -87,7 +81,7 @@ void Parallel::clear()
* Parallel Constructor
*/
Parallel::Parallel(const std::vector<HashFunction*>& hash_in) :
- HashFunction(sum_of_hash_lengths(hash_in)), hashes(hash_in)
+ hashes(hash_in)
{
}
diff --git a/src/hash/par_hash/par_hash.h b/src/hash/par_hash/par_hash.h
index 35154dde4..4f5395c23 100644
--- a/src/hash/par_hash/par_hash.h
+++ b/src/hash/par_hash/par_hash.h
@@ -23,6 +23,8 @@ class BOTAN_DLL Parallel : public HashFunction
std::string name() const;
HashFunction* clone() const;
+ size_t output_length() const;
+
/**
* @param hashes a set of hashes to compute in parallel
*/
diff --git a/src/hash/rmd128/rmd128.h b/src/hash/rmd128/rmd128.h
index faead3245..d64cf3c84 100644
--- a/src/hash/rmd128/rmd128.h
+++ b/src/hash/rmd128/rmd128.h
@@ -18,11 +18,13 @@ namespace Botan {
class BOTAN_DLL RIPEMD_128 : public MDx_HashFunction
{
public:
- void clear();
std::string name() const { return "RIPEMD-128"; }
+ size_t output_length() const { return 16; }
HashFunction* clone() const { return new RIPEMD_128; }
- RIPEMD_128() : MDx_HashFunction(16, 64, false, true), M(16), digest(4)
+ void clear();
+
+ RIPEMD_128() : MDx_HashFunction(64, false, true), M(16), digest(4)
{ clear(); }
private:
void compress_n(const byte[], size_t blocks);
diff --git a/src/hash/rmd160/rmd160.h b/src/hash/rmd160/rmd160.h
index 69c6b4a40..5df4ad490 100644
--- a/src/hash/rmd160/rmd160.h
+++ b/src/hash/rmd160/rmd160.h
@@ -18,11 +18,13 @@ namespace Botan {
class BOTAN_DLL RIPEMD_160 : public MDx_HashFunction
{
public:
- void clear();
std::string name() const { return "RIPEMD-160"; }
+ size_t output_length() const { return 20; }
HashFunction* clone() const { return new RIPEMD_160; }
- RIPEMD_160() : MDx_HashFunction(20, 64, false, true), M(16), digest(5)
+ void clear();
+
+ RIPEMD_160() : MDx_HashFunction(64, false, true), M(16), digest(5)
{ clear(); }
private:
void compress_n(const byte[], size_t blocks);
diff --git a/src/hash/sha1/sha160.cpp b/src/hash/sha1/sha160.cpp
index aa6a066e8..7a42ca867 100644
--- a/src/hash/sha1/sha160.cpp
+++ b/src/hash/sha1/sha160.cpp
@@ -152,22 +152,4 @@ void SHA_160::clear()
digest[4] = 0xC3D2E1F0;
}
-/*
-* SHA_160 Constructor
-*/
-SHA_160::SHA_160() :
- MDx_HashFunction(20, 64, true, true), digest(5), W(80)
- {
- clear();
- }
-
-/*
-* SHA_160 Constructor
-*/
-SHA_160::SHA_160(size_t 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 d420f8f94..3038039cf 100644
--- a/src/hash/sha1/sha160.h
+++ b/src/hash/sha1/sha160.h
@@ -18,11 +18,16 @@ namespace Botan {
class BOTAN_DLL SHA_160 : public MDx_HashFunction
{
public:
- void clear();
std::string name() const { return "SHA-160"; }
+ size_t output_length() const { return 20; }
HashFunction* clone() const { return new SHA_160; }
- SHA_160();
+ void clear();
+
+ SHA_160() : MDx_HashFunction(64, true, true), digest(5), W(80)
+ {
+ clear();
+ }
protected:
/**
* Set a custom size for the W array. Normally 80, but some
@@ -30,7 +35,11 @@ class BOTAN_DLL SHA_160 : public MDx_HashFunction
* constraints
* @param W_size how big to make W
*/
- SHA_160(size_t W_size);
+ SHA_160(size_t W_size) :
+ MDx_HashFunction(64, true, true), digest(5), W(W_size)
+ {
+ clear();
+ }
void compress_n(const byte[], size_t blocks);
void copy_out(byte[]);
diff --git a/src/hash/sha2_32/sha2_32.h b/src/hash/sha2_32/sha2_32.h
index 3b95812b8..ffda11772 100644
--- a/src/hash/sha2_32/sha2_32.h
+++ b/src/hash/sha2_32/sha2_32.h
@@ -19,11 +19,13 @@ namespace Botan {
class BOTAN_DLL SHA_224 : public MDx_HashFunction
{
public:
- void clear();
std::string name() const { return "SHA-224"; }
+ size_t output_length() const { return 28; }
HashFunction* clone() const { return new SHA_224; }
- SHA_224() : MDx_HashFunction(28, 64, true, true), W(64), digest(8)
+ void clear();
+
+ SHA_224() : MDx_HashFunction(64, true, true), W(64), digest(8)
{ clear(); }
private:
void compress_n(const byte[], size_t blocks);
@@ -38,11 +40,13 @@ class BOTAN_DLL SHA_224 : public MDx_HashFunction
class BOTAN_DLL SHA_256 : public MDx_HashFunction
{
public:
- void clear();
std::string name() const { return "SHA-256"; }
+ size_t output_length() const { return 32; }
HashFunction* clone() const { return new SHA_256; }
- SHA_256() : MDx_HashFunction(32, 64, true, true), W(64), digest(8)
+ void clear();
+
+ SHA_256() : MDx_HashFunction(64, true, true), W(64), digest(8)
{ clear(); }
private:
void compress_n(const byte[], size_t blocks);
diff --git a/src/hash/sha2_64/sha2_64.h b/src/hash/sha2_64/sha2_64.h
index 59e2c4c83..dcfb7224c 100644
--- a/src/hash/sha2_64/sha2_64.h
+++ b/src/hash/sha2_64/sha2_64.h
@@ -18,11 +18,13 @@ namespace Botan {
class BOTAN_DLL SHA_384 : public MDx_HashFunction
{
public:
- void clear();
std::string name() const { return "SHA-384"; }
+ size_t output_length() const { return 48; }
HashFunction* clone() const { return new SHA_384; }
- SHA_384() : MDx_HashFunction(48, 128, true, true, 16), W(80), digest(8)
+ void clear();
+
+ SHA_384() : MDx_HashFunction(128, true, true, 16), W(80), digest(8)
{ clear(); }
private:
void compress_n(const byte[], size_t blocks);
@@ -37,10 +39,13 @@ class BOTAN_DLL SHA_384 : public MDx_HashFunction
class BOTAN_DLL SHA_512 : public MDx_HashFunction
{
public:
- void clear();
std::string name() const { return "SHA-512"; }
+ size_t output_length() const { return 64; }
HashFunction* clone() const { return new SHA_512; }
- SHA_512() : MDx_HashFunction(64, 128, true, true, 16), W(80), digest(8)
+
+ void clear();
+
+ SHA_512() : MDx_HashFunction(128, true, true, 16), W(80), digest(8)
{ clear(); }
private:
void compress_n(const byte[], size_t blocks);
diff --git a/src/hash/skein/skein_512.cpp b/src/hash/skein/skein_512.cpp
index 37aed4357..1434f0b3e 100644
--- a/src/hash/skein/skein_512.cpp
+++ b/src/hash/skein/skein_512.cpp
@@ -168,7 +168,6 @@ void initial_block(MemoryRegion<u64bit>& H,
Skein_512::Skein_512(size_t arg_output_bits,
const std::string& arg_personalization) :
- HashFunction(arg_output_bits / 8),
personalization(arg_personalization),
output_bits(arg_output_bits),
H(9), T(3), buffer(64), buf_pos(0)
diff --git a/src/hash/skein/skein_512.h b/src/hash/skein/skein_512.h
index 54cdd002c..8605e5991 100644
--- a/src/hash/skein/skein_512.h
+++ b/src/hash/skein/skein_512.h
@@ -29,6 +29,7 @@ class BOTAN_DLL Skein_512 : public HashFunction
const std::string& personalization = "");
size_t hash_block_size() const { return 64; }
+ size_t output_length() const { return output_bits / 8; }
HashFunction* clone() const;
std::string name() const;
diff --git a/src/hash/tiger/tiger.cpp b/src/hash/tiger/tiger.cpp
index 7f95267aa..6f40f84c8 100644
--- a/src/hash/tiger/tiger.cpp
+++ b/src/hash/tiger/tiger.cpp
@@ -55,7 +55,7 @@ void Tiger::compress_n(const byte input[], size_t blocks)
pass(C, A, B, X, 7); mix(X);
pass(B, C, A, X, 9);
- for(size_t j = 3; j != PASS; ++j)
+ for(size_t j = 3; j != passes; ++j)
{
mix(X);
pass(A, B, C, X, 9);
@@ -160,24 +160,26 @@ void Tiger::clear()
*/
std::string Tiger::name() const
{
- return "Tiger(" + to_string(output_length()) + "," + to_string(PASS) + ")";
+ return "Tiger(" + to_string(output_length()) + "," + to_string(passes) + ")";
}
/*
* Tiger Constructor
*/
-Tiger::Tiger(size_t hashlen, size_t pass) :
- MDx_HashFunction(hashlen, 64, false, false),
+Tiger::Tiger(size_t hash_len, size_t passes) :
+ MDx_HashFunction(64, false, false),
X(8),
digest(3),
- PASS(pass)
+ hash_len(hash_len),
+ passes(passes)
{
if(output_length() != 16 && output_length() != 20 && output_length() != 24)
throw Invalid_Argument("Tiger: Illegal hash output size: " +
to_string(output_length()));
- if(PASS < 3)
+
+ if(passes < 3)
throw Invalid_Argument("Tiger: Invalid number of passes: "
- + to_string(PASS));
+ + to_string(passes));
clear();
}
diff --git a/src/hash/tiger/tiger.h b/src/hash/tiger/tiger.h
index 7d753c237..09c9947fb 100644
--- a/src/hash/tiger/tiger.h
+++ b/src/hash/tiger/tiger.h
@@ -18,14 +18,16 @@ namespace Botan {
class BOTAN_DLL Tiger : public MDx_HashFunction
{
public:
- void clear();
std::string name() const;
+ size_t output_length() const { return hash_len; }
HashFunction* clone() const
{
- return new Tiger(output_length(), PASS);
+ return new Tiger(output_length(), passes);
}
+ void clear();
+
/**
* @param out_size specifies the output length; can be 16, 20, or 24
* @param passes to make in the algorithm
@@ -45,7 +47,7 @@ class BOTAN_DLL Tiger : public MDx_HashFunction
static const u64bit SBOX4[256];
SecureVector<u64bit> X, digest;
- const size_t PASS;
+ const size_t hash_len, passes;
};
}
diff --git a/src/hash/whirlpool/whrlpool.h b/src/hash/whirlpool/whrlpool.h
index 30bf91a34..ab7a78bc8 100644
--- a/src/hash/whirlpool/whrlpool.h
+++ b/src/hash/whirlpool/whrlpool.h
@@ -18,11 +18,13 @@ namespace Botan {
class BOTAN_DLL Whirlpool : public MDx_HashFunction
{
public:
- void clear();
std::string name() const { return "Whirlpool"; }
+ size_t output_length() const { return 64; }
HashFunction* clone() const { return new Whirlpool; }
- Whirlpool() : MDx_HashFunction(64, 64, true, true, 32), M(8), digest(8)
+ void clear();
+
+ Whirlpool() : MDx_HashFunction(64, true, true, 32), M(8), digest(8)
{ clear(); }
private:
void compress_n(const byte[], size_t blocks);
diff --git a/src/mac/cbc_mac/cbc_mac.cpp b/src/mac/cbc_mac/cbc_mac.cpp
index a3899c87e..118570e72 100644
--- a/src/mac/cbc_mac/cbc_mac.cpp
+++ b/src/mac/cbc_mac/cbc_mac.cpp
@@ -89,7 +89,6 @@ MessageAuthenticationCode* CBC_MAC::clone() const
* CBC-MAC Constructor
*/
CBC_MAC::CBC_MAC(BlockCipher* e_in) :
- MessageAuthenticationCode(e_in->block_size()),
e(e_in), state(e->block_size())
{
position = 0;
diff --git a/src/mac/cbc_mac/cbc_mac.h b/src/mac/cbc_mac/cbc_mac.h
index ff2a8f3fa..5cc8adc67 100644
--- a/src/mac/cbc_mac/cbc_mac.h
+++ b/src/mac/cbc_mac/cbc_mac.h
@@ -19,9 +19,10 @@ namespace Botan {
class BOTAN_DLL CBC_MAC : public MessageAuthenticationCode
{
public:
- void clear();
std::string name() const;
MessageAuthenticationCode* clone() const;
+ size_t output_length() const { return e->block_size(); }
+ void clear();
Key_Length_Specification key_spec() const
{
diff --git a/src/mac/cmac/cmac.cpp b/src/mac/cmac/cmac.cpp
index 37f83ffe4..7db597fff 100644
--- a/src/mac/cmac/cmac.cpp
+++ b/src/mac/cmac/cmac.cpp
@@ -130,9 +130,7 @@ MessageAuthenticationCode* CMAC::clone() const
/*
* CMAC Constructor
*/
-CMAC::CMAC(BlockCipher* e_in) :
- MessageAuthenticationCode(e_in->block_size()),
- e(e_in)
+CMAC::CMAC(BlockCipher* e_in) : e(e_in)
{
if(e->block_size() == 16)
polynomial = 0x87;
diff --git a/src/mac/cmac/cmac.h b/src/mac/cmac/cmac.h
index aa9bfb38e..98634bdb7 100644
--- a/src/mac/cmac/cmac.h
+++ b/src/mac/cmac/cmac.h
@@ -19,10 +19,12 @@ namespace Botan {
class BOTAN_DLL CMAC : public MessageAuthenticationCode
{
public:
- void clear();
std::string name() const;
+ size_t output_length() const { return e->block_size(); }
MessageAuthenticationCode* clone() const;
+ void clear();
+
Key_Length_Specification key_spec() const
{
return e->key_spec();
diff --git a/src/mac/hmac/hmac.cpp b/src/mac/hmac/hmac.cpp
index 284bc87ec..fc35e26ea 100644
--- a/src/mac/hmac/hmac.cpp
+++ b/src/mac/hmac/hmac.cpp
@@ -84,9 +84,7 @@ MessageAuthenticationCode* HMAC::clone() const
/*
* HMAC Constructor
*/
-HMAC::HMAC(HashFunction* hash_in) :
- MessageAuthenticationCode(hash_in->output_length()),
- hash(hash_in)
+HMAC::HMAC(HashFunction* hash_in) : hash(hash_in)
{
if(hash->hash_block_size() == 0)
throw Invalid_Argument("HMAC cannot be used with " + hash->name());
diff --git a/src/mac/hmac/hmac.h b/src/mac/hmac/hmac.h
index 505d0dd6b..b76a058f4 100644
--- a/src/mac/hmac/hmac.h
+++ b/src/mac/hmac/hmac.h
@@ -23,6 +23,8 @@ class BOTAN_DLL HMAC : public MessageAuthenticationCode
std::string name() const;
MessageAuthenticationCode* clone() const;
+ size_t output_length() const { return hash->output_length(); }
+
Key_Length_Specification key_spec() const
{
return Key_Length_Specification(0, 2*hash->hash_block_size());
diff --git a/src/mac/mac.h b/src/mac/mac.h
index 1cb87d21e..f46cd7e35 100644
--- a/src/mac/mac.h
+++ b/src/mac/mac.h
@@ -39,15 +39,6 @@ class BOTAN_DLL MessageAuthenticationCode : public BufferedComputation,
* @return name of this algorithm
*/
virtual std::string name() const = 0;
-
- /**
- * @param mac_len the output length of this MAC
- * @param key_min the minimum key size
- * @param key_max the maximum key size
- * @param key_mod the modulo restriction on the key size
- */
- MessageAuthenticationCode(size_t mac_len) :
- BufferedComputation(mac_len) {}
};
}
diff --git a/src/mac/ssl3mac/ssl3_mac.cpp b/src/mac/ssl3mac/ssl3_mac.cpp
index daaca1b57..a07622eb3 100644
--- a/src/mac/ssl3mac/ssl3_mac.cpp
+++ b/src/mac/ssl3mac/ssl3_mac.cpp
@@ -72,9 +72,7 @@ MessageAuthenticationCode* SSL3_MAC::clone() const
/*
* SSL3-MAC Constructor
*/
-SSL3_MAC::SSL3_MAC(HashFunction* hash_in) :
- MessageAuthenticationCode(hash_in->output_length()),
- hash(hash_in)
+SSL3_MAC::SSL3_MAC(HashFunction* hash_in) : hash(hash_in)
{
if(hash->hash_block_size() == 0)
throw Invalid_Argument("SSL3-MAC cannot be used with " + hash->name());
diff --git a/src/mac/ssl3mac/ssl3_mac.h b/src/mac/ssl3mac/ssl3_mac.h
index 455cfa266..a85a78263 100644
--- a/src/mac/ssl3mac/ssl3_mac.h
+++ b/src/mac/ssl3mac/ssl3_mac.h
@@ -19,10 +19,12 @@ namespace Botan {
class BOTAN_DLL SSL3_MAC : public MessageAuthenticationCode
{
public:
- void clear();
std::string name() const;
+ size_t output_length() const { return hash->output_length(); }
MessageAuthenticationCode* clone() const;
+ void clear();
+
Key_Length_Specification key_spec() const
{
return Key_Length_Specification(hash->output_length());
diff --git a/src/mac/x919_mac/x919_mac.cpp b/src/mac/x919_mac/x919_mac.cpp
index bd53a6c7d..fcbe77537 100644
--- a/src/mac/x919_mac/x919_mac.cpp
+++ b/src/mac/x919_mac/x919_mac.cpp
@@ -85,7 +85,6 @@ MessageAuthenticationCode* ANSI_X919_MAC::clone() const
* ANSI X9.19 MAC Constructor
*/
ANSI_X919_MAC::ANSI_X919_MAC(BlockCipher* e_in) :
- MessageAuthenticationCode(e_in->block_size()),
e(e_in), d(e->clone()), state(e->block_size()), position(0)
{
if(e->name() != "DES")
diff --git a/src/mac/x919_mac/x919_mac.h b/src/mac/x919_mac/x919_mac.h
index 600955919..58a005e0b 100644
--- a/src/mac/x919_mac/x919_mac.h
+++ b/src/mac/x919_mac/x919_mac.h
@@ -21,6 +21,7 @@ class BOTAN_DLL ANSI_X919_MAC : public MessageAuthenticationCode
public:
void clear();
std::string name() const;
+ size_t output_length() const { return e->block_size(); }
MessageAuthenticationCode* clone() const;
Key_Length_Specification key_spec() const
diff --git a/src/utils/buf_comp/buf_comp.h b/src/utils/buf_comp/buf_comp.h
index 0b0ef6e16..78955fe87 100644
--- a/src/utils/buf_comp/buf_comp.h
+++ b/src/utils/buf_comp/buf_comp.h
@@ -20,16 +20,12 @@ namespace Botan {
class BOTAN_DLL BufferedComputation
{
public:
- /**
- * The length of the output of this function in bytes.
- * @deprecated Use output_length()
- */
- const size_t OUTPUT_LENGTH;
+ virtual ~BufferedComputation() {}
/**
* @return length of the output of this function in bytes
*/
- size_t output_length() const { return OUTPUT_LENGTH; }
+ virtual size_t output_length() const = 0;
/**
* Add new input to process.
@@ -133,13 +129,6 @@ class BOTAN_DLL BufferedComputation
update(in);
return final();
}
-
- /**
- * @param out_len the output length of this computation
- */
- BufferedComputation(size_t out_len) : OUTPUT_LENGTH(out_len) {}
-
- virtual ~BufferedComputation() {}
private:
BufferedComputation& operator=(const BufferedComputation&);