diff options
-rw-r--r-- | src/libstate/info.txt | 5 | ||||
-rw-r--r-- | src/libstate/pk_engine.cpp | 36 | ||||
-rw-r--r-- | src/libstate/pk_engine.h | 31 | ||||
-rw-r--r-- | src/math/numbertheory/pow_mod.cpp | 21 |
4 files changed, 19 insertions, 74 deletions
diff --git a/src/libstate/info.txt b/src/libstate/info.txt index 4607739f0..3992d25bd 100644 --- a/src/libstate/info.txt +++ b/src/libstate/info.txt @@ -11,16 +11,11 @@ lookup.h scan_name.h </header:public> -<header:internal> -pk_engine.h -</header:internal> - <source> get_enc.cpp init.cpp libstate.cpp lookup.cpp -pk_engine.cpp policy.cpp scan_name.cpp </source> diff --git a/src/libstate/pk_engine.cpp b/src/libstate/pk_engine.cpp deleted file mode 100644 index 2c9ee4bfd..000000000 --- a/src/libstate/pk_engine.cpp +++ /dev/null @@ -1,36 +0,0 @@ -/* -* PK Engine Lookup -* (C) 1999-2007 Jack Lloyd -* -* Distributed under the terms of the Botan license -*/ - -#include <botan/internal/pk_engine.h> -#include <botan/libstate.h> -#include <botan/engine.h> - -namespace Botan { - -namespace Engine_Core { - -/* -* Acquire a modular exponentiator -*/ -Modular_Exponentiator* mod_exp(const BigInt& n, Power_Mod::Usage_Hints hints) - { - Algorithm_Factory::Engine_Iterator i(global_state().algorithm_factory()); - - while(const Engine* engine = i.next()) - { - Modular_Exponentiator* op = engine->mod_exp(n, hints); - - if(op) - return op; - } - - throw Lookup_Error("Engine_Core::mod_exp: Unable to find a working engine"); - } - -} - -} diff --git a/src/libstate/pk_engine.h b/src/libstate/pk_engine.h deleted file mode 100644 index 0e6b8dc41..000000000 --- a/src/libstate/pk_engine.h +++ /dev/null @@ -1,31 +0,0 @@ -/** -* Engine for PK -* (C) 1999-2007 Jack Lloyd -* -* Distributed under the terms of the Botan license -*/ - -#ifndef BOTAN_ENGINE_PK_LOOKUP_H__ -#define BOTAN_ENGINE_PK_LOOKUP_H__ - -#include <botan/bigint.h> -#include <botan/pow_mod.h> - -namespace Botan { - -class Algorithm_Factory; -class Keyed_Filter; -class Modular_Exponentiator; - -namespace Engine_Core { - -/* -* Get an operation from an Engine -*/ -Modular_Exponentiator* mod_exp(const BigInt&, Power_Mod::Usage_Hints); - -} - -} - -#endif diff --git a/src/math/numbertheory/pow_mod.cpp b/src/math/numbertheory/pow_mod.cpp index 8d6bac699..e98364fea 100644 --- a/src/math/numbertheory/pow_mod.cpp +++ b/src/math/numbertheory/pow_mod.cpp @@ -6,7 +6,8 @@ */ #include <botan/pow_mod.h> -#include <botan/internal/pk_engine.h> +#include <botan/libstate.h> +#include <botan/engine.h> namespace Botan { @@ -55,7 +56,23 @@ Power_Mod::~Power_Mod() void Power_Mod::set_modulus(const BigInt& n, Usage_Hints hints) const { delete core; - core = ((n == 0) ? 0 : Engine_Core::mod_exp(n, hints)); + core = 0; + + if(n != 0) + { + Algorithm_Factory::Engine_Iterator i(global_state().algorithm_factory()); + + while(const Engine* engine = i.next()) + { + core = engine->mod_exp(n, hints); + + if(core) + break; + } + + if(!core) + throw Lookup_Error("Power_Mod: Unable to find a working engine"); + } } /* |