summaryrefslogtreecommitdiff
path: root/mpi
diff options
context:
space:
mode:
Diffstat (limited to 'mpi')
-rw-r--r--mpi/ec.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/mpi/ec.c b/mpi/ec.c
index 29b2ce30..e25d9d8a 100644
--- a/mpi/ec.c
+++ b/mpi/ec.c
@@ -1117,6 +1117,15 @@ _gcry_mpi_ec_get_affine (gcry_mpi_t x, gcry_mpi_t y, mpi_point_t point,
{
gcry_mpi_t z1, z2, z3;
+ if (!mpi_cmp_ui (point->z, 1))
+ {
+ if (x)
+ mpi_set (x, point->x);
+ if (y)
+ mpi_set (y, point->y);
+ return 0;
+ }
+
z1 = mpi_new (0);
z2 = mpi_new (0);
ec_invm (z1, point->z, ctx); /* z1 = z^(-1) mod p */
@@ -1156,6 +1165,15 @@ _gcry_mpi_ec_get_affine (gcry_mpi_t x, gcry_mpi_t y, mpi_point_t point,
{
gcry_mpi_t z;
+ if (!mpi_cmp_ui (point->z, 1))
+ {
+ if (x)
+ mpi_set (x, point->x);
+ if (y)
+ mpi_set (y, point->y);
+ return 0;
+ }
+
z = mpi_new (0);
ec_invm (z, point->z, ctx);