Botan
1.11.15
|
#include <def_powm.h>
Public Member Functions | |
Modular_Exponentiator * | copy () const |
BigInt | execute () const |
Fixed_Window_Exponentiator (const BigInt &, Power_Mod::Usage_Hints) | |
void | set_base (const BigInt &) |
void | set_exponent (const BigInt &) |
Fixed Window Exponentiator
Definition at line 20 of file def_powm.h.
Botan::Fixed_Window_Exponentiator::Fixed_Window_Exponentiator | ( | const BigInt & | n, |
Power_Mod::Usage_Hints | hints | ||
) |
Definition at line 61 of file powm_fw.cpp.
Referenced by copy().
{ reducer = Modular_Reducer(n); this->hints = hints; window_bits = 0; }
Modular_Exponentiator* Botan::Fixed_Window_Exponentiator::copy | ( | ) | const [inline, virtual] |
Implements Botan::Modular_Exponentiator.
Definition at line 27 of file def_powm.h.
References Fixed_Window_Exponentiator().
{ return new Fixed_Window_Exponentiator(*this); }
BigInt Botan::Fixed_Window_Exponentiator::execute | ( | ) | const [virtual] |
Implements Botan::Modular_Exponentiator.
Definition at line 40 of file powm_fw.cpp.
References Botan::BigInt::bits(), Botan::BigInt::get_substring(), Botan::Modular_Reducer::multiply(), Botan::Modular_Reducer::square(), and x.
{ const size_t exp_nibbles = (exp.bits() + window_bits - 1) / window_bits; BigInt x = 1; for(size_t i = exp_nibbles; i > 0; --i) { for(size_t j = 0; j != window_bits; ++j) x = reducer.square(x); const u32bit nibble = exp.get_substring(window_bits*(i-1), window_bits); x = reducer.multiply(x, g[nibble]); } return x; }
void Botan::Fixed_Window_Exponentiator::set_base | ( | const BigInt & | base | ) | [virtual] |
Implements Botan::Modular_Exponentiator.
Definition at line 25 of file powm_fw.cpp.
References Botan::BigInt::bits(), Botan::Modular_Reducer::multiply(), and Botan::Power_Mod::window_bits().
{ window_bits = Power_Mod::window_bits(exp.bits(), base.bits(), hints); g.resize((1 << window_bits)); g[0] = 1; g[1] = base; for(size_t i = 2; i != g.size(); ++i) g[i] = reducer.multiply(g[i-1], g[0]); }
void Botan::Fixed_Window_Exponentiator::set_exponent | ( | const BigInt & | e | ) | [virtual] |
Implements Botan::Modular_Exponentiator.
Definition at line 17 of file powm_fw.cpp.
References e.
{ exp = e; }