summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNIIBE Yutaka <gniibe@fsij.org>2015-11-26 11:37:47 +0900
committerNIIBE Yutaka <gniibe@fsij.org>2015-11-26 11:37:47 +0900
commit3658afd09c3b03b4398aaa5748387220c93b1a94 (patch)
tree1e4f53d1ff6295d6604c344c4087ef6fc9431a23
parent88e1358962e902ff1cbec8d53ba3eee46407851a (diff)
downloadlibgcrypt-3658afd09c3b03b4398aaa5748387220c93b1a94.tar.gz
ecc: minor improvement of point multiplication.
* mpi/ec.c (_gcry_mpi_ec_mul_point): Move ec_subm out of the loop.
-rw-r--r--mpi/ec.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/mpi/ec.c b/mpi/ec.c
index 4d59a7e5..40e09bed 100644
--- a/mpi/ec.c
+++ b/mpi/ec.c
@@ -1415,6 +1415,10 @@ _gcry_mpi_ec_mul_point (mpi_point_t result,
point_init (&p2);
point_init (&p1inv);
+ /* Invert point: y = p - y mod p */
+ point_set (&p1inv, &p1);
+ ec_subm (p1inv.y, ctx->p, p1inv.y, ctx);
+
for (i=loops-2; i > 0; i--)
{
_gcry_mpi_ec_dup_point (result, result, ctx);
@@ -1426,9 +1430,6 @@ _gcry_mpi_ec_mul_point (mpi_point_t result,
if (mpi_test_bit (h, i) == 0 && mpi_test_bit (k, i) == 1)
{
point_set (&p2, result);
- /* Invert point: y = p - y mod p */
- point_set (&p1inv, &p1);
- ec_subm (p1inv.y, ctx->p, p1inv.y, ctx);
_gcry_mpi_ec_add_points (result, &p2, &p1inv, ctx);
}
}