summaryrefslogtreecommitdiff
path: root/src/mpi.h
diff options
context:
space:
mode:
authorWerner Koch <wk@gnupg.org>2013-09-03 12:01:15 +0200
committerWerner Koch <wk@gnupg.org>2013-09-04 11:25:06 +0200
commitc26be7a337d0bf98193bc58e043209e46d0769bb (patch)
tree71f15800908d68666f80fee8c42a7b344f5be178 /src/mpi.h
parent8698530b2f9ef95542f1dd550961de7af86cc256 (diff)
downloadlibgcrypt-c26be7a337d0bf98193bc58e043209e46d0769bb.tar.gz
Prepare support for non-Weierstrass EC equations.
* src/mpi.h (gcry_mpi_ec_models): New. * src/ec-context.h (mpi_ec_ctx_s): Add MODEL. * cipher/ecc-common.h (elliptic_curve_t): Ditto. * cipher/ecc-curves.c (ecc_domain_parms_t): Ditto. (domain_parms): Mark als as Weierstrass. (_gcry_ecc_fill_in_curve): Check model. (_gcry_ecc_get_curve): Set model to Weierstrass. * cipher/ecc-misc.c (_gcry_ecc_model2str): New. * cipher/ecc.c (generate_key, ecc_generate_ext): Print model in the debug output. * mpi/ec.c (_gcry_mpi_ec_dup_point): Switch depending on model. Factor code out to ... (dup_point_weierstrass): new. (dup_point_montgomery, dup_point_twistededwards): New stub functions. (_gcry_mpi_ec_add_points): Switch depending on model. Factor code out to ... (add_points_weierstrass): new. (add_points_montgomery, add_points_twistededwards): New stub functions. * tests/Makefile.am (TESTS): Reorder tests. Signed-off-by: Werner Koch <wk@gnupg.org>
Diffstat (limited to 'src/mpi.h')
-rw-r--r--src/mpi.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/mpi.h b/src/mpi.h
index fd265bf2..0114dba7 100644
--- a/src/mpi.h
+++ b/src/mpi.h
@@ -272,6 +272,18 @@ void _gcry_mpi_get_point (gcry_mpi_t x, gcry_mpi_t y, gcry_mpi_t z,
void _gcry_mpi_snatch_point (gcry_mpi_t x, gcry_mpi_t y, gcry_mpi_t z,
mpi_point_t point);
+/* Models describing an elliptic curve. */
+enum gcry_mpi_ec_models
+ {
+
+ MPI_EC_WEIERSTRASS = 0,
+ MPI_EC_MONTGOMERY,
+ MPI_EC_TWISTEDEDWARDS
+ /* The equation for Twisted Edwards curves is
+ ax^2 + y^2 = 1 + bx^2y^2
+ Note that we use 'b' instead of the commonly used 'd'. */
+ };
+
/* Context used with elliptic curve functions. */
struct mpi_ec_ctx_s;
typedef struct mpi_ec_ctx_s *mpi_ec_t;