diff options
Diffstat (limited to 'src/mac')
-rw-r--r-- | src/mac/cbc_mac/cbc_mac.cpp | 4 | ||||
-rw-r--r-- | src/mac/cbc_mac/cbc_mac.h | 8 | ||||
-rw-r--r-- | src/mac/cmac/cmac.cpp | 7 | ||||
-rw-r--r-- | src/mac/cmac/cmac.h | 9 | ||||
-rw-r--r-- | src/mac/hmac/hmac.cpp | 5 | ||||
-rw-r--r-- | src/mac/hmac/hmac.h | 7 | ||||
-rw-r--r-- | src/mac/info.txt | 3 | ||||
-rw-r--r-- | src/mac/mac.h | 22 | ||||
-rw-r--r-- | src/mac/ssl3mac/ssl3_mac.cpp | 8 | ||||
-rw-r--r-- | src/mac/ssl3mac/ssl3_mac.h | 9 | ||||
-rw-r--r-- | src/mac/x919_mac/x919_mac.cpp | 4 | ||||
-rw-r--r-- | src/mac/x919_mac/x919_mac.h | 6 |
12 files changed, 43 insertions, 49 deletions
diff --git a/src/mac/cbc_mac/cbc_mac.cpp b/src/mac/cbc_mac/cbc_mac.cpp index 48cc8ab3e..118570e72 100644 --- a/src/mac/cbc_mac/cbc_mac.cpp +++ b/src/mac/cbc_mac/cbc_mac.cpp @@ -89,10 +89,6 @@ MessageAuthenticationCode* CBC_MAC::clone() const * CBC-MAC Constructor */ CBC_MAC::CBC_MAC(BlockCipher* e_in) : - MessageAuthenticationCode(e_in->block_size(), - e_in->MINIMUM_KEYLENGTH, - e_in->MAXIMUM_KEYLENGTH, - e_in->KEYLENGTH_MULTIPLE), 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 6b30ef764..5cc8adc67 100644 --- a/src/mac/cbc_mac/cbc_mac.h +++ b/src/mac/cbc_mac/cbc_mac.h @@ -19,9 +19,15 @@ 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 + { + return e->key_spec(); + } /** * @param cipher the underlying block cipher to use diff --git a/src/mac/cmac/cmac.cpp b/src/mac/cmac/cmac.cpp index 2147f9a45..7db597fff 100644 --- a/src/mac/cmac/cmac.cpp +++ b/src/mac/cmac/cmac.cpp @@ -130,12 +130,7 @@ MessageAuthenticationCode* CMAC::clone() const /* * CMAC Constructor */ -CMAC::CMAC(BlockCipher* e_in) : - MessageAuthenticationCode(e_in->block_size(), - e_in->MINIMUM_KEYLENGTH, - e_in->MAXIMUM_KEYLENGTH, - e_in->KEYLENGTH_MULTIPLE), - 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 ac929eaf3..98634bdb7 100644 --- a/src/mac/cmac/cmac.h +++ b/src/mac/cmac/cmac.h @@ -19,10 +19,17 @@ 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(); + } + /** * CMAC's polynomial doubling operation * @param in the input diff --git a/src/mac/hmac/hmac.cpp b/src/mac/hmac/hmac.cpp index 06923138a..fc35e26ea 100644 --- a/src/mac/hmac/hmac.cpp +++ b/src/mac/hmac/hmac.cpp @@ -84,10 +84,7 @@ MessageAuthenticationCode* HMAC::clone() const /* * HMAC Constructor */ -HMAC::HMAC(HashFunction* hash_in) : - MessageAuthenticationCode(hash_in->output_length(), - 0, 2*hash_in->hash_block_size()), - 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 33af62f6a..b76a058f4 100644 --- a/src/mac/hmac/hmac.h +++ b/src/mac/hmac/hmac.h @@ -23,6 +23,13 @@ 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()); + } + /** * @param hash the hash to use for HMACing */ diff --git a/src/mac/info.txt b/src/mac/info.txt index 6a74d8445..d991577f7 100644 --- a/src/mac/info.txt +++ b/src/mac/info.txt @@ -1,4 +1,3 @@ <requires> -buf_comp -sym_algo +algo_base </requires> diff --git a/src/mac/mac.h b/src/mac/mac.h index b788e06c8..d42092908 100644 --- a/src/mac/mac.h +++ b/src/mac/mac.h @@ -17,7 +17,7 @@ namespace Botan { /** * This class represents Message Authentication Code (MAC) objects. */ -class BOTAN_DLL MessageAuthenticationCode : public BufferedComputation, +class BOTAN_DLL MessageAuthenticationCode : public Buffered_Computation, public SymmetricAlgorithm { public: @@ -39,26 +39,6 @@ class BOTAN_DLL MessageAuthenticationCode : public BufferedComputation, * @return name of this algorithm */ virtual std::string name() const = 0; - - /** - * Reset the internal state of this object. - */ - virtual void clear() = 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, - size_t key_min, - size_t key_max = 0, - size_t key_mod = 1) : - BufferedComputation(mac_len), - SymmetricAlgorithm(key_min, key_max, key_mod) {} - - virtual ~MessageAuthenticationCode() {} }; } diff --git a/src/mac/ssl3mac/ssl3_mac.cpp b/src/mac/ssl3mac/ssl3_mac.cpp index fcbccc06e..a07622eb3 100644 --- a/src/mac/ssl3mac/ssl3_mac.cpp +++ b/src/mac/ssl3mac/ssl3_mac.cpp @@ -72,15 +72,13 @@ MessageAuthenticationCode* SSL3_MAC::clone() const /* * SSL3-MAC Constructor */ -SSL3_MAC::SSL3_MAC(HashFunction* hash_in) : - MessageAuthenticationCode(hash_in->output_length(), - 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()); - size_t INNER_HASH_LENGTH = + // Quirk to deal with specification bug + const size_t INNER_HASH_LENGTH = (hash->name() == "SHA-160") ? 60 : hash->hash_block_size(); i_key.resize(INNER_HASH_LENGTH); diff --git a/src/mac/ssl3mac/ssl3_mac.h b/src/mac/ssl3mac/ssl3_mac.h index 50042f3d0..a85a78263 100644 --- a/src/mac/ssl3mac/ssl3_mac.h +++ b/src/mac/ssl3mac/ssl3_mac.h @@ -19,10 +19,17 @@ 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()); + } + /** * @param hash the underlying hash to use */ diff --git a/src/mac/x919_mac/x919_mac.cpp b/src/mac/x919_mac/x919_mac.cpp index c46ab82cb..fcbe77537 100644 --- a/src/mac/x919_mac/x919_mac.cpp +++ b/src/mac/x919_mac/x919_mac.cpp @@ -85,10 +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_in->MINIMUM_KEYLENGTH, - 2*e_in->MAXIMUM_KEYLENGTH, - 2*e_in->KEYLENGTH_MULTIPLE), 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 e9fe56c8d..58a005e0b 100644 --- a/src/mac/x919_mac/x919_mac.h +++ b/src/mac/x919_mac/x919_mac.h @@ -21,8 +21,14 @@ 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 + { + return Key_Length_Specification(8, 16, 8); + } + /** * @param cipher the underlying block cipher to use */ |