aboutsummaryrefslogtreecommitdiffstats
path: root/src/modes/eax
diff options
context:
space:
mode:
authorlloyd <[email protected]>2008-11-08 22:55:53 +0000
committerlloyd <[email protected]>2008-11-08 22:55:53 +0000
commit5e79ee8939aa3cfcaed9159168153ee020ebd8de (patch)
treeac224fc7d8af6880a5ce12d29ef6077f4870e077 /src/modes/eax
parent1a93a9c7e73becbfce821705b387ce3cf660dad0 (diff)
Remove lookup.h use from EAX
Diffstat (limited to 'src/modes/eax')
-rw-r--r--src/modes/eax/eax.cpp36
-rw-r--r--src/modes/eax/eax.h23
-rw-r--r--src/modes/eax/eax_dec.cpp9
3 files changed, 26 insertions, 42 deletions
diff --git a/src/modes/eax/eax.cpp b/src/modes/eax/eax.cpp
index f246a9dea..c31a823cf 100644
--- a/src/modes/eax/eax.cpp
+++ b/src/modes/eax/eax.cpp
@@ -4,7 +4,7 @@
*************************************************/
#include <botan/eax.h>
-#include <botan/lookup.h>
+#include <botan/cmac.h>
#include <botan/xor_buf.h>
#include <botan/parsing.h>
#include <algorithm>
@@ -32,15 +32,13 @@ SecureVector<byte> eax_prf(byte tag, u32bit BLOCK_SIZE,
/*************************************************
* EAX_Base Constructor *
*************************************************/
-EAX_Base::EAX_Base(const std::string& cipher_name,
+EAX_Base::EAX_Base(BlockCipher* ciph,
u32bit tag_size) :
- TAG_SIZE(tag_size ? tag_size / 8 : block_size_of(cipher_name)),
- BLOCK_SIZE(block_size_of(cipher_name))
+ TAG_SIZE(tag_size ? tag_size / 8 : ciph->BLOCK_SIZE),
+ BLOCK_SIZE(ciph->BLOCK_SIZE)
{
- const std::string mac_name = "CMAC(" + cipher_name + ")";
-
- cipher = get_block_cipher(cipher_name);
- mac = get_mac(mac_name);
+ cipher = ciph;
+ mac = new CMAC(cipher->clone());
if(tag_size % 8 != 0 || TAG_SIZE == 0 || TAG_SIZE > mac->OUTPUT_LENGTH)
throw Invalid_Argument(name() + ": Bad tag size " + to_string(tag_size));
@@ -121,28 +119,6 @@ void EAX_Base::increment_counter()
}
/*************************************************
-* EAX_Encryption Constructor *
-*************************************************/
-EAX_Encryption::EAX_Encryption(const std::string& cipher_name,
- u32bit tag_size) :
- EAX_Base(cipher_name, tag_size)
- {
- }
-
-/*************************************************
-* EAX_Encryption Constructor *
-*************************************************/
-EAX_Encryption::EAX_Encryption(const std::string& cipher_name,
- const SymmetricKey& key,
- const InitializationVector& iv,
- u32bit tag_size) :
- EAX_Base(cipher_name, tag_size)
- {
- set_key(key);
- set_iv(iv);
- }
-
-/*************************************************
* Encrypt in EAX mode *
*************************************************/
void EAX_Encryption::write(const byte input[], u32bit length)
diff --git a/src/modes/eax/eax.h b/src/modes/eax/eax.h
index aea1383db..67507f776 100644
--- a/src/modes/eax/eax.h
+++ b/src/modes/eax/eax.h
@@ -27,7 +27,7 @@ class BOTAN_DLL EAX_Base : public Keyed_Filter
~EAX_Base() { delete cipher; delete mac; }
protected:
- EAX_Base(const std::string&, u32bit);
+ EAX_Base(BlockCipher*, u32bit);
void start_msg();
void increment_counter();
@@ -44,9 +44,16 @@ class BOTAN_DLL EAX_Base : public Keyed_Filter
class BOTAN_DLL EAX_Encryption : public EAX_Base
{
public:
- EAX_Encryption(const std::string&, u32bit = 0);
- EAX_Encryption(const std::string&, const SymmetricKey&,
- const InitializationVector&, u32bit = 0);
+ EAX_Encryption(BlockCipher* ciph, u32bit tag_size = 0) :
+ EAX_Base(ciph, tag_size) {}
+
+ EAX_Encryption(BlockCipher* ciph, const SymmetricKey& key,
+ const InitializationVector& iv,
+ u32bit tag_size) : EAX_Base(ciph, tag_size)
+ {
+ set_key(key);
+ set_iv(iv);
+ }
private:
void write(const byte[], u32bit);
void end_msg();
@@ -58,9 +65,11 @@ class BOTAN_DLL EAX_Encryption : public EAX_Base
class BOTAN_DLL EAX_Decryption : public EAX_Base
{
public:
- EAX_Decryption(const std::string&, u32bit = 0);
- EAX_Decryption(const std::string&, const SymmetricKey&,
- const InitializationVector&, u32bit = 0);
+ EAX_Decryption(BlockCipher* ciph, u32bit tag_size = 0);
+
+ EAX_Decryption(BlockCipher* ciph, const SymmetricKey& key,
+ const InitializationVector& iv,
+ u32bit tag_size = 0);
private:
void write(const byte[], u32bit);
void do_write(const byte[], u32bit);
diff --git a/src/modes/eax/eax_dec.cpp b/src/modes/eax/eax_dec.cpp
index 70cdd9863..1b4a05b3c 100644
--- a/src/modes/eax/eax_dec.cpp
+++ b/src/modes/eax/eax_dec.cpp
@@ -4,7 +4,6 @@
*************************************************/
#include <botan/eax.h>
-#include <botan/lookup.h>
#include <botan/xor_buf.h>
#include <botan/parsing.h>
#include <algorithm>
@@ -14,9 +13,9 @@ namespace Botan {
/*************************************************
* EAX_Decryption Constructor *
*************************************************/
-EAX_Decryption::EAX_Decryption(const std::string& cipher_name,
+EAX_Decryption::EAX_Decryption(BlockCipher* ciph,
u32bit tag_size) :
- EAX_Base(cipher_name, tag_size)
+ EAX_Base(ciph, tag_size)
{
queue.create(2*TAG_SIZE + DEFAULT_BUFFERSIZE);
queue_start = queue_end = 0;
@@ -25,11 +24,11 @@ EAX_Decryption::EAX_Decryption(const std::string& cipher_name,
/*************************************************
* EAX_Decryption Constructor *
*************************************************/
-EAX_Decryption::EAX_Decryption(const std::string& cipher_name,
+EAX_Decryption::EAX_Decryption(BlockCipher* ciph,
const SymmetricKey& key,
const InitializationVector& iv,
u32bit tag_size) :
- EAX_Base(cipher_name, tag_size)
+ EAX_Base(ciph, tag_size)
{
set_key(key);
set_iv(iv);