From d07128a584f623b87d51ddacd9a2b0d453b0717b Mon Sep 17 00:00:00 2001 From: tb Date: Sat, 1 Jul 2023 14:50:39 +0000 Subject: [PATCH] Simplify handling of ret ok jsing --- lib/libcrypto/ecdh/ech_key.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/libcrypto/ecdh/ech_key.c b/lib/libcrypto/ecdh/ech_key.c index b364b31c882..662fc5bba1f 100644 --- a/lib/libcrypto/ecdh/ech_key.c +++ b/lib/libcrypto/ecdh/ech_key.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ech_key.c,v 1.21 2023/07/01 14:48:01 tb Exp $ */ +/* $OpenBSD: ech_key.c,v 1.22 2023/07/01 14:50:39 tb Exp $ */ /* ==================================================================== * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. * @@ -97,9 +97,9 @@ ossl_ecdh_compute_key(void *out, size_t outlen, const EC_POINT *pub_key, BIGNUM *x; const BIGNUM *priv_key; const EC_GROUP* group; - int ret = -1; unsigned char *buf = NULL; int buflen, len; + int ret = -1; if (outlen > INT_MAX) { /* Sort of, anyway. */ @@ -166,7 +166,6 @@ ossl_ecdh_compute_key(void *out, size_t outlen, const EC_POINT *pub_key, ECDHerror(ECDH_R_KDF_FAILED); goto err; } - ret = outlen; } else { /* No KDF, just copy out the key and zero the rest. */ if (outlen > buflen) { @@ -174,15 +173,16 @@ ossl_ecdh_compute_key(void *out, size_t outlen, const EC_POINT *pub_key, outlen = buflen; } memcpy(out, buf, outlen); - ret = outlen; } + ret = outlen; err: EC_POINT_free(tmp); BN_CTX_end(ctx); BN_CTX_free(ctx); free(buf); - return (ret); + + return ret; } int @@ -199,5 +199,5 @@ ECDH_compute_key(void *out, size_t outlen, const EC_POINT *pub_key, int ECDH_size(const EC_KEY *d) { - return ((EC_GROUP_get_degree(EC_KEY_get0_group(d)) + 7) / 8); + return (EC_GROUP_get_degree(EC_KEY_get0_group(d)) + 7) / 8; } -- 2.20.1