From 18fa2b9438547f5f3b73b47166d5665dbf82ddd2 Mon Sep 17 00:00:00 2001 From: Jack Lloyd Date: Sun, 20 Dec 2020 09:55:13 -0500 Subject: Compare also order and cofactor in EC_Group::operator== --- src/lib/pubkey/ec_group/ec_group.cpp | 8 +++----- src/lib/pubkey/ec_group/ec_group.h | 12 ++++++------ 2 files changed, 9 insertions(+), 11 deletions(-) (limited to 'src/lib/pubkey') 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 */ @@ -217,12 +223,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 * -- cgit v1.2.3