diff options
author | Werner Koch <wk@gnupg.org> | 2013-09-03 12:01:15 +0200 |
---|---|---|
committer | Werner Koch <wk@gnupg.org> | 2013-09-04 11:25:06 +0200 |
commit | c26be7a337d0bf98193bc58e043209e46d0769bb (patch) | |
tree | 71f15800908d68666f80fee8c42a7b344f5be178 /src/mpi.h | |
parent | 8698530b2f9ef95542f1dd550961de7af86cc256 (diff) | |
download | libgcrypt-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.h | 12 |
1 files changed, 12 insertions, 0 deletions
@@ -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; |