summaryrefslogtreecommitdiff
path: root/modexppc.h
diff options
context:
space:
mode:
authorweidai <weidai@57ff6487-cd31-0410-9ec3-f628ee90f5f0>2002-10-04 17:31:41 +0000
committerweidai <weidai@57ff6487-cd31-0410-9ec3-f628ee90f5f0>2002-10-04 17:31:41 +0000
commitb21162cf8e06f40baa1f58be6a8c17435cebc34d (patch)
tree8b045309c238226c32a563b1df6b9c30a2f0e0b3 /modexppc.h
downloadcryptopp-b21162cf8e06f40baa1f58be6a8c17435cebc34d.tar.gz
Initial revision
git-svn-id: svn://svn.code.sf.net/p/cryptopp/code/trunk/c5@2 57ff6487-cd31-0410-9ec3-f628ee90f5f0
Diffstat (limited to 'modexppc.h')
-rw-r--r--modexppc.h32
1 files changed, 32 insertions, 0 deletions
diff --git a/modexppc.h b/modexppc.h
new file mode 100644
index 0000000..05cdaa6
--- /dev/null
+++ b/modexppc.h
@@ -0,0 +1,32 @@
+#ifndef CRYPTOPP_MODEXPPC_H
+#define CRYPTOPP_MODEXPPC_H
+
+#include "modarith.h"
+#include "eprecomp.h"
+#include "smartptr.h"
+#include "pubkey.h"
+
+NAMESPACE_BEGIN(CryptoPP)
+
+class ModExpPrecomputation : public DL_GroupPrecomputation<Integer>
+{
+public:
+ // DL_GroupPrecomputation
+ bool NeedConversions() const {return true;}
+ Element ConvertIn(const Element &v) const {return m_mr->ConvertIn(v);}
+ virtual Element ConvertOut(const Element &v) const {return m_mr->ConvertOut(v);}
+ const AbstractGroup<Element> & GetGroup() const {return m_mr->MultiplicativeGroup();}
+ Element BERDecodeElement(BufferedTransformation &bt) const {return Integer(bt);}
+ void DEREncodeElement(BufferedTransformation &bt, const Element &v) const {v.DEREncode(bt);}
+
+ // non-inherited
+ void SetModulus(const Integer &v) {m_mr.reset(new MontgomeryRepresentation(v));}
+ const Integer & GetModulus() const {return m_mr->GetModulus();}
+
+private:
+ value_ptr<MontgomeryRepresentation> m_mr;
+};
+
+NAMESPACE_END
+
+#endif