From 0a56c2c6984cf62cb6408c002a2ff1ab7b542138 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20P=C3=A9gouri=C3=A9-Gonnard?= Date: Fri, 17 Jan 2014 21:24:04 +0100 Subject: [PATCH] Fix bug in ecdh_calc_secret() Only affects curves with nbits != pbits (currently only secp224k1) --- library/ecdh.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/ecdh.c b/library/ecdh.c index 302531db8..ebc167674 100644 --- a/library/ecdh.c +++ b/library/ecdh.c @@ -246,7 +246,7 @@ int ecdh_calc_secret( ecdh_context *ctx, size_t *olen, if( mpi_size( &ctx->z ) > blen ) return( POLARSSL_ERR_ECP_BAD_INPUT_DATA ); - *olen = ctx->grp.nbits / 8 + ( ( ctx->grp.nbits % 8 ) != 0 ); + *olen = ctx->grp.pbits / 8 + ( ( ctx->grp.pbits % 8 ) != 0 ); return mpi_write_binary( &ctx->z, buf, *olen ); }