diff --git a/ChangeLog b/ChangeLog index 005573d81..0f9c81b78 100644 --- a/ChangeLog +++ b/ChangeLog @@ -5,6 +5,7 @@ mbed TLS ChangeLog (Sorted per branch, date) Bugfix * Run the AD too long test only if MBEDTLS_CCM_ALT is not defined. Raised as a comment in #1996. + * Fix returning the value 1 when mbedtls_ecdsa_genkey failed. = mbed TLS 2.7.9 branch released 2018-12-21 diff --git a/library/ecdsa.c b/library/ecdsa.c index 17a88bdd2..ab75620b3 100644 --- a/library/ecdsa.c +++ b/library/ecdsa.c @@ -420,8 +420,13 @@ cleanup: int mbedtls_ecdsa_genkey( mbedtls_ecdsa_context *ctx, mbedtls_ecp_group_id gid, int (*f_rng)(void *, unsigned char *, size_t), void *p_rng ) { - return( mbedtls_ecp_group_load( &ctx->grp, gid ) || - mbedtls_ecp_gen_keypair( &ctx->grp, &ctx->d, &ctx->Q, f_rng, p_rng ) ); + int ret = 0; + ret = mbedtls_ecp_group_load( &ctx->grp, gid ); + if( ret != 0 ) + return( ret ); + + return( mbedtls_ecp_gen_keypair( &ctx->grp, &ctx->d, + &ctx->Q, f_rng, p_rng ) ); } #endif /* MBEDTLS_ECDSA_GENKEY_ALT */