aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/pubkey
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/pubkey')
-rw-r--r--src/lib/pubkey/ec_group/ec_group.cpp21
-rw-r--r--src/lib/pubkey/ec_group/ec_group.h10
2 files changed, 20 insertions, 11 deletions
diff --git a/src/lib/pubkey/ec_group/ec_group.cpp b/src/lib/pubkey/ec_group/ec_group.cpp
index 978e59985..93747a166 100644
--- a/src/lib/pubkey/ec_group/ec_group.cpp
+++ b/src/lib/pubkey/ec_group/ec_group.cpp
@@ -270,17 +270,17 @@ const OID& EC_Group::get_curve_oid() const
PointGFp EC_Group::OS2ECP(const uint8_t bits[], size_t len) const
{
- return Botan::OS2ECP(bits, len, get_curve());
+ return Botan::OS2ECP(bits, len, data().m_curve);
}
PointGFp EC_Group::point(const BigInt& x, const BigInt& y) const
{
- return PointGFp(get_curve(), x, y);
+ return PointGFp(data().m_curve, x, y);
}
PointGFp EC_Group::zero_point() const
{
- return PointGFp(get_curve());
+ return PointGFp(data().m_curve);
}
std::vector<uint8_t>
@@ -333,6 +333,21 @@ std::string EC_Group::PEM_encode() const
return PEM_Code::encode(der, "EC PARAMETERS");
}
+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_base_point() == other.get_base_point());
+ }
+
bool EC_Group::verify_group(RandomNumberGenerator& rng,
bool) const
{
diff --git a/src/lib/pubkey/ec_group/ec_group.h b/src/lib/pubkey/ec_group/ec_group.h
index f1a3f8fff..0e6b57b5a 100644
--- a/src/lib/pubkey/ec_group/ec_group.h
+++ b/src/lib/pubkey/ec_group/ec_group.h
@@ -112,7 +112,7 @@ class BOTAN_PUBLIC_API(2,0) EC_Group final
* Return domain parameter curve
* @result domain parameter curve
*/
- const CurveGFp& BOTAN_DEPRECATED("Avoid CurveGFp") get_curve() const;
+ BOTAN_DEPRECATED("Avoid CurveGFp") const CurveGFp& get_curve() const;
/**
* Return the size of p in bits (same as get_p().bits())
@@ -196,13 +196,7 @@ class BOTAN_PUBLIC_API(2,0) EC_Group final
bool verify_group(RandomNumberGenerator& rng,
bool strong = false) const;
- bool operator==(const EC_Group& other) const
- {
- return ((get_curve() == other.get_curve()) &&
- (get_base_point() == other.get_base_point()) &&
- (get_order() == other.get_order()) &&
- (get_cofactor() == other.get_cofactor()));
- }
+ bool operator==(const EC_Group& other) const;
/**
* Return PEM representation of named EC group