aboutsummaryrefslogtreecommitdiffstats
path: root/src/mac
diff options
context:
space:
mode:
authorlloyd <[email protected]>2008-09-30 05:46:54 +0000
committerlloyd <[email protected]>2008-09-30 05:46:54 +0000
commitc9749d5d4693b5d93171f6085b29fc72c1e12ba0 (patch)
treed4c8c958863dbcc18751abd5b084c89ce6a5296c /src/mac
parent75ef07ee5378341adf054bd729232167c73e9e47 (diff)
Remove lookup dependency on CMAC: takes a BlockCipher as constructor arg
Diffstat (limited to 'src/mac')
-rw-r--r--src/mac/cmac/cmac.cpp22
-rw-r--r--src/mac/cmac/cmac.h2
2 files changed, 12 insertions, 12 deletions
diff --git a/src/mac/cmac/cmac.cpp b/src/mac/cmac/cmac.cpp
index 5a99f93b1..d3110f9f2 100644
--- a/src/mac/cmac/cmac.cpp
+++ b/src/mac/cmac/cmac.cpp
@@ -4,7 +4,6 @@
*************************************************/
#include <botan/cmac.h>
-#include <botan/lookup.h>
#include <botan/xor_buf.h>
namespace Botan {
@@ -123,22 +122,23 @@ std::string CMAC::name() const
*************************************************/
MessageAuthenticationCode* CMAC::clone() const
{
- return new CMAC(e->name());
+ return new CMAC(e->clone());
}
/*************************************************
* CMAC Constructor *
*************************************************/
-CMAC::CMAC(const std::string& bc_name) :
- MessageAuthenticationCode(block_size_of(bc_name),
- min_keylength_of(bc_name),
- max_keylength_of(bc_name),
- keylength_multiple_of(bc_name))
+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)
{
- e = get_block_cipher(bc_name);
-
- if(e->BLOCK_SIZE == 16) polynomial = 0x87;
- else if(e->BLOCK_SIZE == 8) polynomial = 0x1B;
+ if(e->BLOCK_SIZE == 16)
+ polynomial = 0x87;
+ else if(e->BLOCK_SIZE == 8)
+ polynomial = 0x1B;
else
throw Invalid_Argument("CMAC cannot use the cipher " + e->name());
diff --git a/src/mac/cmac/cmac.h b/src/mac/cmac/cmac.h
index c7f107258..0fe5b75f8 100644
--- a/src/mac/cmac/cmac.h
+++ b/src/mac/cmac/cmac.h
@@ -23,7 +23,7 @@ class BOTAN_DLL CMAC : public MessageAuthenticationCode
static SecureVector<byte> poly_double(const MemoryRegion<byte>& in,
byte polynomial);
- CMAC(const std::string&);
+ CMAC(BlockCipher* e);
~CMAC() { delete e; }
private:
void add_data(const byte[], u32bit);