/*************************************************
* Montgomery Reducer Header File                 *
* (C) 1999-2004 The Botan Project                *
*************************************************/

#ifndef BOTAN_MONTGOMERY_H__
#define BOTAN_MONTGOMERY_H__

#include <botan/reducer.h>

namespace Botan {

/*************************************************
* Montgomery Reducer                             *
*************************************************/
class MontgomeryReducer : public ModularReducer
   {
   public:
      BigInt reduce(const BigInt&) const;
      BigInt multiply(const BigInt&, const BigInt&) const;

      BigInt convert_in(const BigInt&) const;
      BigInt convert_out(const BigInt&) const;

      bool must_convert() const { return true; }

      MontgomeryReducer(const BigInt&);
   private:
      BigInt R, RR, N_inv;
      u32bit rbits;
      mutable BigInt t1, t2;
   };

}

#endif
