Botan  2.6.0
Crypto and TLS for C++11
powm_mnt.cpp
Go to the documentation of this file.
1 /*
2 * Montgomery Exponentiation
3 * (C) 1999-2010,2012,2018 Jack Lloyd
4 * 2016 Matthias Gierlings
5 *
6 * Botan is released under the Simplified BSD License (see license.txt)
7 */
8 
9 #include <botan/internal/def_powm.h>
10 #include <botan/numthry.h>
11 #include <botan/monty.h>
12 #include <botan/internal/monty_exp.h>
13 
14 namespace Botan {
15 
17  {
18  m_e = exp;
19  }
20 
22  {
23  size_t window_bits = Power_Mod::window_bits(m_e.bits(), base.bits(), m_hints);
24  m_monty = monty_precompute(m_monty_params, base, window_bits);
25  }
26 
28  {
29  return monty_execute(*m_monty, m_e);
30  }
31 
33  Power_Mod::Usage_Hints hints) :
34  m_p(mod),
35  m_mod_p(mod),
36  m_monty_params(std::make_shared<Montgomery_Params>(m_p, m_mod_p)),
37  m_hints(hints)
38  {
39  }
40 
41 }
std::shared_ptr< const Montgomery_Exponentation_State > monty_precompute(std::shared_ptr< const Montgomery_Params > params, const BigInt &g, size_t window_bits)
Definition: monty_exp.cpp:142
size_t bits() const
Definition: bigint.cpp:216
Definition: bigint.h:719
BigInt execute() const override
Definition: powm_mnt.cpp:27
void set_exponent(const BigInt &) override
Definition: powm_mnt.cpp:16
Montgomery_Exponentiator(const BigInt &, Power_Mod::Usage_Hints)
Definition: powm_mnt.cpp:32
void set_base(const BigInt &) override
Definition: powm_mnt.cpp:21
BigInt monty_execute(const Montgomery_Exponentation_State &precomputed_state, const BigInt &k)
Definition: monty_exp.cpp:149
Definition: alg_id.cpp:13
static size_t window_bits(size_t exp_bits, size_t base_bits, Power_Mod::Usage_Hints hints)
Definition: pow_mod.cpp:102
Modular_Reducer m_mod_p
Definition: rsa.cpp:258