From 5e79ee8939aa3cfcaed9159168153ee020ebd8de Mon Sep 17 00:00:00 2001 From: lloyd Date: Sat, 8 Nov 2008 22:55:53 +0000 Subject: Remove lookup.h use from EAX --- src/modes/cts/cts.cpp | 1 - src/modes/eax/eax.cpp | 36 ++++++------------------------------ src/modes/eax/eax.h | 23 ++++++++++++++++------- src/modes/eax/eax_dec.cpp | 9 ++++----- 4 files changed, 26 insertions(+), 43 deletions(-) (limited to 'src/modes') 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 -#include #include #include 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 -#include +#include #include #include #include @@ -32,15 +32,13 @@ SecureVector 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)); @@ -120,28 +118,6 @@ void EAX_Base::increment_counter() position = 0; } -/************************************************* -* 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 * *************************************************/ 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 -#include #include #include #include @@ -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); -- cgit v1.2.3