aboutsummaryrefslogtreecommitdiffstats
path: root/src
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
parent1a93a9c7e73becbfce821705b387ce3cf660dad0 (diff)
Remove lookup.h use from EAX
Diffstat (limited to 'src')
-rw-r--r--src/engine/def_engine/def_mode.cpp4
-rw-r--r--src/modes/cts/cts.cpp1
-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
5 files changed, 28 insertions, 45 deletions
diff --git a/src/engine/def_engine/def_mode.cpp b/src/engine/def_engine/def_mode.cpp
index d69d6175c..831ece4f1 100644
--- a/src/engine/def_engine/def_mode.cpp
+++ b/src/engine/def_engine/def_mode.cpp
@@ -161,9 +161,9 @@ Keyed_Filter* Default_Engine::get_cipher(const std::string& algo_spec,
{
#if defined(BOTAN_HAS_EAX)
if(direction == ENCRYPTION)
- return new EAX_Encryption(cipher, bits);
+ return new EAX_Encryption(get_block_cipher(cipher), bits);
else
- return new EAX_Decryption(cipher, bits);
+ return new EAX_Decryption(get_block_cipher(cipher), bits);
#else
return 0;
#endif
diff --git a/src/modes/cts/cts.cpp b/src/modes/cts/cts.cpp
index 12756eb58..120cf8386 100644
--- a/src/modes/cts/cts.cpp
+++ b/src/modes/cts/cts.cpp
@@ -4,7 +4,6 @@
*************************************************/
#include <botan/cts.h>
-#include <botan/lookup.h>
#include <botan/xor_buf.h>
#include <algorithm>
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);