From a04efb8b899829598557a66fb9570cf770705a9c 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 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 */ From 5351afa5b11a08a513186801b241502cd5ba5ad9 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 | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ChangeLog b/ChangeLog index be28645d6..6a783f604 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,10 @@ mbed TLS ChangeLog (Sorted per branch, date) += mbed TLS x.xx.x branch released xxxx-xx-xx + +Bugfix + * Fix returning the value 1 when mbedtls_ecdsa_genkey failed. + = mbed TLS 2.16.0 branch released 2018-12-21 Features