Botan  2.4.0
Crypto and TLS for C++11
def_powm.h
Go to the documentation of this file.
1 /*
2 * Modular Exponentiation
3 * (C) 1999-2007 Jack Lloyd
4 *
5 * Botan is released under the Simplified BSD License (see license.txt)
6 */
7 
8 #ifndef BOTAN_DEFAULT_MODEXP_H_
9 #define BOTAN_DEFAULT_MODEXP_H_
10 
11 #include <botan/pow_mod.h>
12 #include <botan/reducer.h>
13 #include <vector>
14 
15 namespace Botan {
16 
17 /**
18 * Fixed Window Exponentiator
19 */
21  {
22  public:
23  void set_exponent(const BigInt&) override;
24  void set_base(const BigInt&) override;
25  BigInt execute() const override;
26 
27  Modular_Exponentiator* copy() const override
28  { return new Fixed_Window_Exponentiator(*this); }
29 
31  private:
32  Modular_Reducer m_reducer;
33  BigInt m_exp;
34  size_t m_window_bits;
35  std::vector<BigInt> m_g;
36  Power_Mod::Usage_Hints m_hints;
37  };
38 
39 /**
40 * Montgomery Exponentiator
41 */
43  {
44  public:
45  void set_exponent(const BigInt&) override;
46  void set_base(const BigInt&) override;
47  BigInt execute() const override;
48 
49  Modular_Exponentiator* copy() const override
50  { return new Montgomery_Exponentiator(*this); }
51 
53  private:
54  BigInt m_exp, m_modulus, m_R_mod, m_R2_mod;
55  Modular_Reducer m_reducer;
56  word m_mod_prime;
57  size_t m_mod_words, m_exp_bits, m_window_bits;
58  Power_Mod::Usage_Hints m_hints;
59  std::vector<BigInt> m_g;
60  };
61 
62 }
63 
64 #endif
void set_base(const BigInt &) override
Definition: powm_fw.cpp:24
Fixed_Window_Exponentiator(const BigInt &, Power_Mod::Usage_Hints)
Definition: powm_fw.cpp:60
void set_exponent(const BigInt &) override
Definition: powm_fw.cpp:16
Modular_Exponentiator * copy() const override
Definition: def_powm.h:27
Definition: alg_id.cpp:13
Modular_Exponentiator * copy() const override
Definition: def_powm.h:49
BigInt execute() const override
Definition: powm_fw.cpp:39