From fdbcf2dcc45094f6eee2fe2f17ee287118dc6cfd Mon Sep 17 00:00:00 2001 From: Jack Lloyd Date: Wed, 21 Feb 2018 12:36:53 -0500 Subject: Expose EC_Group::a_is_minus_3 --- src/lib/pubkey/ec_group/ec_group.cpp | 11 ++++++++++- src/lib/pubkey/ec_group/ec_group.h | 5 +++++ 2 files changed, 15 insertions(+), 1 deletion(-) (limited to 'src/lib/pubkey/ec_group') 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 @@ -125,6 +125,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()) */ -- cgit v1.2.3