diff options
author | Werner Koch <wk@gnupg.org> | 2013-10-17 10:45:14 +0200 |
---|---|---|
committer | Werner Koch <wk@gnupg.org> | 2013-10-17 10:46:08 +0200 |
commit | b22417158c50ec3a0b2ff55b4ade063b42a87e8f (patch) | |
tree | 4c1f4b0f1e3d379762236cb1080d002141134e0a /mpi/ec.c | |
parent | f9371c026aad09ff48746d22c8333746c886e773 (diff) | |
download | libgcrypt-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.c | 19 |
1 files changed, 17 insertions, 2 deletions
@@ -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", |