aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/libstate/engine/def_engine/def_eng.h3
-rw-r--r--src/libstate/engine/def_engine/info.txt1
-rw-r--r--src/libstate/engine/def_engine/lookup_bc_pad.cpp40
-rw-r--r--src/libstate/engine/engine.cpp21
-rw-r--r--src/libstate/engine/engine.h8
-rw-r--r--src/libstate/get_enc.cpp28
-rw-r--r--src/libstate/lookup.cpp51
-rw-r--r--src/libstate/lookup.h8
-rw-r--r--src/modes/cbc/cbc.h4
-rw-r--r--src/modes/ecb/ecb.h1
10 files changed, 35 insertions, 130 deletions
diff --git a/src/libstate/engine/def_engine/def_eng.h b/src/libstate/engine/def_engine/def_eng.h
index 4f1bd89a7..377333856 100644
--- a/src/libstate/engine/def_engine/def_eng.h
+++ b/src/libstate/engine/def_engine/def_eng.h
@@ -63,9 +63,6 @@ class BOTAN_DLL Default_Engine : public Engine
StreamCipher* find_stream_cipher(const std::string&) const;
HashFunction* find_hash(const std::string&) const;
MessageAuthenticationCode* find_mac(const std::string&) const;
-
- class BlockCipherModePaddingMethod*
- find_bc_pad(const std::string&) const;
};
}
diff --git a/src/libstate/engine/def_engine/info.txt b/src/libstate/engine/def_engine/info.txt
index da2683bb7..503a4392f 100644
--- a/src/libstate/engine/def_engine/info.txt
+++ b/src/libstate/engine/def_engine/info.txt
@@ -9,7 +9,6 @@ def_eng.h
def_mode.cpp
def_pk_ops.cpp
def_powm.cpp
-lookup_bc_pad.cpp
lookup_block.cpp
lookup_hash.cpp
lookup_mac.cpp
diff --git a/src/libstate/engine/def_engine/lookup_bc_pad.cpp b/src/libstate/engine/def_engine/lookup_bc_pad.cpp
deleted file mode 100644
index 0ed5267f6..000000000
--- a/src/libstate/engine/def_engine/lookup_bc_pad.cpp
+++ /dev/null
@@ -1,40 +0,0 @@
-/*************************************************
-* Block Cipher Padding Lookup *
-* (C) 1999-2007 Jack Lloyd *
-*************************************************/
-
-#include <botan/def_eng.h>
-#include <botan/scan_name.h>
-
-#if defined(BOTAN_HAS_CIPHER_MODE_PADDING)
- #include <botan/mode_pad.h>
-#endif
-
-namespace Botan {
-
-/*************************************************
-* Look for an algorithm with this name *
-*************************************************/
-BlockCipherModePaddingMethod*
-Default_Engine::find_bc_pad(const std::string& algo_spec) const
- {
- SCAN_Name request(algo_spec);
-
-#if defined(BOTAN_HAS_CIPHER_MODE_PADDING)
- if(request.algo_name() == "PKCS7")
- return new PKCS7_Padding;
-
- if(request.algo_name() == "OneAndZeros")
- return new OneAndZeros_Padding;
-
- if(request.algo_name() == "X9.23")
- return new ANSI_X923_Padding;
-
- if(request.algo_name() == "NoPadding")
- return new Null_Padding;
-#endif
-
- return 0;
- }
-
-}
diff --git a/src/libstate/engine/engine.cpp b/src/libstate/engine/engine.cpp
index b5d48a0ca..95111014e 100644
--- a/src/libstate/engine/engine.cpp
+++ b/src/libstate/engine/engine.cpp
@@ -100,16 +100,6 @@ const MessageAuthenticationCode* Engine::mac(const std::string& name) const
}
/*************************************************
-* Acquire a cipher padding object *
-*************************************************/
-const BlockCipherModePaddingMethod*
-Engine::bc_pad(const std::string& name) const
- {
- return lookup_algo(cache_of_bc_pad, global_state().deref_alias(name),
- this, &Engine::find_bc_pad);
- }
-
-/*************************************************
* Add a block cipher to the lookup table *
*************************************************/
void Engine::add_algorithm(BlockCipher* algo) const
@@ -142,14 +132,6 @@ void Engine::add_algorithm(MessageAuthenticationCode* algo) const
}
/*************************************************
-* Add a cipher pad method to the lookup table *
-*************************************************/
-void Engine::add_algorithm(BlockCipherModePaddingMethod* algo) const
- {
- cache_of_bc_pad->add(algo);
- }
-
-/*************************************************
* Create an Engine *
*************************************************/
Engine::Engine()
@@ -158,8 +140,6 @@ Engine::Engine()
cache_of_sc = new Algorithm_Cache_Impl<StreamCipher>();
cache_of_hf = new Algorithm_Cache_Impl<HashFunction>();
cache_of_mac = new Algorithm_Cache_Impl<MessageAuthenticationCode>();
- cache_of_bc_pad =
- new Algorithm_Cache_Impl<BlockCipherModePaddingMethod>();
}
/*************************************************
@@ -171,7 +151,6 @@ Engine::~Engine()
delete cache_of_sc;
delete cache_of_hf;
delete cache_of_mac;
- delete cache_of_bc_pad;
}
namespace Engine_Core {
diff --git a/src/libstate/engine/engine.h b/src/libstate/engine/engine.h
index 584219045..9e83ce97f 100644
--- a/src/libstate/engine/engine.h
+++ b/src/libstate/engine/engine.h
@@ -119,8 +119,6 @@ class BOTAN_DLL Engine
const StreamCipher* stream_cipher(const std::string&) const;
const HashFunction* hash(const std::string&) const;
const MessageAuthenticationCode* mac(const std::string&) const;
- const class BlockCipherModePaddingMethod*
- bc_pad(const std::string&) const;
virtual bool can_add_algorithms() { return false; }
@@ -128,7 +126,6 @@ class BOTAN_DLL Engine
void add_algorithm(StreamCipher*) const;
void add_algorithm(HashFunction*) const;
void add_algorithm(MessageAuthenticationCode*) const;
- void add_algorithm(class BlockCipherModePaddingMethod*) const;
Engine();
virtual ~Engine();
@@ -145,10 +142,6 @@ class BOTAN_DLL Engine
virtual MessageAuthenticationCode* find_mac(const std::string&) const
{ return 0; }
- virtual class BlockCipherModePaddingMethod*
- find_bc_pad(const std::string&) const
- { return 0; }
-
template<typename T>
const T* lookup_algo(const Algorithm_Cache<T>* cache,
const std::string& name,
@@ -169,7 +162,6 @@ class BOTAN_DLL Engine
Algorithm_Cache<StreamCipher>* cache_of_sc;
Algorithm_Cache<HashFunction>* cache_of_hf;
Algorithm_Cache<MessageAuthenticationCode>* cache_of_mac;
- Algorithm_Cache<BlockCipherModePaddingMethod>* cache_of_bc_pad;
};
namespace Engine_Core {
diff --git a/src/libstate/get_enc.cpp b/src/libstate/get_enc.cpp
index f2398e318..4c28c4b98 100644
--- a/src/libstate/get_enc.cpp
+++ b/src/libstate/get_enc.cpp
@@ -76,6 +76,10 @@
#include <botan/prf_tls.h>
#endif
+#if defined(BOTAN_HAS_CIPHER_MODE_PADDING)
+ #include <botan/mode_pad.h>
+#endif
+
namespace Botan {
/*************************************************
@@ -104,6 +108,30 @@ S2K* get_s2k(const std::string& algo_spec)
}
/*************************************************
+* Get a block cipher padding method by name *
+*************************************************/
+BlockCipherModePaddingMethod* get_bc_pad(const std::string& algo_spec)
+ {
+ SCAN_Name request(algo_spec);
+
+#if defined(BOTAN_HAS_CIPHER_MODE_PADDING)
+ if(request.algo_name() == "PKCS7")
+ return new PKCS7_Padding;
+
+ if(request.algo_name() == "OneAndZeros")
+ return new OneAndZeros_Padding;
+
+ if(request.algo_name() == "X9.23")
+ return new ANSI_X923_Padding;
+
+ if(request.algo_name() == "NoPadding")
+ return new Null_Padding;
+#endif
+
+ throw Algorithm_Not_Found(algo_spec);
+ }
+
+/*************************************************
* Get an EMSA by name *
*************************************************/
EMSA* get_emsa(const std::string& algo_spec)
diff --git a/src/libstate/lookup.cpp b/src/libstate/lookup.cpp
index 700a62a7a..956f508e4 100644
--- a/src/libstate/lookup.cpp
+++ b/src/libstate/lookup.cpp
@@ -54,19 +54,6 @@ MessageAuthenticationCode* get_mac(const std::string& name)
}
/*************************************************
-* Get a block cipher padding method by name *
-*************************************************/
-const BlockCipherModePaddingMethod* get_bc_pad(const std::string& name)
- {
- const BlockCipherModePaddingMethod* pad =
- retrieve_bc_pad(global_state(), name);
-
- if(pad)
- return pad;
- throw Algorithm_Not_Found(name);
- }
-
-/*************************************************
* Query if an algorithm exists *
*************************************************/
bool have_algorithm(const std::string& name)
@@ -300,24 +287,6 @@ const MessageAuthenticationCode* retrieve_mac(Library_State& libstate,
}
/*************************************************
-* Retrieve a block cipher padding method *
-*************************************************/
-const BlockCipherModePaddingMethod* retrieve_bc_pad(Library_State& libstate,
- const std::string& name)
- {
- Library_State::Engine_Iterator i(libstate);
-
- while(const Engine* engine = i.next())
- {
- const BlockCipherModePaddingMethod* algo = engine->bc_pad(name);
- if(algo)
- return algo;
- }
-
- return 0;
- }
-
-/*************************************************
* Add a new block cipher *
*************************************************/
void add_algorithm(Library_State& libstate, BlockCipher* algo)
@@ -395,26 +364,6 @@ void add_algorithm(Library_State& libstate,
}
/*************************************************
-* Add a padding method to the lookup table *
-*************************************************/
-void add_algorithm(Library_State& libstate,
- BlockCipherModePaddingMethod* algo)
- {
- Library_State::Engine_Iterator i(libstate);
-
- while(Engine* engine = i.next())
- {
- if(engine->can_add_algorithms())
- {
- engine->add_algorithm(algo);
- return;
- }
- }
-
- throw Invalid_State("add_algorithm: Couldn't find the Default_Engine");
- }
-
-/*************************************************
* Get a cipher object *
*************************************************/
Keyed_Filter* get_cipher(const std::string& algo_spec,
diff --git a/src/libstate/lookup.h b/src/libstate/lookup.h
index 34618a835..868765874 100644
--- a/src/libstate/lookup.h
+++ b/src/libstate/lookup.h
@@ -39,9 +39,6 @@ retrieve_hash(Library_State&, const std::string&);
BOTAN_DLL const MessageAuthenticationCode*
retrieve_mac(Library_State&, const std::string&);
-BOTAN_DLL const BlockCipherModePaddingMethod*
-retrieve_bc_pad(Library_State&, const std::string&);
-
/*************************************************
* Get an algorithm object *
*************************************************/
@@ -85,12 +82,11 @@ BOTAN_DLL MessageAuthenticationCode* get_mac(const std::string& name);
BOTAN_DLL S2K* get_s2k(const std::string& name);
/**
-* Block cipher padding mode factory/retrieval method.
+* Block cipher padding mode factory method.
* @param name the name of the desired block cipher padding mode
* @return the block cipher padding mode object
*/
-BOTAN_DLL const BlockCipherModePaddingMethod*
- get_bc_pad(const std::string& name);
+BOTAN_DLL BlockCipherModePaddingMethod* get_bc_pad(const std::string& name);
/*************************************************
* Get an EMSA/EME/KDF/MGF function *
diff --git a/src/modes/cbc/cbc.h b/src/modes/cbc/cbc.h
index 3069d6cb5..238780067 100644
--- a/src/modes/cbc/cbc.h
+++ b/src/modes/cbc/cbc.h
@@ -20,6 +20,8 @@ class BOTAN_DLL CBC_Encryption : public BlockCipherMode
CBC_Encryption(BlockCipher*, const BlockCipherModePaddingMethod*);
CBC_Encryption(BlockCipher*, const BlockCipherModePaddingMethod*,
const SymmetricKey&, const InitializationVector&);
+
+ ~CBC_Encryption() { delete padder; }
private:
std::string name() const;
void write(const byte[], u32bit);
@@ -36,6 +38,8 @@ class BOTAN_DLL CBC_Decryption : public BlockCipherMode
CBC_Decryption(BlockCipher*, const BlockCipherModePaddingMethod*);
CBC_Decryption(BlockCipher*, const BlockCipherModePaddingMethod*,
const SymmetricKey&, const InitializationVector&);
+
+ ~CBC_Decryption() { delete padder; }
private:
std::string name() const;
void write(const byte[], u32bit);
diff --git a/src/modes/ecb/ecb.h b/src/modes/ecb/ecb.h
index d15d2f202..902713455 100644
--- a/src/modes/ecb/ecb.h
+++ b/src/modes/ecb/ecb.h
@@ -20,6 +20,7 @@ class BOTAN_DLL ECB : public BlockCipherMode
protected:
ECB(BlockCipher* ciph, const BlockCipherModePaddingMethod* pad) :
BlockCipherMode(ciph, "ECB", 0), padder(pad) {}
+ ~ECB() { delete padder; }
std::string name() const;
const BlockCipherModePaddingMethod* padder;