aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/pubkey
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2020-12-20 09:55:13 -0500
committerJack Lloyd <[email protected]>2020-12-20 09:55:13 -0500
commit18fa2b9438547f5f3b73b47166d5665dbf82ddd2 (patch)
tree948c190c2b12cd8ecc7785636c229359dd20188a /src/lib/pubkey
parent8d3c1c9c5adf7bd3689fdf8464f73fd33628b2c3 (diff)
Compare also order and cofactor in EC_Group::operator==
Diffstat (limited to 'src/lib/pubkey')
-rw-r--r--src/lib/pubkey/ec_group/ec_group.cpp8
-rw-r--r--src/lib/pubkey/ec_group/ec_group.h12
2 files changed, 9 insertions, 11 deletions
diff --git a/src/lib/pubkey/ec_group/ec_group.cpp b/src/lib/pubkey/ec_group/ec_group.cpp
index 2e6739729..9eca26c45 100644
--- a/src/lib/pubkey/ec_group/ec_group.cpp
+++ b/src/lib/pubkey/ec_group/ec_group.cpp
@@ -668,15 +668,13 @@ bool EC_Group::operator==(const EC_Group& other) const
if(m_data == other.m_data)
return true; // same shared rep
- /*
- * No point comparing order/cofactor as they are uniquely determined
- * by the curve equation (p,a,b) and the base point.
- */
return (get_p() == other.get_p() &&
get_a() == other.get_a() &&
get_b() == other.get_b() &&
get_g_x() == other.get_g_x() &&
- get_g_y() == other.get_g_y());
+ get_g_y() == other.get_g_y() &&
+ get_order() == other.get_order() &&
+ get_cofactor() == other.get_cofactor());
}
bool EC_Group::verify_public_element(const PointGFp& point) const
diff --git a/src/lib/pubkey/ec_group/ec_group.h b/src/lib/pubkey/ec_group/ec_group.h
index 5f50edc9b..3c37a8d0e 100644
--- a/src/lib/pubkey/ec_group/ec_group.h
+++ b/src/lib/pubkey/ec_group/ec_group.h
@@ -192,6 +192,12 @@ class BOTAN_PUBLIC_API(2,0) EC_Group final
*/
const BigInt& get_order() const;
+ /**
+ * Return the cofactor
+ * @result the cofactor
+ */
+ const BigInt& get_cofactor() const;
+
/*
* Reduce x modulo the order
*/
@@ -218,12 +224,6 @@ class BOTAN_PUBLIC_API(2,0) EC_Group final
BigInt multiply_mod_order(const BigInt& x, const BigInt& y, const BigInt& z) const;
/**
- * Return the cofactor
- * @result the cofactor
- */
- const BigInt& get_cofactor() const;
-
- /**
* Check if y is a plausible point on the curve
*
* In particular, checks that it is a point on the curve, not infinity,