File indexing completed on 2025-01-18 09:55:05
0001 #ifndef CRYPTOPP_MODEXPPC_H
0002 #define CRYPTOPP_MODEXPPC_H
0003
0004 #include "cryptlib.h"
0005 #include "modarith.h"
0006 #include "integer.h"
0007 #include "algebra.h"
0008 #include "eprecomp.h"
0009 #include "smartptr.h"
0010 #include "pubkey.h"
0011
0012 #if CRYPTOPP_MSC_VERSION
0013 # pragma warning(push)
0014 # pragma warning(disable: 4231 4275)
0015 #endif
0016
0017 NAMESPACE_BEGIN(CryptoPP)
0018
0019 CRYPTOPP_DLL_TEMPLATE_CLASS DL_FixedBasePrecomputationImpl<Integer>;
0020
0021 class ModExpPrecomputation : public DL_GroupPrecomputation<Integer>
0022 {
0023 public:
0024 virtual ~ModExpPrecomputation() {}
0025
0026
0027 bool NeedConversions() const {return true;}
0028 Element ConvertIn(const Element &v) const {return m_mr->ConvertIn(v);}
0029 virtual Element ConvertOut(const Element &v) const {return m_mr->ConvertOut(v);}
0030 const AbstractGroup<Element> & GetGroup() const {return m_mr->MultiplicativeGroup();}
0031 Element BERDecodeElement(BufferedTransformation &bt) const {return Integer(bt);}
0032 void DEREncodeElement(BufferedTransformation &bt, const Element &v) const {v.DEREncode(bt);}
0033
0034
0035 void SetModulus(const Integer &v) {m_mr.reset(new MontgomeryRepresentation(v));}
0036 const Integer & GetModulus() const {return m_mr->GetModulus();}
0037
0038 private:
0039 value_ptr<MontgomeryRepresentation> m_mr;
0040 };
0041
0042 NAMESPACE_END
0043
0044 #if CRYPTOPP_MSC_VERSION
0045 # pragma warning(pop)
0046 #endif
0047
0048 #endif