diff --git a/Filelist.txt b/Filelist.txt
index ffe00e56..57a5d48e 100644
--- a/Filelist.txt
+++ b/Filelist.txt
@@ -92,6 +92,7 @@ eccrypto.cpp
eccrypto.h
ecp.cpp
ecp.h
+ecpoint.h
elgamal.cpp
elgamal.h
emsa2.cpp
diff --git a/cryptdll.vcxproj b/cryptdll.vcxproj
index a353fe07..2dfcc36c 100644
--- a/cryptdll.vcxproj
+++ b/cryptdll.vcxproj
@@ -263,6 +263,7 @@
+
diff --git a/cryptdll.vcxproj.filters b/cryptdll.vcxproj.filters
index 7161f5f0..d3e59ffa 100644
--- a/cryptdll.vcxproj.filters
+++ b/cryptdll.vcxproj.filters
@@ -241,6 +241,9 @@
Header Files
+
+ Header Files
+
Header Files
diff --git a/cryptlib.vcxproj b/cryptlib.vcxproj
index e1c83be2..1dbe9b8b 100644
--- a/cryptlib.vcxproj
+++ b/cryptlib.vcxproj
@@ -374,6 +374,7 @@
+
diff --git a/cryptlib.vcxproj.filters b/cryptlib.vcxproj.filters
index bbfb85ca..25c1ee0d 100644
--- a/cryptlib.vcxproj.filters
+++ b/cryptlib.vcxproj.filters
@@ -513,6 +513,9 @@
Header Files
+
+ Header Files
+
Header Files
diff --git a/ec2n.h b/ec2n.h
index b300644f..ab3ceeee 100644
--- a/ec2n.h
+++ b/ec2n.h
@@ -12,38 +12,16 @@
#include "gf2n.h"
#include "integer.h"
#include "algebra.h"
+#include "ecpoint.h"
#include "eprecomp.h"
#include "smartptr.h"
#include "pubkey.h"
NAMESPACE_BEGIN(CryptoPP)
-//! \class EC2NPoint
-//! \brief Elliptical Curve Point over GF(2^n)
-struct CRYPTOPP_DLL EC2NPoint
-{
-#ifndef CRYPTOPP_MAINTAIN_BACKWARDS_COMPATIBILITY_562
- virtual ~EC2NPoint() {}
-#endif
-
- EC2NPoint() : identity(true) {}
- EC2NPoint(const PolynomialMod2 &x, const PolynomialMod2 &y)
- : x(x), y(y), identity(false) {}
-
- bool operator==(const EC2NPoint &t) const
- {return (identity && t.identity) || (!identity && !t.identity && x==t.x && y==t.y);}
- bool operator< (const EC2NPoint &t) const
- {return identity ? !t.identity : (!t.identity && (x;
-
//! \class EC2N
//! \brief Elliptic Curve over GF(2^n)
-class CRYPTOPP_DLL EC2N : public AbstractGroup
+class CRYPTOPP_DLL EC2N : public AbstractGroup, public EncodedPoint
{
public:
typedef GF2NP Field;
diff --git a/ecp.h b/ecp.h
index 471dc71c..93ab6267 100644
--- a/ecp.h
+++ b/ecp.h
@@ -10,43 +10,16 @@
#include "integer.h"
#include "algebra.h"
#include "modarith.h"
+#include "ecpoint.h"
#include "eprecomp.h"
#include "smartptr.h"
#include "pubkey.h"
NAMESPACE_BEGIN(CryptoPP)
-//! \class ECPPoint
-//! \brief Elliptical Curve Point over GF(p), where p is prime
-struct CRYPTOPP_DLL ECPPoint
-{
-#ifndef CRYPTOPP_MAINTAIN_BACKWARDS_COMPATIBILITY_562
- virtual ~ECPPoint() {}
-#endif
-
- //! \brief Construct an ECPPoint
- //! \details identity is set to true
- ECPPoint() : identity(true) {}
-
- //! \brief Construct an ECPPoint from coordinates
- //! \details identity is set to false
- ECPPoint(const Integer &x, const Integer &y)
- : x(x), y(y), identity(false) {}
-
- bool operator==(const ECPPoint &t) const
- {return (identity && t.identity) || (!identity && !t.identity && x==t.x && y==t.y);}
- bool operator< (const ECPPoint &t) const
- {return identity ? !t.identity : (!t.identity && (x;
-
//! \class ECP
//! \brief Elliptic Curve over GF(p), where p is prime
-class CRYPTOPP_DLL ECP : public AbstractGroup
+class CRYPTOPP_DLL ECP : public AbstractGroup, public EncodedPoint
{
public:
typedef ModularArithmetic Field;
diff --git a/ecpoint.h b/ecpoint.h
new file mode 100644
index 00000000..63d1195e
--- /dev/null
+++ b/ecpoint.h
@@ -0,0 +1,149 @@
+// ecpoint.h - written and placed in the public domain by Jeffrey Walton
+// Data structures moved from ecp.h and ec2n.h. Added EncodedPoint interface
+
+//! \file ecpoint.h
+//! \brief Classes for Elliptic Curve points
+//! \since Crypto++ 5.7
+
+#ifndef CRYPTOPP_ECPOINT_H
+#define CRYPTOPP_ECPOINT_H
+
+#include "cryptlib.h"
+#include "integer.h"
+#include "algebra.h"
+#include "gf2n.h"
+
+NAMESPACE_BEGIN(CryptoPP)
+
+//! \class ECPPoint
+//! \brief Elliptical Curve Point over GF(p), where p is prime
+//! \since Crypto++ 2.0
+struct CRYPTOPP_DLL ECPPoint
+{
+ virtual ~ECPPoint() {}
+
+ //! \brief Construct an ECPPoint
+ //! \details identity is set to true
+ ECPPoint() : identity(true) {}
+
+ //! \brief Construct an ECPPoint from coordinates
+ //! \details identity is set to false
+ ECPPoint(const Integer &x, const Integer &y)
+ : x(x), y(y), identity(false) {}
+
+ //! \brief Tests points for equality
+ //! \param t the other point
+ //! \returns true if the points are equal, false otherwise
+ bool operator==(const ECPPoint &t) const
+ {return (identity && t.identity) || (!identity && !t.identity && x==t.x && y==t.y);}
+
+ //! \brief Tests points for ordering
+ //! \param t the other point
+ //! \returns true if this point is less than other, false otherwise
+ bool operator< (const ECPPoint &t) const
+ {return identity ? !t.identity : (!t.identity && (x;
+
+//! \class EC2NPoint
+//! \brief Elliptical Curve Point over GF(2^n)
+//! \since Crypto++ 2.0
+struct CRYPTOPP_DLL EC2NPoint
+{
+ virtual ~EC2NPoint() {}
+
+ //! \brief Construct an EC2NPoint
+ //! \details identity is set to true
+ EC2NPoint() : identity(true) {}
+
+ //! \brief Construct an EC2NPoint from coordinates
+ //! \details identity is set to false
+ EC2NPoint(const PolynomialMod2 &x, const PolynomialMod2 &y)
+ : x(x), y(y), identity(false) {}
+
+ //! \brief Tests points for equality
+ //! \param t the other point
+ //! \returns true if the points are equal, false otherwise
+ bool operator==(const EC2NPoint &t) const
+ {return (identity && t.identity) || (!identity && !t.identity && x==t.x && y==t.y);}
+
+ //! \brief Tests points for ordering
+ //! \param t the other point
+ //! \returns true if this point is less than other, false otherwise
+ bool operator< (const EC2NPoint &t) const
+ {return identity ? !t.identity : (!t.identity && (x;
+
+//! \class EncodedPoint
+//! \brief Abstract class for encoding and decoding ellicptic curve points
+//! \tparam Point ellicptic curve point
+//! \details EncodedPoint is an interface for encoding and decoding elliptic curve points.
+//! The template parameter Point should be a class like ECP or EC2N.
+//! \since Crypto++ 5.7
+template
+class EncodedPoint
+{
+public:
+ virtual ~EncodedPoint() {}
+
+ //! \brief Decodes an elliptic curve point
+ //! \param P point which is decoded
+ //! \param bt source BufferedTransformation
+ //! \param len number of bytes to read from the BufferedTransformation
+ //! \returns true if a point was decoded, false otherwise
+ virtual bool DecodePoint(Point &P, BufferedTransformation &bt, size_t len) const =0;
+
+ //! \brief Decodes an elliptic curve point
+ //! \param P point which is decoded
+ //! \param encodedPoint byte array with the encoded point
+ //! \param len the size of the array
+ //! \returns true if a point was decoded, false otherwise
+ virtual bool DecodePoint(Point &P, const byte *encodedPoint, size_t len) const =0;
+
+ //! \brief Verifies points on elliptic curve
+ //! \param P point to verify
+ //! \returns true if the point is valid, false otherwise
+ virtual bool VerifyPoint(const Point &P) const =0;
+
+ //! \brief Determines encoded point size
+ //! \param compressed flag indicating if the point is compressed
+ //! \returns the minimum number of bytes required to encode the point
+ virtual unsigned int EncodedPointSize(bool compressed = false) const =0;
+
+ //! \brief Encodes an elliptic curve point
+ //! \param P point which is decoded
+ //! \param encodedPoint byte array for the encoded point
+ //! \param compressed flag indicating if the point is compressed
+ //! \details encodedPoint must be at least EncodedPointSize() in length
+ virtual void EncodePoint(byte *encodedPoint, const Point &P, bool compressed) const =0;
+
+ //! \brief Encodes an elliptic curve point
+ //! \param bt target BufferedTransformation
+ //! \param P point which is encoded
+ //! \param compressed flag indicating if the point is compressed
+ virtual void EncodePoint(BufferedTransformation &bt, const Point &P, bool compressed) const =0;
+
+ //! \brief BER Decodes an elliptic curve point
+ //! \param bt source BufferedTransformation
+ //! \returns the decoded elliptic curve point
+ virtual Point BERDecodePoint(BufferedTransformation &bt) const =0;
+
+ //! \brief DER Encodes an elliptic curve point
+ //! \param bt target BufferedTransformation
+ //! \param P point which is encoded
+ //! \param compressed flag indicating if the point is compressed
+ virtual void DEREncodePoint(BufferedTransformation &bt, const Point &P, bool compressed) const =0;
+};
+
+NAMESPACE_END
+
+#endif // CRYPTOPP_ECPOINT_H