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/ec_group.cpp11
-rw-r--r--src/lib/pubkey/ec_group/ec_group.h5
2 files changed, 15 insertions, 1 deletions
diff --git a/src/lib/pubkey/ec_group/ec_group.cpp b/src/lib/pubkey/ec_group/ec_group.cpp
index a41a59b66..26af32a16 100644
--- a/src/lib/pubkey/ec_group/ec_group.cpp
+++ b/src/lib/pubkey/ec_group/ec_group.cpp
@@ -43,7 +43,8 @@ class EC_Group_Data final
m_base_mult(m_base_point, 5),
m_oid(oid),
m_p_bits(p.bits()),
- m_order_bits(order.bits())
+ m_order_bits(order.bits()),
+ m_a_is_minus_3(a == p - 3)
{
#if defined(BOTAN_HAS_SYSTEM_RNG)
m_base_mult.randomize(system_rng());
@@ -77,6 +78,8 @@ class EC_Group_Data final
const CurveGFp& curve() const { return m_curve; }
const PointGFp& base_point() const { return m_base_point; }
+ bool a_is_minus_3() const { return m_a_is_minus_3; }
+
BigInt mod_order(const BigInt& x) const { return m_mod_order.reduce(x); }
BigInt multiply_mod_order(const BigInt& x, const BigInt& y) const
@@ -101,6 +104,7 @@ class EC_Group_Data final
OID m_oid;
size_t m_p_bits;
size_t m_order_bits;
+ bool m_a_is_minus_3;
};
class EC_Group_Data_Map final
@@ -365,6 +369,11 @@ const CurveGFp& EC_Group::get_curve() const
return data().curve();
}
+bool EC_Group::a_is_minus_3() const
+ {
+ return data().a_is_minus_3();
+ }
+
size_t EC_Group::get_p_bits() const
{
return data().p_bits();
diff --git a/src/lib/pubkey/ec_group/ec_group.h b/src/lib/pubkey/ec_group/ec_group.h
index 0e5f352f2..16a6abe28 100644
--- a/src/lib/pubkey/ec_group/ec_group.h
+++ b/src/lib/pubkey/ec_group/ec_group.h
@@ -126,6 +126,11 @@ class BOTAN_PUBLIC_API(2,0) EC_Group final
BOTAN_DEPRECATED("Avoid CurveGFp") const CurveGFp& get_curve() const;
/**
+ * Return if a == -3 mod p
+ */
+ bool a_is_minus_3() const;
+
+ /**
* Return the size of p in bits (same as get_p().bits())
*/
size_t get_p_bits() const;