aboutsummaryrefslogtreecommitdiffstats
path: root/src/math/numbertheory/reducer.h
blob: d234e0735aeec39d537e68014af07f5f3241bf9b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
/*
* Modular Reducer
* (C) 1999-2007 Jack Lloyd
*
* Distributed under the terms of the Botan license
*/

#ifndef BOTAN_MODARITH_H__
#define BOTAN_MODARITH_H__

#include <botan/bigint.h>

namespace Botan {

/*
* Modular Reducer
*/
class BOTAN_DLL Modular_Reducer
   {
   public:
      BigInt multiply(const BigInt&, const BigInt&) const;
      BigInt square(const BigInt&) const;
      BigInt reduce(const BigInt&) const;

      bool initialized() const { return (mod_words != 0); }

      Modular_Reducer() { mod_words = 0; }
      Modular_Reducer(const BigInt&);
   private:
      BigInt modulus, modulus_2, mu;
      u32bit mod_words, mod2_words, mu_words;
   };

}

#endif