diff options
Diffstat (limited to 'src/modes/ecb')
-rw-r--r-- | src/modes/ecb/ecb.cpp | 50 | ||||
-rw-r--r-- | src/modes/ecb/ecb.h | 27 |
2 files changed, 20 insertions, 57 deletions
diff --git a/src/modes/ecb/ecb.cpp b/src/modes/ecb/ecb.cpp index 2d0888cea..b76e86ad9 100644 --- a/src/modes/ecb/ecb.cpp +++ b/src/modes/ecb/ecb.cpp @@ -4,20 +4,10 @@ *************************************************/ #include <botan/ecb.h> -#include <botan/lookup.h> namespace Botan { /************************************************* -* ECB Constructor * -*************************************************/ -ECB::ECB(const std::string& cipher_name, const std::string& padding_name) : - BlockCipherMode(get_block_cipher(cipher_name), - "ECB", 0), padder(get_bc_pad(padding_name)) - { - } - -/************************************************* * Verify the IV is not set * *************************************************/ bool ECB::valid_iv_size(u32bit iv_size) const @@ -36,26 +26,6 @@ std::string ECB::name() const } /************************************************* -* ECB Encryption Constructor * -*************************************************/ -ECB_Encryption::ECB_Encryption(const std::string& cipher_name, - const std::string& padding_name) : - ECB(cipher_name, padding_name) - { - } - -/************************************************* -* ECB Encryption Constructor * -*************************************************/ -ECB_Encryption::ECB_Encryption(const std::string& cipher_name, - const std::string& padding_name, - const SymmetricKey& key) : - ECB(cipher_name, padding_name) - { - set_key(key); - } - -/************************************************* * Encrypt in ECB mode * *************************************************/ void ECB_Encryption::write(const byte input[], u32bit length) @@ -93,26 +63,6 @@ void ECB_Encryption::end_msg() } /************************************************* -* ECB Decryption Constructor * -*************************************************/ -ECB_Decryption::ECB_Decryption(const std::string& cipher_name, - const std::string& padding_name) : - ECB(cipher_name, padding_name) - { - } - -/************************************************* -* ECB Decryption Constructor * -*************************************************/ -ECB_Decryption::ECB_Decryption(const std::string& cipher_name, - const std::string& padding_name, - const SymmetricKey& key) : - ECB(cipher_name, padding_name) - { - set_key(key); - } - -/************************************************* * Decrypt in ECB mode * *************************************************/ void ECB_Decryption::write(const byte input[], u32bit length) diff --git a/src/modes/ecb/ecb.h b/src/modes/ecb/ecb.h index b730a4fd4..d15d2f202 100644 --- a/src/modes/ecb/ecb.h +++ b/src/modes/ecb/ecb.h @@ -8,6 +8,7 @@ #include <botan/modebase.h> #include <botan/mode_pad.h> +#include <botan/block_cipher.h> namespace Botan { @@ -17,7 +18,9 @@ namespace Botan { class BOTAN_DLL ECB : public BlockCipherMode { protected: - ECB(const std::string&, const std::string&); + ECB(BlockCipher* ciph, const BlockCipherModePaddingMethod* pad) : + BlockCipherMode(ciph, "ECB", 0), padder(pad) {} + std::string name() const; const BlockCipherModePaddingMethod* padder; private: @@ -30,9 +33,14 @@ class BOTAN_DLL ECB : public BlockCipherMode class BOTAN_DLL ECB_Encryption : public ECB { public: - ECB_Encryption(const std::string&, const std::string&); - ECB_Encryption(const std::string&, const std::string&, - const SymmetricKey&); + ECB_Encryption(BlockCipher* ciph, + const BlockCipherModePaddingMethod* pad) : + ECB(ciph, pad) {} + + ECB_Encryption(BlockCipher* ciph, + const BlockCipherModePaddingMethod* pad, + const SymmetricKey& key) : + ECB(ciph, pad) { set_key(key); } private: void write(const byte[], u32bit); void end_msg(); @@ -44,9 +52,14 @@ class BOTAN_DLL ECB_Encryption : public ECB class BOTAN_DLL ECB_Decryption : public ECB { public: - ECB_Decryption(const std::string&, const std::string&); - ECB_Decryption(const std::string&, const std::string&, - const SymmetricKey&); + ECB_Decryption(BlockCipher* ciph, + const BlockCipherModePaddingMethod* pad) : + ECB(ciph, pad) {} + + ECB_Decryption(BlockCipher* ciph, + const BlockCipherModePaddingMethod* pad, + const SymmetricKey& key) : + ECB(ciph, pad) { set_key(key); } private: void write(const byte[], u32bit); void end_msg(); |