aboutsummaryrefslogtreecommitdiffstats
path: root/src/math/def_powm.h
diff options
context:
space:
mode:
authorlloyd <[email protected]>2008-09-29 18:12:16 +0000
committerlloyd <[email protected]>2008-09-29 18:12:16 +0000
commit0d8e9744ef02aba33ddd89c93194ce526f6ff6ee (patch)
treee60064db23397f9a9dc3b847f9c4199be7c7ca0d /src/math/def_powm.h
parent26abd45c61294aacdd59fa4763ff1cd78aefbc7c (diff)
Put only the implementation of BigInt in src/bigint, mathematical functions
on top of BigInt go to src/math. Some prototypes were moved in order to complete the split, in particular random_integer() is now a static member of BigInt instead of being a global function, and divide() is in divide.h instead of numthry.h
Diffstat (limited to 'src/math/def_powm.h')
-rw-r--r--src/math/def_powm.h62
1 files changed, 62 insertions, 0 deletions
diff --git a/src/math/def_powm.h b/src/math/def_powm.h
new file mode 100644
index 000000000..c91ff002c
--- /dev/null
+++ b/src/math/def_powm.h
@@ -0,0 +1,62 @@
+/*************************************************
+* Modular Exponentiation Header File *
+* (C) 1999-2007 Jack Lloyd *
+*************************************************/
+
+#ifndef BOTAN_DEFAULT_MODEXP_H__
+#define BOTAN_DEFAULT_MODEXP_H__
+
+#include <botan/pow_mod.h>
+#include <botan/reducer.h>
+#include <vector>
+
+namespace Botan {
+
+/*************************************************
+* Fixed Window Exponentiator *
+*************************************************/
+class BOTAN_DLL Fixed_Window_Exponentiator : public Modular_Exponentiator
+ {
+ public:
+ void set_exponent(const BigInt&);
+ void set_base(const BigInt&);
+ BigInt execute() const;
+
+ Modular_Exponentiator* copy() const
+ { return new Fixed_Window_Exponentiator(*this); }
+
+ Fixed_Window_Exponentiator(const BigInt&, Power_Mod::Usage_Hints);
+ private:
+ Modular_Reducer reducer;
+ BigInt exp;
+ u32bit window_bits;
+ std::vector<BigInt> g;
+ Power_Mod::Usage_Hints hints;
+ };
+
+/*************************************************
+* Montgomery Exponentiator *
+*************************************************/
+class BOTAN_DLL Montgomery_Exponentiator : public Modular_Exponentiator
+ {
+ public:
+ void set_exponent(const BigInt&);
+ void set_base(const BigInt&);
+ BigInt execute() const;
+
+ Modular_Exponentiator* copy() const
+ { return new Montgomery_Exponentiator(*this); }
+
+ Montgomery_Exponentiator(const BigInt&, Power_Mod::Usage_Hints);
+ private:
+ BigInt exp, modulus;
+ BigInt R2, R_mod;
+ std::vector<BigInt> g;
+ word mod_prime;
+ u32bit mod_words, exp_bits, window_bits;
+ Power_Mod::Usage_Hints hints;
+ };
+
+}
+
+#endif