Botan  1.11.15
Public Member Functions
Botan::Fixed_Window_Exponentiator Class Reference

#include <def_powm.h>

Inheritance diagram for Botan::Fixed_Window_Exponentiator:
Botan::Modular_Exponentiator

List of all members.

Public Member Functions

Modular_Exponentiatorcopy () const
BigInt execute () const
 Fixed_Window_Exponentiator (const BigInt &, Power_Mod::Usage_Hints)
void set_base (const BigInt &)
void set_exponent (const BigInt &)

Detailed Description

Fixed Window Exponentiator

Definition at line 20 of file def_powm.h.


Constructor & Destructor Documentation

Definition at line 61 of file powm_fw.cpp.

Referenced by copy().

   {
   reducer = Modular_Reducer(n);
   this->hints = hints;
   window_bits = 0;
   }

Member Function Documentation

Implements Botan::Modular_Exponentiator.

Definition at line 27 of file def_powm.h.

References Fixed_Window_Exponentiator().

         { return new Fixed_Window_Exponentiator(*this); }

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]);
   }

Implements Botan::Modular_Exponentiator.

Definition at line 17 of file powm_fw.cpp.

References e.

   {
   exp = e;
   }

The documentation for this class was generated from the following files: