diff options
author | NIIBE Yutaka <gniibe@fsij.org> | 2015-11-26 11:37:47 +0900 |
---|---|---|
committer | NIIBE Yutaka <gniibe@fsij.org> | 2015-11-26 11:37:47 +0900 |
commit | 3658afd09c3b03b4398aaa5748387220c93b1a94 (patch) | |
tree | 1e4f53d1ff6295d6604c344c4087ef6fc9431a23 /mpi | |
parent | 88e1358962e902ff1cbec8d53ba3eee46407851a (diff) | |
download | libgcrypt-3658afd09c3b03b4398aaa5748387220c93b1a94.tar.gz |
ecc: minor improvement of point multiplication.
* mpi/ec.c (_gcry_mpi_ec_mul_point): Move ec_subm out of the loop.
Diffstat (limited to 'mpi')
-rw-r--r-- | mpi/ec.c | 7 |
1 files changed, 4 insertions, 3 deletions
@@ -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); } } |