diff options
-rw-r--r-- | src/engine/def_engine/def_mode.cpp | 4 | ||||
-rw-r--r-- | src/modes/cts/cts.cpp | 46 | ||||
-rw-r--r-- | src/modes/cts/cts.h | 24 |
3 files changed, 20 insertions, 54 deletions
diff --git a/src/engine/def_engine/def_mode.cpp b/src/engine/def_engine/def_mode.cpp index 16cbcd57e..d69d6175c 100644 --- a/src/engine/def_engine/def_mode.cpp +++ b/src/engine/def_engine/def_mode.cpp @@ -138,9 +138,9 @@ Keyed_Filter* Default_Engine::get_cipher(const std::string& algo_spec, { #if defined(BOTAN_HAS_CTS) if(direction == ENCRYPTION) - return new CTS_Encryption(cipher); + return new CTS_Encryption(get_block_cipher(cipher)); else - return new CTS_Decryption(cipher); + return new CTS_Decryption(get_block_cipher(cipher)); #else return 0; #endif diff --git a/src/modes/cts/cts.cpp b/src/modes/cts/cts.cpp index 0bce248b5..12756eb58 100644 --- a/src/modes/cts/cts.cpp +++ b/src/modes/cts/cts.cpp @@ -11,28 +11,6 @@ namespace Botan { /************************************************* -* CTS Encryption Constructor * -*************************************************/ -CTS_Encryption::CTS_Encryption(const std::string& cipher_name) : - BlockCipherMode(get_block_cipher(cipher_name), - "CTS", block_size_of(cipher_name), 0, 2) - { - } - -/************************************************* -* CTS Encryption Constructor * -*************************************************/ -CTS_Encryption::CTS_Encryption(const std::string& cipher_name, - const SymmetricKey& key, - const InitializationVector& iv) : - BlockCipherMode(get_block_cipher(cipher_name), - "CTS", block_size_of(cipher_name), 0, 2) - { - set_key(key); - set_iv(iv); - } - -/************************************************* * Encrypt a block * *************************************************/ void CTS_Encryption::encrypt(const byte block[]) @@ -92,30 +70,6 @@ void CTS_Encryption::end_msg() } /************************************************* -* CTS Decryption Constructor * -*************************************************/ -CTS_Decryption::CTS_Decryption(const std::string& cipher_name) : - BlockCipherMode(get_block_cipher(cipher_name), - "CTS", block_size_of(cipher_name), 0, 2) - { - temp.create(BLOCK_SIZE); - } - -/************************************************* -* CTS Decryption Constructor * -*************************************************/ -CTS_Decryption::CTS_Decryption(const std::string& cipher_name, - const SymmetricKey& key, - const InitializationVector& iv) : - BlockCipherMode(get_block_cipher(cipher_name), - "CTS", block_size_of(cipher_name), 0, 2) - { - temp.create(BLOCK_SIZE); - set_key(key); - set_iv(iv); - } - -/************************************************* * Decrypt a block * *************************************************/ void CTS_Decryption::decrypt(const byte block[]) diff --git a/src/modes/cts/cts.h b/src/modes/cts/cts.h index 6a07c4eb2..57582d8de 100644 --- a/src/modes/cts/cts.h +++ b/src/modes/cts/cts.h @@ -7,6 +7,7 @@ #define BOTAN_CTS_H__ #include <botan/modebase.h> +#include <botan/block_cipher.h> namespace Botan { @@ -16,9 +17,14 @@ namespace Botan { class BOTAN_DLL CTS_Encryption : public BlockCipherMode { public: - CTS_Encryption(const std::string&); - CTS_Encryption(const std::string&, - const SymmetricKey&, const InitializationVector&); + CTS_Encryption(BlockCipher* ciph) : + BlockCipherMode(ciph, "CTS", ciph->BLOCK_SIZE, 0, 2) {} + + CTS_Encryption(BlockCipher* ciph, + const SymmetricKey& key, + const InitializationVector& iv) : + BlockCipherMode(ciph, "CTS", ciph->BLOCK_SIZE, 0, 2) + { set_key(key); set_iv(iv); } private: void write(const byte[], u32bit); void end_msg(); @@ -31,9 +37,15 @@ class BOTAN_DLL CTS_Encryption : public BlockCipherMode class BOTAN_DLL CTS_Decryption : public BlockCipherMode { public: - CTS_Decryption(const std::string&); - CTS_Decryption(const std::string&, - const SymmetricKey&, const InitializationVector&); + CTS_Decryption(BlockCipher* ciph) : + BlockCipherMode(ciph, "CTS", ciph->BLOCK_SIZE, 0, 2) + { temp.create(BLOCK_SIZE); } + + CTS_Decryption(BlockCipher* ciph, + const SymmetricKey& key, + const InitializationVector& iv) : + BlockCipherMode(ciph, "CTS", ciph->BLOCK_SIZE, 0, 2) + { set_key(key); set_iv(iv); temp.create(BLOCK_SIZE); } private: void write(const byte[], u32bit); void end_msg(); |