From 5179e463d5c7d3e542eb3797ddaf9cbfe176784a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20P=C3=A9gouri=C3=A9-Gonnard?= Date: Wed, 31 Oct 2012 19:37:54 +0100 Subject: [PATCH] Allowed point at infinity, supressed ecp_double() --- include/polarssl/ecp.h | 21 +++++---------------- library/ecp.c | 3 +++ 2 files changed, 8 insertions(+), 16 deletions(-) diff --git a/include/polarssl/ecp.h b/include/polarssl/ecp.h index d9e6ed635..e76cd9eb0 100644 --- a/include/polarssl/ecp.h +++ b/include/polarssl/ecp.h @@ -38,8 +38,9 @@ */ typedef struct { - mpi X; /*!< the point's X coordinate */ - mpi Y; /*!< the point's Y coordinate */ + char is_zero; /*!< true if point at infinity */ + mpi X; /*!< the point's X coordinate */ + mpi Y; /*!< the point's Y coordinate */ } ecp_point; @@ -156,18 +157,6 @@ extern "C" { int ecp_add( const ecp_group *grp, ecp_point *R, const ecp_point *P, const ecp_point *Q ); -/** - * \brief Duplication: R = 2 P - * - * \param grp ECP group - * \param R Destination point - * \param P Point to double - * - * \return 0 if successful, or an POLARSSL_ERR_ECP_XXX error code - */ -int ecp_double( const ecp_group *grp, ecp_point *R, - const ecp_point *P ); - /** * \brief Multiplication by an integer: R = m * P * @@ -178,8 +167,8 @@ int ecp_double( const ecp_group *grp, ecp_point *R, * * \return 0 if successful, or an POLARSSL_ERR_ECP_XXX error code */ -int ecp_multiply( const ecp_group *grp, ecp_point *R, - const mpi *m, const ecp_point *P ); +int ecp_mul( const ecp_group *grp, ecp_point *R, + const mpi *m, const ecp_point *P ); /** * \brief Free the components of a point diff --git a/library/ecp.c b/library/ecp.c index 7f157377f..2173e2484 100644 --- a/library/ecp.c +++ b/library/ecp.c @@ -44,6 +44,7 @@ void ecp_point_free( ecp_point *pt ) if( pt == NULL ) return; + pt->is_zero = 1; mpi_free( &( pt->X ) ); mpi_free( &( pt->Y ) ); } @@ -62,6 +63,8 @@ void ecp_group_free( ecp_group *grp ) ecp_point_free( &( grp->G ) ); } + + #if defined(POLARSSL_SELF_TEST) /*