monotone

monotone Mtn Source Tree

Root/botan/mod_exp.h

1/*************************************************
2* Modular Exponentiation Header File *
3* (C) 1999-2005 The Botan Project *
4*************************************************/
5
6#ifndef BOTAN_MODULAR_EXP_H__
7#define BOTAN_MODULAR_EXP_H__
8
9#include <botan/bigint.h>
10#include <botan/reducer.h>
11#include <vector>
12
13namespace Botan {
14
15/*************************************************
16* Fixed Exponent Exponentiation *
17*************************************************/
18class FixedExponent_Exp
19 {
20 public:
21 BigInt operator() (const BigInt& n) const { return power_mod(n); }
22 BigInt reduce(const BigInt&) const;
23 BigInt power_mod(const BigInt&) const;
24
25 const BigInt& get_exponent() const;
26 const BigInt& get_modulus() const;
27
28 bool initialized() const { return (reducer != 0); }
29
30 FixedExponent_Exp& operator=(const FixedExponent_Exp&);
31
32 FixedExponent_Exp() { reducer = 0; }
33 FixedExponent_Exp(const BigInt&, const BigInt&);
34 FixedExponent_Exp(const FixedExponent_Exp&);
35 ~FixedExponent_Exp() { delete reducer; }
36 private:
37 void init_check() const;
38 ModularReducer* reducer;
39 BigInt exponent;
40 };
41
42/*************************************************
43* Fixed Base Exponentiation *
44*************************************************/
45class FixedBase_Exp
46 {
47 public:
48 BigInt operator() (const BigInt& n) const { return power_mod(n); }
49 BigInt reduce(const BigInt& n) const;
50 BigInt power_mod(const BigInt&) const;
51
52 const BigInt& get_base() const;
53 const BigInt& get_modulus() const;
54
55 bool initialized() const { return (reducer != 0); }
56
57 FixedBase_Exp& operator=(const FixedBase_Exp&);
58
59 FixedBase_Exp() { reducer = 0; }
60 FixedBase_Exp(const BigInt&, const BigInt&);
61 FixedBase_Exp(const FixedBase_Exp&);
62 ~FixedBase_Exp() { delete reducer; }
63 private:
64 void init_check() const;
65 ModularReducer* reducer;
66 std::vector<BigInt> g;
67 };
68
69}
70
71#endif

Archive Download this file

Branches

Tags

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