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.cpp5
-rw-r--r--src/lib/pubkey/ec_group/ec_group.h9
-rw-r--r--src/lib/pubkey/ecdsa/ecdsa.cpp2
-rw-r--r--src/lib/pubkey/ecgdsa/ecgdsa.cpp2
-rw-r--r--src/lib/pubkey/eckcdsa/eckcdsa.cpp2
-rw-r--r--src/lib/pubkey/gost_3410/gost_3410.cpp3
-rw-r--r--src/lib/pubkey/sm2/sm2.cpp2
7 files changed, 19 insertions, 6 deletions
diff --git a/src/lib/pubkey/ec_group/ec_group.cpp b/src/lib/pubkey/ec_group/ec_group.cpp
index beff90eec..4123994b5 100644
--- a/src/lib/pubkey/ec_group/ec_group.cpp
+++ b/src/lib/pubkey/ec_group/ec_group.cpp
@@ -429,6 +429,11 @@ PointGFp EC_Group::point(const BigInt& x, const BigInt& y) const
return PointGFp(data().curve(), x, y);
}
+PointGFp EC_Group::point_multiply(const BigInt& x, const PointGFp& pt, const BigInt& y) const
+ {
+ return multi_exponentiate(get_base_point(), x, pt, y);
+ }
+
PointGFp EC_Group::zero_point() const
{
return PointGFp(data().curve());
diff --git a/src/lib/pubkey/ec_group/ec_group.h b/src/lib/pubkey/ec_group/ec_group.h
index b4b0ec9b3..a60c71157 100644
--- a/src/lib/pubkey/ec_group/ec_group.h
+++ b/src/lib/pubkey/ec_group/ec_group.h
@@ -32,6 +32,9 @@ class EC_Group_Data_Map;
/**
* Class representing an elliptic curve
+*
+* The internal representation is stored in a shared_ptr, so copying an
+* EC_Group is inexpensive.
*/
class BOTAN_PUBLIC_API(2,0) EC_Group final
{
@@ -203,6 +206,12 @@ class BOTAN_PUBLIC_API(2,0) EC_Group final
PointGFp point(const BigInt& x, const BigInt& y) const;
/**
+ * Multi exponentiate
+ * @return base_point*x + pt*y
+ */
+ PointGFp point_multiply(const BigInt& x, const PointGFp& pt, const BigInt& y) const;
+
+ /**
* Return the zero (or infinite) point on this curve
*/
PointGFp zero_point() const;
diff --git a/src/lib/pubkey/ecdsa/ecdsa.cpp b/src/lib/pubkey/ecdsa/ecdsa.cpp
index 163936c08..12ccd9608 100644
--- a/src/lib/pubkey/ecdsa/ecdsa.cpp
+++ b/src/lib/pubkey/ecdsa/ecdsa.cpp
@@ -143,7 +143,7 @@ bool ECDSA_Verification_Operation::verify(const uint8_t msg[], size_t msg_len,
const BigInt u1 = m_group.multiply_mod_order(e, w);
const BigInt u2 = m_group.multiply_mod_order(r, w);
- const PointGFp R = multi_exponentiate(m_group.get_base_point(), u1, m_public_point, u2);
+ const PointGFp R = m_group.point_multiply(u1, m_public_point, u2);
if(R.is_zero())
return false;
diff --git a/src/lib/pubkey/ecgdsa/ecgdsa.cpp b/src/lib/pubkey/ecgdsa/ecgdsa.cpp
index 3685306c6..f8e5744d9 100644
--- a/src/lib/pubkey/ecgdsa/ecgdsa.cpp
+++ b/src/lib/pubkey/ecgdsa/ecgdsa.cpp
@@ -117,7 +117,7 @@ bool ECGDSA_Verification_Operation::verify(const uint8_t msg[], size_t msg_len,
const BigInt u1 = m_group.multiply_mod_order(e, w);
const BigInt u2 = m_group.multiply_mod_order(s, w);
- const PointGFp R = multi_exponentiate(m_group.get_base_point(), u1, m_public_point, u2);
+ const PointGFp R = m_group.point_multiply(u1, m_public_point, u2);
if(R.is_zero())
return false;
diff --git a/src/lib/pubkey/eckcdsa/eckcdsa.cpp b/src/lib/pubkey/eckcdsa/eckcdsa.cpp
index d6e0957f6..743d5ab95 100644
--- a/src/lib/pubkey/eckcdsa/eckcdsa.cpp
+++ b/src/lib/pubkey/eckcdsa/eckcdsa.cpp
@@ -171,7 +171,7 @@ bool ECKCDSA_Verification_Operation::verify(const uint8_t msg[], size_t,
BigInt w(r_xor_e.data(), r_xor_e.size());
w = m_group.mod_order(w);
- const PointGFp q = multi_exponentiate(m_group.get_base_point(), w, m_public_point, s);
+ const PointGFp q = m_group.point_multiply(w, m_public_point, s);
const BigInt q_x = q.get_affine_x();
secure_vector<uint8_t> c(q_x.bytes());
q_x.binary_encode(c.data());
diff --git a/src/lib/pubkey/gost_3410/gost_3410.cpp b/src/lib/pubkey/gost_3410/gost_3410.cpp
index 5d7c425d0..760e667aa 100644
--- a/src/lib/pubkey/gost_3410/gost_3410.cpp
+++ b/src/lib/pubkey/gost_3410/gost_3410.cpp
@@ -194,8 +194,7 @@ bool GOST_3410_Verification_Operation::verify(const uint8_t msg[], size_t msg_le
const BigInt z1 = m_group.multiply_mod_order(s, v);
const BigInt z2 = m_group.multiply_mod_order(-r, v);
- PointGFp R = multi_exponentiate(m_group.get_base_point(), z1,
- m_public_point, z2);
+ const PointGFp R = m_group.point_multiply(z1, m_public_point, z2);
if(R.is_zero())
return false;
diff --git a/src/lib/pubkey/sm2/sm2.cpp b/src/lib/pubkey/sm2/sm2.cpp
index 05c8417ec..e2bc5d92d 100644
--- a/src/lib/pubkey/sm2/sm2.cpp
+++ b/src/lib/pubkey/sm2/sm2.cpp
@@ -179,7 +179,7 @@ bool SM2_Verification_Operation::is_valid_signature(const uint8_t sig[], size_t
if(t == 0)
return false;
- const PointGFp R = multi_exponentiate(m_group.get_base_point(), s, m_public_point, t);
+ const PointGFp R = m_group.point_multiply(s, m_public_point, t);
// ???
if(R.is_zero())