diff --git a/ChangeLog b/ChangeLog index f1291e855..9b1230e20 100644 --- a/ChangeLog +++ b/ChangeLog @@ -23,6 +23,7 @@ Bugfix * Remove a duplicate #include in a sample program. Fixed by Masashi Honma #2326. * Remove the mbedtls namespacing from the header file, to fix a "file not found" build error. Fixed by Haijun Gu #2319. + * Fix returning the value 1 when mbedtls_ecdsa_genkey failed. Changes * Include configuration file in all header files that use configuration, diff --git a/library/ecdsa.c b/library/ecdsa.c index 1204ef994..dc19384d6 100644 --- a/library/ecdsa.c +++ b/library/ecdsa.c @@ -800,11 +800,16 @@ 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 ) { + int ret = 0; ECDSA_VALIDATE_RET( ctx != NULL ); ECDSA_VALIDATE_RET( f_rng != NULL ); - return( mbedtls_ecp_group_load( &ctx->grp, gid ) || - mbedtls_ecp_gen_keypair( &ctx->grp, &ctx->d, &ctx->Q, f_rng, p_rng ) ); + 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 */