summaryrefslogtreecommitdiff
path: root/mpi/ec.c
diff options
context:
space:
mode:
authorWerner Koch <wk@gnupg.org>2013-10-17 10:45:14 +0200
committerWerner Koch <wk@gnupg.org>2013-10-17 10:46:08 +0200
commitb22417158c50ec3a0b2ff55b4ade063b42a87e8f (patch)
tree4c1f4b0f1e3d379762236cb1080d002141134e0a /mpi/ec.c
parentf9371c026aad09ff48746d22c8333746c886e773 (diff)
downloadlibgcrypt-b22417158c50ec3a0b2ff55b4ade063b42a87e8f.tar.gz
ecc: Support Weierstrass curves in gcry_mpi_ec_curve_point.
* mpi/ec.c (_gcry_mpi_ec_curve_point): Support MPI_EC_WEIERSTRASS.
Diffstat (limited to 'mpi/ec.c')
-rw-r--r--mpi/ec.c19
1 files changed, 17 insertions, 2 deletions
diff --git a/mpi/ec.c b/mpi/ec.c
index 889df8ec..39ab5ebe 100644
--- a/mpi/ec.c
+++ b/mpi/ec.c
@@ -1216,8 +1216,23 @@ _gcry_mpi_ec_curve_point (gcry_mpi_point_t point, mpi_ec_t ctx)
switch (ctx->model)
{
case MPI_EC_WEIERSTRASS:
- log_fatal ("%s: %s not yet supported\n",
- "_gcry_mpi_ec_curve_point", "Weierstrass");
+ {
+ gcry_mpi_t xx = mpi_new (0);
+
+ /* y^2 == x^3 + a·x^2 + b */
+ ec_pow2 (y, y, ctx);
+
+ ec_pow2 (xx, x, ctx);
+ ec_mulm (w, ctx->a, xx, ctx);
+ ec_addm (w, w, ctx->b, ctx);
+ ec_mulm (xx, xx, x, ctx);
+ ec_addm (w, w, xx, ctx);
+
+ if (!mpi_cmp (y, w))
+ res = 1;
+
+ gcry_mpi_release (xx);
+ }
break;
case MPI_EC_MONTGOMERY:
log_fatal ("%s: %s not yet supported\n",