Botan 1.10.17
Botan::Fixed_Window_Exponentiator Class Reference

#include <def_powm.h>

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

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

◆ Fixed_Window_Exponentiator()

Botan::Fixed_Window_Exponentiator::Fixed_Window_Exponentiator ( const BigInt & n,
Power_Mod::Usage_Hints hints )

Definition at line 61 of file powm_fw.cpp.

63 {
64 reducer = Modular_Reducer(n);
65 this->hints = hints;
66 window_bits = 0;
67 }

References Botan::Modular_Reducer::Modular_Reducer().

Referenced by copy(), and Botan::Core_Engine::mod_exp().

Member Function Documentation

◆ copy()

Modular_Exponentiator * Botan::Fixed_Window_Exponentiator::copy ( ) const
inlinevirtual

Implements Botan::Modular_Exponentiator.

Definition at line 27 of file def_powm.h.

28 { return new Fixed_Window_Exponentiator(*this); }
Fixed_Window_Exponentiator(const BigInt &, Power_Mod::Usage_Hints)
Definition powm_fw.cpp:61

References Fixed_Window_Exponentiator().

◆ execute()

BigInt Botan::Fixed_Window_Exponentiator::execute ( ) const
virtual

Implements Botan::Modular_Exponentiator.

Definition at line 40 of file powm_fw.cpp.

41 {
42 const size_t exp_nibbles = (exp.bits() + window_bits - 1) / window_bits;
43
44 BigInt x = 1;
45
46 for(size_t i = exp_nibbles; i > 0; --i)
47 {
48 for(size_t j = 0; j != window_bits; ++j)
49 x = reducer.square(x);
50
51 const u32bit nibble = exp.get_substring(window_bits*(i-1), window_bits);
52
53 x = reducer.multiply(x, g[nibble]);
54 }
55 return x;
56 }
unsigned int u32bit
Definition types.h:32

◆ set_base()

void Botan::Fixed_Window_Exponentiator::set_base ( const BigInt & base)
virtual

Implements Botan::Modular_Exponentiator.

Definition at line 25 of file powm_fw.cpp.

26 {
27 window_bits = Power_Mod::window_bits(exp.bits(), base.bits(), hints);
28
29 g.resize((1 << window_bits));
30 g[0] = 1;
31 g[1] = base;
32
33 for(size_t i = 2; i != g.size(); ++i)
34 g[i] = reducer.multiply(g[i-1], g[1]);
35 }
static size_t window_bits(size_t exp_bits, size_t base_bits, Power_Mod::Usage_Hints hints)
Definition pow_mod.cpp:119

References Botan::BigInt::bits(), and Botan::Power_Mod::window_bits().

◆ set_exponent()

void Botan::Fixed_Window_Exponentiator::set_exponent ( const BigInt & e)
virtual

Implements Botan::Modular_Exponentiator.

Definition at line 17 of file powm_fw.cpp.

18 {
19 exp = e;
20 }

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