diff options
author | lloyd <[email protected]> | 2015-02-03 08:11:45 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2015-02-03 08:11:45 +0000 |
commit | f9a7c85b74be0f4a7273e8e0591703af83036e81 (patch) | |
tree | 075dbe119fc16863cad99b432ca6251778bd8fd1 /src/lib/math/numbertheory | |
parent | 69d2cd919c698a6b138b2ccba0de5d5aa2a33a03 (diff) |
Convert PK operations to using Algo_Registry instead of Engine.
Remove global PRNG.
Diffstat (limited to 'src/lib/math/numbertheory')
-rw-r--r-- | src/lib/math/numbertheory/pow_mod.cpp | 24 |
1 files changed, 6 insertions, 18 deletions
diff --git a/src/lib/math/numbertheory/pow_mod.cpp b/src/lib/math/numbertheory/pow_mod.cpp index b5fc3747e..9a9bff2ad 100644 --- a/src/lib/math/numbertheory/pow_mod.cpp +++ b/src/lib/math/numbertheory/pow_mod.cpp @@ -6,8 +6,7 @@ */ #include <botan/pow_mod.h> -#include <botan/libstate.h> -#include <botan/engine.h> +#include <botan/internal/def_powm.h> namespace Botan { @@ -48,6 +47,7 @@ Power_Mod& Power_Mod::operator=(const Power_Mod& other) Power_Mod::~Power_Mod() { delete core; + core = nullptr; } /* @@ -56,23 +56,11 @@ Power_Mod::~Power_Mod() void Power_Mod::set_modulus(const BigInt& n, Usage_Hints hints) const { delete core; - core = nullptr; - - 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"); - } + if(n.is_odd()) + core = new Montgomery_Exponentiator(n, hints); + else if(n != 0) + core = new Fixed_Window_Exponentiator(n, hints); } /* |