monotone

monotone Mtn Source Tree

Root/botan/def_powm.h

1/*************************************************
2* Modular Exponentiation Header File *
3* (C) 1999-2007 The Botan Project *
4*************************************************/
5
6#ifndef BOTAN_DEFAULT_MODEXP_H__
7#define BOTAN_DEFAULT_MODEXP_H__
8
9#include <botan/pow_mod.h>
10#include <botan/reducer.h>
11#include <vector>
12
13namespace Botan {
14
15/*************************************************
16* Fixed Window Exponentiator *
17*************************************************/
18class Fixed_Window_Exponentiator : public Modular_Exponentiator
19 {
20 public:
21 void set_exponent(const BigInt&);
22 void set_base(const BigInt&);
23 BigInt execute() const;
24
25 Modular_Exponentiator* copy() const
26 { return new Fixed_Window_Exponentiator(*this); }
27
28 Fixed_Window_Exponentiator(const BigInt&, Power_Mod::Usage_Hints);
29 private:
30 Modular_Reducer reducer;
31 BigInt exp;
32 u32bit window_bits;
33 std::vector<BigInt> g;
34 Power_Mod::Usage_Hints hints;
35 };
36
37/*************************************************
38* Montgomery Exponentiator *
39*************************************************/
40class Montgomery_Exponentiator : public Modular_Exponentiator
41 {
42 public:
43 void set_exponent(const BigInt&);
44 void set_base(const BigInt&);
45 BigInt execute() const;
46
47 Modular_Exponentiator* copy() const
48 { return new Montgomery_Exponentiator(*this); }
49
50 Montgomery_Exponentiator(const BigInt&, Power_Mod::Usage_Hints);
51 private:
52 BigInt exp, modulus;
53 BigInt R2, R_mod;
54 std::vector<BigInt> g;
55 word mod_prime;
56 u32bit mod_words, exp_bits, window_bits;
57 Power_Mod::Usage_Hints hints;
58 };
59
60}
61
62#endif

Archive Download this file

Branches

Tags

Quick Links:     www.monotone.ca    -     Downloads    -     Documentation    -     Wiki    -     Code Forge    -     Build Status