aboutsummaryrefslogtreecommitdiffstats
path: root/src/mac
diff options
context:
space:
mode:
authorlloyd <[email protected]>2008-09-30 06:20:10 +0000
committerlloyd <[email protected]>2008-09-30 06:20:10 +0000
commit33bb3dca54ecef2599b756d27b66781e14d06ae3 (patch)
tree4c7b07a1b1b3f40e82202570c7aec298a672339c /src/mac
parentc9749d5d4693b5d93171f6085b29fc72c1e12ba0 (diff)
Remove lookup from Randpool, HMAC, CMAC, CBC-MAC, TLS-PRF, and PBKDF2
Diffstat (limited to 'src/mac')
-rw-r--r--src/mac/cbc_mac/cbc_mac.cpp16
-rw-r--r--src/mac/cbc_mac/cbc_mac.h3
-rw-r--r--src/mac/cmac/cmac.cpp8
-rw-r--r--src/mac/cmac/cmac.h2
-rw-r--r--src/mac/hmac/hmac.cpp12
-rw-r--r--src/mac/hmac/hmac.h3
6 files changed, 26 insertions, 18 deletions
diff --git a/src/mac/cbc_mac/cbc_mac.cpp b/src/mac/cbc_mac/cbc_mac.cpp
index d5275b0ed..de9a3c17d 100644
--- a/src/mac/cbc_mac/cbc_mac.cpp
+++ b/src/mac/cbc_mac/cbc_mac.cpp
@@ -4,7 +4,6 @@
*************************************************/
#include <botan/cbc_mac.h>
-#include <botan/lookup.h>
#include <botan/xor_buf.h>
#include <algorithm>
@@ -81,20 +80,19 @@ std::string CBC_MAC::name() const
*************************************************/
MessageAuthenticationCode* CBC_MAC::clone() const
{
- return new CBC_MAC(e->name());
+ return new CBC_MAC(e->clone());
}
/*************************************************
* CBC-MAC Constructor *
*************************************************/
-CBC_MAC::CBC_MAC(const std::string& cipher) :
- MessageAuthenticationCode(block_size_of(cipher),
- min_keylength_of(cipher),
- max_keylength_of(cipher),
- keylength_multiple_of(cipher)),
- state(block_size_of(cipher))
+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)
{
- e = get_block_cipher(cipher);
position = 0;
}
diff --git a/src/mac/cbc_mac/cbc_mac.h b/src/mac/cbc_mac/cbc_mac.h
index a5646d07a..9559751c8 100644
--- a/src/mac/cbc_mac/cbc_mac.h
+++ b/src/mac/cbc_mac/cbc_mac.h
@@ -19,7 +19,8 @@ class BOTAN_DLL CBC_MAC : public MessageAuthenticationCode
void clear() throw();
std::string name() const;
MessageAuthenticationCode* clone() const;
- CBC_MAC(const std::string&);
+
+ CBC_MAC(BlockCipher* e);
~CBC_MAC();
private:
void add_data(const byte[], u32bit);
diff --git a/src/mac/cmac/cmac.cpp b/src/mac/cmac/cmac.cpp
index d3110f9f2..937c15c63 100644
--- a/src/mac/cmac/cmac.cpp
+++ b/src/mac/cmac/cmac.cpp
@@ -149,4 +149,12 @@ CMAC::CMAC(BlockCipher* e_in) :
position = 0;
}
+/*************************************************
+* CMAC Destructor *
+*************************************************/
+CMAC::~CMAC()
+ {
+ delete e;
+ }
+
}
diff --git a/src/mac/cmac/cmac.h b/src/mac/cmac/cmac.h
index 0fe5b75f8..b8af593e3 100644
--- a/src/mac/cmac/cmac.h
+++ b/src/mac/cmac/cmac.h
@@ -24,7 +24,7 @@ class BOTAN_DLL CMAC : public MessageAuthenticationCode
byte polynomial);
CMAC(BlockCipher* e);
- ~CMAC() { delete e; }
+ ~CMAC();
private:
void add_data(const byte[], u32bit);
void final_result(byte[]);
diff --git a/src/mac/hmac/hmac.cpp b/src/mac/hmac/hmac.cpp
index b8c76e8f6..6401b0000 100644
--- a/src/mac/hmac/hmac.cpp
+++ b/src/mac/hmac/hmac.cpp
@@ -5,7 +5,6 @@
*************************************************/
#include <botan/hmac.h>
-#include <botan/lookup.h>
#include <botan/xor_buf.h>
namespace Botan {
@@ -77,19 +76,20 @@ std::string HMAC::name() const
*************************************************/
MessageAuthenticationCode* HMAC::clone() const
{
- return new HMAC(hash->name());
+ return new HMAC(hash->clone());
}
/*************************************************
* HMAC Constructor *
*************************************************/
-HMAC::HMAC(const std::string& hash_name) :
- MessageAuthenticationCode(output_length_of(hash_name),
- 1, 2*block_size_of(hash_name)),
- hash(get_hash(hash_name))
+HMAC::HMAC(HashFunction* hash_in) :
+ MessageAuthenticationCode(hash_in->OUTPUT_LENGTH,
+ 1, 2*hash_in->HASH_BLOCK_SIZE),
+ hash(hash_in)
{
if(hash->HASH_BLOCK_SIZE == 0)
throw Invalid_Argument("HMAC cannot be used with " + hash->name());
+
i_key.create(hash->HASH_BLOCK_SIZE);
o_key.create(hash->HASH_BLOCK_SIZE);
}
diff --git a/src/mac/hmac/hmac.h b/src/mac/hmac/hmac.h
index 62529cf13..67ebc4190 100644
--- a/src/mac/hmac/hmac.h
+++ b/src/mac/hmac/hmac.h
@@ -19,7 +19,8 @@ class BOTAN_DLL HMAC : public MessageAuthenticationCode
void clear() throw();
std::string name() const;
MessageAuthenticationCode* clone() const;
- HMAC(const std::string&);
+
+ HMAC(HashFunction* hash);
~HMAC() { delete hash; }
private:
void add_data(const byte[], u32bit);