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 /cipher/ecc-misc.c | |
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 'cipher/ecc-misc.c')
-rw-r--r-- | cipher/ecc-misc.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/cipher/ecc-misc.c b/cipher/ecc-misc.c index 5e06bef9..5c86121a 100644 --- a/cipher/ecc-misc.c +++ b/cipher/ecc-misc.c @@ -64,6 +64,25 @@ _gcry_ecc_curve_copy (elliptic_curve_t E) } +/* + * Return a description of the curve model. + */ +const char * +_gcry_ecc_model2str (enum gcry_mpi_ec_models model) +{ + const char *str = "?"; + switch (model) + { + case MPI_EC_WEIERSTRASS: str = "Weierstrass"; break; + case MPI_EC_MONTGOMERY: str = "Montgomery"; break; + case MPI_EC_TWISTEDEDWARDS: str = "Twisted Edwards"; break; + } + return str; +} + + + + gcry_mpi_t _gcry_ecc_ec2os (gcry_mpi_t x, gcry_mpi_t y, gcry_mpi_t p) { |