Skip to content

Commit 52ff8e9

Browse files
committed
Fix ECDH secret export for Mongomery curves
We only switched to little endian for Curve25519, but all Montgomery curves require little endian byte order.
1 parent bf42408 commit 52ff8e9

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

library/ecdh.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -638,7 +638,7 @@ static int ecdh_calc_secret_internal( mbedtls_ecdh_context_mbed *ctx,
638638

639639
*olen = ctx->grp.pbits / 8 + ( ( ctx->grp.pbits % 8 ) != 0 );
640640

641-
if( ctx->grp.id == MBEDTLS_ECP_DP_CURVE25519 )
641+
if( mbedtls_ecp_get_type( &ctx->grp ) == MBEDTLS_ECP_TYPE_MONTGOMERY )
642642
return mbedtls_mpi_write_binary_le( &ctx->z, buf, *olen );
643643

644644
return mbedtls_mpi_write_binary( &ctx->z, buf, *olen );

0 commit comments

Comments
 (0)