summaryrefslogtreecommitdiff
path: root/cipher/ecc-common.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 /cipher/ecc-common.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 'cipher/ecc-common.h')
-rw-r--r--cipher/ecc-common.h5
1 files changed, 4 insertions, 1 deletions
diff --git a/cipher/ecc-common.h b/cipher/ecc-common.h
index 94da73e1..614baae0 100644
--- a/cipher/ecc-common.h
+++ b/cipher/ecc-common.h
@@ -23,9 +23,11 @@
/* Definition of a curve. */
typedef struct
{
+ enum gcry_mpi_ec_models model;/* The model descrinbing this curve. */
gcry_mpi_t p; /* Prime specifying the field GF(p). */
gcry_mpi_t a; /* First coefficient of the Weierstrass equation. */
- gcry_mpi_t b; /* Second coefficient of the Weierstrass equation. */
+ gcry_mpi_t b; /* Second coefficient of the Weierstrass equation.
+ or d as used by Twisted Edwards curves. */
mpi_point_struct G; /* Base point (generator). */
gcry_mpi_t n; /* Order of G. */
const char *name; /* Name of the curve or NULL. */
@@ -73,6 +75,7 @@ gcry_sexp_t _gcry_ecc_get_param_sexp (const char *name);
/*-- ecc-misc.c --*/
void _gcry_ecc_curve_free (elliptic_curve_t *E);
elliptic_curve_t _gcry_ecc_curve_copy (elliptic_curve_t E);
+const char *_gcry_ecc_model2str (enum gcry_mpi_ec_models model);
gcry_mpi_t _gcry_ecc_ec2os (gcry_mpi_t x, gcry_mpi_t y, gcry_mpi_t p);
gcry_error_t _gcry_ecc_os2ec (mpi_point_t result, gcry_mpi_t value);