From: Nicola Tuveri Date: Mon, 3 Oct 2016 22:30:54 +0000 (+0300) Subject: Handle EVP_PKEY_derive errors and fix coding style issues X-Git-Tag: OpenSSL_1_1_1-pre1~3019 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=dfdd45f72c03d19ba815a127cab1338eff8084e9;p=oweals%2Fopenssl.git Handle EVP_PKEY_derive errors and fix coding style issues Reviewed-by: Richard Levitte Reviewed-by: Rich Salz (Merged from https://github.com/openssl/openssl/pull/1658) --- diff --git a/apps/speed.c b/apps/speed.c index ebbd8e46d6..f40f9fa50c 100644 --- a/apps/speed.c +++ b/apps/speed.c @@ -1038,15 +1038,17 @@ static int ECDSA_verify_loop(void *args) /* ******************************************************************** */ static long ecdh_c[EC_NUM][1]; -static void ECDH_EVP_derive_key(unsigned char *derived_secret, +static int ECDH_EVP_derive_key(unsigned char *derived_secret, size_t *outlen, EVP_PKEY_CTX *ctx) { - if( !EVP_PKEY_derive(ctx, derived_secret, outlen) ) { - /* FIXME: handle errors */ - ; + int rt=1; + if ( (rt=EVP_PKEY_derive(ctx, derived_secret, outlen)) <= 0 ) { + BIO_printf(bio_err, "ECDH EVP_PKEY_derive failure: returned %d\n", rt); + ERR_print_errors(bio_err); + return rt; } - return; + return rt; } static int ECDH_EVP_derive_key_loop(void *args) @@ -1058,7 +1060,8 @@ static int ECDH_EVP_derive_key_loop(void *args) size_t *outlen = &(tempargs->outlen); for (count = 0; COND(ecdh_c[testnum][0]); count++) { - ECDH_EVP_derive_key(derived_secret, outlen, ctx); + if ( !ECDH_EVP_derive_key(derived_secret, outlen, ctx) ) + break; } return count; } @@ -2565,7 +2568,7 @@ int speed_main(int argc, char **argv) EVP_PKEY_CTX *pctx = NULL; EVP_PKEY *params = NULL; - if( /* Create the context for parameter generation */ + if ( /* Create the context for parameter generation */ !(pctx = EVP_PKEY_CTX_new_id(EVP_PKEY_EC, NULL)) || /* Initialise the parameter generation */ !EVP_PKEY_paramgen_init(pctx) ||