aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/pubkey/ec_group
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/pubkey/ec_group')
-rw-r--r--src/lib/pubkey/ec_group/curve_gfp.h29
-rw-r--r--src/lib/pubkey/ec_group/point_gfp.cpp3
2 files changed, 19 insertions, 13 deletions
diff --git a/src/lib/pubkey/ec_group/curve_gfp.h b/src/lib/pubkey/ec_group/curve_gfp.h
index 865bb68f8..888f87d46 100644
--- a/src/lib/pubkey/ec_group/curve_gfp.h
+++ b/src/lib/pubkey/ec_group/curve_gfp.h
@@ -201,6 +201,22 @@ class BOTAN_UNSTABLE_API CurveGFp final
std::swap(m_repr, other.m_repr);
}
+ /**
+ * Equality operator
+ * @param lhs a curve
+ * @param rhs a curve
+ * @return true iff lhs is the same as rhs
+ */
+ inline bool operator==(const CurveGFp& other) const
+ {
+ if(m_repr.get() == other.m_repr.get())
+ return true;
+
+ return (get_p() == other.get_p()) &&
+ (get_a() == other.get_a()) &&
+ (get_b() == other.get_b());
+ }
+
private:
static std::shared_ptr<CurveGFp_Repr>
choose_repr(const BigInt& p, const BigInt& a, const BigInt& b);
@@ -208,19 +224,6 @@ class BOTAN_UNSTABLE_API CurveGFp final
std::shared_ptr<CurveGFp_Repr> m_repr;
};
-/**
-* Equality operator
-* @param lhs a curve
-* @param rhs a curve
-* @return true iff lhs is the same as rhs
-*/
-inline bool operator==(const CurveGFp& lhs, const CurveGFp& rhs)
- {
- return (lhs.get_p() == rhs.get_p()) &&
- (lhs.get_a() == rhs.get_a()) &&
- (lhs.get_b() == rhs.get_b());
- }
-
inline bool operator!=(const CurveGFp& lhs, const CurveGFp& rhs)
{
return !(lhs == rhs);
diff --git a/src/lib/pubkey/ec_group/point_gfp.cpp b/src/lib/pubkey/ec_group/point_gfp.cpp
index 8f53bb079..b1c921a51 100644
--- a/src/lib/pubkey/ec_group/point_gfp.cpp
+++ b/src/lib/pubkey/ec_group/point_gfp.cpp
@@ -87,6 +87,7 @@ inline bool all_zeros(const word x[], size_t len)
void PointGFp::add_affine(const PointGFp& rhs, std::vector<BigInt>& workspace)
{
+ BOTAN_ASSERT_NOMSG(m_curve == rhs.m_curve);
BOTAN_DEBUG_ASSERT(rhs.is_affine());
const size_t p_words = m_curve.get_p_words();
@@ -180,6 +181,8 @@ void PointGFp::add_affine(const word x_words[], size_t x_size,
// Point addition
void PointGFp::add(const PointGFp& rhs, std::vector<BigInt>& ws_bn)
{
+ BOTAN_ASSERT_NOMSG(m_curve == rhs.m_curve);
+
if(rhs.is_zero())
return;