mpi: Add functions to manipulate an EC context.
authorWerner Koch <wk@gnupg.org>
Fri, 15 Mar 2013 13:43:19 +0000 (14:43 +0100)
committerWerner Koch <wk@gnupg.org>
Fri, 15 Mar 2013 13:53:42 +0000 (14:53 +0100)
commit229f3219f80c9369ed9624242c0436ae6d293201
tree1eaa99a11af69b72dc6c96d1222c4d1ffb0c4228
parente005629bd7bebb3e13945645c6e1230b44ab16a2
mpi: Add functions to manipulate an EC context.

* src/gcrypt.h.in (gcry_mpi_ec_p_new): Remove.
(gcry_mpi_ec_new): New.
(gcry_mpi_ec_get_mpi): New.
(gcry_mpi_ec_get_point): New.
(gcry_mpi_ec_set_mpi): New.
(gcry_mpi_ec_set_point): New.
* src/visibility.c (gcry_mpi_ec_p_new): Remove.
* mpi/ec.c (_gcry_mpi_ec_p_new): Make it an internal function and
change to return an error code.
(_gcry_mpi_ec_get_mpi): New.
(_gcry_mpi_ec_get_point): New.
(_gcry_mpi_ec_set_mpi): New.
(_gcry_mpi_ec_set_point): New.
* src/mpi.h: Add new prototypes.
* src/ec-context.h: New.
* mpi/ec.c: Include that header.
(mpi_ec_ctx_s): Move to ec-context.h, add new fields, and put some
fields into an inner struct.
(point_copy): New.
* cipher/ecc.c (fill_in_curve): Allow passing NULL for R_NBITS.
(mpi_from_keyparam, point_from_keyparam): New.
(_gcry_mpi_ec_new): New.

* tests/t-mpi-point.c (test-curve): New.
(ec_p_new): New.  Use it instead of the removed gcry_mpi_ec_p_new.
(get_and_cmp_mpi, get_and_cmp_point): New.
(context_param): New test.
(basic_ec_math_simplified): New test.
(main): Call new tests.

* src/context.c (_gcry_ctx_get_pointer): Check for a NULL CTX.
--

gcry_mpi_ec_p_new() was a specialized version of the more general new
gcry_mpi_ec_new().  It was added to master only a few days ago, thus
there should be no problem to remove it.  A replacement can easily be
written (cf. t-mpi-point.c).

Note that gcry_mpi_ec_set_mpi and gcry_mpi_ec_set_point have not yet
been tested.
14 files changed:
NEWS
cipher/ecc.c
doc/gcrypt.texi
mpi/ec.c
src/Makefile.am
src/context.c
src/ec-context.h [new file with mode: 0644]
src/gcrypt.h.in
src/libgcrypt.def
src/libgcrypt.vers
src/mpi.h
src/visibility.c
src/visibility.h
tests/t-mpi-point.c