aboutsummaryrefslogtreecommitdiffstats
path: root/src/libstate
diff options
context:
space:
mode:
authorlloyd <[email protected]>2008-11-10 02:44:12 +0000
committerlloyd <[email protected]>2008-11-10 02:44:12 +0000
commitba1271baf1ccbc0302971e7300229d0dec0405ab (patch)
treecbf5b81dd55f71a6c4b9fa220aef0424853498db /src/libstate
parent032a4574bee834337b8ccf7fc29779c69c161e2b (diff)
Remove support for S2K in Engines. There are only three implementations of
an S2K in Botan, all in the core library, and it's relatively unlikely that that many more will be added. get_s2k still exists and performs a direct search across the possibilities.
Diffstat (limited to 'src/libstate')
-rw-r--r--src/libstate/engine/def_engine/def_eng.h1
-rw-r--r--src/libstate/engine/def_engine/info.txt1
-rw-r--r--src/libstate/engine/def_engine/lookup_s2k.cpp50
-rw-r--r--src/libstate/engine/engine.cpp20
-rw-r--r--src/libstate/engine/engine.h6
-rw-r--r--src/libstate/get_enc.cpp40
-rw-r--r--src/libstate/lookup.cpp29
-rw-r--r--src/libstate/lookup.h2
8 files changed, 39 insertions, 110 deletions
diff --git a/src/libstate/engine/def_engine/def_eng.h b/src/libstate/engine/def_engine/def_eng.h
index 3d3fba809..4f1bd89a7 100644
--- a/src/libstate/engine/def_engine/def_eng.h
+++ b/src/libstate/engine/def_engine/def_eng.h
@@ -64,7 +64,6 @@ class BOTAN_DLL Default_Engine : public Engine
HashFunction* find_hash(const std::string&) const;
MessageAuthenticationCode* find_mac(const std::string&) const;
- class S2K* find_s2k(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 823df1559..da2683bb7 100644
--- a/src/libstate/engine/def_engine/info.txt
+++ b/src/libstate/engine/def_engine/info.txt
@@ -13,6 +13,5 @@ lookup_bc_pad.cpp
lookup_block.cpp
lookup_hash.cpp
lookup_mac.cpp
-lookup_s2k.cpp
lookup_stream.cpp
</add>
diff --git a/src/libstate/engine/def_engine/lookup_s2k.cpp b/src/libstate/engine/def_engine/lookup_s2k.cpp
deleted file mode 100644
index 73f012b18..000000000
--- a/src/libstate/engine/def_engine/lookup_s2k.cpp
+++ /dev/null
@@ -1,50 +0,0 @@
-/*************************************************
-* S2K Lookup *
-* (C) 1999-2007 Jack Lloyd *
-*************************************************/
-
-#include <botan/def_eng.h>
-#include <botan/lookup.h>
-#include <botan/scan_name.h>
-
-#if defined(BOTAN_HAS_PBKDF1)
- #include <botan/pbkdf1.h>
-#endif
-
-#if defined(BOTAN_HAS_PBKDF2)
- #include <botan/pbkdf2.h>
- #include <botan/hmac.h>
-#endif
-
-#if defined(BOTAN_HAS_PGPS2K)
- #include <botan/pgp_s2k.h>
-#endif
-
-namespace Botan {
-
-/*************************************************
-* Look for an algorithm with this name *
-*************************************************/
-S2K* Default_Engine::find_s2k(const std::string& algo_spec) const
- {
- SCAN_Name request(algo_spec);
-
-#if defined(BOTAN_HAS_PBKDF1)
- if(request.algo_name() == "PBKDF1" && request.arg_count() == 1)
- return new PKCS5_PBKDF1(get_hash(request.argument(0)));
-#endif
-
-#if defined(BOTAN_HAS_PBKDF2)
- if(request.algo_name() == "PBKDF2" && request.arg_count() == 1)
- return new PKCS5_PBKDF2(new HMAC(get_hash(request.argument(0))));
-#endif
-
-#if defined(BOTAN_HAS_PGPS2K)
- if(request.algo_name() == "OpenPGP-S2K" && request.arg_count() == 1)
- return new OpenPGP_S2K(get_hash(request.argument(0)));
-#endif
-
- return 0;
- }
-
-}
diff --git a/src/libstate/engine/engine.cpp b/src/libstate/engine/engine.cpp
index 59621a7d3..b5d48a0ca 100644
--- a/src/libstate/engine/engine.cpp
+++ b/src/libstate/engine/engine.cpp
@@ -7,7 +7,6 @@
#include <botan/libstate.h>
#include <botan/stl_util.h>
#include <botan/mode_pad.h>
-#include <botan/s2k.h>
namespace Botan {
@@ -101,15 +100,6 @@ const MessageAuthenticationCode* Engine::mac(const std::string& name) const
}
/*************************************************
-* Acquire a S2K object *
-*************************************************/
-const S2K* Engine::s2k(const std::string& name) const
- {
- return lookup_algo(cache_of_s2k, global_state().deref_alias(name),
- this, &Engine::find_s2k);
- }
-
-/*************************************************
* Acquire a cipher padding object *
*************************************************/
const BlockCipherModePaddingMethod*
@@ -152,14 +142,6 @@ void Engine::add_algorithm(MessageAuthenticationCode* algo) const
}
/*************************************************
-* Add a S2K to the lookup table *
-*************************************************/
-void Engine::add_algorithm(S2K* algo) const
- {
- cache_of_s2k->add(algo);
- }
-
-/*************************************************
* Add a cipher pad method to the lookup table *
*************************************************/
void Engine::add_algorithm(BlockCipherModePaddingMethod* algo) const
@@ -176,7 +158,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_s2k = new Algorithm_Cache_Impl<S2K>();
cache_of_bc_pad =
new Algorithm_Cache_Impl<BlockCipherModePaddingMethod>();
}
@@ -190,7 +171,6 @@ Engine::~Engine()
delete cache_of_sc;
delete cache_of_hf;
delete cache_of_mac;
- delete cache_of_s2k;
delete cache_of_bc_pad;
}
diff --git a/src/libstate/engine/engine.h b/src/libstate/engine/engine.h
index 5073b6d0d..584219045 100644
--- a/src/libstate/engine/engine.h
+++ b/src/libstate/engine/engine.h
@@ -119,7 +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 S2K* s2k(const std::string&) const;
const class BlockCipherModePaddingMethod*
bc_pad(const std::string&) const;
@@ -129,7 +128,6 @@ class BOTAN_DLL Engine
void add_algorithm(StreamCipher*) const;
void add_algorithm(HashFunction*) const;
void add_algorithm(MessageAuthenticationCode*) const;
- void add_algorithm(class S2K*) const;
void add_algorithm(class BlockCipherModePaddingMethod*) const;
Engine();
@@ -147,9 +145,6 @@ class BOTAN_DLL Engine
virtual MessageAuthenticationCode* find_mac(const std::string&) const
{ return 0; }
- virtual class S2K* find_s2k(const std::string&) const
- { return 0; }
-
virtual class BlockCipherModePaddingMethod*
find_bc_pad(const std::string&) const
{ return 0; }
@@ -175,7 +170,6 @@ class BOTAN_DLL Engine
Algorithm_Cache<HashFunction>* cache_of_hf;
Algorithm_Cache<MessageAuthenticationCode>* cache_of_mac;
Algorithm_Cache<BlockCipherModePaddingMethod>* cache_of_bc_pad;
- Algorithm_Cache<S2K>* cache_of_s2k;
};
namespace Engine_Core {
diff --git a/src/libstate/get_enc.cpp b/src/libstate/get_enc.cpp
index f93ecb703..f2398e318 100644
--- a/src/libstate/get_enc.cpp
+++ b/src/libstate/get_enc.cpp
@@ -1,5 +1,5 @@
/*************************************************
-* EMSA/EME/KDF/MGF Retrieval Source File *
+* PBKDF/EMSA/EME/KDF/MGF Retrieval Source File *
* (C) 1999-2007 Jack Lloyd *
*************************************************/
@@ -7,6 +7,19 @@
#include <botan/libstate.h>
#include <botan/scan_name.h>
+#if defined(BOTAN_HAS_PBKDF1)
+ #include <botan/pbkdf1.h>
+#endif
+
+#if defined(BOTAN_HAS_PBKDF2)
+ #include <botan/pbkdf2.h>
+ #include <botan/hmac.h>
+#endif
+
+#if defined(BOTAN_HAS_PGPS2K)
+ #include <botan/pgp_s2k.h>
+#endif
+
#if defined(BOTAN_HAS_MGF1)
#include <botan/mgf1.h>
#endif
@@ -66,6 +79,31 @@
namespace Botan {
/*************************************************
+* Get a S2K algorithm by name *
+*************************************************/
+S2K* get_s2k(const std::string& algo_spec)
+ {
+ SCAN_Name request(algo_spec);
+
+#if defined(BOTAN_HAS_PBKDF1)
+ if(request.algo_name() == "PBKDF1" && request.arg_count() == 1)
+ return new PKCS5_PBKDF1(get_hash(request.argument(0)));
+#endif
+
+#if defined(BOTAN_HAS_PBKDF2)
+ if(request.algo_name() == "PBKDF2" && request.arg_count() == 1)
+ return new PKCS5_PBKDF2(new HMAC(get_hash(request.argument(0))));
+#endif
+
+#if defined(BOTAN_HAS_PGPS2K)
+ if(request.algo_name() == "OpenPGP-S2K" && request.arg_count() == 1)
+ return new OpenPGP_S2K(get_hash(request.argument(0)));
+#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 b34a532e3..700a62a7a 100644
--- a/src/libstate/lookup.cpp
+++ b/src/libstate/lookup.cpp
@@ -54,17 +54,6 @@ MessageAuthenticationCode* get_mac(const std::string& name)
}
/*************************************************
-* Get a S2K algorithm by name *
-*************************************************/
-S2K* get_s2k(const std::string& name)
- {
- const S2K* s2k = retrieve_s2k(global_state(), name);
- if(s2k)
- return s2k->clone();
- throw Algorithm_Not_Found(name);
- }
-
-/*************************************************
* Get a block cipher padding method by name *
*************************************************/
const BlockCipherModePaddingMethod* get_bc_pad(const std::string& name)
@@ -311,24 +300,6 @@ const MessageAuthenticationCode* retrieve_mac(Library_State& libstate,
}
/*************************************************
-* Acquire a string-to-key algorithm *
-*************************************************/
-const S2K* retrieve_s2k(Library_State& libstate,
- const std::string& name)
- {
- Library_State::Engine_Iterator i(libstate);
-
- while(const Engine* engine = i.next())
- {
- const S2K* algo = engine->s2k(name);
- if(algo)
- return algo;
- }
-
- return 0;
- }
-
-/*************************************************
* Retrieve a block cipher padding method *
*************************************************/
const BlockCipherModePaddingMethod* retrieve_bc_pad(Library_State& libstate,
diff --git a/src/libstate/lookup.h b/src/libstate/lookup.h
index 4a97a2aeb..34618a835 100644
--- a/src/libstate/lookup.h
+++ b/src/libstate/lookup.h
@@ -39,8 +39,6 @@ retrieve_hash(Library_State&, const std::string&);
BOTAN_DLL const MessageAuthenticationCode*
retrieve_mac(Library_State&, const std::string&);
-BOTAN_DLL const S2K* retrieve_s2k(Library_State&, const std::string&);
-
BOTAN_DLL const BlockCipherModePaddingMethod*
retrieve_bc_pad(Library_State&, const std::string&);