From c83e418149d9f410c550d68c6b7ea2e432f5c461 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20P=C3=A9gouri=C3=A9-Gonnard?= Date: Tue, 17 Sep 2013 10:48:41 +0200 Subject: [PATCH] Prepare for ECDH point blinding just in case --- include/polarssl/ecdh.h | 3 +++ library/ecdh.c | 10 ++++------ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/include/polarssl/ecdh.h b/include/polarssl/ecdh.h index 08de72cfc..0fa2dfae1 100644 --- a/include/polarssl/ecdh.h +++ b/include/polarssl/ecdh.h @@ -44,6 +44,9 @@ typedef struct ecp_point Qp; /*!< peer's public value */ mpi z; /*!< shared secret */ int point_format; /*!< format for point export */ + ecp_point Vi; /*!< blinding value (for later) */ + ecp_point Vf; /*!< un-blinding value (for later) */ + mpi _d; /*!< previous d */ } ecdh_context; diff --git a/library/ecdh.c b/library/ecdh.c index 8ef02f54b..050f99dfc 100644 --- a/library/ecdh.c +++ b/library/ecdh.c @@ -85,12 +85,7 @@ cleanup: */ void ecdh_init( ecdh_context *ctx ) { - ecp_group_init( &ctx->grp ); - mpi_init ( &ctx->d ); - ecp_point_init( &ctx->Q ); - ecp_point_init( &ctx->Qp ); - mpi_init ( &ctx->z ); - ctx->point_format = POLARSSL_ECP_PF_UNCOMPRESSED; + memset( ctx, 0, sizeof( ecdh_context ) ); } /* @@ -106,6 +101,9 @@ void ecdh_free( ecdh_context *ctx ) ecp_point_free( &ctx->Q ); ecp_point_free( &ctx->Qp ); mpi_free ( &ctx->z ); + ecp_point_free( &ctx->Vi ); + ecp_point_free( &ctx->Vf ); + mpi_free ( &ctx->_d ); } /*