aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2018-04-11 09:31:47 -0400
committerJack Lloyd <[email protected]>2018-04-11 09:31:47 -0400
commit95f1a86b78bf27df37a94a129cec557b8daf08c5 (patch)
tree0498ceff23ac75a1cdeff9d5666524ee8a1e93cc /src/lib
parent5f2ac554842c97ac15b46c94ee840c3129682c71 (diff)
Add EC_Group::a_is_zero
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/pubkey/ec_group/ec_group.cpp10
-rw-r--r--src/lib/pubkey/ec_group/ec_group.h5
2 files changed, 14 insertions, 1 deletions
diff --git a/src/lib/pubkey/ec_group/ec_group.cpp b/src/lib/pubkey/ec_group/ec_group.cpp
index 1fb762e4b..d5a94c90c 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_oid(oid),
m_p_bits(p.bits()),
m_order_bits(order.bits()),
- m_a_is_minus_3(a == p - 3)
+ m_a_is_minus_3(a == p - 3),
+ m_a_is_zero(a.is_zero())
{
}
@@ -79,6 +80,7 @@ class EC_Group_Data final
const PointGFp& base_point() const { return m_base_point; }
bool a_is_minus_3() const { return m_a_is_minus_3; }
+ bool a_is_zero() const { return m_a_is_zero; }
BigInt mod_order(const BigInt& x) const { return m_mod_order.reduce(x); }
@@ -108,6 +110,7 @@ class EC_Group_Data final
size_t m_p_bits;
size_t m_order_bits;
bool m_a_is_minus_3;
+ bool m_a_is_zero;
};
class EC_Group_Data_Map final
@@ -399,6 +402,11 @@ bool EC_Group::a_is_minus_3() const
return data().a_is_minus_3();
}
+bool EC_Group::a_is_zero() const
+ {
+ return data().a_is_zero();
+ }
+
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 031e5cc34..8bb1a3044 100644
--- a/src/lib/pubkey/ec_group/ec_group.h
+++ b/src/lib/pubkey/ec_group/ec_group.h
@@ -132,6 +132,11 @@ class BOTAN_PUBLIC_API(2,0) EC_Group final
bool a_is_minus_3() const;
/**
+ * Return if a == 0 mod p
+ */
+ bool a_is_zero() const;
+
+ /**
* Return the size of p in bits (same as get_p().bits())
*/
size_t get_p_bits() const;