From c7aac417f2dc2a4935ea78271331cef46cd8b283 Mon Sep 17 00:00:00 2001 From: Ron Eldor Date: Mon, 17 Dec 2018 10:06:12 +0200 Subject: [PATCH 1/2] Return error code of underlying function. Return the error code if failed, instead of returning value `1`. If not failed, return the call of the underlying function, in `mbedtls_ecdsa_genkey()`. --- library/ecdsa.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) 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 */ From bdcb54ff205574a7f9ccff1e16f9d796e9879509 Mon Sep 17 00:00:00 2001 From: Ron Eldor Date: Mon, 17 Dec 2018 10:12:55 +0200 Subject: [PATCH 2/2] Add entry describing the bug fix Add entry describing the bug fix in `mbedtls_ecdsa_genkey()`. --- ChangeLog | 1 + 1 file changed, 1 insertion(+) diff --git a/ChangeLog b/ChangeLog index 8eab14b61..c8cba4a6d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -15,6 +15,7 @@ Bugfix * Add explicit integer to enumeration type casts to example program programs/pkey/gen_key which previously led to compilation failure on some toolchains. Reported by phoenixmcallister. Fixes #2170. + * Fix returning the value 1 when mbedtls_ecdsa_genkey failed. = mbed TLS 2.7.8 branch released 2018-11-30