Botan  2.7.0
Crypto and TLS for C++11
Public Member Functions | List of all members
Botan::Montgomery_Exponentiator Class Referencefinal

#include <def_powm.h>

Inheritance diagram for Botan::Montgomery_Exponentiator:
Botan::Modular_Exponentiator

Public Member Functions

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

Detailed Description

Montgomery Exponentiator

Definition at line 45 of file def_powm.h.

Constructor & Destructor Documentation

◆ Montgomery_Exponentiator()

Botan::Montgomery_Exponentiator::Montgomery_Exponentiator ( const BigInt mod,
Power_Mod::Usage_Hints  hints 
)

Definition at line 37 of file powm_mnt.cpp.

Referenced by copy().

38  :
39  m_p(mod),
40  m_mod_p(mod),
41  m_monty_params(std::make_shared<Montgomery_Params>(m_p, m_mod_p)),
42  m_hints(hints)
43  {
44  }

Member Function Documentation

◆ copy()

Modular_Exponentiator* Botan::Montgomery_Exponentiator::copy ( ) const
inlineoverridevirtual

Implements Botan::Modular_Exponentiator.

Definition at line 52 of file def_powm.h.

References Montgomery_Exponentiator().

53  { return new Montgomery_Exponentiator(*this); }
Montgomery_Exponentiator(const BigInt &, Power_Mod::Usage_Hints)
Definition: powm_mnt.cpp:37

◆ execute()

BigInt Botan::Montgomery_Exponentiator::execute ( ) const
overridevirtual

Implements Botan::Modular_Exponentiator.

Definition at line 28 of file powm_mnt.cpp.

References Botan::BigInt::bits(), Botan::monty_execute(), and Botan::round_up().

29  {
30  /*
31  This leaks size of e via loop iterations, not possible to fix without
32  breaking this API. Round up to avoid leaking fine details.
33  */
34  return monty_execute(*m_monty, m_e, round_up(m_e.bits(), 8));
35  }
size_t bits() const
Definition: bigint.cpp:228
BigInt monty_execute(const Montgomery_Exponentation_State &precomputed_state, const BigInt &k, size_t max_k_bits)
Definition: monty_exp.cpp:159
size_t round_up(size_t n, size_t align_to)
Definition: rounding.h:21

◆ set_base()

void Botan::Montgomery_Exponentiator::set_base ( const BigInt base)
overridevirtual

Implements Botan::Modular_Exponentiator.

Definition at line 22 of file powm_mnt.cpp.

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

23  {
24  size_t window_bits = Power_Mod::window_bits(m_e.bits(), base.bits(), m_hints);
25  m_monty = monty_precompute(m_monty_params, base, window_bits);
26  }
size_t bits() const
Definition: bigint.cpp:228
std::shared_ptr< const Montgomery_Exponentation_State > monty_precompute(std::shared_ptr< const Montgomery_Params > params, const BigInt &g, size_t window_bits, bool const_time)
Definition: monty_exp.cpp:151
static size_t window_bits(size_t exp_bits, size_t base_bits, Power_Mod::Usage_Hints hints)
Definition: pow_mod.cpp:102

◆ set_exponent()

void Botan::Montgomery_Exponentiator::set_exponent ( const BigInt exp)
overridevirtual

Implements Botan::Modular_Exponentiator.

Definition at line 17 of file powm_mnt.cpp.

18  {
19  m_e = exp;
20  }

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