summaryrefslogtreecommitdiff
path: root/src/context.c
diff options
context:
space:
mode:
authorWerner Koch <wk@gnupg.org>2013-03-15 14:43:19 +0100
committerWerner Koch <wk@gnupg.org>2013-03-15 14:53:42 +0100
commit229f3219f80c9369ed9624242c0436ae6d293201 (patch)
tree1eaa99a11af69b72dc6c96d1222c4d1ffb0c4228 /src/context.c
parente005629bd7bebb3e13945645c6e1230b44ab16a2 (diff)
downloadlibgcrypt-229f3219f80c9369ed9624242c0436ae6d293201.tar.gz
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.
Diffstat (limited to 'src/context.c')
-rw-r--r--src/context.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/context.c b/src/context.c
index ae991c52..2c02c9c4 100644
--- a/src/context.c
+++ b/src/context.c
@@ -86,7 +86,7 @@ _gcry_ctx_alloc (int type, size_t length, void (*deinit)(void*))
void *
_gcry_ctx_get_pointer (gcry_ctx_t ctx, int type)
{
- if (memcmp (ctx->magic, CTX_MAGIC, CTX_MAGIC_LEN))
+ if (!ctx || memcmp (ctx->magic, CTX_MAGIC, CTX_MAGIC_LEN))
log_fatal ("bad pointer %p passed to _gcry_ctx_get_pointer\n", ctx);
if (ctx->type != type)
log_fatal ("wrong context type %d request for context %p of type %d\n",